@koderlabs/tasks-sdk-web-network
v0.2.0
Published
Browser network capture for the InstantTasks SDK — fetch + XMLHttpRequest.
Downloads
723
Maintainers
Readme
@koderlabs/tasks-sdk-web-network
Runtime: browser DOM only — patches
window.fetchandXMLHttpRequest. For RN network breadcrumbs use thecaptureNetworkoption on@koderlabs/tasks-sdk-rn.
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.
By itself this package does not POST anything — it's a passive recorder.
Install
npm install @koderlabs/tasks-sdk @koderlabs/tasks-sdk-web-network
# or
pnpm add @koderlabs/tasks-sdk @koderlabs/tasks-sdk-web-network
# or
yarn add @koderlabs/tasks-sdk @koderlabs/tasks-sdk-web-networkUsage
import { init } from '@koderlabs/tasks-sdk';
import { errorsIntegration } from '@koderlabs/tasks-sdk-web-errors';
import { networkIntegration } from '@koderlabs/tasks-sdk-web-network';
init({
projectId: 'FE',
accessKey: 'sk_live_…',
integrations: [
errorsIntegration(),
networkIntegration({
maxEntries: 20,
recordRequestBody: false,
recordResponseBody: false,
ignoreUrls: [/\/sdk\/events$/, 'https://analytics.example.com'],
}),
],
});networkIntegration(opts)
| Option | Type | Default | Notes |
|---|---|---|---|
| maxEntries | number | 20 | Ring buffer size. |
| recordRequestBody | boolean | false | PII risk — off by default. |
| recordResponseBody | boolean | false | PII risk — off by default. |
| requestSanitizer | (entry) => entry \| null | — | Mutate or drop before recording. |
| responseSanitizer | (entry) => entry \| null | — | Mutate or drop before recording. |
| ignoreUrls | Array<string \| RegExp> | [] | Prefix string or RegExp; excludes from capture. |
Returned integration object also exposes getEntries() for manual inspection.
NetworkEntry shape
{
method: string;
url: string;
statusCode: number | null;
duration: number | null; // ms
requestBody: unknown | null;
responseBody: unknown | null;
requestHeaders: Record<string, string>;
timestamp: string; // ISO 8601
}Caveats
- Patches
window.fetchandXMLHttpRequestglobally — anything that depends on the original references (rare) will see the wrapped versions. - Request/response bodies are off by default. Turn on per-route only via a sanitizer that strips PII fields.
- The SDK's own ingest endpoint is not auto-excluded — add it to
ignoreUrlsif you don't want to record self-traffic (e.g. exclude/sdk/events). - Sanitizers receive the entry after body capture decision; returning
nulldrops the entry entirely (not just bodies). getEntries()returns a snapshot copy. Mutating it does not affect the live buffer.
Suite overview
Full SDK suite map + platform availability matrix: docs/sdk/overview.md.
License
KoderLabs proprietary. See LICENSE for terms. Use of this package requires a separate signed written agreement with KoderLabs; access alone confers no rights.
Licensing inquiries: [email protected]
