TypeScript (tsc)
This guide is only applicable if you're using tsc
to compile your project. If you use another tool (such as Webpack) in combination with TypeScript, you'll most likely want to follow that guide instead.
Sentry uses releases to match the correct source maps to your events.
If you're using TypeScript (tsc
) to compile your project, you should configure TypeScript to generate source maps, and use Sentry CLI to create the release and upload the generated source maps.
1. Generate Source Maps
First, configure the TypeScript compiler to output source maps:
tsconfig.json
{
"compilerOptions": {
"sourceMap": true,
"inlineSources": true,
// Set `sourceRoot` to `/` to strip the build path prefix from
// generated source code references. This allows Sentry to match source files
// relative to your source root folder.
"sourceRoot": "/"
}
}
2. Update SDK Options
To be able to match Sentry errors with the correct release, you must provide a release
property in the SDK options:
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>",
});
3. Upload Source Maps Using Sentry CLI
You can find installation instructions for Sentry CLI here: https://docs.sentry.io/product/cli/installation/
For more info on Sentry CLI configuration visit the Sentry CLI configuration docs.
Make sure Sentry CLI is configured for your project. You can use a .sentryclirc
file or environment variables:
Visit the auth token user settings page to find your auth tokens.
.sentryclirc
[auth]
token=your-auth-token
[defaults]
org=example-org
project=example-project
After configuring Sentry CLI and compiling your project with tsc
, create a release with Sentry CLI:
sentry-cli releases new <release_name>
Next, upload your release artifacts (source files and source maps):
sentry-cli releases files <release_name> upload-sourcemaps /path/to/files
You can verify that your upload was successful by navigating to Releases -> [latest release] -> Source Maps (right sidebar) on Sentry.
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:
sentry-cli releases finalize <release_name>
For more information on how to configure releases via Sentry CLI, see our Sentry CLI release management docs.
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").
- Package:
- npm:@sentry/capacitor
- Version:
- 0.11.2
- Repository:
- https://github.com/getsentry/sentry-capacitor