Skip to content

Commit 2b1b3a0

Browse files
author
Gregor Gololicic
committed
filter out messages
1 parent 4397c6b commit 2b1b3a0

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/index.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11
import * as React from 'react';
22
import * as ReactDOM from 'react-dom';
3-
43
import * as Sentry from '@sentry/react';
54
import { BrowserTracing } from '@sentry/tracing';
6-
import { CaptureConsole as CaptureConsoleIntegration } from '@sentry/integrations';
75

86
import App from './App';
97

108
Sentry.init({
119
dsn: process.env.SENTRY_DSN,
1210
integrations: [
13-
new BrowserTracing(),
14-
new CaptureConsoleIntegration({ levels: ['error'] }),
11+
new BrowserTracing()
1512
],
1613
tracesSampleRate: 1.0,
14+
beforeSend(event, hint) {
15+
const error = hint.originalException;
16+
17+
const ignoreErrors = [
18+
/GraphQL/i, // filter out graphql errors
19+
/Failed to fetch/i // filter out failed to fetch network errors
20+
]
21+
22+
// filter out blacklisted errors
23+
if (error && error.message) {
24+
for (const filter in ignoreErrors) {
25+
if (error.message.match(filter)) {
26+
return null
27+
}
28+
}
29+
}
30+
31+
return event;
32+
},
1733
});
1834

1935
const root = document.getElementById('root');

0 commit comments

Comments
 (0)