Sentry is a great tool to monitor your application and Heroku is great to deploy applications.
To make the most of both services we created a routine that enables all Sentry features like
- release tracking (with the correct Heroku release version),
- commit trackings (so you know who broke what),
- sourcemap or assset publishing (so you always have a pretty stack trace on Sentry).
The Heroku legacy integration isn't able to provide all that information to Sentry, but it can be setup via the Sentry CLI with a coupple simple steps:
You will need to add the Node.JS buildpack, if you don't use it already:
heroku buildpacks:add heroku/nodejs
Next, you need to add the Sentry CLI to your projects runtime dependencies:
npm i @sentry/cli
Finally you will need to enable Heroku Dyno Metadata. (This is a labs feature, but has been around for ages.)
heroku labs:enable runtime-dyno-metadata
You will also need some Sentry specific environment variables:
heroku config:set SENTRY_AUTH_TOKEN=xxxxx \
SENTRY_ORG=your_sentry_org \
SENTRY_PROJECT=your_sentry_project \
GITHUB_ORG=your_gh_org
GITHUB_REPO=your_gh_repo
Finally add or extend your Heroku release phase with the scripts below. You can of course skip any step, like uploading sourcemaps, if you don't have any.
PS: Don't forget to make your script files executeable chmod +x
;)