Hermes
Sentry added support for react-native
builds that use the hermes
engine, which required changes to the sentry SDK, sentry-cli
as well as Sentry itself.
Sentry customers using the
sentry-cli
.
The minimum required version for the SDK is @sentry/react-native
SDK version 1.3.3
,
and @sentry/cli
version 1.51.1
.For self-hosted Sentry users, the minimum version required is f07352b.
Once you have the minimum version of the SDK, Sentry provides the standard integration as described in the React Native Sentry documentation.
If you are using Hermes, you should not have the RAM bundles feature enabled. In Hermes, when loading the bytecode, mmap
ensures that the entire file is not loaded. Using Hermes with RAM bundles might lead to issues, because those mechanisms are not compatible with each other.
Source Maps
If you do not need custom sourcemaps, the sentry.gradle
build step fully supports Hermes source maps.
Custom Source Maps
If you are manually bundling and building React Native apps, follow this three-step process.
Compile Sourcemaps
Currently, there is an issue when bundling the hermes
bundle and source maps
manually.
We recommend not bundling these manually until this is fixed.
Follow the issue for more details.
For iOS, only the step 1. is required.
- Bundle/minify with
metro
(react-native
) to get the bundle (.bundle
or.jsbundle
) and packager source map (.map
):
npx react-native bundle --platform android --dev false --entry-file index.js --reset-cache --bundle-output index.android.bundle --sourcemap-output index.android.bundle.packager.map --minify false
- Compile to bytecode using
hermes
to get the compiler source map (.hbc.map
):
OS-BIN
is osx-bin
, win64-bin
, or linux64-bin
, depending on which operating system you are using.
If you're using Hermes with React Native 0.68 or below:
node_modules/hermes-engine/{OS-BIN}/hermesc -O -emit-binary -output-source-map -out=index.android.bundle.hbc index.android.bundle
rm -f index.android.bundle
mv index.android.bundle.hbc index.android.bundle
Starting with React Native 0.69, hermes
has been shipped with React Native, so you should use hermesc
from react-native
:
node_modules/react-native/sdks/hermesc/{OS-BIN}/hermesc -O -emit-binary -output-source-map -out=index.android.bundle.hbc index.android.bundle
rm -f index.android.bundle
mv index.android.bundle.hbc index.android.bundle
- Merge the two source maps using
compose-source-maps
to get the final source map (.map
):
node node_modules/react-native/scripts/compose-source-maps.js index.android.bundle.packager.map index.android.bundle.hbc.map -o index.android.bundle.map
Upload the Bundle and Source Maps
Upload your source maps following Step 3 on the normal source maps guide.
You will upload the index.android.bundle
and index.android.bundle.map
for Android, main.jsbundle
and main.jsbundle.map
for iOS.
When uploaded, the index.android.bundle
file will be sized at 0 bytes. This is expected with Hermes bytecode and won't affect the source maps resolution.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").
- Package:
- npm:@sentry/react-native
- Version:
- 5.3.0
- Repository:
- https://github.com/getsentry/sentry-react-native