Upload source map files to allow BugSnag to de-obfuscate React Native JavaScript stack traces.
Upload source maps to translate JavaScript code that has been bundled by Metro (including the RAM bundle format) back to the original code.
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.
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/
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:
apiKey
doesn’t correspond to a BugSnag project.overwrite
parameter.If the uploaded source map is not being applied correctly, you should verify that:
codeBundleId
uploaded with the source map matches that of the app generating the error (if using App Center CodePush) orappVersion
/appVersionCode
/appBundleVersion
uploaded with the source map matches that of the app generating the errorplatform
uploaded with the source map matches that of the app generating the errordev
flag uploaded with the source map matches the value used when generating source map files with react-native bundle
Uploaded source maps can be viewed and deleted by going to Project Settings -> Source maps.
Uploaded source maps can be viewed and deleted by going to Project Settings -> Source maps.
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.
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.