Showing full stacktraces

Your React Native app can send stacktraces to BugSnag in both JavaScript format as well that of the native Android or Apple device. If the code in your app is obfuscated or minified then you will need to upload various files to BugSnag so that a full stacktrace with methods, file paths and line numbers can be shown.

The file types to consider for upload are:

  • JavaScript bundles and source maps – for both Android and Apple builds
  • Android ProGuard mappings
  • Android NDK symbol (.so) files
  • Apple symbol (.dSYM) files

A number of options exist for you to upload these files, depending on your build and release process.

BugSnag React Native CLI init

If you used our React Native CLI package (npx @bugsnag/react-native-cli init) to install and configure BugSnag then it will have installed a collection of npm tasks to perform the uploads after you have built your app:

npm run bugsnag:upload-rn-android
npm run bugsnag:upload-rn-ios
npm run bugsnag:upload-android-ndk
npm run bugsnag:upload-android-proguard
npm run bugsnag:upload-dsym

Or to run them all:

npm run bugsnag:upload

If you didn’t run init, or you are upgrading your BugSnag upload process, you can use the automate-symbolication command separately to add these settings.

Manual integration

Enabling source map generation

On Android, source maps are automatically generated during the Gradle build.

To enable generation of source maps for iOS builds, set the SOURCEMAP_FILE environment variable during the Xcode build. To do this for all builds, we recommend adding this to your .xocde.env file:

SOURCEMAP_FILE=$(pwd)/build/sourcemaps/main.jsbundle.map

BugSnag CLI

The BugSnag CLI is our general-purpose tool for uploading files to BugSnag and can either be installed manually or via an NPM package:

npm install --save-dev @bugsnag/cli
# or
yarn add --dev @bugsnag/cli

The CLI can then be called to perform each of the file uploads from the root of your project after a build:

bugsnag-cli upload react-native-android
bugsnag-cli upload react-native-ios
bugsnag-cli upload android-ndk android
bugsnag-cli upload android-proguard android
bugsnag-cli upload dsym ios

If you wish to trigger this from your NPM build, these commands can be added to your package.json as follows:

"bugsnag:upload-rn-android": "./node_modules/.bin/bugsnag-cli upload react-native-android"
"bugsnag:upload-rn-ios": "./node_modules/.bin/bugsnag-cli upload react-native-ios"
"bugsnag:upload-android-ndk": "./node_modules/.bin/bugsnag-cli upload android-ndk android/"
"bugsnag:upload-android-proguard": "./node_modules/.bin/bugsnag-cli upload android-proguard android/"
"bugsnag:upload-dsym": "./node_modules/.bin/bugsnag-cli upload dsym ios/"

Each command can be customized to suit your needs using the options documented in our BugSnag CLI reference. For example, if your build contains multiple Android build variants or has a non-standard project layout, you might need to provide extra options.

For a fully automated upload process, you can integrate these calls into a native Gradle task and Xcode post-build phase, or equivalent for your build system.

Other tools

CodePush

If you’re using CodePush, you’ll need to upload source maps with the @bugsnag/source-maps tool. See our examples for CodePush.

Native Android and iOS uploads

Additional information and techniques for uploading ProGuard mappings, NDK files and dSYMs can be found in our stacktrace guides for Android and iOS respectively.