@koderlabs/tasks-sdk-rn 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -5
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,9 +1,135 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @koderlabs/tasks-sdk-rn
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Runtime: React Native 0.72+ with Hermes or JSC. New Architecture compatible. Expo SDK 50+ recommended. **Browser DOM is not supported** — use `@koderlabs/tasks-sdk-web-errors` / `@koderlabs/tasks-sdk-web-network` instead.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
React Native client for InstantTasks. Wraps the core SDK (`@koderlabs/tasks-sdk`) with mobile-specific instrumentation:
|
|
6
|
+
|
|
7
|
+
- Global JS error capture via `ErrorUtils.setGlobalHandler`.
|
|
8
|
+
- Unhandled promise rejections (Hermes `enablePromiseRejectionTracker`, JSC fallback).
|
|
9
|
+
- Console-as-breadcrumb capture (`console.error` / `warn`).
|
|
10
|
+
- `fetch()` network breadcrumbs (no bodies — PII guard).
|
|
11
|
+
- `AppState` foreground/background transitions.
|
|
12
|
+
- React Navigation / Expo Router transition breadcrumbs.
|
|
13
|
+
- Native-crash recovery — drains the file written by the previous launch when a native iOS NSException / Android Throwable killed the app (companion package: `@koderlabs/tasks-sdk-rn-native`).
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @koderlabs/tasks-sdk @koderlabs/tasks-sdk-rn
|
|
19
|
+
# optional native-crash capture:
|
|
20
|
+
pnpm add @koderlabs/tasks-sdk-rn-native
|
|
21
|
+
# optional Expo file system (for crash recovery):
|
|
22
|
+
pnpm add expo-file-system
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Peer: `react-native`. The Expo config plugin lives at `@koderlabs/tasks-sdk-rn-native` — register it in `app.json#plugins` for native crash capture.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
// App.tsx or earliest possible bootstrap
|
|
31
|
+
import { init } from '@koderlabs/tasks-sdk-rn';
|
|
32
|
+
|
|
33
|
+
const handle = init({
|
|
34
|
+
projectId: 'IT-MOBILE',
|
|
35
|
+
accessKey: 'sk_live_…',
|
|
36
|
+
release: '1.4.2',
|
|
37
|
+
environment: 'production',
|
|
38
|
+
captureGlobalErrors: true,
|
|
39
|
+
captureUnhandledRejections: true,
|
|
40
|
+
captureConsole: true,
|
|
41
|
+
captureNetwork: true,
|
|
42
|
+
captureAppState: true,
|
|
43
|
+
captureNativeCrash: true,
|
|
44
|
+
maxBreadcrumbs: 50,
|
|
45
|
+
networkSlowThresholdMs: 2000,
|
|
46
|
+
networkIncludeQueryString: false,
|
|
47
|
+
onNativeCrashError: (err) => console.warn('[IT native]', err.stage, err.message),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Manual capture
|
|
51
|
+
handle.captureException(new Error('payment failed'), { level: 'error' });
|
|
52
|
+
|
|
53
|
+
// Breadcrumbs
|
|
54
|
+
handle.addBreadcrumb({ category: 'user', message: 'tapped Checkout' });
|
|
55
|
+
|
|
56
|
+
// Flush before app goes to background
|
|
57
|
+
await handle.flush();
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### React Navigation integration
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { attachReactNavigation } from '@koderlabs/tasks-sdk-rn';
|
|
64
|
+
import { useNavigationContainerRef } from '@react-navigation/native';
|
|
65
|
+
|
|
66
|
+
const navRef = useNavigationContainerRef();
|
|
67
|
+
useEffect(() => attachReactNavigation(navRef, handle.buffer), []);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Expo Router
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { useExpoRouterReporter } from '@koderlabs/tasks-sdk-rn';
|
|
74
|
+
|
|
75
|
+
function RootLayout() {
|
|
76
|
+
useExpoRouterReporter(handle.buffer);
|
|
77
|
+
return <Slot />;
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## `RnInitOptions`
|
|
82
|
+
|
|
83
|
+
Extends `InitOptions` from `@koderlabs/tasks-sdk`. Mobile-specific additions:
|
|
84
|
+
|
|
85
|
+
| Option | Type | Default | Notes |
|
|
86
|
+
|---|---|---|---|
|
|
87
|
+
| `captureGlobalErrors` | `boolean` | `true` | `ErrorUtils.setGlobalHandler`. |
|
|
88
|
+
| `captureUnhandledRejections` | `boolean` | `true` | HermesInternal where available; `process.on('unhandledRejection')` fallback. |
|
|
89
|
+
| `captureConsole` | `boolean` | `true` | `console.error` / `console.warn` → breadcrumbs. |
|
|
90
|
+
| `captureNetwork` | `boolean` | `true` | `fetch()` breadcrumbs. Bodies **never** captured. |
|
|
91
|
+
| `networkIncludeUrls` | `RegExp[]` | — | Allowlist. |
|
|
92
|
+
| `networkExcludeUrls` | `RegExp[]` | — | Denylist. The ingest endpoint is always skipped. |
|
|
93
|
+
| `networkSlowThresholdMs` | `number` | `2000` | Tags requests above this as `slow: true`. |
|
|
94
|
+
| `networkIncludeQueryString` | `boolean` | `false` | Off by default — query strings often carry tokens / emails. |
|
|
95
|
+
| `captureAppState` | `boolean` | `true` | Foreground/background breadcrumbs. |
|
|
96
|
+
| `captureNativeCrash` | `boolean` | `true` | Drain previous-launch native crash file. No-op when `expo-file-system` is absent. |
|
|
97
|
+
| `maxBreadcrumbs` | `number` | `50` | Ring buffer. |
|
|
98
|
+
| `onNativeCrashError` | `(err) => void` | — | Surface decode/IO failures. Without this, a failed decode is indistinguishable from "no crash". |
|
|
99
|
+
| `platformOverride` | `{ os?, osVersion?, deviceModel?, bundleId? }` | — | For tests where `react-native` is not loaded. |
|
|
100
|
+
|
|
101
|
+
## `RnClientHandle`
|
|
102
|
+
|
|
103
|
+
| Method | Purpose |
|
|
104
|
+
|---|---|
|
|
105
|
+
| `client` | Underlying core `Client`. |
|
|
106
|
+
| `buffer` | Breadcrumb buffer (also accessible via `getBuffer()`). |
|
|
107
|
+
| `captureException(err, { level? })` | Manual capture (`fatal \| error \| warning`). |
|
|
108
|
+
| `addBreadcrumb({ category, message, data?, level? })` | Manual breadcrumb. |
|
|
109
|
+
| `recordNavigation(to, { from?, params? })` | Manual navigation breadcrumb. |
|
|
110
|
+
| `flush()` | Best-effort flush of queued events / spans. |
|
|
111
|
+
| `close()` | Stop all auto-instrumentation. |
|
|
112
|
+
|
|
113
|
+
Globals: `getClient()`, `getBuffer()`. Re-exports: `BreadcrumbBuffer`, `recordNavigation`, `attachReactNavigation`, `useExpoRouterReporter`, types.
|
|
114
|
+
|
|
115
|
+
## Caveats
|
|
116
|
+
|
|
117
|
+
- `init()` tears down any prior instrumentation before installing new wrappers — otherwise multiple wrappers stack on `console` / `fetch` / `ErrorUtils` and prior teardown functions are silently overwritten.
|
|
118
|
+
- Network bodies are **never** captured (PII risk). Only method, URL (optionally query string), status, duration.
|
|
119
|
+
- Native crashes require `@koderlabs/tasks-sdk-rn-native` to be installed *and* registered as an Expo plugin *and* a prebuild — Expo Go cannot load native code. The recovery path no-ops gracefully when the native side is absent.
|
|
120
|
+
- `captureNativeCrash` requires `expo-file-system` for the recovery read. Without it the option silently no-ops.
|
|
121
|
+
- React Navigation integration is opt-in via `attachReactNavigation` — there is no auto-attach.
|
|
122
|
+
- `flush()` covers spans; errors are POSTed inline so there's nothing extra to drain on the error path.
|
|
123
|
+
- Phase 2b will add an in-app reporter (screenshot + annotate) for RN. Until then, in-app reporting is web-only via `@koderlabs/tasks-sdk-web-reporter`.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Suite overview
|
|
128
|
+
|
|
129
|
+
Full SDK suite map + platform availability matrix: [docs/sdk/overview.md](https://github.com/jawaidgadiwala/instant-tasks/blob/main/docs/sdk/overview.md).
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
KoderLabs proprietary. See [`LICENSE`](./LICENSE) for terms. Use of this package requires a separate signed written agreement with KoderLabs; access alone confers no rights.
|
|
8
134
|
|
|
9
135
|
Licensing inquiries: jawaidgadiwala@gmail.com
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koderlabs/tasks-sdk-rn",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "React Native adapter for the InstantTasks SDK — errors + network + breadcrumbs + navigation + native crash recovery.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"instanttasks",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
],
|
|
46
46
|
"sideEffects": false,
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@koderlabs/tasks-sdk": "0.1.
|
|
49
|
-
"@koderlabs/tasks-sdk-types": "0.1.
|
|
48
|
+
"@koderlabs/tasks-sdk": "0.1.1",
|
|
49
|
+
"@koderlabs/tasks-sdk-types": "0.1.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"react-native": ">=0.72.0",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"node": ">=20"
|
|
71
71
|
},
|
|
72
72
|
"publishConfig": {
|
|
73
|
-
"access": "
|
|
73
|
+
"access": "public"
|
|
74
74
|
},
|
|
75
75
|
"app.plugin.js": "./plugin/dist/index.cjs",
|
|
76
76
|
"scripts": {
|