Ignore errors that don't come from your code

With Sentry's JavaScript SDK 8.10.0 release you have added new ways to reduce noise in your issue feed.

A lot of noisy errors come from JavaScript that wasn't written by yourself. Browser extensions, code-injecting browsers, or widgets from third-party services all may throw errors that you cannot address.

There are two possibilities to filter out these kinds of errors:

  1. Using the allowUrls and denyUrls options
  2. Using the thirdPartyErrorFilterIntegration (new and recommended)

Using allowUrls and denyUrls

You have been able to define an array of patterns matching the URLs of scripts where errors have been created. Only errors that match one of the patterns will be recorded and sent to Sentry. If your scripts are loaded from cdn.example.com and your site is example.com, you can set allowUrls to:

Sentry.init({
  allowUrls: [/https?:\/\/((cdn|www)\.)?example\.com/],
});

If you want to block errors from specific URLs you can use denyUrls.

Using the thirdPartyErrorFilterIntegration

The thirdPartyErrorFilterIntegration is an approach to automatically filter out errors that are unrelated to the code that you wrote.

This feature is available in all browser-based SDKs from version 8.10.0 onwards and requires you to use a bundler and one of Sentry's bundler plugins.

This integration works by "marking" your JavaScript files with an "application key" during the build process. At runtime, if an error occurs, the thirdPartyErrorFilterIntegration checks application keys for each stack frame in the stack trace. This allows you to filter out errors with "unmarked" stack frames, which would indicate third-party code.

To get started using the thirdPartyErrorFilterIntegration check out the Docs.