How to opt-out/in of monitor capturing using @sentry/nextjs #7464
-
| Hello Sentry team, I want to ask if it is possible to opt-out/in of Sentry monitoring during the runtime using the  | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
| 
 sentry-javascript/packages/core/src/baseclient.ts Lines 261 to 266 in ef6b3c7 To re-enable Sentry, you shouldn't call  import { getCurrentHub } from '@sentry/nextjs';
const hub = getCurrentHub();
const client = hub.getClient();
if (client) {
  client.getOptions().enabled = true;
}Which will make the SDK resume instrumenting your app! | 
Beta Was this translation helpful? Give feedback.
Sentry.close()should close the sentry instance. If you look at the implementation you can see internally it sets the internalenabledflag:sentry-javascript/packages/core/src/baseclient.ts
Lines 261 to 266 in ef6b3c7
To re-enable Sentry, you shouldn't call
initagain. Instead you should do the following:Which will make the SDK res…