Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Filter out certain browser from sending events to Sentry #2338

Merged
merged 6 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { withFeatureFlagProvider } from 'shared/featureFlags'
import App from './App'
import './globals.css'
import reportWebVitals from './reportWebVitals'
import { setupSentry } from './sentry.js'
import { setupSentry } from './sentry'

if (
process.env.NODE_ENV === 'development' &&
Expand Down
14 changes: 13 additions & 1 deletion src/sentry.js → src/sentry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as Sentry from '@sentry/react'
import { Replay } from '@sentry/replay'
import { createBrowserHistory } from 'history'
import { Route } from 'react-router-dom'

import config from './config'
Expand Down Expand Up @@ -50,7 +51,11 @@

export const SentryRoute = Sentry.withSentryRouting(Route)

export const setupSentry = ({ history }) => {
export const setupSentry = ({
history,
}: {
history: ReturnType<typeof createBrowserHistory>
}) => {

Check warning on line 58 in src/sentry.ts

View check run for this annotation

Codecov - QA / codecov/patch

src/sentry.ts#L58

Added line #L58 was not covered by tests

Check warning on line 58 in src/sentry.ts

View check run for this annotation

Codecov Public QA / codecov/patch

src/sentry.ts#L58

Added line #L58 was not covered by tests

Check warning on line 58 in src/sentry.ts

View check run for this annotation

Codecov / codecov/patch

src/sentry.ts#L58

Added line #L58 was not covered by tests
const browserTracing = new Sentry.BrowserTracing({
routingInstrumentation: Sentry.reactRouterV5Instrumentation(history),
tracePropagationTargets: ['api.codecov.io', 'stage-api.codecov.dev'],
Expand All @@ -71,6 +76,13 @@
environment: config.SENTRY_ENVIRONMENT,
integrations: [browserTracing, replay],
tracesSampleRate: config?.SENTRY_TRACING_SAMPLE_RATE,
beforeSend: (event, _hint) => {

Check warning on line 79 in src/sentry.ts

View check run for this annotation

Codecov - QA / codecov/patch

src/sentry.ts#L79

Added line #L79 was not covered by tests

Check warning on line 79 in src/sentry.ts

View check run for this annotation

Codecov Public QA / codecov/patch

src/sentry.ts#L79

Added line #L79 was not covered by tests

Check warning on line 79 in src/sentry.ts

View check run for this annotation

Codecov / codecov/patch

src/sentry.ts#L79

Added line #L79 was not covered by tests
if (window?.navigator?.userAgent?.includes('Bytespider')) {
return null

Check warning on line 81 in src/sentry.ts

View check run for this annotation

Codecov - QA / codecov/patch

src/sentry.ts#L81

Added line #L81 was not covered by tests

Check warning on line 81 in src/sentry.ts

View check run for this annotation

Codecov Public QA / codecov/patch

src/sentry.ts#L81

Added line #L81 was not covered by tests

Check warning on line 81 in src/sentry.ts

View check run for this annotation

Codecov / codecov/patch

src/sentry.ts#L81

Added line #L81 was not covered by tests
}

return event

Check warning on line 84 in src/sentry.ts

View check run for this annotation

Codecov - QA / codecov/patch

src/sentry.ts#L84

Added line #L84 was not covered by tests

Check warning on line 84 in src/sentry.ts

View check run for this annotation

Codecov Public QA / codecov/patch

src/sentry.ts#L84

Added line #L84 was not covered by tests

Check warning on line 84 in src/sentry.ts

View check run for this annotation

Codecov / codecov/patch

src/sentry.ts#L84

Added line #L84 was not covered by tests
},
...deClutterConfig,
})
}
Loading