CodePush
To use Sentry together with CodePush, pass release
and dist
to Sentry.init
. Our suggestion is to store them in an app.json
, or you can just use the package.json
. These values need to be unique to each version of your codebase and match the version on the source maps exactly, or they might not be symbolicated.
When you set a custom release
and dist
, or manually upload source maps, you will need to disable the automatic source map upload script. Learn more in the Disable the automatic source maps upload script documentation.
For more information on the release
and dist
parameters, check out the section on Source Maps.
We recommend using the format ${BUNDLE_ID}@${APP_VERSION}+codepush:${DIST}
for release names.
import { release, dist } from "app.json";
Sentry.init({
// ...
release,
dist,
});
If you need to use codePush.getUpdateMetadata
, you will have to wait to initialize the Sentry SDK until the Promise is resolved.
This method is not recommended as any errors or crashes that happen before the initialization of the Sentry SDK will not be caught.
import codePush from "react-native-code-push";
codePush.getUpdateMetadata().then(update => {
if (update) {
Sentry.init({
// ...
release: `${update.appVersion}+codepush:${update.label}`,
dist: update.label,
});
}
});
Making Releases
After updating your CodePush release, you have to upload the new assets to Sentry:
When making the release with CodePush, make sure to output the bundle and source maps by specifying --sourcemap-output
and --output-dir ./build
. This will output to the ./build/CodePush
folder.
appcenter codepush release-react -a {APP} -d {DEPLOYMENT} --sourcemap-output --output-dir ./build
Exporting the SENTRY_PROPERTIES
will tell sentry-cli to use the properties in your project. The sentry-wizard install step should have generated this file for you. Alternatively, you can either pass it via parameters or a global settings file. To find more about this refer to Working with Projects.
export SENTRY_PROPERTIES=./ios/sentry.properties
Upload the outputted bundle and source maps to Sentry.
If you use custom deployment names in CodePush, you will need to use --deployment
to specify the deployment.
sentry-cli react-native appcenter {APP} ios ./build/CodePush --deployment {DEPLOYMENT} --dist {DIST}
If you still have issues with CodePush source maps, you can refer to Source Maps for Other Platforms to manually bundle and upload source maps to Sentry.
- Package:
- npm:@sentry/react-native
- Version:
- 5.27.0
- Repository:
- https://github.com/getsentry/sentry-react-native