React Native

React Native SDK - JS exception capture wired through a TurboModule into the native Android/iOS BugWatch SDKs, so you get native crash/ANR/hang coverage and JS error tracking from one package.

Requirementslink

  • React Native 0.74+ (new architecture / TurboModules) · Android minSdk 24 · iOS 15.1+
  • Expo: config plugin included - add "@newinstance/bugwatch-react-native" to plugins in app.json and rebuild the dev client (Expo Go is not supported; native code is required)

1 - Installlink

npm install @newinstance/bugwatch-react-native
cd ios && pod install

2 - Initialise (before your root component renders)link

import { BugWatch } from '@newinstance/bugwatch-react-native';

BugWatch.init({
  projectId: Config.BUGWATCH_PROJECT_ID,
  appSecret: Config.BUGWATCH_APP_SECRET,
  environment: __DEV__ ? 'development' : 'production',
  release: '1.4.2+318',
});

3 - Configuration optionslink

enableAutoCapture (true) · sampleRate (1.0) · sensitiveFields · batchSize 50 · flushIntervalMs 5000 · maxQueueSize 1000 · retry (3 attempts, exponential 500 ms → 8 s) · debug.

4 - Capture APIlink

BugWatch.captureException(err);
BugWatch.captureMessage('Sync finished', 'info');
BugWatch.setUser({ id: 'u_123', email: 'ada@example.com' });
BugWatch.setTag('tenant', 'acme');
BugWatch.setContext('payment', { provider: 'paystack' });
BugWatch.addBreadcrumb('Tapped checkout');
await BugWatch.flush();

Automatic capturelink

  • JS errors - ErrorUtils global handler + unhandled promise rejections. Existing handlers (including other tools') are chained, not replaced.
  • Native side - the underlying native SDKs contribute native crashes, ANRs (Android), app hangs (iOS), sessions, lifecycle/network breadcrumbs and the persistent offline queue. One credential pair covers both layers.

5 - Symbolication (CI)link

Hermes/JSC bundle frames are resolved server-side from your uploaded source map - the --release string must equal init.release exactly:

npx react-native bundle --platform android --dev false \
  --entry-file index.js --bundle-output main.jsbundle --sourcemap-output main.jsbundle.map
npx @newinstance/bugwatch-cli artifacts upload main.jsbundle.map \
  --release "1.4.2+318" --platform react-native --type sourcemap --token "$BUGWATCH_CI_KEY"

Also upload the Android R8 mapping and iOS dSYMs for the native layer (see Android and iOS & macOS).

Troubleshootinglink

  • "BugWatch native module not found" → you're in Expo Go or didn't rebuild after install - build a dev client / pod install + rebuild.
  • JS stacks unreadable → the source map upload's release string differs from init.release, or you uploaded the dev-mode map.
  • Events missing in release only → check ProGuard didn't strip the module (the AAR ships consumer rules; custom shrinker configs can override them).

The request below is the exact wire call for a JS exception forwarded through the bridge.