raven-node icon indicating copy to clipboard operation
raven-node copied to clipboard

Add option to filter out breadcrumbs

Open emmenko opened this issue 7 years ago • 2 comments

Do you want to request a feature or report a bug? This is a feature request.

Has someone had this problem before? I haven't found anything similar in the issue tracker.

What is the current behavior? At the moment, breadcrumbs are collected for e.g. all http requests, all console logs, etc.

What is the expected behavior? I'm using the latest version 1.1.4.


The breadcrumb feature is really great, I love it! However it would be really nice if we can specify some kind of filters for "tracking" the breadcrumb or not (e.g. some http requests should / must not be tracked, etc).

I think something like this should be enough:

Raven.config('https://[email protected]/123', {
  autoBreadcrumbs: {
    // pass a function that returns a boolean if you want to filter out some of them
    http: (breadcrumb) => {
      // filter out all GET methods
      return breadcrumb.method !== GET
      // filter out breadcrumbs matching a specific route
      return !/\/login/.test(breadcrumb.url)
      // and so on, depending on the available fields
      // https://github.com/getsentry/raven-node/blob/fa3aa077410346530bbff82956fb9f022b0121d4/lib/breadcrumbs.js#L96-L99
    },
    // pass a boolean to simply enable/disable all breadcrumbs for console
    console: true,
  }
})

Thanks a lot for the help!

emmenko avatar Mar 14 '17 10:03 emmenko

Hi @emmenko! Great point to bring up. The browser JS SDK, raven-js, has roughly the functionality you're describing in the form of the breadcrumbCallback option (docs, pr), but raven-node does not.

There's sort of a bigger picture "events and filtering" ongoing discussion that this ties into so we didn't immediately add a corresponding breadcrumbCallback option to raven-node, but I wouldn't be against doing that if it would be useful; it can cover until we have a more permanent resolution on filter-callbacks/events emitted/etc. Take a look at the raven-js functionality and let me know if it's what you have in mind or if there's anything more to what you're imagining.

LewisJEllis avatar Mar 14 '17 20:03 LewisJEllis

Ah cool, I missed that in raven-js. As far as I can see that is more or less what I imagined and should perfectly do the job 👍

Thanks!

emmenko avatar Mar 14 '17 21:03 emmenko