@koderlabs/tasks-sdk-web-network 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 +79 -5
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,9 +1,83 @@
1
- # Proprietary Software
1
+ # @koderlabs/tasks-sdk-web-network
2
2
 
3
- KoderLabs proprietary. All rights reserved.
3
+ > Runtime: browser DOM only — patches `window.fetch` and `XMLHttpRequest`. For RN network breadcrumbs use the `captureNetwork` option on `@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
+ Records the last N HTTP requests (method, URL, status, duration, optional bodies) into a ring buffer. The buffer is attached to error events by `@koderlabs/tasks-sdk-web-errors` so you can see what the page was doing right before it broke.
6
+
7
+ By itself this package does not POST anything it's a passive recorder.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pnpm add @koderlabs/tasks-sdk @koderlabs/tasks-sdk-web-network
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { init } from '@koderlabs/tasks-sdk';
19
+ import { errorsIntegration } from '@koderlabs/tasks-sdk-web-errors';
20
+ import { networkIntegration } from '@koderlabs/tasks-sdk-web-network';
21
+
22
+ init({
23
+ projectId: 'FE',
24
+ accessKey: 'sk_live_…',
25
+ integrations: [
26
+ errorsIntegration(),
27
+ networkIntegration({
28
+ maxEntries: 20,
29
+ recordRequestBody: false,
30
+ recordResponseBody: false,
31
+ ignoreUrls: [/\/sdk\/events$/, 'https://analytics.example.com'],
32
+ }),
33
+ ],
34
+ });
35
+ ```
36
+
37
+ ## `networkIntegration(opts)`
38
+
39
+ | Option | Type | Default | Notes |
40
+ |---|---|---|---|
41
+ | `maxEntries` | `number` | `20` | Ring buffer size. |
42
+ | `recordRequestBody` | `boolean` | `false` | PII risk — off by default. |
43
+ | `recordResponseBody` | `boolean` | `false` | PII risk — off by default. |
44
+ | `requestSanitizer` | `(entry) => entry \| null` | — | Mutate or drop before recording. |
45
+ | `responseSanitizer` | `(entry) => entry \| null` | — | Mutate or drop before recording. |
46
+ | `ignoreUrls` | `Array<string \| RegExp>` | `[]` | Prefix string or RegExp; excludes from capture. |
47
+
48
+ Returned integration object also exposes `getEntries()` for manual inspection.
49
+
50
+ ## `NetworkEntry` shape
51
+
52
+ ```ts
53
+ {
54
+ method: string;
55
+ url: string;
56
+ statusCode: number | null;
57
+ duration: number | null; // ms
58
+ requestBody: unknown | null;
59
+ responseBody: unknown | null;
60
+ requestHeaders: Record<string, string>;
61
+ timestamp: string; // ISO 8601
62
+ }
63
+ ```
64
+
65
+ ## Caveats
66
+
67
+ - Patches `window.fetch` and `XMLHttpRequest` globally — anything that depends on the original references (rare) will see the wrapped versions.
68
+ - Request/response bodies are **off by default**. Turn on per-route only via a sanitizer that strips PII fields.
69
+ - The SDK's own ingest endpoint is **not** auto-excluded — add it to `ignoreUrls` if you don't want to record self-traffic (the dogfood example excludes `/sdk/events`).
70
+ - Sanitizers receive the entry **after** body capture decision; returning `null` drops the entry entirely (not just bodies).
71
+ - `getEntries()` returns a snapshot copy. Mutating it does not affect the live buffer.
72
+
73
+ ---
74
+
75
+ ## Suite overview
76
+
77
+ Full SDK suite map + platform availability matrix: [docs/sdk/overview.md](https://github.com/jawaidgadiwala/instant-tasks/blob/main/docs/sdk/overview.md).
78
+
79
+ ## License
80
+
81
+ 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
82
 
9
83
  Licensing inquiries: jawaidgadiwala@gmail.com
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koderlabs/tasks-sdk-web-network",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Browser network capture for the InstantTasks SDK — fetch + XMLHttpRequest.",
5
5
  "keywords": [
6
6
  "instanttasks",
@@ -40,7 +40,7 @@
40
40
  ],
41
41
  "sideEffects": false,
42
42
  "dependencies": {
43
- "@koderlabs/tasks-sdk": "0.1.0"
43
+ "@koderlabs/tasks-sdk": "0.1.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "tsup": "^8.3.0",
@@ -51,7 +51,7 @@
51
51
  "node": ">=20"
52
52
  },
53
53
  "publishConfig": {
54
- "access": "restricted"
54
+ "access": "public"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "tsup",