React Native source map upload

Upload source map files to allow BugSnag to de-obfuscate React Native JavaScript stack traces.

Overview

Upload source maps to translate JavaScript code that has been bundled by Metro (including the RAM bundle format) back to the original code.

Uploading source maps

To send React Native source map files to BugSnag, simply POST them to https://upload.bugsnag.com/react-native-source-map with the following parameters:

  • apiKey - the BugSnag API key that is used in your app.
  • appVersion (optional) - the appVersion of the application.
  • appVersionCode (optional) - the versionCode for the application. (Android only)
  • appBundleVersion (optional) - the bundle version for the application. (iOS only)
  • codeBundleId (optional) - the codeBundleId if using App Center CodePush.
  • dev (optional) - indicates whether the application is a debug or release build. This value should mirror the value used when generating source map files with react-native bundle. (default: false)
  • platform - the application platform, either android or ios.
  • sourceMap - the path to the source map file.
  • bundle - the path to the bundle file.
  • projectRoot (optional) - the root path of the project on the filesystem where the source map was built. This will be stripped off from the file name in the displayed stacktraces and improves error grouping for errors reported from the same location within the app but with a different project root.
  • overwrite (optional) - denotes whether to overwrite an existing source map for the specified dev, platform and version combination. (default: true)

If using App Center CodePush only the codeBundleId should be provided. Otherwise, at least one of appVersion, appVersionCode or appBundleVersion is required.

Please note that errors that were received before the source maps were uploaded will not be retrospectively de-obfuscated.

cURL example

Here’s an example request with cURL, where the ‘@’ sign indicates that the sourceMap and bundle parameters are uploaded files:

$ curl --http1.1 https://upload.bugsnag.com/react-native-source-map \
   -F apiKey=YOUR_API_KEY_HERE \
   -F appVersion=1.2.3 \
   -F dev=true \
   -F platform=android \
   -F sourceMap=@path/to/example.jsbundle.map \
   -F bundle=@path/to/example.jsbundle \
   -F projectRoot=/path/to/project/

Response codes

If the files are accepted then an HTTP 200 response will be returned with the body “OK”. If not, there are several possible problems which will be indicated with an HTTP 4XX response:

  • 400 - missing required param -indicates that a required parameter is missing.
  • 401 - invalid apiKey - indicates that the provided apiKey doesn’t correspond to a BugSnag project.
  • 409 - duplicate source map file - indicates that BugSnag already has a file for this url and app version. You can ignore this error by using the overwrite parameter.

Frequently asked questions

Why isn’t the uploaded source map getting applied to my error?

If the uploaded source map is not being applied correctly, you should verify that:

  • The error event was received after the source map was uploaded
  • The codeBundleId uploaded with the source map matches that of the app generating the error (if using App Center CodePush) or
  • The appVersion/appVersionCode/appBundleVersion uploaded with the source map matches that of the app generating the error
  • The platform uploaded with the source map matches that of the app generating the error
  • The dev flag uploaded with the source map matches the value used when generating source map files with react-native bundle

Where can I see the details of the source maps that I’ve uploaded?

Uploaded source maps can be viewed and deleted by going to Project Settings -> Source maps.

How do I delete source maps I’ve uploaded?

Uploaded source maps can be viewed and deleted by going to Project Settings -> Source maps.

Do the uploaded source maps get applied retroactively to existing errors?

Once a source map is uploaded it will only get applied to new error events. It does not get applied retroactively to existing errors events.

Why is my mapped stacktrace showing the wrong line of code?

If the stacktrace has been mapped but is pointing to the wrong line of code, it’s often due to the wrong bundle/source map file being uploaded for the file in the reported stacktrace.

See the React Native build integration guide for guidance on different bundle types.