40thieves/webpack-sentry-plugin

What is 'release' ?

refaelos opened this issue · 1 comments

Hey guys,

Sorry for the (possibly) dump question but what exactly you expect the release to be? Is it the hash that is created with the output files or is it latest commit?

If it's the commit, how am I supposed to supply it to you?

An example would be great!

Thanks!

Thanks for the question :)

So a release is really a concept that Sentry enforces. To attach source maps you need to create a "release", which is really just a name for a particular version of the your code. A release can just be a string. Here's a quote from the Sentry docs:

Sentry provides an abstraction called Releases which you can attach source artifacts to

Sentry can then use the release to say that a it found a bug in X version of your code. Passing the string to the plugin really depends on your setup. There are 2 main approaches:

A git commit hash is very useful for releases - it is a string that defines a particular version of your code, which is what Sentry is expecting.

At work, we use Heroku with git hook deploys, so we can access a SOURCE_VERSION environment variable that is the latest commit's hash. I also know that CircleCI provides the git hash in a CIRCLE_SHA1 environment variable. I believe that Travis does something similar. Beyond those examples I'm afraid I can't really help you much more as it really depends on how you are deploying.

To supply it to the plugin you can configure the release option to be a function. The one I use at work on Heroku looks like:

new SentryPlugin({
  // ...
  release: function() {
    return process.env.SOURCE_VERSION;
  }
})

Alternatively you can use the webpack build hash. This is generated by webpack and is based on the contents of the build - so if you change the code, the hash also changes. This also is useful for Sentry releases as it identifies a particular version of your code. The plugin provides the webpack hash to you as the first argument to the release function:

new SentryPlugin({
  // ...
  release: function(hash) {
    return hash; // webpack build hash
  }
})

The final approach is to manually change it yourself. You can do this by setting release to a string in the config:

new SentryPlugin({
  // ...
  release: 'foo-release'
})

Unfortunately at the moment this may be a bit annoying/fragile as the plugin doesn't support overwriting an existing release - so if you forget to update the release string it will fail. #17 is open to track this.

One last thing with releases - after you deploy you need to tell the Sentry client that you install on your page (Raven) which is the current release. There is an option called release that you pass when configuring it:

Raven.config({
    release: 'YOUR-RELEASE-STRING-HERE'
});

Pick whichever approach works for you! I hope this answers your question 🙂