Skip to main content
API preview: names may change before 1.0. @apsio/react-native is a thin layer over the iOS and Android SDKs, which do the work: native crashes, hangs and ANRs, app start, sessions, session replay, the disk queue and delivery. The package adds what only JavaScript sees: JS errors and promise rejections with their JS stacks, screen names from React Navigation and Expo Router, and the API to JS.

Requirements

  • React Native 0.80 or later with the New Architecture and Hermes (built and tested on 0.87).
  • iOS or iPadOS 15.1 or later; Android 7.0 (API level 24) or later.
  • Expo: a development build. Expo Go does not include the native module; there every call does nothing.

Install

The package is not on npm yet: it is published once the Android SDK it wraps is in Apsio’s public Maven repository. Until then, try it with the sample app in apsio-react-native-sdk, which builds the native SDKs itself.
  • iOS. The pod adds the Apple SDK, a Swift package, with React Native’s spm_dependency. If a static build fails to link it, build with USE_FRAMEWORKS=dynamic. The Apple SDK links KSCrash 2.6.0 through Swift Package Manager: an app that also pulls KSCrash through CocoaPods (some crash reporters vendor it) gets duplicate symbols.
  • iOS 27 requires the scene lifecycle, which the React Native 0.87 template has not adopted: start React Native in your scene’s window from a UIWindowSceneDelegate.
  • Android. Autolinking adds the module. An app with minSdk under 26 turns on core library desugaring, as for the Android SDK.

Start

Start the native SDK as early as possible, natively, and the JS layer first thing in JS. The native start measures app start and catches a crash before the JS bundle runs; a start from JS alone comes after the launch, so it records no app start. iOS, in application(_:didFinishLaunchingWithOptions:):
Android, in MainApplication.onCreate, after super.onCreate():
JavaScript, in the entry file, before AppRegistry.registerComponent:
When the native SDK is already running, the JS start adds the JS instrumentation to it and the native start’s options are the ones in use, so give the SDK’s options to the native start only. A development build warns when Apsio.start gets native options after a native start, naming the ones not applied. Without a native start, the JS start starts the native SDK itself, with the options it is given (Apsio.start(keys, { firstPartyHosts: ['api.example.com'] })). The app key is not a secret: it ships inside your app and only routes data to your project.

Expo

The config plugin writes the native starts above into the generated AppDelegate.swift and MainApplication.kt, turns on core library desugaring on Android and adds the source map upload (see Source maps). Apsio.start in JS is still needed. The native start the plugin writes wins over the JS one, so an Expo app sets these options in the plugin: endpoint, configEndpoint, installationId, firstPartyHosts, replay, redact and battery, each as Apsio.start takes it (see Options). For example, "installationId": false turns the installation id off: no id is made on the device and none is sent. A value the native SDKs do not take fails the prebuild.

Options

These are the JS start’s options; they apply when the JS start starts the native SDK. A native start takes the same options natively.

What is recorded

Everything the native SDKs record (see iOS and Android), and from JavaScript:
  • Uncaught JS errors. One that is fatal in a release build is a crash: recorded synchronously with its JS stack before React Native’s own handler terminates the app, and sent by the next launch. React Native’s native fatal error that follows is not reported a second time. Other uncaught errors, and fatal ones in development (the red box keeps the app running), are handled errors.
  • Render errors. An error thrown while rendering that no error boundary catches is a crash too, with React’s component stack. Errors an error boundary catches are left to the app.
  • Unhandled promise rejections, as handled errors.
  • Network requests made with fetch and XMLHttpRequest, as client spans recorded by the native SDKs: method, URL without the query string, host, status and duration.
Apsio’s handler always calls the handler installed before it; it never swallows an error. On iOS the pod ships its own privacy manifest beside the Apple SDK’s; your App Store privacy label is the same as for a native app (App Store privacy labels).

Users, logs, errors and spans

