Blog |

5 ways to reduce noise when logging your JavaScript exceptions

5 ways to reduce noise when logging your JavaScript exceptions
Table of Contents

Developing and maintaining user facing software is a challenge and a very distracting one at that. πŸ™‚ Often times it can be difficult trying to stay focused on what matters most. It can be hard to tell what's really broken and why, with dozens of alerts notifying you every other minute. Volatile...The client-side being one of the most volatile of them all.

When we attempt to capture errors in this environment we can very quickly get overwhelmed by lots and lots of noise. This noise is typically generated from many different places. Some examples would be old outdated browsers, browser extensions, third-party scripts, bots, spiders, etc. Rollbar's JavaScript error monitoring supports many different ways of reducing this noise so you can be more proactive in what and how you're collecting your JavaScript exceptions.

1. Ignore noisy errors on the client-side

Rollbar.js supports the ability to ignore errors on the client-side. This option is really great because you have access to the entire payload and can filter by any value in it. By doing this the error will never be sent to the Rollbar API. This is supported via the checkIgnore configuration option.

var _rollbarConfig = {
    ...
    checkIgnore: function(isUncaught, args, payload) {
        // Code here to determine whether or not to send the payload
        // to the Rollbar API
    }
    ...
};

Let's break down the function value. First the parameters passed to the function.

  1. isUncaught: This is true if the error bubbled up to window.onerror or false if this came from one of the Rollbar.js logging methods
  2. args: This is the args passed to the Rollbar.js logging method. If the error is uncaught and is from an unhandled rejection, the args parameter contains the Promise object.
  3. payload: This is the payload that will be sent to the Rollbar API. You can use anything in the payload to conditionally filter these errors out.

To have Rollbar.js ignore the payload here, return true from the function, otherwise return false to continue processing and have the error sent to the Rollbar API.

2. Whitelist specific domains

You can configure Rollbar.js to only accept errors from your own domains. This option works really well when you use a lot of third party scripts and only want to see errors coming from domains that you have control over.

var _rollbarConfig = {
    ...
    hostWhiteList: ['domain1.com', 'domain2.com']
    ...
};

When hostWhiteList has been configured, we will enumerate over the stack frames in each error. At least one of the frames must contain a filename that contains at least one of the strings in this configuration option. The items in the array are compiled into a Regex that is used to compare against the filenames. This can be useful if you use a lot of third party scripts which could be generating errors that you can not do anything about and have little control over.

3. Ignore certain types of messages

Rollbar.js has support for ignoring specific messages. This is configured under the ignoredMessages key. This method of cleaning up noisy data works really well when you have a small sample of messages that you don't care about.

var _rollbarConfig = {
    ...
    ignoredMessages: ["Can't find Clippy.bmp. The end is nigh."]
    ...
};

When this configuration key is set, rollbar.js looks through the values in the setting, and if any of them match the exception message, the error will be discarded. Again these will be compiled into a regex that is compared against the exception mesasge.

4. Custom error grouping options

The first three options (ignoring errors on the client-side, whitelist accepted hosts, ignore messages) are all specific to the client-side and work to prevent the error from ever being sent to and recorded in Rollbar. Custom Grouping however is when you still want the error data sent to Rollbar and viewable in your dashboard for data metrics and reporting purposes, but you want to reduce the some of the 'noise' in the Items list. You can setup custom grouping rules to group your errors together in a way that makes sense for you. This is the best option to use when you still want to see the error occurrences in your dashboard, but want full control over how they are grouped together. Here is a really in depth blog post on how to improve your error grouping in Rollbar.

5. Ask for help πŸ™‚

Email us at [email protected]. We'd be happy to help you set things up for your Projects and unique situation.

If you haven’t already, signup for a 14-day free trial of Rollbar and let us help you defeat annoying client-side javascript errors in your applications. πŸ™‚

"Rollbar allows us to go from alerting to impact analysis and resolution in a matter of minutes. Without it we would be flying blind."

Error Monitoring

Start continuously improving your code today.

Get Started Shape