diff --git a/packages/twenty-server/src/integrations/exception-handler/drivers/sentry.driver.ts b/packages/twenty-server/src/integrations/exception-handler/drivers/sentry.driver.ts index 6c6add8ba..a843fb27b 100644 --- a/packages/twenty-server/src/integrations/exception-handler/drivers/sentry.driver.ts +++ b/packages/twenty-server/src/integrations/exception-handler/drivers/sentry.driver.ts @@ -49,6 +49,15 @@ export class ExceptionHandlerSentryDriver scope.setExtra('document', options.document); } + if (options?.user) { + scope.setUser({ + id: options.user.id, + ip_address: options.user.ipAddress, + email: options.user.email, + username: options.user.username, + }); + } + for (const exception of exceptions) { const errorPath = (exception.path ?? []) .map((v: string | number) => (typeof v === 'number' ? '$index' : v)) diff --git a/packages/twenty-server/src/integrations/exception-handler/hooks/use-exception-handler.hook.ts b/packages/twenty-server/src/integrations/exception-handler/hooks/use-exception-handler.hook.ts index 707767072..df39db28e 100644 --- a/packages/twenty-server/src/integrations/exception-handler/hooks/use-exception-handler.hook.ts +++ b/packages/twenty-server/src/integrations/exception-handler/hooks/use-exception-handler.hook.ts @@ -90,7 +90,7 @@ export const useExceptionHandler = < }>( (acc, err) => { // Filter out exceptions that we don't want to be captured by exception handler - if (filterException(err)) { + if (filterException(err?.originalError ?? err)) { acc.filtered.push(err); } else { acc.unfiltered.push(err);