@newinstance/bugwatch-react-native
v0.1.1
Published
BugWatch React Native SDK — crash, error, and log observability for iOS and Android.
Maintainers
Readme
@newinstance/bugwatch-react-native
BugWatch React Native SDK — crash, error, and log observability for your iOS and Android app. Capture exceptions and messages, attach user / tags / release context and breadcrumbs, and ship them to your newinstance.cloud project.
Skeleton release. This package currently ships the public TypeScript API surface backed by an in-memory event queue, plus a no-op native TurboModule stub on both platforms. Native crash handling, device collection, and network delivery land once the native BugWatch SDKs are published. The JS API will not change when they do.
Requirements
- React Native 0.74+ (TurboModule support — recommended 0.85+)
- iOS 15.1+
- Android API 24+, JDK 17
Installation
npm install @newinstance/bugwatch-react-native
# or
yarn add @newinstance/bugwatch-react-nativeiOS
cd ios && pod installAutolink pulls the BugWatchReactNative podspec, which depends on the
native BugWatch iOS SDK pod.
Android
Autolink registers BugWatchPackage — no extra steps.
Quick start
import { BugWatch, Severity } from '@newinstance/bugwatch-react-native';
BugWatch.init({
projectKey: 'sk_live_…', // <keyId>:<secret> from your dashboard
environment: 'production',
release: '1.4.2+318',
});
// Capture a log message
BugWatch.captureMessage('Checkout started', Severity.Info);
// Capture an error
try {
doRiskyThing();
} catch (err) {
BugWatch.captureException(err);
}Scope
Attach context that rides along with every subsequent event:
BugWatch.setUser({ id: 'u_123', email: '[email protected]' });
BugWatch.setTag('screen', 'Checkout');
BugWatch.setContext('cartId', 'c_998');
BugWatch.setRelease('1.4.3+320');
BugWatch.addBreadcrumb({
category: 'ui.tap',
message: 'Pay button',
level: Severity.Info,
});
// Clear the user on sign-out:
BugWatch.setUser(null);The breadcrumb buffer is bounded to the 100 most recent entries.
Delivery
await BugWatch.flush(); // drain pending events
BugWatch.close(); // stop the SDK and clear stateConfiguration
init(options) accepts:
| Option | Default | Description |
| ------------------ | ------------------------------ | -------------------------------------------------- |
| projectKey | — | Central ingest key <keyId>:<secret> (required). |
| endpoint | https://api.newinstance.cloud| Ingest API base URL. |
| environment | — | Environment tag (e.g. production). |
| release | — | Release / build identifier. |
| enabled | true | Master switch; when false nothing is collected. |
| debug | false | Emit internal diagnostic lines. |
| sampleRate | 1.0 | Fraction of events to keep (0.0–1.0). |
| sensitiveFields | built-in list | Case-insensitive keys redacted before sending. |
| maxQueueSize | 1000 | Pending events held before the oldest are dropped. |
| batchSize | 50 | Events delivered per ingest request. |
| flushIntervalMs | 5000 | Auto-flush cadence in ms (0 disables the timer). |
| requestTimeoutMs | 15000 | Per-request network timeout in ms. |
| retry | 3 attempts / 500ms base | Retry policy for failed ingest requests. |
Severity levels are numeric and match every BugWatch SDK and the ingest
API: Severity.Trace (10), Debug (20), Info (30), Warn (40),
Error (50), Fatal (60).
See src/types.ts for the full event and option shapes.
Contributing
License
MIT
