Using custom Release and Distribution
However, if you use custom values for your release other than the version included with the build in Xcode or Android Studio, the automatic source maps upload script will no longer work because it does not detect custom values. As a result, you'll need to manually upload source maps using these steps:
1. Set the Release and Distribution
For events sent from Sentry to correctly be attributed to a release and subsequently its source maps, both the
dist values will need to be set. You can set these values in the call to
init, as discussed in our Releases & Health content.
Before disabling the automatic source maps upload, you can set the
dist as environment variables,
SENTRY_DIST respectively. The script that performs the automatic source maps upload will use those values instead the default ones, and they will match the given
dist. This ensures that the given custom
dist values are used.
export SENTRY_RELEASE="firstname.lastname@example.org" export SENTRY_DIST="52"
If you've exported the environment variables and they match the given
dist during the
Sentry.init call, you can skip the next steps.
2. Disable the automatic source maps upload script
When you set a custom release or manually upload source maps, you will need to disable the automatic source map upload script:
In iOS, revert the build script "Bundle React Native code and images".
In Android, remove the gradle integration.
Preparing Source Maps for a Release
You need to generate and upload the source maps at build time for every release of your app for the events sent to be correctly unminified. To do so, follow these steps:
1. Configure CLI
Configure the CLI by reviewing the configuration guide for CLI commands.
2. Generate the bundle and source maps
If you use the Hermes engine, you will need to follow this guide to compile source maps for Hermes.
react-native bundle \ --dev false \ --platform android \ --entry-file index.android.js \ --reset-cache \ --bundle-output index.android.bundle \ --sourcemap-output index.android.bundle.map
Learn more about the React Native CLI bundle command.
2.1 Pass your entry file
Pass your entry file to
--entry-file for Android or iOS, respectively. By default, this file is usually named
index.js. It is often named
index.android.js for Android or
index.ios.js for iOS.
2.2 Output your bundle files and source maps
These files will output your bundle and source maps. By default, these files are named
index.android.bundle.map for Android and
main.jsbundle.map for iOS.
The source map's name must be the bundle's name appended with
.map for source maps to correctly be detected.
3. Upload the bundle and source maps
node_modules/@sentry/cli/bin/sentry-cli releases \ files <release> \ upload-sourcemaps \ --dist <dist> \ --strip-prefix /path/to/project/root \ index.android.bundle index.android.bundle.map
If you're using
sentry-cli prior to version 1.59.0, pass
--rewrite to the
upload-sourcemaps command to fix up the source maps before the upload (inlines sources and so forth). Version 1.59.0 does this automatically.
If source maps are still not recognized, check for warnings similar to:
The bundle filename needs to match the filename on the event (and shown on the warning) to correctly apply the source maps.
Find more troubleshooting cases in our Troubleshooting documentation.
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").