Skip to content

Programmatically init the SDK? #7647

Closed Answered by AbhiPrasad
re2005 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey you can call Sentry.init with enabled: false to start (which disables the SDK).

Sentry.init({
  app,
  dsn: '__MY_DSN__',
  enabled: false,
});

Then later on you can re-enable the SDK once the user agrees to terms and conditions:

const hub = Sentry.getCurrentHub();
const client = hub.getClient();
if (client) {
  // enable SDK to start sending events again.
  client.getOptions().enabled = true;
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@re2005
Comment options

Answer selected by AbhiPrasad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants