Improve sentry grouping (#12007)
This PR attemps at improving sentry grouping and filtering by - Using the exceptionCode as the fingerprint when the error is a customException. For this to work in this PR we are now throwing customExceptions instead of internalServerError deprived of their code. They will still be converted to Internal server errors when sent back as response - Filtering 4xx issues where it was missing (for emailVerification because errors were not handled, for invalid captcha and billing errors because they are httpErrors and not graphqlErrors) --------- Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@ -3,6 +3,7 @@ import * as Sentry from '@sentry/node';
|
||||
import { ExceptionHandlerOptions } from 'src/engine/core-modules/exception-handler/interfaces/exception-handler-options.interface';
|
||||
|
||||
import { ExceptionHandlerDriverInterface } from 'src/engine/core-modules/exception-handler/interfaces';
|
||||
import { CustomException } from 'src/utils/custom-exception';
|
||||
|
||||
export class ExceptionHandlerSentryDriver
|
||||
implements ExceptionHandlerDriverInterface
|
||||
@ -15,8 +16,7 @@ export class ExceptionHandlerSentryDriver
|
||||
|
||||
Sentry.withScope((scope) => {
|
||||
if (options?.operation) {
|
||||
scope.setTag('operation', options.operation.name);
|
||||
scope.setTag('operationName', options.operation.name);
|
||||
scope.setExtra('operation', options.operation.name);
|
||||
}
|
||||
|
||||
if (options?.document) {
|
||||
@ -49,6 +49,11 @@ export class ExceptionHandlerSentryDriver
|
||||
});
|
||||
}
|
||||
|
||||
if (exception instanceof CustomException) {
|
||||
scope.setTag('customExceptionCode', exception.code);
|
||||
scope.setFingerprint([exception.code]);
|
||||
}
|
||||
|
||||
const eventId = Sentry.captureException(exception, {
|
||||
contexts: {
|
||||
GraphQL: {
|
||||
|
||||
Reference in New Issue
Block a user