Browser: Disable auto reporting, or just manually catch errors

My use case: I’m building a widget that is inserted in our user’s site. I want to only catch errors in my code, with try catch or similar, and not auto capture other errors or exceptions.

Is it possible?

Thanks!

Yes, this works

You can do like this:

Sentry.init({
  ...
  defaultIntegrations: false,
  ...
});

This disables all global integrations and handlers and only calls to Sentry.captureException will work.

Besides that you can just disable the Global Error handlers like, please check other integrations what else can be disabled.

Sentry.init({
  ...
integrations: [
    new Sentry.Integrations.GlobalHandlers({ 
      onunhandledrejection: false,
      onerror: false
    })
],
  ...
});
1 Like