UglifyJS

Sentry uses releases to match the correct source maps to your events. If you're using UglifyJS to transpile your project you should configure UglifyJS to generate source maps and use Sentry CLI to create the release and upload the source maps.

1. Update SDK Options

To be able to match Sentry errors with the correct release, you must provide a release property in the SDK options:

Copied
Sentry.init({
  // Make sure this value is identical to the name you give the release that you
  // create below using Sentry CLI
  release: "<release_name>",
});

2. Generate Source Maps

Next, configure UglifyJS to output source maps:

Copied
uglifyjs app.js \
  -o app.min.js.map \
  --source-map url=app.min.js.map,includeSources

3. Upload Source Maps Using Sentry CLI

Make sure Sentry CLI is configured for your project. You can use a .sentryclirc file or environment variables:

.sentryclirc
Copied
[auth]
token=your-auth-token

[defaults]
org=example-org
project=example-project

After configuring Sentry CLI and bundling your project, create a release with Sentry CLI:

Copied
sentry-cli releases new <release_name>

Next, upload your release artifacts (source files and source maps):

Copied
sentry-cli releases files <release_name> upload-sourcemaps /path/to/files

At this point, the release is in a draft state (“unreleased”). Once all source maps have been uploaded, and your app has been published successfully, finalize the release with the following command:

Copied
sentry-cli releases finalize <release_name>

For more information on how to configure releases via Sentry CLI, check out our Sentry CLI release management docs.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").