If you are using Honeybadger for JS error monitoring on your Rails app, you may want to upload source maps so they can be applied to JS stack traces.
Here’s how you can do that if you are using esbuild, Sprockets, and deploying to Heroku. The source map will be uploaded to Honeybadger during the build phase, via a Rake task enhancing the assets:precompile step.
assets:precompile
<script src="//js.honeybadger.io/v6.9/honeybadger.min.js" type="text/javascript"></script> <script type="text/javascript"> Honeybadger.configure({ apiKey: "<%= ENV["HONEYBADGER_API_KEY_JS"] %>", environment: "<%= ENV["HONEYBADGER_ENV"] %>", revision: "<%= ENV["HEROKU_SLUG_COMMIT"] %>", }); </script>
You’d render this partial in the <head> of your app layout.
<head>
You’ll need to ensure HONEYBADGER_API_KEY_JS and HONEYBADGER_ENV config vars are set in Heroku. The HEROKU_SLUG_COMMIT var will be the commit hash for the current release.
HONEYBADGER_API_KEY_JS
HONEYBADGER_ENV
HEROKU_SLUG_COMMIT