@koderlabs/tasks-sdk-web-errors 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 +83 -5
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,9 +1,87 @@
1
- # Proprietary Software
1
+ # @koderlabs/tasks-sdk-web-errors
2
2
 
3
- KoderLabs proprietary. All rights reserved.
3
+ > Runtime: browser DOM only. For RN errors use `@koderlabs/tasks-sdk-rn` (which bundles its own ErrorUtils-based capture). For Node use `@koderlabs/tasks-sdk-nestjs` or `process.on('uncaughtException')`.
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
+ Auto-captures uncaught JS errors, unhandled promise rejections, and (optionally) console messages from the browser. Attaches breadcrumbs, user info, feature flags, contexts, and the last N network entries (when paired with `@koderlabs/tasks-sdk-web-network`).
6
+
7
+ Registered as an integration against the core SDK client.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pnpm add @koderlabs/tasks-sdk @koderlabs/tasks-sdk-web-errors
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { init } from '@koderlabs/tasks-sdk';
19
+ import { errorsIntegration, notify, leaveBreadcrumb, setUser } from '@koderlabs/tasks-sdk-web-errors';
20
+
21
+ init({
22
+ projectId: 'FE',
23
+ accessKey: 'sk_live_…',
24
+ integrations: [
25
+ errorsIntegration({
26
+ captureGlobalErrors: true,
27
+ captureUnhandledRejections: true,
28
+ captureConsole: false,
29
+ maxBreadcrumbs: 50,
30
+ }),
31
+ ],
32
+ });
33
+
34
+ setUser({ id: 'u_123', email: 'user@example.com' });
35
+ leaveBreadcrumb('Opened settings modal', 'info', 'user');
36
+
37
+ try { riskyThing(); } catch (e) { notify(e); }
38
+ ```
39
+
40
+ ## `errorsIntegration(opts)`
41
+
42
+ | Option | Type | Default | Notes |
43
+ |---|---|---|---|
44
+ | `captureGlobalErrors` | `boolean` | `true` | Hook `window.onerror`. |
45
+ | `captureUnhandledRejections` | `boolean` | `true` | Hook `window.onunhandledrejection`. |
46
+ | `captureConsole` | `boolean` | `false` | Intercept `console.error`/`warn` as events. Also emits matching breadcrumbs. |
47
+ | `maxBreadcrumbs` | `number` | `50` | Ring-buffer size. |
48
+ | `beforeSend` | `(event) => event \| null` | — | Sync only. Return `null` to drop. |
49
+
50
+ ## Module-level helpers
51
+
52
+ These operate on the singleton state established by `errorsIntegration().setup()`. They are safe to import anywhere — they no-op when the integration is not active.
53
+
54
+ | Export | Purpose |
55
+ |---|---|
56
+ | `notify(err, { level? })` | Manually capture an `Error \| string`. `level`: `'error' \| 'warning' \| 'info'` (default `error`). |
57
+ | `leaveBreadcrumb(message, level?, category?, data?)` | Append breadcrumb. |
58
+ | `setUser(user \| null)` | Attach user info to subsequent events. |
59
+ | `addFeatureFlag(name, variant)` | Tag events with active flag/variant. |
60
+ | `clearFeatureFlag(name)` | Remove a flag. |
61
+ | `setContext(key, value \| null)` | Add/replace/remove a context block. |
62
+ | `BreadcrumbRing` | Class — exposed for advanced ring access. |
63
+ | `parseStack(error)` | Stack-frame parser used internally. |
64
+
65
+ ## Integration with web-network
66
+
67
+ When `@koderlabs/tasks-sdk-web-network` is registered alongside this package, the last N network entries are attached to every error event automatically — no extra wiring. The network package calls `_registerNetworkRing` on this module to expose its ring buffer.
68
+
69
+ ## Caveats
70
+
71
+ - Uses module-level singleton state — only one active errors integration per page. Re-init via `init()` tears the prior one down cleanly.
72
+ - `captureConsole: true` will capture errors logged by your own logger / 3rd-party libs; expect higher volume.
73
+ - `notify()` never throws. If the integration isn't set up yet the call silently no-ops.
74
+ - `beforeSend` here is **synchronous** (unlike the core SDK `beforeSend` which can be async).
75
+ - Stack-frame parsing is regex-based and best-effort. Symbol resolution requires uploading source maps (see `@koderlabs/tasks-sdk-nextjs` or `@koderlabs/tasks-cli`).
76
+
77
+ ---
78
+
79
+ ## Suite overview
80
+
81
+ Full SDK suite map + platform availability matrix: [docs/sdk/overview.md](https://github.com/jawaidgadiwala/instant-tasks/blob/main/docs/sdk/overview.md).
82
+
83
+ ## License
84
+
85
+ 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
86
 
9
87
  Licensing inquiries: jawaidgadiwala@gmail.com
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koderlabs/tasks-sdk-web-errors",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Browser error capture for the InstantTasks SDK — window.onerror + unhandledrejection + console breadcrumbs.",
5
5
  "keywords": [
6
6
  "instanttasks",
@@ -40,8 +40,8 @@
40
40
  ],
41
41
  "sideEffects": false,
42
42
  "dependencies": {
43
- "@koderlabs/tasks-sdk": "0.1.0",
44
- "@koderlabs/tasks-sdk-types": "0.1.0"
43
+ "@koderlabs/tasks-sdk": "0.1.1",
44
+ "@koderlabs/tasks-sdk-types": "0.1.1"
45
45
  },
46
46
  "devDependencies": {
47
47
  "tsup": "^8.3.0",
@@ -52,7 +52,7 @@
52
52
  "node": ">=20"
53
53
  },
54
54
  "publishConfig": {
55
- "access": "restricted"
55
+ "access": "public"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "tsup",