React Native and Expo
Use@aient/otel-browser/react-native in the JavaScript bootstrap for your iOS
and Android app. The SDK sends OTLP traces and logs to Aient using native
fetch. It has no native module installation step.
The native entry point requires Metro package exports, which React Native enables by default starting with 0.79. Aient tested Expo 57 with React Native 0.86.3 and Hermes.
Install
Configure the app bootstrap
Use the app’s existing build configuration and initialize one sender per JavaScript runtime. In Expo, read theEXPO_PUBLIC_* values with static property access so
Metro inlines them. In bare React Native, supply the same options through your
existing build configuration.
forceFlush() before returning from short-lived work. The OS can suspend the
runtime before the request finishes. Use shutdown() when disposing of the sender.
Use a publishable ingest key for the target Aient environment. Anything under
EXPO_PUBLIC_ is visible in the app bundle. Keep upload keys and other
credentials in CI. Set the full Git commit of the code in each native build and
each OTA update in EXPO_PUBLIC_COMMIT_SHA, along with its branch and environment.
Use the Git commit of the OTA bundle when an update replaces the embedded bundle.
Record work and errors
Use the SDK’s scoped tracer and logger in your application code. Pass context explicitly when correlating logs and child spans across asynchronous work.captureException once for each error you want Aient to
receive. It emits an error log with the JavaScript stack and marks a supplied
span as failed. Existing crash reporters can continue to handle native crashes.
The SDK instruments the operations you wire into it and exports their traces
and logs. Retain the matching Metro/Hermes source maps for each artifact in
your release pipeline. Aient receives the raw JavaScript stack from this SDK.