Custom Sourcemap URLs

Custom sourcemap URLs allow you to specify where Airbrake should look for the sourcemap to any minified file. Custom sourcemap URLs can be used with public and private sourcemaps.

When to use custom sourcemap URLs

You should use custom sourcemap URLs if you match either of these two cases:

  1. Your sourcemaps are not accessible according to the public sourcemaps rules (ie: they are publicly accessible but in a different place).
  2. Your sourcemaps are privately uploaded but need to be matched to minified code with more granularity than private sourcemaps pattern provides (eg: if app.min.js could either be mapped to version-1/app.map.js or version-2/app.map.js).

How to use custom sourcemap URLs

Custom sourcemap URLs are supported by assigning a special property of notice.context called sourceMaps. The keys of the sourceMaps object represent shell filename patterns and the values are URLs of your sourcemaps.

airbrake.addFilter(function(notice) {
  notice.context.sourceMaps = {
    'https://example.com/app.min.js': 'https://example.com/app.min.js.map'
  };
  return notice;
});

Filename pattern uses Unix glob-like syntax:

  • * matches any sequence of non-path-separators
  • ** matches any sequence of characters, including path separators
  • ? matches any single non-path-separator character

For example:

airbrake.addFilter(function(notice) {
  notice.context.sourceMaps = {
    '**/app.min.js': 'https://example.com/app.min.js.map'
  };
  return notice;
});