Skip to content

The open alternative to Salesforce, designed for AI.

fix: exception handler (#3768)

Jérémy M25f4a80c7cbf
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 6c6add8ba02..a843fb27b9c 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 70776707215..df39db28ee7 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);