Source Maps

To get unminified stack traces for JavaScript code, source maps must be generated and uploaded. The React Native SDK handles source maps automatically for iOS with Xcode and Android with Gradle.

If you want to manually invoke the react-native packager, you can get source maps by passing –sourcemap-output. Then upload the generated source maps with sentry-cli with the command upload-sourcemaps.

Configure CLI

Configure the CLI by reviewing the configuration guide for CLI commands.

Copied
react-native bundle \
  --dev false \
  --platform android \
  --entry-file index.android.js \
  --bundle-output index.android.bundle \
  --sourcemap-output index.android.bundle.map

To upload:

Copied
node_modules/@sentry/cli/bin/sentry-cli releases \
    files RELEASE_NAME \
    upload-sourcemaps \
    --dist DISTRIBUTION_NAME \
    --strip-prefix /path/to/project/root \
    --rewrite index.android.bundle index.android.bundle.map

The values for RELEASE_NAME and DISTRIBUTION_NAME are as follows:

RELEASE_NAME:
the bundle ID or package name (reverse DNS notation of your app) followed by a dash and the human-readable version name that is set for your release. For instance, com.example.myapp-1.0.

If you set the release name within your app, the RELEASE_NAME should be the same value. For example:

Copied
Sentry.init({
  // ...
  release: RELEASE_NAME,
});

DISTRIBUTION_NAME:
This is the version code or build ID depending on your platform. So for instance just set this to whatever is set in your Info.plist or what your Gradle setup generates (For example, 52).

Copied
Sentry.init({
  // ...
  dist: DISTRIBUTION_NAME,
});

Naming Rules

Name of the bundle files must be set differently per platform:

  • for iOS, the file name must be set to main.jsbundle
  • for Android, the file name must be set to index.android.bundle

Troubleshooting

If source maps are still not recognized, check for warnings similar to:

Missing sources warning

The bundle filename needs to match the filename on the event (and shown on the warning) to correctly apply the source maps.

You can edit this page on GitHub.