-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
- Review the documentation: https://docs.sentry.io/
- Search for existing issues: https://github.com/getsentry/sentry-javascript/issues
- Use the latest release: https://github.com/getsentry/sentry-javascript/releases
- Provide a link to the affected event from your Sentry account
Package + Version
-
@sentry/browser -
@sentry/node -
raven-js -
raven-node(raven for node) - other:
Version:
6.5.1
Description
Sentry.init({
dsn: SENTRY_DSN,
integrations: [
new Integrations.BrowserTracing(),
],
tracesSampleRate: 1.0,
debug: true,
enabled: DEFINE.IS_PROD, // replaced by webpack.DefinePlugin to be false
})Currently when enabled flag is set to false, Sentry.init will still start session tracking because autoSessionTracking defaults to true:
sentry-javascript/packages/browser/src/sdk.ts
Lines 87 to 95 in d712e13
| if (options.autoSessionTracking === undefined) { | |
| options.autoSessionTracking = true; | |
| } | |
| initAndBind(BrowserClient, options); | |
| if (options.autoSessionTracking) { | |
| startSessionTracking(); | |
| } |
Problems:
- This causes CORS errors to show up in my console during development
- It's also not intuitive that
enabledflag doesn't actually disable Sentry
Workarounds:
Simply wrapping everything with an if statement or manually setting autoSessionTracking would fix this issue but it clutters my code and makes the enabled option redundant.
if (DEFINE.IS_PROD) {
Sentry.init({
autoSessionTracking: DEFINE.IS_PROD,
enabled: DEFINE.IS_PROD,
})
}I propose either use options.autoSessionTracking = options.enabled ?? true or have an early exit at the top of init that checks options.enabled