Skip to content

Sentry.init starts session tracking even when enabled is set to false #3685

@Trinovantes

Description

@Trinovantes

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:

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 enabled flag 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

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions