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.

Copied
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.

Copied
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.

Copied
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.

Copied
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.

Copied
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.