Sentry-javascript: Cannot change/override breadcrumbs integration options

Created on 2 Apr 2019  路  6Comments  路  Source: getsentry/sentry-javascript

Package + Version

  • [*] @sentry/browser
  • [ ] @sentry/node
  • [ ] raven-js
  • [ ] raven-node _(raven for node)_
  • [ ] other:

Version:

5.0.2

Description

Simple demo: https://github.com/d7ark/sentry-breadcrumbs-issue (need to provide sentry dsn in index.js).

I cannot find way to override Breadcrumbs integration options. Way provided in documentation is not working.

integrations: [new Sentry.Integrations.Breadcrumbs({ console: false })].

Solution from example app is also not working.

I have a hunch this is because the defaultIntegrations are creating new Integrations.Breadcrumbs which adds event listeners with default options (everything true) and there's no way to remove those listeners. But Im not sure.

I've found a workaround using beforeBreadcrumb but I'd prefer to use intented way (Breadcrumbs integration with { dom: false }).

  // workaround using beforeBreadcrumb
  Sentry.init({
    beforeBreadcrumb: removeUiBreadcrumbs,
    dsn: SENTRY_DSN,
  });

  function removeUiBreadcrumbs(breadcrumb) {
    return breadcrumb.category.startsWith('ui.') ? null : breadcrumb;
  }
Confirmed Bug

All 6 comments

Thanks for taking the time writing this excellent bug report, I am looking into this right now.

found the issue, 5.0.4 will fix this
https://github.com/getsentry/sentry-javascript/pull/1983

OK, we found the issue, the fix is not as simple as we thought.
We hope to fix it tomorrow with 5.0.5

It's perfectly fine. Thank you for your work. I'll keep an eye out.

@d7ark So the problem is that we are emitting a breadcrumb in the try/catch integration we always emit a breadcrumb in case of an error. So the breadcrumb integration itself is working correctly.
We still haven't found a good solution for this since wrapping addEventListener twice is tricky.

So to confirm, if you also remove the TryCatch Integration it should not emit a breadcrumb anymore.

The fix for this will be shipped in the new version today:

The way it works then is like this:

Sentry.init({ 
...
    integrations(integrations) {
      integrations = integrations.filter(
        integration => integration.name !== "Breadcrumbs"
      );
      return [
        ...integrations,
        new Sentry.Integrations.Breadcrumbs({ dom: false })
      ];
    },
...
  });
Was this page helpful?
0 / 5 - 0 ratings