@koderlabs/tasks-sdk-react 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.
Files changed (2) hide show
  1. package/README.md +100 -5
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,9 +1,104 @@
1
- # Proprietary Software
1
+ # @koderlabs/tasks-sdk-react
2
2
 
3
- KoderLabs proprietary. All rights reserved.
3
+ > Runtime: browser DOM with React 18+. For Next.js App Router use `@koderlabs/tasks-sdk-nextjs/client` (which re-exports these). For RN see `@koderlabs/tasks-sdk-rn`.
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 adapter for the InstantTasks SDK. Provides `<InstantTasksProvider>`, the `useInstantTasks()` hook, a `useUser()` helper, and an `<ErrorBoundary>` class component.
6
+
7
+ The provider initialises the core SDK at mount and exposes the client + any registered sub-clients (reporter, errors, network) via React context.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pnpm add @koderlabs/tasks-sdk @koderlabs/tasks-sdk-react
13
+ # plus the integrations you need:
14
+ pnpm add @koderlabs/tasks-sdk-web-errors @koderlabs/tasks-sdk-web-network @koderlabs/tasks-sdk-web-reporter
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```tsx
20
+ import { InstantTasksProvider, useInstantTasks, ErrorBoundary } from '@koderlabs/tasks-sdk-react';
21
+ import { errorsIntegration } from '@koderlabs/tasks-sdk-web-errors';
22
+ import { networkIntegration } from '@koderlabs/tasks-sdk-web-network';
23
+ import { reporterIntegration } from '@koderlabs/tasks-sdk-web-reporter';
24
+
25
+ const sdkOptions = {
26
+ projectId: 'FE',
27
+ accessKey: import.meta.env.VITE_IT_ACCESS_KEY,
28
+ release: import.meta.env.VITE_APP_VERSION,
29
+ environment: import.meta.env.MODE,
30
+ integrations: [errorsIntegration(), networkIntegration(), reporterIntegration()],
31
+ };
32
+
33
+ export function App() {
34
+ return (
35
+ <InstantTasksProvider options={sdkOptions}>
36
+ <ErrorBoundary fallback={(err) => <div>Crashed: {err.message}</div>}>
37
+ <Routes />
38
+ </ErrorBoundary>
39
+ </InstantTasksProvider>
40
+ );
41
+ }
42
+
43
+ function ReportBugBtn() {
44
+ const { reporter } = useInstantTasks();
45
+ return <button onClick={() => reporter?.show()}>Report a bug</button>;
46
+ }
47
+ ```
48
+
49
+ ## API
50
+
51
+ ### `<InstantTasksProvider options={InitOptions}>`
52
+
53
+ Initialises the SDK at mount and tears it down on unmount.
54
+
55
+ - **Browser mount**: client is created via a `useState` lazy initialiser so consumers in the same paint see a real `Client` (no null window).
56
+ - **SSR / RSC**: lazy init returns `null` (no `window`); a browser-only `useEffect` then initialises and surfaces the client via state.
57
+ - **StrictMode double-mount (dev)**: `init()` is idempotent and tears down the prior client on the second mount.
58
+ - Re-init on `options` change is **not** supported. Memoize upstream or use `setUser` / `setCustomData` for runtime updates.
59
+
60
+ ### `useInstantTasks(): UseInstantTasksResult`
61
+
62
+ | Field | Type | Notes |
63
+ |---|---|---|
64
+ | `client` | `Client \| null` | Core SDK client. |
65
+ | `reporter` | `any \| null` | From `@koderlabs/tasks-sdk-web-reporter` integration. |
66
+ | `widget` | `any \| null` | **Deprecated alias** of `reporter`. Will be removed in v1. |
67
+ | `errors` | `any \| null` | From `@koderlabs/tasks-sdk-web-errors` integration. |
68
+ | `network` | `any \| null` | From `@koderlabs/tasks-sdk-web-network` integration. |
69
+
70
+ Strongly-typed sub-clients ship in Phase E. For now consumers cast as needed.
71
+
72
+ ### `useUser()`
73
+
74
+ Convenience hook for setting the current user on the client. See `src/useUser.ts` for signature.
75
+
76
+ ### `<ErrorBoundary fallback={ReactNode | (err) => ReactNode} client?={…}>`
77
+
78
+ Sentry-style class boundary. On `componentDidCatch` it calls `client.errors.notify(err, { componentStack })` if the errors sub-client is registered, otherwise falls back to `client.send(...)`. Renders `fallback` when caught.
79
+
80
+ Must be a class component — React 18/19 has no functional equivalent for `componentDidCatch`.
81
+
82
+ ### Other exports
83
+
84
+ - `InstantTasksContext`, `InstantTasksContextValue` — for advanced custom providers.
85
+ - `InstantTasksProviderProps`, `ErrorBoundaryProps`, `UseInstantTasksResult` — types.
86
+
87
+ ## Caveats
88
+
89
+ - `<InstantTasksProvider>` swallows `init()` errors (bad endpoint, malformed key) — the host app continues to render without telemetry. Use `debug: true` on `InitOptions` to surface them.
90
+ - `options` are read once. To change the user/customData at runtime, get the `client` from the hook and call its mutators.
91
+ - `ErrorBoundary` will not catch errors in event handlers, async code, SSR, or its own children's `componentDidMount` after the boundary itself unmounted — standard React boundary limitations.
92
+ - `useInstantTasks().widget` is deprecated. Migrate to `.reporter`. See `docs/sdk/migration-v1.md`.
93
+
94
+ ---
95
+
96
+ ## Suite overview
97
+
98
+ Full SDK suite map + platform availability matrix: [docs/sdk/overview.md](https://github.com/jawaidgadiwala/instant-tasks/blob/main/docs/sdk/overview.md).
99
+
100
+ ## License
101
+
102
+ 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
103
 
9
104
  Licensing inquiries: jawaidgadiwala@gmail.com
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koderlabs/tasks-sdk-react",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "React Provider + hooks for the InstantTasks SDK.",
5
5
  "keywords": [
6
6
  "instanttasks",
@@ -39,7 +39,7 @@
39
39
  ],
40
40
  "sideEffects": false,
41
41
  "dependencies": {
42
- "@koderlabs/tasks-sdk": "0.1.0"
42
+ "@koderlabs/tasks-sdk": "0.1.1"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "react": "^18 || ^19",
@@ -61,7 +61,7 @@
61
61
  "node": ">=20"
62
62
  },
63
63
  "publishConfig": {
64
- "access": "restricted"
64
+ "access": "public"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "tsup",