The same API as the native SDKs:
The user hash is up to 256 letters, digits and + / = _ . : -, the value you can erase the user by (Erasing a user). Keep it at least 16 characters long: requests for one user’s devices and live testers match a user by hash only from 16 characters (The user hash). Every call is safe at any time: before start it does nothing, calls made while the native SDK starts are applied once it runs, and a failure inside the SDK is never thrown into the app. Attribute values are strings, booleans, numbers and string arrays; anything else is dropped. Network requests do not nest under JS spans: React Native sends them from its networking thread.

Screens

React Navigation, in the component that renders the container:
Expo Router, in the root _layout.tsx:
React Navigation screens are named by route.name; Expo Router screens by the route’s file pattern without groups (/users/[id], never the id). Both helpers take a screenName function. Each route the app shows is a screen view, told apart by its route key. A route shown for the first time is also a screen load, ending at its first frame; Apsio.reportFullyDrawn() adds its time to full display. Going back to a route is a view only.

Session replay

Session replay is recorded by the native SDKs as a wireframe of the screen, never pixels, and only for the sessions kept for replay, at most 5 minutes per session (2 on Free; see how much is recorded); the remote configuration can still turn it off. It is off until you turn it on in the start that starts the native SDK:
Without a native start, pass replay to the JS start (ApsioReplayOptions):
In an Expo app, turn replay on in the config plugin, whose native start wins over the JS one. It takes the same options, with each class list given per platform:

What is masked

Masking fails closed. By default the native SDKs:
  • mask every text, every text input and every secure input (letters replaced, shape kept);
  • draw images as boxes;
  • hide any view they cannot read, such as a view that draws itself, a web view, a map or a video, as a box with nothing inside;
  • record touches only over shown views.
textMasking: 'inputs' masks text inputs only. Secure inputs stay masked whatever any setting says, and the remote configuration can only tighten masking, never loosen it.

Settings per view

Give a view its own setting with replayProps or <ApsioReplayMask>: mask replaces its text, hide removes its content and unmask shows it.
The nearest setting wins, nothing is revealed inside a hidden view, and a view’s own setting beats its class’s. An unknown setting masks. The setting travels as an apsio-mask, apsio-unmask or apsio-hide token in testID, after the view’s own: order-number apsio-unmask. That is where the native SDKs look (the accessibility identifier on iOS, the view tag on Android). A token counts only as a whole word of the identifier, a word being a run of letters, digits and -: card.apsio-hide hides, apsio-hidden does not. replayProps replaces any token the testID already has, so the view gets one setting. A test that finds the view by id then matches a pattern (id: "order-number.*" in Maestro). The props also set collapsable={false}, so the view is not flattened away. Settings apply to native views only, and follow the native view tree, not the React one:
  • Nested <Text>. A <Text> inside another is a span of the outer one’s native paragraph, not a view of its own: it follows its outermost <Text>, and its own setting is lost. This hides nothing, and the card number shows wherever the outer text is unmasked:
    Put the setting on the outermost <Text>, or render the number in its own <Text>.
  • Components must pass testID on to a native view for the setting to count.
  • Modals, portals and bottom sheets render their content in another native window, or elsewhere in the native tree: a setting around <Modal> or a portal does not reach what it shows. Put the setting inside, on the content.

Settings per class

maskClasses, unmaskClasses and hideClasses apply a setting to every view of a native class or its subclasses, such as a view a library draws. Each takes one list per platform, { ios: [...], android: [...] }, since each platform names the class its own way:
  • iOS: the class as NSStringFromClass names it. A Swift class carries its module: MyApp.SignatureView, not SignatureView.
  • Android: the fully qualified class. R8 renames classes in a minified release build, so keep the name in the app’s ProGuard rules (android/app/proguard-rules.pro), or the setting misses it:
At start, the module logs a warning for a class it cannot find: a typo, a Swift class without its module, or a class R8 renamed. The views the native SDKs know themselves, React Native’s and react-native-screens’ among them, keep their names through the SDK’s own rules. A name in maskClasses or hideClasses, or in the remote configuration’s lists, that matches no class fails closed: the native SDK records the rest of the session in strict mode, with all text masked and images and views that draw themselves hidden, and sends a warning record, apsio.replay.strict_mode, listing the names it could not find. Fix the name, or keep it from R8, and the next session records normally. See the Android SDK’s Class names and R8.

Source maps and symbolication

Release builds compile the bundle to Hermes bytecode, so a JS stack reads crashCheckout (address at main.jsbundle:1:454705). The bundle’s source map turns it into crashCheckout in src/App.tsx:122. Release builds upload the map with the apsio CLI, under the build id the native SDK reports, when APSIO_TOKEN (an upload token; in CI, a secret) is set. iOS: in the app target’s Bundle React Native code and images build phase, write the map and upload it after React Native’s script:
The map goes up once per architecture of the app binary, under that slice’s UUID (the dSYM’s). Keep SOURCEMAP_FILE out of the products directory: React Native deletes an intermediate map of the same name there. Android: in android/app/build.gradle, after the react { } block:
It uploads the map after each release variant’s assemble, bundle or package. Apply the Android SDK’s Gradle plugin, io.apsio.gradle, too: it writes a fresh build id into each build (see Give the build an id). Without it, every rebuild of a version shares one build id, so a second build of that version cannot upload its map. Expo: the config plugin does both (sourceMaps: false leaves them out; gradlePlugin: true also applies io.apsio.gradle). The CLI reads APSIO_TOKEN and APSIO_SYMBOLS_URL and receives nothing else from the build’s environment. An over-the-air bundle (EAS Update, CodePush) does not change the native build: give it an id with start(key, { jsBundleId }) and upload its map with --bundle-id. Uploading by hand, and what stays unsymbolicated: Upload React Native source maps.

Live inspection

Let your team watch this device live when your project marks its user or install as an internal tester: its log lines, memory and power state, and masked wireframes of the screen. Call it from your own setting, in internal and test builds:
Both call the native SDKs at once, in any state, before start too, and the native SDK keeps the choice across launches. Both are synchronous: setLiveInspection returns the stored choice. With native SDKs that have no live inspection, setLiveInspection does nothing (with a warning in development) and both return false.
  • The indicator is the native SDK’s, over React Native’s views and modals; it stays up after a render error that leaves the app running (see Known issues), and a JS reload does not end a live session.
  • Console lines reach live only with logBridge on. Live copies them before the bridge’s limits, so a long view is not cut off. A viewer’s raised log level lowers the bridge’s floor to debug for 30 minutes, whatever minLevel says; what it lets through is stored too and counts against the limits. The raise ends early, with the native SDK’s, when consent or live inspection is withdrawn or the kill switch turns on.
The rest, consent, the foreground, wireframes, the commands, the limits and privacy, is the native SDKs’: see Live inspection and the iOS and Android pages.

Known limits

  • Network spans do not nest under JS spans.
  • On Android, an OkHttp client factory the app sets after Apsio’s replaces it; call io.apsio.okhttp.ApsioOkHttp.instrument(builder) in it to keep network spans. To turn network spans off on Android, set the manifest meta-data io.apsio.react_native.network to false.
  • An over-the-air bundle is found only through jsBundleId; no debug id is embedded in bundles yet.
  • Requests made with expo/fetch, which brings its own client on Android, are not verified.
  • Expo apps and Expo Router are covered by unit tests, not yet by an end-to-end run.

Known issues

  • react-native-screens on iOS 27. When an uncaught render error makes React unmount a native stack (@react-navigation/native-stack), react-native-screens 4.28 can crash the app natively while it unmounts (EXC_BAD_ACCESS (SIGBUS) in -[RNSScreen addSnapshotToView]), before React Native’s own fatal error. Apsio has recorded the JS crash by then, so the report keeps the render error, its JS stack and its component stack; the native crash of the same session is not reported again.

Next