rollbar / rollbar.js

Error tracking and logging from Javascript to Rollbar
https://docs.rollbar.com/docs/javascript
MIT License
571 stars 213 forks source link

Configuration for `checkIgnore` does not work #1101

Open moskvin opened 1 year ago

moskvin commented 1 year ago

I've setup filters for rollbar.js and it does not work on production servers. I still can see new rollbar items are creating with payload data are not allowed:

  const ignoredCodes = {
      401: 'Unauthorized',
    };

  new Rollbar({
      checkIgnore: function (isUncaught, args, payload: any) {
        const { body } = payload;
        if (body?.trace?.extra) {
          if (Object.keys(ignoredCodes).includes(`${body.trace.extra.status}`)) return true;
          if (Object.values(ignoredCodes).includes(body.trace.extra.error)) return true;
        }
        return false;
      },
  })

Please can you help to find a reason why rollbar items are still creating for trace -> extra -> status equals 401

waltjones commented 1 year ago

The only thing I notice is the ignoredCodes key '401' is a string. If body.trace.extra.status is a number, one or the other needs to be converted for includes() to work.

Otherwise, everything looks correct.