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:
Marie
2025-05-14 11:00:06 +02:00
committed by GitHub
parent 6a1da5fe53
commit 9c2b88870f
57 changed files with 376 additions and 152 deletions

View File

@ -1,6 +1,7 @@
import { CustomException } from 'src/utils/custom-exception';
export class RemoteServerException extends CustomException {
declare code: RemoteServerExceptionCode;
constructor(message: string, code: RemoteServerExceptionCode) {
super(message, code);
}

View File

@ -1,6 +1,7 @@
import { CustomException } from 'src/utils/custom-exception';
export class RemoteTableException extends CustomException {
declare code: RemoteTableExceptionCode;
constructor(message: string, code: RemoteTableExceptionCode) {
super(message, code);
}

View File

@ -1,6 +1,5 @@
import {
ConflictError,
InternalServerError,
NotFoundError,
UserInputError,
} from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
@ -21,8 +20,11 @@ export const remoteTableGraphqlApiExceptionHandler = (error: Error) => {
throw new UserInputError(error.message);
case RemoteTableExceptionCode.REMOTE_TABLE_ALREADY_EXISTS:
throw new ConflictError(error.message);
default:
throw new InternalServerError(error.message);
default: {
const _exhaustiveCheck: never = error.code;
throw error;
}
}
}

View File

@ -1,7 +1,6 @@
import {
ConflictError,
ForbiddenError,
InternalServerError,
NotFoundError,
UserInputError,
} from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
@ -21,8 +20,13 @@ export const remoteServerGraphqlApiExceptionHandler = (error: any) => {
throw new ForbiddenError(error.message);
case RemoteServerExceptionCode.REMOTE_SERVER_ALREADY_EXISTS:
throw new ConflictError(error.message);
default:
throw new InternalServerError(error.message);
case RemoteServerExceptionCode.REMOTE_SERVER_CONNECTION_ERROR:
throw error;
default: {
const _exhaustiveCheck: never = error.code;
throw error;
}
}
}