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,
    });
  }
});

If you're wrapping your root component with Sentry.wrap to access Performance features, codePush should be the outer most function because it needs access to the root component in order to swap out the bundle.

Copied
export default codePush(Sentry.wrap(App));

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-dir ./build and --output-dir ./build.

Copied
appcenter codepush release-react -a {APP} -d {DEPLOYMENT} --sourcemap-output-dir ./build --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 ./build/CodePush --deployment {DEPLOYMENT} --dist {DIST}

For non-macOS devices building for iOS, you will need to pass extra parameters that can't be computed automatically (--bundle-id and --version-name). Within your Info.plist, --version-name corresponds to CFBundleShortVersionString .

On iOS:

Copied
sentry-cli react-native appcenter {APP} ios ./build ./build/CodePush --deployment {DEPLOYMENT} --dist {DIST} --bundle-id {BUNDLE_ID} --version-name {VERSION_NAME}

If you don't want to use the automatically computed release format, instead of passing --bundle-id and --version-name, you'll need to pass the --release-name parameter.

Copied
sentry-cli react-native appcenter {APP} ios ./build ./build/CodePush --deployment {DEPLOYMENT} --dist {DIST} --release-name {RELEASE_NAME}

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.

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