Files
twenty/packages/twenty-server/src/command/command.ts
Marie dc4bcc3049 Improve sentry filtering and grouping (#12071)
Follow-up on https://github.com/twentyhq/twenty/pull/12007

In this PR

- adding a filter on HttpExceptionHandlerService to filter out 4xx
errors from driver handling (as we do for graphQL errors: see
useGraphQLErrorHandler hook - only filteredIssues are sent to`
exceptionHandlerService.captureExceptions()`.)
- grouping together more missing metadata issues
- attempting to use error codes as issues names in sentry to improve UI;
for now it says "Error" all the time
2025-05-16 11:35:48 +02:00

35 lines
1.1 KiB
TypeScript

import { CommandFactory } from 'nest-commander';
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
import { LoggerService } from 'src/engine/core-modules/logger/logger.service';
import { shouldCaptureException } from 'src/engine/utils/global-exception-handler.util';
import { CommandModule } from './command.module';
async function bootstrap() {
const errorHandler = (err: Error) => {
loggerService.error(err?.message, err?.name);
if (shouldCaptureException(err)) {
exceptionHandlerService.captureExceptions([err]);
}
};
const app = await CommandFactory.createWithoutRunning(CommandModule, {
logger: ['error', 'warn', 'log'],
bufferLogs: process.env.LOGGER_IS_BUFFER_ENABLED === 'true',
errorHandler,
serviceErrorHandler: errorHandler,
});
const loggerService = app.get(LoggerService);
const exceptionHandlerService = app.get(ExceptionHandlerService);
// Inject our logger
app.useLogger(loggerService);
await CommandFactory.runApplication(app);
app.close();
}
bootstrap();