Files
myeasycms-v2/packages/monitoring/sentry/src/services/sentry-server-monitoring.service.ts
giancarlo e8d34ce77e Add event capturing to monitoring services
Updated the monitoring services - baselime-server and sentry-server, to capture specific events. This includes modifications in their respective fetch methods for logging these events. Also, expanded the core monitoring service to allow for event tracking.
2024-04-25 15:03:20 +07:00

26 lines
686 B
TypeScript

import * as Sentry from '@sentry/nextjs';
import { MonitoringService } from '@kit/monitoring-core';
/**
* @class
* @implements {MonitoringService}
* ServerSentryMonitoringService is responsible for capturing exceptions and identifying users using the Sentry monitoring service.
*/
export class SentryServerMonitoringService implements MonitoringService {
captureException(error: Error | null) {
return Sentry.captureException(error);
}
captureEvent<Extra extends Sentry.Event>(event: string, extra?: Extra) {
return Sentry.captureEvent({
message: event,
...(extra ?? {}),
});
}
identifyUser(user: Sentry.User) {
Sentry.setUser(user);
}
}