Separated and isolated the responsibilities of monitoring tools. Reorganized the code by introducing a core package that contains common code related to monitoring and moved all the service operations like error capturing and identification of users into their respective packages. This ensures each tool is independent and easy to maintain.
19 lines
519 B
TypeScript
19 lines
519 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);
|
|
}
|
|
|
|
identifyUser(user: Sentry.User) {
|
|
Sentry.setUser(user);
|
|
}
|
|
}
|