@koderlabs/tasks-sdk-rn 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +139 -5
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,9 +1,143 @@
1
- # Proprietary Software
1
+ # @koderlabs/tasks-sdk-rn
2
2
 
3
- KoderLabs proprietary. All rights reserved.
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
- See the bundled `LICENSE` for terms. No grant of any rights, express or
6
- implied, is conferred by access to or possession of this package. A
7
- separate signed written licence from KoderLabs is required for any use.
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
+ npm install @koderlabs/tasks-sdk @koderlabs/tasks-sdk-rn
19
+ # optional native-crash capture:
20
+ npm install @koderlabs/tasks-sdk-rn-native
21
+ # optional Expo file system (for crash recovery):
22
+ npm install expo-file-system
23
+ ```
24
+
25
+ Using pnpm or yarn:
26
+
27
+ ```bash
28
+ pnpm add @koderlabs/tasks-sdk @koderlabs/tasks-sdk-rn
29
+ # or
30
+ yarn add @koderlabs/tasks-sdk @koderlabs/tasks-sdk-rn
31
+ ```
32
+
33
+ Peer: `react-native`. The Expo config plugin lives at `@koderlabs/tasks-sdk-rn-native` — register it in `app.json#plugins` for native crash capture.
34
+
35
+ ## Usage
36
+
37
+ ```ts
38
+ // App.tsx or earliest possible bootstrap
39
+ import { init } from '@koderlabs/tasks-sdk-rn';
40
+
41
+ const handle = init({
42
+ projectId: 'IT-MOBILE',
43
+ accessKey: 'sk_live_…',
44
+ release: '1.4.2',
45
+ environment: 'production',
46
+ captureGlobalErrors: true,
47
+ captureUnhandledRejections: true,
48
+ captureConsole: true,
49
+ captureNetwork: true,
50
+ captureAppState: true,
51
+ captureNativeCrash: true,
52
+ maxBreadcrumbs: 50,
53
+ networkSlowThresholdMs: 2000,
54
+ networkIncludeQueryString: false,
55
+ onNativeCrashError: (err) => console.warn('[IT native]', err.stage, err.message),
56
+ });
57
+
58
+ // Manual capture
59
+ handle.captureException(new Error('payment failed'), { level: 'error' });
60
+
61
+ // Breadcrumbs
62
+ handle.addBreadcrumb({ category: 'user', message: 'tapped Checkout' });
63
+
64
+ // Flush before app goes to background
65
+ await handle.flush();
66
+ ```
67
+
68
+ ### React Navigation integration
69
+
70
+ ```ts
71
+ import { attachReactNavigation } from '@koderlabs/tasks-sdk-rn';
72
+ import { useNavigationContainerRef } from '@react-navigation/native';
73
+
74
+ const navRef = useNavigationContainerRef();
75
+ useEffect(() => attachReactNavigation(navRef, handle.buffer), []);
76
+ ```
77
+
78
+ ### Expo Router
79
+
80
+ ```ts
81
+ import { useExpoRouterReporter } from '@koderlabs/tasks-sdk-rn';
82
+
83
+ function RootLayout() {
84
+ useExpoRouterReporter(handle.buffer);
85
+ return <Slot />;
86
+ }
87
+ ```
88
+
89
+ ## `RnInitOptions`
90
+
91
+ Extends `InitOptions` from `@koderlabs/tasks-sdk`. Mobile-specific additions:
92
+
93
+ | Option | Type | Default | Notes |
94
+ |---|---|---|---|
95
+ | `captureGlobalErrors` | `boolean` | `true` | `ErrorUtils.setGlobalHandler`. |
96
+ | `captureUnhandledRejections` | `boolean` | `true` | HermesInternal where available; `process.on('unhandledRejection')` fallback. |
97
+ | `captureConsole` | `boolean` | `true` | `console.error` / `console.warn` → breadcrumbs. |
98
+ | `captureNetwork` | `boolean` | `true` | `fetch()` breadcrumbs. Bodies **never** captured. |
99
+ | `networkIncludeUrls` | `RegExp[]` | — | Allowlist. |
100
+ | `networkExcludeUrls` | `RegExp[]` | — | Denylist. The ingest endpoint is always skipped. |
101
+ | `networkSlowThresholdMs` | `number` | `2000` | Tags requests above this as `slow: true`. |
102
+ | `networkIncludeQueryString` | `boolean` | `false` | Off by default — query strings often carry tokens / emails. |
103
+ | `captureAppState` | `boolean` | `true` | Foreground/background breadcrumbs. |
104
+ | `captureNativeCrash` | `boolean` | `true` | Drain previous-launch native crash file. No-op when `expo-file-system` is absent. |
105
+ | `maxBreadcrumbs` | `number` | `50` | Ring buffer. |
106
+ | `onNativeCrashError` | `(err) => void` | — | Surface decode/IO failures. Without this, a failed decode is indistinguishable from "no crash". |
107
+ | `platformOverride` | `{ os?, osVersion?, deviceModel?, bundleId? }` | — | For tests where `react-native` is not loaded. |
108
+
109
+ ## `RnClientHandle`
110
+
111
+ | Method | Purpose |
112
+ |---|---|
113
+ | `client` | Underlying core `Client`. |
114
+ | `buffer` | Breadcrumb buffer (also accessible via `getBuffer()`). |
115
+ | `captureException(err, { level? })` | Manual capture (`fatal \| error \| warning`). |
116
+ | `addBreadcrumb({ category, message, data?, level? })` | Manual breadcrumb. |
117
+ | `recordNavigation(to, { from?, params? })` | Manual navigation breadcrumb. |
118
+ | `flush()` | Best-effort flush of queued events / spans. |
119
+ | `close()` | Stop all auto-instrumentation. |
120
+
121
+ Globals: `getClient()`, `getBuffer()`. Re-exports: `BreadcrumbBuffer`, `recordNavigation`, `attachReactNavigation`, `useExpoRouterReporter`, types.
122
+
123
+ ## Caveats
124
+
125
+ - `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.
126
+ - Network bodies are **never** captured (PII risk). Only method, URL (optionally query string), status, duration.
127
+ - 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.
128
+ - `captureNativeCrash` requires `expo-file-system` for the recovery read. Without it the option silently no-ops.
129
+ - React Navigation integration is opt-in via `attachReactNavigation` — there is no auto-attach.
130
+ - `flush()` covers spans; errors are POSTed inline so there's nothing extra to drain on the error path.
131
+ - 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`.
132
+
133
+ ---
134
+
135
+ ## Suite overview
136
+
137
+ Full SDK suite map + platform availability matrix: [docs/sdk/overview.md](https://github.com/jawaidgadiwala/instant-tasks/blob/main/docs/sdk/overview.md).
138
+
139
+ ## License
140
+
141
+ 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
142
 
9
143
  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.0",
3
+ "version": "0.1.2",
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.0",
49
- "@koderlabs/tasks-sdk-types": "0.1.0"
48
+ "@koderlabs/tasks-sdk": "0.1.2",
49
+ "@koderlabs/tasks-sdk-types": "0.1.2"
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": "restricted"
73
+ "access": "public"
74
74
  },
75
75
  "app.plugin.js": "./plugin/dist/index.cjs",
76
76
  "scripts": {