mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 13:26:08 +00:00
add telemetry
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { object, z } from 'zod';
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { MessageRemoteDataSourceService } from '../../../../module/chat/data/repository/message/message-remote-data-source.service';
|
||||
import { MessageSocketRepositoryService } from '../../../../module/chat/data/repository/message/message-live-signalr-data-source.service';
|
||||
import { z } from 'zod';
|
||||
import { IMessageSocketRepository } from '../../repository/message/message-socket-repository';
|
||||
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { zodSafeValidation } from 'src/app/utils/zodValidation';
|
||||
|
||||
const MessageReactionInputDTOSchema = z.object({
|
||||
memberId: z.number(),
|
||||
@@ -25,8 +23,23 @@ export class MessageReactionUseCaseService {
|
||||
public repository: IMessageSocketRepository
|
||||
) { }
|
||||
|
||||
@ValidateSchema(MessageReactionInputDTOSchema)
|
||||
execute(input: MessageReactionInput) {
|
||||
return this.repository.reactToMessageSocket(input)
|
||||
@XTracerAsync({name:'MessageReactionUseCaseService', module:'chat', bugPrint: true, waitNThrow: 5000})
|
||||
async execute(input: MessageReactionInput, tracing?: TracingType) {
|
||||
|
||||
const validation = zodSafeValidation<MessageReactionInput>(MessageReactionInputDTOSchema, input)
|
||||
|
||||
if(validation.isOk()) {
|
||||
const result = await this.repository.reactToMessageSocket(input)
|
||||
|
||||
// console.log('result', result)
|
||||
|
||||
return result
|
||||
} else {
|
||||
tracing.hasError('invalid input', {
|
||||
error: validation.error
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { FirebasePushNotificationService } from 'src/app/module/notification/data/datasource/firebase-push-notification.service';
|
||||
import { NotificationLive } from 'src/app/module/notification/data/dto/NotificationLiveOutputDTO';
|
||||
import { NotificationMapper } from 'src/app/module/notification/domain/mapper/notificationMapper';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import {
|
||||
SpanStatus, SpanStatusCode
|
||||
} from '@opentelemetry/api';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NotificationReceiveService {
|
||||
|
||||
constructor(
|
||||
private FirebasePushNotificationService: FirebasePushNotificationService,
|
||||
) { }
|
||||
|
||||
@XTracerAsync({name:'NotificationReceiveService', module:'notification', bugPrint: true})
|
||||
async execute(func:Function,tracing?: TracingType) {
|
||||
|
||||
const notificationSubject: Subject<NotificationLive> = new Subject<NotificationLive>();
|
||||
|
||||
this.FirebasePushNotificationService.onReceiveForeground(async (data)=> {
|
||||
|
||||
try {
|
||||
func(NotificationMapper(data));
|
||||
} catch (error) {
|
||||
const NewTracing = tracing.newTracer({name:'NotificationReceiveService-item-error'})
|
||||
NewTracing.setAttribute('notification-item-error', 'true')
|
||||
NewTracing.hasError('NotificationMapper', {
|
||||
notificationData: data
|
||||
})
|
||||
NewTracing.log('invalid notification', data);
|
||||
NewTracing.finish()
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
return notificationSubject
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user