From 4e7dc34634502a1fe48ba3efcf893d9a23bbba21 Mon Sep 17 00:00:00 2001 From: Valentyne Stigloher Date: Sat, 9 Mar 2024 14:56:37 +0100 Subject: [PATCH] (sentry) filter out errors by inspecting the stacktrace --- nuxt.config.ts | 56 ++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index a74b7eed3..3f74166ec 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -232,6 +232,38 @@ const nuxtConfig: NuxtConfig = { return scope; }, beforeSend(event) { + const denyUrls = [ + 'chrome-extension://', + 'moz-extension://', + 'webkit-masked-url://', + 'https://s0.2mdn.net', + 'https://j.adlooxtracking.com', + 'https://c.amazon-adsystem.com', + 'https://assets.a-mo.net', + 'https://btloader.com', + 'https://challenges.cloudflare.com', + 'https://static.criteo.net', + 'https://securepubads.g.doubleclick.net', + 'https://cdn.flashtalking.com', + 'https://ajs-assets.ftstatic.com', + 'https://cdn.fuseplatform.net', + 'https://cmp.inmobi.com', + 'https://cdn.js7k.com', + 'https://z.moatads.com', + 'https://ced-ns.sascdn.com', + 'https://a.teads.tv', + 'https://s.yimg.com', + ]; + + // filter out exceptions originating from third party + for (const exception of event.exception?.values || []) { + for (const frame of exception.stacktrace?.frames || []) { + if (denyUrls.some((denyUrl) => frame.abs_path?.startsWith(denyUrl))) { + return null; + } + } + } + // do not send user information as Sentry somehow automatically detects username, email and user id // https://docs.sentry.io/platforms/javascript/data-management/sensitive-data/ delete event.user; @@ -243,30 +275,6 @@ const nuxtConfig: NuxtConfig = { return event; }, }, - clientConfig: { - denyUrls: [ - 'chrome-extension://', - 'moz-extension://', - 'webkit-masked-url://', - 's0.2mdn.net', - 'j.adlooxtracking.com', - 'c.amazon-adsystem.com', - 'assets.a-mo.net', - 'btloader.com', - 'challenges.cloudflare.com', - 'static.criteo.net', - 'securepubads.g.doubleclick.net', - 'cdn.flashtalking.com', - 'ajs-assets.ftstatic.com', - 'cdn.fuseplatform.net', - 'cmp.inmobi.com', - 'cdn.js7k.com', - 'z.moatads.com', - 'ced-ns.sascdn.com', - 'a.teads.tv', - 's.yimg.com', - ], - }, }, publicRuntimeConfig: { ...config,