sendError. Report render errors with the ErrorBoundary from @appsignal/react. AppSignal for JavaScript reports errors only. It doesn’t support distributed tracing.
An error is easiest to fix when its backtrace points to your source code. A mobile app doesn’t run your source code directly. Expo compiles your JavaScript into a Hermes bundle that ships to each device. Backtrace lines then point to that bundle on the user’s device, like this:
- Give the bundle paths a fixed name with
matchBacktracePaths. - Generate Hermes sourcemaps with
npx expo export --source-maps. - Upload the sourcemaps under that fixed name.
Expo is a set of tools built on top of React Native. Every Expo app is a React Native app, but not every React Native app uses Expo. These steps are for Expo apps. Sourcemaps for apps without Expo are not documented yet.
matchBacktracePaths option, which is only available in that library. AppSignal for Browser doesn’t support this option.
Give the bundle paths a fixed name
ThematchBacktracePaths option rewrites each backtrace path before the error is sent. Add a function that gives the bundle a fixed name for each platform:
index.ios.bundle on iOS and index.android.bundle on Android. iOS and Android need different names, because each platform has its own sourcemap. Other paths stay unchanged.
The backtrace from the start of this page then reaches AppSignal as index.android.bundle:1:123456.
The revision must match the revision you upload the sourcemaps with.
Generate Hermes sourcemaps
Expo apps use the Hermes JavaScript engine by default. Export the app with sourcemaps:.hbc.map, to dist/_expo/static/js/android and dist/_expo/static/js/ios.
Each .hbc.map file combines Metro’s sourcemap with the Hermes sourcemap, so it maps the bytecode back to your source code. You don’t need a separate Metro sourcemap.
Upload the sourcemaps
Upload each.hbc.map file to the sourcemaps API. Set name[] to the name your function returns, and revision to the same app version as the revision option in your app:
name[]=index.ios.bundle and the sourcemap from dist/_expo/static/js/ios. Use the app name and environment shown in AppSignal.
Repeat the export and upload for every build or update you ship. A sourcemap only describes the code it was exported from.
Check the result
Report a test error from your app, then open it in AppSignal. The backtrace shows your source files, functions, and line numbers.
A backtrace line translated with an uploaded sourcemap, pointing to a source file in the app.