@koderlabs/tasks-sdk-web-network 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.
- package/README.md +83 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,9 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @koderlabs/tasks-sdk-web-network
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
npm install @koderlabs/tasks-sdk @koderlabs/tasks-sdk-web-network
|
|
13
|
+
# or
|
|
14
|
+
pnpm add @koderlabs/tasks-sdk @koderlabs/tasks-sdk-web-network
|
|
15
|
+
# or
|
|
16
|
+
yarn add @koderlabs/tasks-sdk @koderlabs/tasks-sdk-web-network
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { init } from '@koderlabs/tasks-sdk';
|
|
23
|
+
import { errorsIntegration } from '@koderlabs/tasks-sdk-web-errors';
|
|
24
|
+
import { networkIntegration } from '@koderlabs/tasks-sdk-web-network';
|
|
25
|
+
|
|
26
|
+
init({
|
|
27
|
+
projectId: 'FE',
|
|
28
|
+
accessKey: 'sk_live_…',
|
|
29
|
+
integrations: [
|
|
30
|
+
errorsIntegration(),
|
|
31
|
+
networkIntegration({
|
|
32
|
+
maxEntries: 20,
|
|
33
|
+
recordRequestBody: false,
|
|
34
|
+
recordResponseBody: false,
|
|
35
|
+
ignoreUrls: [/\/sdk\/events$/, 'https://analytics.example.com'],
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## `networkIntegration(opts)`
|
|
42
|
+
|
|
43
|
+
| Option | Type | Default | Notes |
|
|
44
|
+
|---|---|---|---|
|
|
45
|
+
| `maxEntries` | `number` | `20` | Ring buffer size. |
|
|
46
|
+
| `recordRequestBody` | `boolean` | `false` | PII risk — off by default. |
|
|
47
|
+
| `recordResponseBody` | `boolean` | `false` | PII risk — off by default. |
|
|
48
|
+
| `requestSanitizer` | `(entry) => entry \| null` | — | Mutate or drop before recording. |
|
|
49
|
+
| `responseSanitizer` | `(entry) => entry \| null` | — | Mutate or drop before recording. |
|
|
50
|
+
| `ignoreUrls` | `Array<string \| RegExp>` | `[]` | Prefix string or RegExp; excludes from capture. |
|
|
51
|
+
|
|
52
|
+
Returned integration object also exposes `getEntries()` for manual inspection.
|
|
53
|
+
|
|
54
|
+
## `NetworkEntry` shape
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
{
|
|
58
|
+
method: string;
|
|
59
|
+
url: string;
|
|
60
|
+
statusCode: number | null;
|
|
61
|
+
duration: number | null; // ms
|
|
62
|
+
requestBody: unknown | null;
|
|
63
|
+
responseBody: unknown | null;
|
|
64
|
+
requestHeaders: Record<string, string>;
|
|
65
|
+
timestamp: string; // ISO 8601
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Caveats
|
|
70
|
+
|
|
71
|
+
- Patches `window.fetch` and `XMLHttpRequest` globally — anything that depends on the original references (rare) will see the wrapped versions.
|
|
72
|
+
- Request/response bodies are **off by default**. Turn on per-route only via a sanitizer that strips PII fields.
|
|
73
|
+
- The SDK's own ingest endpoint is **not** auto-excluded — add it to `ignoreUrls` if you don't want to record self-traffic (e.g. exclude `/sdk/events`).
|
|
74
|
+
- Sanitizers receive the entry **after** body capture decision; returning `null` drops the entry entirely (not just bodies).
|
|
75
|
+
- `getEntries()` returns a snapshot copy. Mutating it does not affect the live buffer.
|
|
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-network",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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.
|
|
43
|
+
"@koderlabs/tasks-sdk": "0.1.2"
|
|
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": "
|
|
54
|
+
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsup",
|