@fixprompt/react-native
v0.0.3
Published
FixPrompt React Native SDK — captures uncaught JS errors, unhandled promise rejections, and tagged console output; buffers offline; forwards to the FixPrompt broker.
Readme
@fixprompt/react-native
React Native SDK for the FixPrompt broker. Captures uncaught JS errors, unhandled promise rejections, and tagged console.error / console.warn output. Buffers events when offline; drains on the next successful send.
Install
npm install github:Geos-LLC/FixPrompt#path:react-native-sdk \
@react-native-async-storage/async-storageOptional but recommended for stable per-device IDs:
npx expo install expo-secure-storeWire it up
// App.tsx — call once before any render
import { initFixPrompt } from '@fixprompt/react-native';
initFixPrompt({
projectKey: process.env.EXPO_PUBLIC_FIXPROMPT_KEY!,
source: process.env.EXPO_PUBLIC_FIXPROMPT_SOURCE!,
service: 'my-app',
app: 'my-app',
env: __DEV__ ? 'dev' : 'prod',
// Optional — empty list (the default) captures every console.error;
// pass regex prefixes to only capture intentional tagged lines.
captureTags: [/^\[CRM\b/, /^\[Analytics\b/],
});Public API
// Manual error report — call from a try/catch
captureException(err, { attrs: { extra: 'context' } });
// Attach user context to every subsequent event
setUser({ id: userId, email });
setUser(null); // clear on logoutNative crash forwarding (optional)
The SDK only sees the JS bridge. If a native module deref crashes the app
(common: native-side TurboModule null pointer), wire up
react-native-exception-handler:
npm install react-native-exception-handlerimport { setNativeExceptionHandler } from 'react-native-exception-handler';
import { captureException } from '@fixprompt/react-native';
setNativeExceptionHandler((exceptionString) => {
// Synchronous — runs once before the app process dies.
// Best we can do is push to the offline buffer; transport will flush on
// next app launch via AsyncStorage replay.
captureException(new Error(exceptionString), {
attrs: { kind: 'native_crash', fatal: true },
});
});Offline buffer
When the broker is unreachable (network down, 5xx, or 8s timeout), events
queue in an in-memory ring buffer of 200, persisted to AsyncStorage key
@fixprompt/buffer. On the next successful send the whole queue drains in
order. Events older than 7 days are dropped. 4xx responses are dropped
immediately (those are bugs on our side, not transient failures).
Auto-attached attrs
Every event ships with:
| attr | source |
|------|--------|
| sdk, sdk_version | this package |
| platform | Platform.OS (ios / android / web / ...) |
| os_version | Platform.Version |
| rn_version | Platform.constants.reactNativeVersion |
| app_version | Constants.expoConfig.version or Constants.nativeAppVersion (needs expo-constants) |
| build_number | Constants.expoConfig.ios.buildNumber / android.versionCode / nativeBuildVersion |
| ota_id | Updates.updateId from expo-updates — present iff an OTA bundle is active |
| runtime_version | Updates.runtimeVersion from expo-updates |
| ota_channel | Updates.channel from expo-updates — e.g. production, preview |
| release | passed to initFixPrompt({ release }) or null |
| session_id | uuid per cold start, in-memory |
| device_id | uuid per device, persisted (SecureStore → AsyncStorage) |
| user_id, user_email | last setUser({...}) call |
expo-constants and expo-updates are optional peer deps — install them and the SDK
auto-detects everything; skip them and the basic platform attrs still ship. Bare React
Native apps without Expo can pass release / build_number manually via
initFixPrompt({ release: '1.2.3+47' }) or via env-var-driven values.
The broker promotes sdk + sdk_version into project_sdk_installations, so the dashboard's support copy ("you're on RN SDK 0.0.1") lights up automatically.
Tag-based capture (advanced)
The captureTags option mirrors the pattern from the original ProofPix errorLogger.js. When set, only console.error / console.warn lines whose first argument matches one of the regexes get forwarded:
initFixPrompt({
// ...
captureTags: [
/^\[Auth\b/,
/^\[Sync\b/,
/^\[CRM\b/,
],
});
console.error('[Auth] refresh token expired'); // → broker
console.error('plain message, untagged'); // → original console onlyLeave captureTags unset to capture every console.error (broader, noisier).
License
UNLICENSED (closed beta).
