Skip to content

Instantly share code, notes, and snippets.

@dcramer
Last active June 23, 2016 17:11
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcramer/619d53dabfbc2ed008a1 to your computer and use it in GitHub Desktop.
Save dcramer/619d53dabfbc2ed008a1 to your computer and use it in GitHub Desktop.
Releases API

Preface: This API is beta. Currently there's no UI for managing releases. Feedback can be sent to getsentry.com's support address.

The release API is intended to allow you to store source files (and sourcemaps) within Sentry. This removes the requirement for them to be web-accessible, and also removes any inconsistency that could come from network flakiness (on either your end, or Sentry's end).

A quick rundown of using the release API for storing JavaScript source and sourcemap files.

  • Start by creating a new API key under your organization's API Keys nav (on the home).

  • Ensure you you have project:write selected under scopes.

  • You'll use HTTP basic auth with the api key being your username, and an empty value for the password.

Setup your build system to create a release, and attach the various source files. You will need to upload all dist files (i.e. the minified/shipped JS), the referenced sourcemaps, and the files that those sourcemaps point to.

# Create a new release
$ curl https://app.getsentry.com/api/0/projects/:organization_slug/:project_slug/releases/ \
  -u [api_key]: \
  -X POST \
  -d '{"version": "abcdef"}' \
  -H 'Content-Type: application/json'

{
  "dateCreated": "2015-03-06T04:51:32.723Z",
  "version": "abcdef"
}

# Upload a file for the given release
# Note: The filename should be the *full* url that this
# would be referenced as in production.
$ curl https://app.getsentry.com/api/0/projects/:organization_slug/:project_slug/releases/abcdef/files/ \
  -u [api_key]: \
  -X POST \
  -F file=@README.rst \
  -F name="http://example.com/readme.rst"

{
  "dateCreated": "2015-03-06T04:53:00.308Z",
  "headers": {
    "Content-Type": "application/octet-stream"
  },
  "id": "1",
  "name": "README.rst",
  "sha1": "22591348ed129fe016c535654f6493737f0f9df6",
  "size": 452
}

# If you make a mistake, you can also simply clear out the release
$ curl https://app.getsentry.com/api/0/projects/:organization_slug/:project_slug/releases/abcdef/ \
  -u [api_key]: \
  -X DELETE 

Additionally, you'll need to run the latest HEAD from raven-js (I think it'll be release 1.2.x when its pushed out), and set the 'release' attribute on config()

Raven.config({
    release: 'abcdef'
});

Note: You dont have to upload the source files (ref'd by sourcemaps), but without them the grouping algorithm will not be as strong, and the UI will not show any contextual source.

Additional documentation for the Releases API is available here: https://app.getsentry.com/docs/api/releases/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment