@innoapm/sdk-react-native
v0.3.0
Published
React Native / Expo SDK for the innoAPM platform
Readme
@innoapm/sdk-react-native
React Native / Expo SDK for innoAPM — an error tracking and application performance monitoring platform.
Captures uncaught JS errors and unhandled promise rejections — and, with the native module linked, native crashes on both platforms: Java/Kotlin exceptions, C/C++ signals and ANRs on Android; Mach exceptions, signals, NSException, Swift traps and app hangs on iOS. Each event carries device context.
Install
npx expo install @innoapm/sdk-react-native(or npm install @innoapm/sdk-react-native for a plain React Native project.)
Quick start
// At the very top of App.tsx, before your component renders.
import { init } from "@innoapm/sdk-react-native";
init({
dsn: "http://PUBLIC_KEY@your-innoapm-host/PROJECT_ID",
environment: __DEV__ ? "development" : "production",
release: "[email protected]",
});The default red-box / crash behaviour is preserved.
Manual capture
import { captureException, captureMessage, addBreadcrumb } from "@innoapm/sdk-react-native";
try {
doWork();
} catch (err) {
captureException(err, { screen: "checkout" });
}Native crashes
The package ships a native module (android/, InnoApmReactNative.podspec) that autolinks in React Native CLI apps and Expo development builds. With it linked, init() also starts the native SDK:
- Native crashes are reported on the next launch, symbolicated against uploaded symbols.
- Sessions are owned natively, so a native crash ends the session it happened in — JS cannot know about it.
- JS events are written to disk synchronously before they are sent. A fatal JS error is followed by React Native crashing the app on purpose; the event is already safe by then. React Native's own native copy of that crash (
JavascriptException,RCTFatalException) is not reported twice. setUserand breadcrumbs are mirrored to native, so native crashes carry them.
In Expo Go, or with enableNative: false, the SDK stays JS-only.
Until the native SDKs are published:
- Android — publish the SDK locally:
./gradlew publishToMavenLocalinpackages/sdk-android. - iOS — add to the app's
Podfile:pod 'InnoApm', :path => '<innoAPM checkout>/packages/sdk-ios'.
To catch crashes during startup, before JS runs, start the native SDK from MainApplication.onCreate with InnoApmNativeModule.initEarly(this, dsn, release, environment).
Readable stack traces
A release build needs symbols uploaded for the same release you pass to init():
npx @innoapm/cli upload-dif --dsn "$INNOAPM_DSN" --release "[email protected]" \
android/app/build/outputs/mapping/release/mapping.txt \
android/app/build/intermediates/merged_native_libs/release \
ios/build/Build/Products/Release-iphoneos/MyApp.app.dSYMplus the Hermes source map (see the usage guide, §3.3). nativeCrash() crashes in native code to verify the setup end to end.
Docs
Full usage guide and DSN format live in the main repo.
License
MIT © Innoworks Software Solutions Pvt Ltd
