bugsnag / bugsnag-js

JavaScript error handling tool for BugSnag. Monitor and report JavaScript bugs & errors.
https://docs.bugsnag.com/platforms/javascript
MIT License
855 stars 252 forks source link

[Feature] Add parameter "ignoreErrors" similar as has Sentry #859

Closed laukstein closed 4 years ago

laukstein commented 4 years ago

Bugsnag has no easy way to define what errors to ignore, referring to https://docs.bugsnag.com/platforms/javascript/customizing-error-reports/#errors

See https://docs.sentry.io/platforms/javascript/#decluttering-sentry "ignoreErrors" how easily it could be achieved.

Sentry.init({
    ignoreErrors: [
      // Random plugins/extensions
      'top.GLOBALS',
      // See: http://blog.errorception.com/2012/03/tale-of-unfindable-js-error.html
      'originalCreateNotification',
      'canvas.contentDocument',
      'MyApp_RemoveAllHighlights',
      'http://tt.epicplay.com',
      'Can\'t find variable: ZiteReader',
      'jigsaw is not defined',
      'ComboSearch is not defined',
      'http://loading.retry.widdit.com/',
      'atomicFindClose',
      // Facebook borked
      'fb_xd_fragment',
      // ISP "optimizing" proxy - `Cache-Control: no-transform` seems to
      // reduce this. (thanks @acdha)
      // See http://stackoverflow.com/questions/4113268
      'bmi_SafeAddOnload',
      'EBCallBackMessageReceived',
      // See http://toolbar.conduit.com/Developer/HtmlAndGadget/Methods/JSInjection.aspx
      'conduitPage'
    ],
    ...
})
bengourley commented 4 years ago

Hi @laukstein. We automatically ignore errors from web extensions so things should be less noisy anyway.

If you are getting some errors through that you want to match against that kind of list, it's straightforward to do with the notifier:

const ignorePatterns = [ /* your list goes here */ ]
Bugsnag.start({
  onError: event => {
    if (ignorePatterns.some(re => re.test(event.errors[0].errorMessage))) return false
  }
})

But we also have tools for this so you don't have ship a new version of your app to start ignoring – we have ignore by error class, domain whitelists etc. in our app which apply immediately. If you click "discard" on an error in the dashboard, all new instances of that error will be discarded too.

Hope this helps!

laukstein commented 4 years ago

@bengourley, why to close this task? You just posted a bad API example. This task is feature request to make it user friendly, intuitive, like does Sentry (example posted above).