Using Source Maps

Honeybadger can automatically un-minify your code if you provide a source map and make it available either via remote download or by uploading it to Honeybadger.

The best way to let us know about your source map is to upload your files to our servers every time you deploy your code. It's also possible for you to host your source map files yourself along with your production assets. In this case we'll try to download your source maps when an error is reported to us.

Configuring the Revision

For source maps to work properly, first make sure you're configuring the revision option in honeybadger-js. The value should be a unique version number for your current code deployment (a git SHA works well for this):

Honeybadger.configure({
  // ...
  revision: 'dcc69529edf375c72df39b0e9195d60d59db18ff'
});

The revision is used to tell Honeybadger that your code has changed and that it should update your source translations for future errors.

Important: Make sure you are using honeybadger.js v0.5.0 or greater since the revision option isn't available in earlier versions.

Generating a Source Map

Most modern minification tools can generate source maps for you:

Some source map generators (such as Uglify) embed your original source files in the source map, or have an option to do so. When this option is enabled, Honeybadger will display a source snippet for each expanded line in your stack trace.

Honeybadger does not currently support downloading remote source files (but may in the future—if this is something you're interested in, let us know).

Uploading Your Source Map

Upload your source map(s) every time you deploy your code using one of the following options:

Webpack

If you use Webpack, you can use honeybadger-webpack to automatically upload your source maps during your build.

Webpacker/Rails

See an example Webpacker/Rails app which uploads generated source maps using honeybadger-webpack.

Upload API

Other users can use the upload API directly:

$ curl https://api.honeybadger.io/v1/source_maps \
  -F api_key=PROJECT_API_KEY \
  -F revision=dcc69529edf375c72df39b0e9195d60d59db18ff \
  -F minified_url=https://example.com/assets/application.min.js \
  -F source_map=@path/to/application.js.map \
  -F minified_file=@path/to/application.min.js

For full information about our API, check out the source map upload API docs.

Hosting Your Source Map

Note: Because we can't prepare your source maps beforehand with this method, it's less reliable—as a result, the first few errors after a deploy may not have your source map applied. We strongly recommend that you upload your source maps to us via our API instead.

In order to make this work you must include a special comment at the bottom of your minified file which points to the corresponding source map file:

// ...minified code...
//# sourceMappingURL=application.min.js.map

See the comment at the bottom of honeybadger.js for a live example. If you upload the original source files along with the source map, Honeybadger will link to those files when displaying the stack trace.

All files must be publically accessible online so that Honeybadger's servers can download and parse them. For the full specification, see the Source Map Revision 3 Proposal.

Authentication

The Honeybadger-Token header can be used to authenticate requests from Honeybadger servers:

Honeybadger-Token: token

You can find your token on the "API Key" tab in your Honeybadger Project's Settings.

Troubleshooting

Check out the Troubleshooting section.