sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Best way to turn off auto-breadcrumbs

Open jrans opened this issue 8 years ago • 12 comments

Is this the quickest way to turn off default breadcrumbs?

  Sentry.init({
        integrations: [new Sentry.Integrations.Breadcrumbs({
          console: false,
          dom: false,
          xhr: false,
          fetch: false,
          beacon: false,
          history: false,
        })]
      })

Documenting here in case anyone else is wondering as can't find specific docs...

jrans avatar Oct 30 '18 12:10 jrans

No, just remove Breadcrumbs integration - https://docs.sentry.io/platforms/javascript/#removing-an-integration :)

Sentry.init({
  dsn: 'https://[email protected]/1',
  integrations(integrations) {
    return integrations.filter(integration => integration.name !== 'Breadcrumbs');
  }
});

kamilogorek avatar Oct 31 '18 10:10 kamilogorek

@kamilogorek It looks like you should actually be filtering on integration.name not integration.id as the integration objects do not have a key named id. Also the documentation needs to be updated.

pljeskavica avatar Nov 14 '18 00:11 pljeskavica

@pljeskavica right, thanks for catching that! PR https://github.com/getsentry/sentry-docs/pull/568

kamilogorek avatar Nov 14 '18 08:11 kamilogorek

This does not work anymore :/

StarryFire avatar May 27 '20 22:05 StarryFire

@StarryFire how so? Can you provide your configuration? It should still work just fine

kamilogorek avatar May 28 '20 18:05 kamilogorek

This does not work anymore :/

I just tried and it works. Check if you spelled it correctly, that was my mistake xD

phihochzwei avatar Jun 17 '20 13:06 phihochzwei

Documentation URL for the solution seems to have changed: https://docs.sentry.io/platforms/javascript/configuration/integrations/default/#removing-an-integration

alexjab avatar Nov 04 '21 08:11 alexjab

I tried many things but for some reason couldn't make it work, so instead I used

Sentry.init({ dsn: config.SENTRY_DSN, maxBreadcrumbs: 0 })

Documented here https://docs.sentry.io/platforms/javascript/configuration/options/#max-breadcrumbs

I unsucessfully tried variations of this:

Sentry.init({
  dsn: config.SENTRY_DSN,
  integrations: (integrations) => {
    return integrations
      .filter((integration) => {
        return integration.name !== 'Breadcrumbs'
      })
      .map((integration) => {
        if (integration.name === 'Http') {
          return new Sentry.Integrations.Http({
            breadcrumbs: false,
            tracing: false,
          })
        }
        return integration
      })
  },
})

Hope it helps

alexjab avatar Nov 04 '21 11:11 alexjab

You can filter breadcumbs by category; something like this:

Sentry.init({
    beforeBreadcrumb(breadcrumb) {
        if (breadcrumb.category === "console") {
            return null
        }

        return breadcrumb
    },
})

Regards 👋

adwher avatar Nov 23 '21 19:11 adwher

@adwher , I can confirm this approach works, although my react native sentry version is 1.3.9. Thanks for sharing!

thalesgaldino avatar Dec 01 '21 11:12 thalesgaldino

if I use beforeBreadcrumb to remove some breadcrumbs, will the 100 breadcrumb limit count before or after the removal?

a7madgamal avatar Nov 17 '23 16:11 a7madgamal

If a breadcrumb is dropped in beforeBreadcrumb, it will not be stored and thus does not count to the limit.

mydea avatar Nov 20 '23 13:11 mydea