Opbeat is joining forces with Elastic – Read our blog post

Node.js Source Map Support

The Opbeat Node.js agent supports source maps by default. If your transpile your source code and suppply a source map, Opbeat will be able to show you correct stack traces and even the original source code if available.

To take advantage of this, simply make sure that your transpiled source code contains a sourceMappingURL comment at the bottom of each JavaScript file. It can either point to a source map file on disk:

//# sourceMappingURL=/path/to/file.js.map

Or you can inline the source map using base64 encoding:

//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmb28uanMiLCJiYXIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O1VBQ0c7Ozs7Ozs7Ozs7Ozs7O3NCQ0RIO3NCQUNBIn0=

All modern build-toolchains support generating source maps and adding these comments to the transpiled source code.

Original source code

Opbeat uses source maps for two things: Showing you stack traces that point to your original source code and showing you the original source code as inline code snippets related to each frame in your stack traces.

For optimal support, we recommend that you either inline the original source code using the sourcesContent property inside the source map, or that you deploy the original source code to your production server along with the transpiled source code.

If you choose to deploy the original source code, make sure that it’s accessible via the file-system at path specified with the sourceRoot property in the source map.

Public access?

Your source maps or original source code does not need to be available via the internet. Everything is handled by the local Opbeat agent on your server.