Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignoredMessages not getting ignored #1140

Open
wulffeld opened this issue Apr 25, 2024 · 2 comments
Open

ignoredMessages not getting ignored #1140

wulffeld opened this issue Apr 25, 2024 · 2 comments

Comments

@wulffeld
Copy link

wulffeld commented Apr 25, 2024

With this configuration the ignoredMessages are getting ignored and not sent to rollbar however if I leave out the checkIgnore option they will be sent to rollbar. That's not what the docs say I think or am I misunderstanding them?

Using latest rollbar.js. I've tested several times back and forth to verify this.

    var _rollbarConfig = {
      accessToken: "redacted",
      captureUncaught: true,
      captureUnhandledRejections: true,
      ignoredMessages: [
        /All ins elements in the DOM with class=adsbygoogle already have ads in them/i,
        /Uncaught TagError: adsbygoogle\.push\(\) error: All 'ins' elements in the DOM with class=adsbygoogle already have ads in them/i,
        /Uncaught TagError: adsbygoogle\.push\(\) error: No slot size for availableWidth=0/i
      ],
      checkIgnore: function(isUncaught, args, payload) {
        return this.ignoredMessages.some(function(ignoredMessage) {
          return ignoredMessage.test(args[0]);
        });
      },
      payload: {
        environment: "production"
      }
    };
@linear linear bot added the Rollbar.js label Apr 25, 2024
@waltjones
Copy link
Contributor

The ignoredMessages handler in Rollbar.js uses RegExp() to compile the expression, and uses 'gi' flags in the 2nd argument. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp

It looks like either your literal expressions are getting converted to strings, or RegExp() errors on the i flag.

I think you'll get the expected result with strings like:
"All ins elements in the DOM with class=adsbygoogle already have ads in them"

@wulffeld
Copy link
Author

@waltjones Thanks however I tried with strings as well. This config will not block any exception:

  var _rollbarConfig = {
    accessToken: "...",
    captureUncaught: true,
    captureUnhandledRejections: true,
    ignoredMessages: [
      "All ins elements in the DOM with class=adsbygoogle already have ads in them",
      "Uncaught TagError: adsbygoogle\.push\(\) error: All 'ins' elements in the DOM with class=adsbygoogle already have ads in them",
      "Uncaught TagError: adsbygoogle\.push\(\) error: No slot size for availableWidth=0",
      "Script error."
    ],
    payload: {
      environment: "production"
    }
  };

unless I add:

  checkIgnore: function(isUncaught, args, payload) {
    return this.ignoredMessages.some(function(msg) {
      return args[0] && args[0].indexOf(msg) === 0;
    });
  },

🤯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants