From f44f12106472658d71f95ddf2b541f737ad9b1a3 Mon Sep 17 00:00:00 2001 From: Claudio Wunder Date: Tue, 14 Nov 2023 18:03:09 +0100 Subject: [PATCH] fix: force fix of sentry client --- sentry.client.config.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sentry.client.config.ts b/sentry.client.config.ts index fb45ff3f6072a..346d44777b730 100644 --- a/sentry.client.config.ts +++ b/sentry.client.config.ts @@ -16,4 +16,20 @@ init({ // we only want to capture errors from _next folder on production // we don't want to capture errors from preview branches here allowUrls: ['https://nodejs.org/_next'], + // Filter-out Events/Errors that are invalid for us + beforeSend: (event, hint) => { + const originalException = hint.originalException as Error; + + // All the Events we send must have a message and stack trace + if (originalException?.message && originalException?.stack) { + // All our Events come eventually from code that originates on node_modules + // so everything else should be discarded + // Even React Errors or other errors will eventually have node_modules in the code + if (String(originalException.stack).includes('node_modules')) { + return event; + } + } + + return null; + }, });