From 2b1b3a04fb2be52bbfd472029fa9df3c4babae6b Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Wed, 7 Sep 2022 11:16:48 +0200 Subject: [PATCH 1/4] filter out messages --- src/index.tsx | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index d171681e..e299598c 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,19 +1,35 @@ import * as React from 'react'; import * as ReactDOM from 'react-dom'; - import * as Sentry from '@sentry/react'; import { BrowserTracing } from '@sentry/tracing'; -import { CaptureConsole as CaptureConsoleIntegration } from '@sentry/integrations'; import App from './App'; Sentry.init({ dsn: process.env.SENTRY_DSN, integrations: [ - new BrowserTracing(), - new CaptureConsoleIntegration({ levels: ['error'] }), + new BrowserTracing() ], tracesSampleRate: 1.0, + beforeSend(event, hint) { + const error = hint.originalException; + + const ignoreErrors = [ + /GraphQL/i, // filter out graphql errors + /Failed to fetch/i // filter out failed to fetch network errors + ] + + // filter out blacklisted errors + if (error && error.message) { + for (const filter in ignoreErrors) { + if (error.message.match(filter)) { + return null + } + } + } + + return event; + }, }); const root = document.getElementById('root'); From c314bf67824a5edcda895066ab70b20782cc353c Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Wed, 7 Sep 2022 11:20:33 +0200 Subject: [PATCH 2/4] filter out messages --- src/index.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index e299598c..2c0c222c 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -18,11 +18,14 @@ Sentry.init({ /GraphQL/i, // filter out graphql errors /Failed to fetch/i // filter out failed to fetch network errors ] - + // filter out blacklisted errors if (error && error.message) { - for (const filter in ignoreErrors) { + console.log("SENTRY ERR") + for (const filter of ignoreErrors) { + console.log("SENTRY FILTER", filter) if (error.message.match(filter)) { + console.log("SENTRY MATCH", filter) return null } } From 35209fa04447b6c00c5444bf474813addfc69bc0 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Wed, 7 Sep 2022 11:20:53 +0200 Subject: [PATCH 3/4] remove debugs --- src/index.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 2c0c222c..f8495dc2 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -21,11 +21,8 @@ Sentry.init({ // filter out blacklisted errors if (error && error.message) { - console.log("SENTRY ERR") for (const filter of ignoreErrors) { - console.log("SENTRY FILTER", filter) if (error.message.match(filter)) { - console.log("SENTRY MATCH", filter) return null } } From 4ceb796a14a7b933a64293d4028b63d16319efde Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Wed, 7 Sep 2022 18:39:05 +0200 Subject: [PATCH 4/4] use init opts --- src/index.tsx | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index f8495dc2..8c22d9cb 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -10,26 +10,8 @@ Sentry.init({ integrations: [ new BrowserTracing() ], + ignoreErrors: [/GraphQL/i, /Failed to fetch/i], tracesSampleRate: 1.0, - beforeSend(event, hint) { - const error = hint.originalException; - - const ignoreErrors = [ - /GraphQL/i, // filter out graphql errors - /Failed to fetch/i // filter out failed to fetch network errors - ] - - // filter out blacklisted errors - if (error && error.message) { - for (const filter of ignoreErrors) { - if (error.message.match(filter)) { - return null - } - } - } - - return event; - }, }); const root = document.getElementById('root');