Skip to content

How to opt-out/in of monitor capturing using @sentry/nextjs #7464

Closed Answered by AbhiPrasad
george-gkas asked this question in Q&A
Discussion options

You must be logged in to vote

Sentry.close() should close the sentry instance. If you look at the implementation you can see internally it sets the internal enabled flag:

public close(timeout?: number): PromiseLike<boolean> {
return this.flush(timeout).then(result => {
this.getOptions().enabled = false;
return result;
});
}

To re-enable Sentry, you shouldn't call init again. Instead you should do the following:

import { getCurrentHub } from '@sentry/nextjs';

const hub = getCurrentHub();
const client = hub.getClient();
if (client) {
  client.getOptions().enabled = true;
}

Which will make the SDK res…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@george-gkas
Comment options

@AbhiPrasad
Comment options

@george-gkas
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