Showing full stacktraces

Bugsnag supports unminifying and demangling stacktraces using ProGuard files, LLVM debug symbol maps (dSYMs), and source maps to show a full stacktrace with methods, file paths, and line numbers for JavaScript and native errors.

These docs are for the @bugsnag/react-native package, which supports React Native v0.60 and above.

If you’re using the previous bugsnag-react-native package, we recommend upgrading to the latest release, unless you’re using a version of React Native older than 0.60. Documentation for bugsnag-react-native can be found on our legacy pages.

Automatic setup

If you use npx @bugsnag/react-native-cli init to install and configure Bugsnag, it will set up your application so that mapping files are uploaded automatically:

npx @bugsnag/react-native-cli init

If for some reason you didn’t run init, or you answered “no” to the uploading mappings prompt, you can use the automate-symbolication command at a later stage:

npx @bugsnag/react-native-cli automate-symbolication

This command automates the modifications specified below in manual setup.

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

Manual setup

Android NDK and ProGuard mappings

To symbolicate Java and C stacktraces, add the Bugsnag Gradle Plugin to your project. NDK and ProGuard mapping files will be uploaded automatically as part of release builds. See the Bugsnag Gradle Plugin guide for setup instructions.

iOS dSYMs

Our iOS symbolication guide provides details on how to upload dSYMs in order to symbolicate native iOS stack traces.

Source maps

To get unminified stack traces for JavaScript code, source maps must be generated and uploaded to Bugsnag. Use the following steps to enable this as part of your release builds using our source map CLI tool.

First, install @bugsnag/source-maps package in your project:

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

To enable JavaScript source map uploads for Android release builds, use the uploadReactNativeMappings option in the Bugsnag Gradle Plugin:

bugsnag {
    uploadReactNativeMappings = true
}

For iOS builds, firstly find the “Bundle React Native code and images” build phase in Xcode, and modify it to generate source maps at a specified location as part of the build:

+ export EXTRA_PACKAGER_ARGS="--sourcemap-output $TMPDIR/$(md5 -qs "$CONFIGURATION_BUILD_DIR")-main.jsbundle.map"
  export NODE_BINARY=node
  ../node_modules/react-native/scripts/react-native-xcode.sh

Then add a new “run script” build phase to your Xcode project and call the following script, setting SOURCE_MAP to the same location:

SOURCE_MAP="$TMPDIR/$(md5 -qs "$CONFIGURATION_BUILD_DIR")-main.jsbundle.map" ../node_modules/@bugsnag/react-native/bugsnag-react-native-xcode.sh

Uploading JavaScript source maps on demand

Using the manual or automatic integrations above, JavaScript source maps will be uploaded when a release build is created.

If you want to upload source maps from the command line, for example, to test out in development, or if you’re using CodePush to create updated JS bundles without doing a native build, see our React Native source map CLI guide.