@keploy/capture-sdk 3.1.0-rc.1 → 3.1.0-rc.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.
Files changed (52) hide show
  1. package/README.md +398 -58
  2. package/body-redact/package.json +6 -0
  3. package/body-worker-start/package.json +6 -0
  4. package/dist/body-jobs.d.ts +134 -0
  5. package/dist/body-redact.d.ts +23 -0
  6. package/dist/body-redact.js +1 -0
  7. package/dist/body-redact.js.map +1 -0
  8. package/dist/body-redact.mjs +1 -0
  9. package/dist/body-redact.mjs.map +1 -0
  10. package/dist/body-worker-none.d.ts +3 -0
  11. package/dist/body-worker-none.js +1 -0
  12. package/dist/body-worker-none.js.map +1 -0
  13. package/dist/body-worker-none.mjs +1 -0
  14. package/dist/body-worker-none.mjs.map +1 -0
  15. package/dist/body-worker-start.d.ts +3 -0
  16. package/dist/body-worker-start.js +1 -0
  17. package/dist/body-worker-start.js.map +1 -0
  18. package/dist/body-worker-start.mjs +1 -0
  19. package/dist/body-worker-start.mjs.map +1 -0
  20. package/dist/body-worker-unbundled.d.ts +1 -0
  21. package/dist/body-worker-unbundled.mjs +1 -0
  22. package/dist/body-worker-unbundled.mjs.map +1 -0
  23. package/dist/body-worker.d.ts +1 -0
  24. package/dist/body-worker.js +1 -0
  25. package/dist/body-worker.js.map +1 -0
  26. package/dist/errors.d.ts +38 -6
  27. package/dist/index.bundler.mjs +1 -0
  28. package/dist/index.bundler.mjs.map +1 -0
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +1 -11
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +1 -11
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/leave.d.ts +67 -0
  35. package/dist/module-of.d.ts +45 -0
  36. package/dist/network.d.ts +52 -37
  37. package/dist/privacy.d.ts +23 -2
  38. package/dist/recorder.d.ts +30 -6
  39. package/dist/request-term.d.ts +2 -0
  40. package/dist/request-term.js +1 -2
  41. package/dist/request-term.js.map +1 -1
  42. package/dist/request-term.mjs +1 -2
  43. package/dist/request-term.mjs.map +1 -1
  44. package/dist/strict-attributes.d.ts +9 -0
  45. package/dist/strict-attributes.js +1 -0
  46. package/dist/strict-attributes.js.map +1 -0
  47. package/dist/strict-attributes.mjs +1 -0
  48. package/dist/strict-attributes.mjs.map +1 -0
  49. package/dist/transport.d.ts +35 -3
  50. package/dist/types.d.ts +21 -5
  51. package/package.json +31 -4
  52. package/strict-attributes/package.json +6 -0
package/README.md CHANGED
@@ -58,23 +58,38 @@ npm install @keploy/capture-sdk
58
58
  A runtime dependency, not a dev one: it runs in production, on the
59
59
  page. Its only dependency is `rrweb`, which your bundler resolves; there
60
60
  are no peer dependencies. The package ships ESM and CommonJS
61
- (`dist/index.mjs`, `dist/index.js`) with types. The bundle is 41.4 kB
61
+ (`dist/index.mjs`, `dist/index.js`) with types, and a second ESM build,
62
+ `dist/index.bundler.mjs`, for the bundlers that read the `module` field
63
+ rather than the `exports` map (webpack 4, Parcel by default): the same
64
+ SDK without the worker start a page with no bundler loads from beside
65
+ it (see below), so webpack 4 never reads `import.meta`, for the web or
66
+ for node. The bundle is 40.7 kB
62
67
  (decimal) gzipped with rrweb excluded -- the ESM build; the CommonJS
63
- build is 41.7 kB -- MEASURED on the repository's build at its
64
- placeholder version (`tsup src/index.ts --minify --sourcemap --platform browser`);
68
+ build is 40.9 kB and the `module` field's build is 40.6 kB, and
69
+ `privacyMode: "strict"` alone loads its 1.3 kB attribute allow-list
70
+ beside it -- MEASURED on the repository's build at its
71
+ placeholder version (`pnpm build`, which runs `node scripts/build-main.mjs`);
65
72
  the published build carries its version in place of the placeholder,
66
73
  which moves both figures by a few bytes either way (MEASURED for
67
74
  3.1.0-rc.1: 2 B more on each build). It is fully minified, so its
68
75
  local names are shortened: that is what keeps an SDK that redacts what
69
- it records, in the browser, near its budget: 40 KiB, the CommonJS build
70
- plus the 356 B its format costs, with a TEMPORARY 464 B allowance on both
71
- builds until the Web Worker redaction PR. On the repository's build the
72
- ESM build is 415 B over its base budget and the CommonJS build 416 B. The source maps ship
73
- beside it as separate files, `dist/index.mjs.map` and
74
- `dist/index.js.map`, never inlined and carrying the SDK's own sources,
76
+ it records, in the browser, under its budget: 40 KiB, and 41,316 B for
77
+ the CommonJS build, set on 2026-11-11 as 40 KiB plus the 356 B its
78
+ format cost then (as built now, the format costs 226 B). Body
79
+ redaction is not in it: it runs in
80
+ a Web Worker, `dist/body-worker.js` (9.3 kB gzipped), which your bundler
81
+ emits beside your app and the SDK starts when a capture that redacts
82
+ bodies starts, in the page's next idle period; its main-thread copy,
83
+ `dist/body-redact.mjs` (9.4 kB), is a chunk `init()` asks for at once
84
+ for such a capture, beside rrweb, while your page's network is recorded
85
+ from the start (see [Your page's own network](#your-pages-own-network)).
86
+ A capture that masks bodies whole (`privacy.maskNetworkBodies`, which
87
+ `privacyMode: "strict"` sets) loads neither. The source maps ship
88
+ beside it as separate files, `dist/index.mjs.map`,
89
+ `dist/index.bundler.mjs.map` and `dist/index.js.map`, never inlined and carrying the SDK's own sources,
75
90
  so a stack trace from the page decodes back to the SDK's functions and
76
- lines in any tool that reads source maps. A test holds the figure, the maps and the limit: the 40 KiB
77
- budget this package is held to, plus the temporary 464 B allowance. There is no
91
+ lines in any tool that reads source maps. A test holds the figures, the maps and the limits: the 40 KiB
92
+ budget this package is held to, and 12 KiB for each body chunk. There is no
78
93
  script-tag build: the only way in is an `import`, and the SDK loads
79
94
  `rrweb` with `import("rrweb")`, which a bundler resolves. Without one,
80
95
  map the
@@ -86,12 +101,64 @@ than recording nothing in silence.
86
101
 
87
102
  A bundler that ignores a package's `exports` map -- webpack 4, as under
88
103
  Create React App 4, or Parcel 2 by default -- resolves the SDK's
89
- `request-term` subpath through the `request-term/package.json` the
104
+ `request-term` and `strict-attributes` subpaths through the
105
+ `request-term/package.json` and `strict-attributes/package.json` the
90
106
  package ships. **Parcel 2 needs the `buffer` package installed** (`npm
91
107
  install buffer`): rrweb's build reads Node's `Buffer`, and Parcel
92
108
  polyfills no Node built-in it is not given. That is rrweb's need, not
93
109
  new in this version; 3.0.1 has it too.
94
110
 
111
+ The body worker is started as `new Worker(new URL("./body-worker.js",
112
+ import.meta.url))`, which webpack 5, Next.js (webpack and Turbopack),
113
+ Vite and Parcel 2 turn into a file of your build (each is built in the
114
+ SDK's tests). These setups have no worker, and redact bodies on the
115
+ page's main thread instead, each body only up to 64 KiB (see [What a
116
+ large body looks like](#what-a-large-body-looks-like)):
117
+
118
+ - **webpack 4** cannot parse `import.meta`, so the SDK keeps it out of
119
+ every file webpack 4 reads.
120
+ - **esbuild** does not emit the worker: copy
121
+ `node_modules/@keploy/capture-sdk/dist/body-worker.js` beside your
122
+ bundle and it runs.
123
+ - **A build whose assets are served from another origin** (webpack's
124
+ `publicPath` or Next's `assetPrefix` on a CDN): a browser runs a
125
+ worker only from the page's own origin.
126
+ - **A Content-Security-Policy that does not let your origin run it**:
127
+ allow `worker-src 'self'` (or the `child-src` or `script-src` it falls
128
+ back to).
129
+ - **The SDK's files served from another origin without a bundler** (a
130
+ CDN): the chunks load from there (it must send CORS headers, as CDNs
131
+ do), the worker cannot. Import `dist/index.mjs` by its path. unpkg's
132
+ package root redirects there too; jsDelivr's answers with the file at
133
+ the root's own URL, where no chunk is beside it, so name the path
134
+ there. The SDK loads only chunks of its own version: unpkg's `?module`
135
+ rewrites the SDK's imports of its own name to the `@latest` version's
136
+ files, which `dist/index.mjs` refuses, loading its own from beside it.
137
+ A package-root URL with `?module` serves the `module` field instead,
138
+ `dist/index.bundler.mjs` (webpack 4's build), which loads no chunk from
139
+ beside it, and records every body as not captured (see below) -- and
140
+ refuses
141
+ every strict capture with `KUI_E_STRICT_ATTRIBUTES_UNAVAILABLE`,
142
+ having no allow-list to load.
143
+
144
+ **Without a bundler**, serve the package's `dist/` directory as it is
145
+ and import `dist/index.mjs` from it, with an import map for `rrweb`
146
+ alone: the SDK loads its chunks and the worker from beside
147
+ `dist/index.mjs` (`dist/body-redact.mjs`, `dist/request-term.mjs`,
148
+ `dist/strict-attributes.mjs` under strict, and
149
+ `dist/body-worker-unbundled.mjs`, which starts `dist/body-worker.js`),
150
+ and an import map that maps `@keploy/capture-sdk/body-redact`,
151
+ `/body-worker-start`, `/request-term` or `/strict-attributes` is
152
+ honoured first. A page that serves `dist/index.mjs` alone has no code
153
+ to redact a body with, and records each body as not captured, never in
154
+ the clear (under strict it records nothing, refused with
155
+ `KUI_E_STRICT_ATTRIBUTES_UNAVAILABLE`):
156
+
157
+ ```
158
+ [Body cut: 0 of N characters kept, unverified]
159
+ [Body not captured: the redaction code could not load]
160
+ ```
161
+
95
162
  ## Use
96
163
 
97
164
  One call, as early in your app's startup as you can make it:
@@ -117,7 +184,7 @@ SDK uses when you leave them out:
117
184
 
118
185
  | option | default | what it does |
119
186
  | --------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
120
- | `privacyMode` | `"balanced"` | `"balanced"` masks every typed input value; `"strict"`, for public sites, also masks every visible text node, records no request or response body and replaces every query value in a URL; `"off"` masks only password and hidden fields — see [Privacy](#privacy) |
187
+ | `privacyMode` | `"balanced"` | `"balanced"` masks every typed input value; `"strict"`, for public sites, records no page text -- it also masks every visible text node, blanks every attribute, `<meta>` content and comment that holds text, records no request or response body and replaces every query value in a URL; `"off"` masks only password and hidden fields — see [Privacy](#privacy) |
121
188
  | `sampleRate` | `1` | fraction of sessions recorded, decided once when a session starts. `0.1` records one visitor in ten; the rest never start |
122
189
  | `networkCapture` | `true` | record `fetch` and `XMLHttpRequest` exchanges. `false` records the DOM only |
123
190
  | `maxSessionDuration` | `600000` | milliseconds after which a session ends on its own (10 minutes): recording stops, the queue is flushed, and a later `init()` starts a new session -- or, with `continuous`, the next one starts by itself |
@@ -379,10 +446,12 @@ loaded again.
379
446
 
380
447
  Once rrweb has loaded, what was held is sent in order, one batch
381
448
  (`batchSize` events) per round trip, and a visitor who leaves while
382
- more is still waiting than one unload request carries (64 KiB, below)
449
+ more is still waiting than one unload request carries (32 KiB, below)
383
450
  loses the first event that does not fit and everything behind it: a
384
451
  snapshot larger than that by itself, or a smaller one whose backlog has
385
- not gone yet. MEASURED in review, in Chromium, with a navigation 100 ms
452
+ not gone yet. MEASURED in review, in Chromium, when that request carried
453
+ 64 KiB (before 3.1.0-rc.2; the 51 KB and 53 KB snapshots below are now
454
+ over it, so they are sent the moment they are queued), with a navigation 100 ms
386
455
  after the network came back: a 141 KB snapshot behind the requests a
387
456
  page made offline was lost 4 times of 4 (an ingest answering in
388
457
  150 ms), and a 51 KB one 3 times of 3 behind 95 requests, where behind
@@ -418,10 +487,10 @@ Those two are the reason this SDK hands rrweb its own map: rrweb's
418
487
  `maskAllInputs` covers the other sixteen rows and neither of these.
419
488
 
420
489
  `radio`, `checkbox`, `submit`, `button`, `reset` and `image` are **not**
421
- in that table: their `value` is recorded verbatim in every mode,
422
- `strict` included. For the first four nothing can reach it —
423
- rrweb serialises those four before masking is consulted, so no option
424
- this SDK could pass would change them. `reset` and `image` could be
490
+ in that table: their `value` is recorded verbatim under `balanced` and
491
+ `off`, and blanked under `strict` (below). For the first four rrweb
492
+ serialises the value before masking is consulted, so no option this
493
+ SDK could pass rrweb would change them; strict blanks them after. `reset` and `image` could be
425
494
  masked and deliberately are not: a reset button's value is the caption
426
495
  it shows, and an image button's is metadata the page's author wrote,
427
496
  neither being anything the person using the page entered. For the
@@ -430,6 +499,84 @@ whose value is an email address, say — the only lever is
430
499
  `privacy.blockSelectors`, and that removes the element from the
431
500
  recording altogether.
432
501
 
502
+ **Strict records no page text in the DOM.** Text lives in more places
503
+ than text nodes, and a page can copy a visitor's search into any of them
504
+ (a search page's `<title>` and `<meta name="description">`). Under
505
+ `strict`, attributes are read by an ALLOW-LIST: an attribute keeps its
506
+ value only when its name is the page's structure -- `id`, `class`,
507
+ `role`, `name`, `type`, `data-testid`, ARIA state and relationships
508
+ (`aria-expanded`, `aria-labelledby`), form and layout attributes (`for`,
509
+ `disabled`, `colspan`, `width`), SVG geometry and paint (`d`,
510
+ `viewBox`, `fill`) and rrweb's own -- or when its own rule reads it: a
511
+ URL (query values replaced), CSS, a `srcset`, a `srcdoc` (its text and
512
+ attributes masked the same way, its scripts included). Every other
513
+ value is recorded as `""`: `title`, `alt`, `placeholder`, `aria-label`
514
+ and the other `aria-*` text, every `data-*` but `data-testid`, every
515
+ `value` rrweb records in clear (a field's that rrweb masked keeps its
516
+ asterisks), a framework's state (`wire:snapshot`, `x-data`, `hx-vals`,
517
+ an Astro island's `props`), a custom element's attributes but its
518
+ global ones (`id`, `class`, `slot`, ARIA state), an input's `min`,
519
+ `max` and `pattern` (a date range copies the start the visitor picked
520
+ into the end's `min`; a confirm field copies a typed email into
521
+ `pattern`) and `aria-valuenow` (a slider's chosen value). SVG geometry
522
+ and paint are kept on SVG elements only, by exact name. A `<meta>`'s
523
+ `content` is blanked unless the meta configures the page (`http-equiv`,
524
+ or a `name` of `viewport`, `color-scheme`, `theme-color`, `referrer`,
525
+ `robots` or `format-detection`) -- in a mutation, unless the change itself carries that `http-equiv` or
526
+ `name`, and in a `srcdoc`, always. A comment is blanked; a checkbox's or
527
+ radio's value in an Input event is asterisks. The `<title>` element's
528
+ text and SVG `<text>` are text nodes, masked as every other.
529
+
530
+ The allow-list is a chunk of its own, `dist/strict-attributes.mjs`
531
+ (`.js` for CommonJS), which only `strict` loads: `balanced` and `off`
532
+ never ask for it and carry none of its bytes. Under `strict` the SDK
533
+ imports it at `init()`, in parallel with rrweb, and records nothing
534
+ until both have loaded, so no snapshot is ever taken without it. A
535
+ bundler emits it as a chunk; with no bundler, serve dist/ as it is and
536
+ the SDK loads it from beside `dist/index.mjs`. If it cannot be loaded (a
537
+ Content-Security-Policy, a network failure, a deployment that drops the
538
+ file), the capture ends before anything is recorded or sent, with
539
+ `KUI_E_STRICT_ATTRIBUTES_UNAVAILABLE` (see [When the server rejects a batch](#when-the-server-rejects-a-batch)): strict
540
+ records nothing rather than attributes it cannot read.
541
+
542
+ ARIA under strict keeps what describes the widget -- its structure
543
+ (`aria-level`, `aria-posinset`, row and column counts), its relationships
544
+ (`aria-labelledby`, `aria-controls` and the other id references), its
545
+ configuration (`aria-haspopup`, `aria-orientation`, `aria-required`) and
546
+ `aria-expanded`/`aria-hidden` -- and blanks every one that reflects what
547
+ the visitor chose or entered: `aria-valuenow`, `aria-valuemin`,
548
+ `aria-valuemax` (a two-thumb slider's bounds are the other thumb's chosen
549
+ value), `aria-valuetext`, `aria-checked`, `aria-selected`,
550
+ `aria-pressed`, `aria-current`, `aria-sort`, `aria-invalid` and
551
+ `aria-activedescendant`; HTML's `checked` and `selected` are dropped
552
+ (rrweb records `checked` as a boolean, and its presence is the choice).
553
+ A checkbox's or radio's Input event still says whether it is checked
554
+ (`isChecked`): the replay needs it to click it. A
555
+ URL-named attribute (`href`, `src`, `action`, `data`, `cite` and the
556
+ rest) keeps a value only when it can be a URL -- no space, quote or
557
+ brace -- through the URL rule (path kept, query values replaced), on a
558
+ custom element as on any other; text in one is blanked.
559
+
560
+ What strict still records, so do not put a visitor's text there: URL
561
+ PATHS (`/search/<term>`, a `#/search/<q>` route, a `<link
562
+ rel="canonical">`; only query and fragment-pair values are replaced),
563
+ `id`s and `class`es, `data-testid` (an app that builds one from user
564
+ data, `row-${email}`, records it), a field's `name`, SVG geometry (a
565
+ signature pad's strokes are its `d`) and text under `unmaskSelectors`. A comment
566
+ outside `<html>` that changes after the snapshot is recorded as rrweb
567
+ records it. And the replay's look pays for it: CSS keyed on a `data-*`
568
+ (`[data-theme=dark]`, Radix's `data-state=open`) or on a `title` no
569
+ longer matches in a strict recording, and a `<progress>` or `<meter>`
570
+ shows no value; an animated or filtered SVG (SMIL `from`/`to`/`dur`,
571
+ filter `basefrequency`/`tablevalues`) and legacy table attributes
572
+ (`bgcolor`, `cellpadding`) replay without them. MEASURED on keploy.io/docs (Docusaurus), replayed
573
+ with rrweb: the layout, colours, cards and icons render and the text is
574
+ asterisks; the themed logo and the colour-mode toggle's icon are gone,
575
+ because Docusaurus shows them by `[data-theme]` CSS. Blank, not asterisks: the flow engine reads an empty
576
+ `aria-label` as none, so a strict recording never names an element by
577
+ a label it does not have; give a control that has only a label a
578
+ `data-testid`.
579
+
433
580
  `privacy.blockSelectors` names elements whose content is never
434
581
  recorded — a video, a chat widget, a wall of customer names — rrweb
435
582
  records an empty box of the same size in their place.
@@ -560,7 +707,7 @@ declined `init()`, and the console line is written once per page.
560
707
  `"grant_type=password&password=…"`, `"Location: /cb#access_token=…"`).
561
708
  A credential's value there runs to the next `&` or the string's end,
562
709
  its spaces and line breaks its own (`"password=correct horse battery
563
- staple"` records `"password=[REDACTED]"`, a PEM key goes whole), so
710
+ staple"` records `"password=[REDACTED]"`, a PEM key goes whole), so
564
711
  what follows it before the next `&` goes with it; one that starts
565
712
  where a text body's value cannot -- a space, a quote, a backtick, a
566
713
  bracket, `<`, `>`, `,`, `;` or a backslash -- is code's and is kept
@@ -570,7 +717,7 @@ declined `init()`, and the console line is written once per page.
570
717
  their bytes (`let a=1;token=getToken()`, `SET password=?`, a class's
571
718
  `#token=null`) -- so a pair a string's prose starts after a `;`, a
572
719
  space or a line break (`"user=bob; password=…"`, `"go to
573
- #access_token=…"`) is not read there, as it is in a text body. Every URL a body holds is read by the one URL rule below: each
720
+ #access_token=…"`) is not read there, as it is in a text body. Every URL a body holds is read by the one URL rule below: each
574
721
  line of a JSON string, a form value or a body that starts with a URL
575
722
  (`https://…?…`, `./cb#…`, `cb?jwt=…`, `/cart;jsessionid=…`), read
576
723
  whole to the line's end — a raw space in a query is its value's, and a
@@ -689,7 +836,27 @@ expected, actual}`, a header list `[{name: "Set-Cookie", value}]` —
689
836
  so it may lose everything from its first sensitive `=` to the cut;
690
837
  that is the price of never keeping half a credential the cut split.
691
838
  `privacy.maskNetworkBodies: true` replaces every body wholesale with
692
- `[MASKED]` instead (a request that had no body keeps `null`).
839
+ `[MASKED]` instead, decided without the SDK reading it: the page's
840
+ Response is the network's own, never read, cloned or relayed, a body
841
+ passed in `fetch()`'s `init` or to `send()` is decided from its kind
842
+ and size, never serialised or decoded (only a string one is scanned,
843
+ for its `requestTerm`, below), and the body chunk is never loaded.
844
+ The browser still makes a body passed in `fetch()`'s `init` the body
845
+ of the `Request` the SDK builds from the call for its URL and headers,
846
+ so it byte-copies a buffer, UTF-8 encodes a string or URLSearchParams
847
+ and multipart-encodes a FormData once more than the page's own
848
+ `fetch()` does (a Blob or a stream is taken as it is); the SDK reads
849
+ none of it. One body is still read: a `Request` object's own
850
+ (`fetch(new Request(url, { body }))`, as ky and axios's fetch adapter
851
+ send one) is copied and read for its `requestTerm` (below), only as
852
+ far as the term needs -- whole when it starts as a JSON object, to its
853
+ first character otherwise (where a `Request` has no body stream, as
854
+ in Firefox, the copy is taken whole as a Blob and only its first KiB
855
+ decoded), and a multipart one is parsed. A body that is absent keeps `null`: a
856
+ request sent with none or an empty one (but an XHR's Blob, which is
857
+ named however small), and a response to a HEAD, a 204, 205 or 304,
858
+ or one whose `Content-Length` is 0. A response that does not declare
859
+ its length is `[MASKED]`, even one that turns out empty.
693
860
  `privacyMode: "strict"` forces that: no body is recorded, and an
694
861
  explicit `privacy.maskNetworkBodies: false` beside it is refused with
695
862
  `KUI_E_PRIVACY_CONFLICT` before anything is recorded — neither option
@@ -1175,13 +1342,23 @@ import { PrivacyEngine } from "@keploy/capture-sdk";
1175
1342
  new PrivacyEngine().maskText("contact user@example.com now"); // "contact [REDACTED] now"
1176
1343
  ```
1177
1344
 
1345
+ `maskNetworkData(event)` masks a network event's headers and URL as the
1346
+ capture does; its BODIES are redacted by the SDK's body code, which is not
1347
+ in the main bundle (it runs in the body worker, see [Your page's own
1348
+ network](#your-pages-own-network)). Called directly, it redacts them once
1349
+ a capture on the page has loaded that code -- which it loads at the
1350
+ capture's start, beside rrweb, when bodies are not masked whole -- and
1351
+ until then
1352
+ records each body `[MASKED]`, never in the clear. Changed in this version: it used to redact them itself, always.
1353
+
1178
1354
  ## Your page's own network
1179
1355
 
1180
1356
  With network capture on, `fetch()` resolves when the response's headers
1181
1357
  arrive, exactly as without the SDK, and the body reaches the page as the
1182
1358
  network delivers it: a streamed response -- SSE over `fetch`, NDJSON, an
1183
1359
  LLM's tokens, a live log view read with `getReader()` -- streams. The SDK
1184
- reads each body once, as its only reader, and hands every chunk on to
1360
+ reads each body once (none when bodies are masked whole), as its only
1361
+ reader, and hands every chunk on to
1185
1362
  the page; it reads ahead of the page only until it has the recording
1186
1363
  (the whole body, or `maxBodySize` of it), so a body the page reads slowly
1187
1364
  is not buffered for it, and a page that cancels (`reader.cancel()`, a
@@ -1196,20 +1373,124 @@ arrived, cut and marked `...[truncated]`; the SDK may have read that far
1196
1373
  ahead of the page. Each of these, whole or cut, is redacted exactly as
1197
1374
  any other recorded body is.
1198
1375
 
1199
- The page has its body first. The SDK redacts and records an exchange in
1200
- a task of its own, after the page's stream has ended and its Response
1201
- resolved (in an idle period where the browser has
1202
- `requestIdleCallback`, at most a second later), never inside the relay.
1203
- In Firefox a page's `text()` or `json()` can still resolve just after
1204
- the redaction, which Firefox finishes through tasks of its own; moving
1205
- the redaction into a Web Worker, next, removes that. MEASURED before
1206
- this: 50 parallel 64 KB JSON fetches took 32 ms without the SDK and
1376
+ The page has its body first. The SDK hands each body to a Web Worker,
1377
+ which redacts it off your page's main thread. It does so in a task of
1378
+ its own, after the page's stream has ended and its Response resolved
1379
+ (in an idle period where the browser has `requestIdleCallback`, at most
1380
+ a second later), never inside the relay: the page's thread copies the
1381
+ body over there (0.04 to 0.14 ms for 64 to 256 KB, MEASURED) and, in
1382
+ another idle period after the relay is over, records the answer. A
1383
+ browser with no idle periods (Safari) copies the body inside the relay
1384
+ instead, as the SDK reads its end or its cap -- while the page may still
1385
+ be reading the rest of a body past the cap -- since a task of its own
1386
+ would fall inside the page's work all the same. So a burst of responses or a
1387
+ run of large POSTs costs it no redaction, and nothing the SDK does can
1388
+ interleave with a page's `text()`. MEASURED before the page-first
1389
+ change: 50 parallel 64 KB JSON fetches took 32 ms without the SDK and
1207
1390
  382 ms with it in Chromium. The exchange keeps its time and its place
1208
- in the recording; `stop()`, `pause()`, the session's end and the page
1209
- leaving record at once any exchange whose task has not run yet, and a
1210
- hidden tab does before its last upload.
1391
+ in the recording. The page leaving and `stop()`'s one-second bound
1392
+ record at once every body still in the worker, on the main thread up to
1393
+ 64 KiB in all and cut past it -- with the main thread's chunk, which
1394
+ `init()` asks for at once, beside rrweb, for a capture that redacts
1395
+ bodies. Neither moment can wait for it,
1396
+ so a body they find before it has arrived (it arrives once its fetch is
1397
+ over; offline, once the browser is back) is recorded as not captured, and
1398
+ never in the clear: the cut note with nothing kept, then a second line
1399
+ that says why. A page whose chunk could not load at all (a CSP that
1400
+ refuses it, a 404 after a deploy, `dist/index.mjs` served alone) records
1401
+ each body the main thread must redact the same way, with its own reason
1402
+ (and logs `KUI_E_BODY_WORKER_UNAVAILABLE` once per page):
1403
+
1404
+ ```
1405
+ [Body cut: 0 of N characters kept, unverified]
1406
+ [Body not captured: the page left or the capture stopped before redaction was ready]
1211
1407
 
1212
- The Response your page gets is one the SDK built around that body. Its
1408
+ [Body cut: 0 of N characters kept, unverified]
1409
+ [Body not captured: the redaction code could not load]
1410
+ ```
1411
+
1412
+ (`notCapturedBodyNote(N, why)` in `@keploy/contract/privacy`, `why`
1413
+ being `"left"` or `"code-failed"`, and `isNotCapturedBody(body, why?)`,
1414
+ which tells either from a body cut at the budget, and one cause from the
1415
+ other). Replay never serves it, as any cut body.
1416
+
1417
+ A page that is leaving starts none of the SDK's own loads (its chunks,
1418
+ rrweb's import and the body worker), and a load its leave refused or
1419
+ cancelled is held, not judged failed: a body the page leaves on is
1420
+ recorded with the first reason, and nothing is logged. A single-page
1421
+ app's route the Navigation API intercepted is no leave (the SDK reads
1422
+ `navigation.transition` a task after the `navigate`). The leave ends only
1423
+ on something a navigation still on its way cannot produce: Chromium's
1424
+ abort of the leaving navigation when no navigate came after it (an
1425
+ "unsaved changes" prompt the visitor cancelled; a link clicked twice,
1426
+ Enter pressed twice and the page's own `history.replaceState` in its
1427
+ `beforeunload` abort it too, each followed by a navigate, so none ends
1428
+ it), `pageshow` from the back/forward cache, or a capture start by the
1429
+ page's script (never a continuous capture's next session, which the
1430
+ visitor's input starts).
1431
+ The SDK then asks once more for what it held -- a worker whose script had
1432
+ not run yet included (Firefox cancels that load and says nothing; the
1433
+ worker says it runs as its first act). Neither `navigatesuccess` nor the
1434
+ visitor's input ends it: the page's own `pushState` or `replaceState`
1435
+ fires a `navigatesuccess` while a real navigation still loads, and the
1436
+ old page gets every click and key then, also after a prompt the visitor
1437
+ accepted. An app's route that comes after a navigation has begun ends no
1438
+ leave either. So a prompt cancelled in Firefox or WebKit, a download, a
1439
+ 204 and a `mailto:` link in Chromium keep the page leaving until a
1440
+ `pageshow` from the back/forward cache or a capture start by the page's
1441
+ script, its bodies recorded with the first reason and nothing logged.
1442
+ While the page leaves, a body of the leave (its exchange answered after
1443
+ the leave began) goes to the worker only if one runs: with none
1444
+ running, it is recorded with the first reason at once and its string
1445
+ dropped, so no body waits on a load the leave holds, and none
1446
+ goes to the main thread's budget because of a leave (a page with no
1447
+ worker at all redacts there as ever). A body the page was still reading
1448
+ (a fetch or an XHR whose headers had arrived), or already waiting for the
1449
+ worker's start, as the leave began is
1450
+ recorded when it can wait no longer -- so one the leave cut (Firefox
1451
+ and WebKit abort a page's fetches as it navigates, before `pagehide`)
1452
+ is recorded cut where the page left, and an XHR the leave aborts as the
1453
+ browser leaves it, status 0 and no response body (XMLHttpRequest drops
1454
+ what had arrived), its request body redacted -- on the main thread once the body code is there: a hidden tab
1455
+ records only those that fit whole, and its session's end or the page
1456
+ leaving the rest, within 64 KiB shared by all of them (those that fit
1457
+ whole first, the rest cut to what is left); with the first reason
1458
+ while the code is not there. A continuous capture's later sessions are
1459
+ no exception: the visitor's input starts each, so none ends that
1460
+ leave. A worker running as the page leaves is kept across their ends
1461
+ and redacts their bodies as ever; a session live or waiting as the
1462
+ leave ends takes it over, and it goes when no capture is live and none
1463
+ waits (the leave's end or `stop()`), at `pagehide` whatever waits (a page
1464
+ entering the back/forward cache keeps no thread; a body after a persisted
1465
+ `pageshow` starts one again), or at a session's end outside a leave, as
1466
+ ever. Without one, their bodies are recorded with
1467
+ the first reason until the leave ends. A body's strings go as it is
1468
+ recorded, so nothing the SDK holds grows with the sessions. Nothing is
1469
+ logged. `init()` never
1470
+ waits on a held load: when a leave holds rrweb's import, `init()`
1471
+ resolves once the capture is set up, and rrweb records from when its
1472
+ import lands after the leave ends; until then no DOM events are recorded,
1473
+ and nothing is logged. The same holds for a continuous capture's session
1474
+ the visitor's input starts while the page is leaving: it opens at once.
1475
+ And no GraphQL request waits on a held load: one whose term code has not
1476
+ loaded is recorded with the term `body:*` at once while the page is
1477
+ leaving, and nothing is logged; once the leave ends the code is asked
1478
+ for, and later requests carry their term. A navigate the app intercepts
1479
+ (a single-page app's route) is no leave: a request the route sends as it
1480
+ begins waits the one task it takes to know that, and has its term.
1481
+
1482
+ The browser coming back online (before
1483
+ the upload that ends an outage, when the body code had loaded before
1484
+ it went offline: nothing is fetched offline, so a page that went
1485
+ offline before its first body records it once back online), a hidden tab before its last upload
1486
+ and `stop()` record at once what fits in that budget and leave the rest
1487
+ to the worker; `pause()` cuts a body still arriving and records it when
1488
+ the worker answers.
1489
+
1490
+ The Response your page gets is one the SDK built around that body
1491
+ (unless bodies are masked whole, or it answers a HEAD or is a 204,
1492
+ 205 or 304, which have no body: then it is the network's own, and
1493
+ none of what follows applies). Its
1213
1494
  `url`, `redirected`, `type`, `headers` and `clone()` answer as the
1214
1495
  network's do, and `instanceof Response`, `bodyUsed` and BYOB readers
1215
1496
  behave as usual. Three things differ:
@@ -1225,7 +1506,7 @@ behave as usual. Three things differ:
1225
1506
  `WebAssembly.instantiateStreaming()` likewise does not see the
1226
1507
  response's URL (it still compiles).
1227
1508
  - A **streamed upload built into a `Request`** (`new Request(url, { body:
1228
- stream, duplex: "half" })`) that the server answers early is pulled
1509
+ stream, duplex: "half" })`) that the server answers early is pulled
1229
1510
  further than without the SDK -- up to the chunk that crosses
1230
1511
  `3 x maxBodySize + 4` bytes (about `maxBodySize` bytes for ASCII). The
1231
1512
  SDK records a Request's body from a copy of it, and that copy reads the
@@ -1307,6 +1588,20 @@ A file inside `FormData` is not one of these: the body is still
1307
1588
  recorded, and that field's value is `[File: name, N bytes]`, URL-encoded
1308
1589
  with the rest of the form. The file's bytes are never read.
1309
1590
 
1591
+ **Where the page has no body worker** (see [Install](#install)), a
1592
+ body is redacted on the page's main thread, and only up to 64 KiB of
1593
+ it: a body over that is recorded cut, its first 64 KiB redacted as
1594
+ above under a first line that says so, `[Body cut: 65536 of N
1595
+ characters kept, unverified]`. The same note marks a body still in the
1596
+ worker when the page leaves, past the 64 KiB the page's last moment
1597
+ redacts (0 kept when nothing was left), and, with nothing kept and a
1598
+ second line saying why, a body the SDK did not capture: the page left
1599
+ before the body chunk had arrived, or the chunk could not load (see
1600
+ [Your page's own network](#your-pages-own-network)).
1601
+ It is not the response the server sent, and replay never serves it as
1602
+ one: the request is answered as a failed one and a test that reaches it
1603
+ is reported `unproven`.
1604
+
1310
1605
  Lower `maxBodySize` to save bandwidth and you will get the second
1311
1606
  answer for most large JSON, not a shorter body. If you need the shape
1312
1607
  of a large response more than its contents, that is the trade.
@@ -1345,7 +1640,7 @@ than thrown back into the code that emitted it; so is an event that
1345
1640
  alone is over the ingest server's 10 MiB body cap (an rrweb snapshot
1346
1641
  of a very large page, a captured body under a raised `maxBodySize`),
1347
1642
  which no batch could carry. The first of each kind in a capture logs a
1348
- `console.error`; any after it are dropped silently, because an emitter in a render loop
1643
+ `console.warn`; any after it are dropped silently, because an emitter in a render loop
1349
1644
  would otherwise write a line every few milliseconds into the page the
1350
1645
  SDK is there to record. `onError` is not called — that is reserved
1351
1646
  for a condition that ENDS the capture, and this session goes on
@@ -1407,7 +1702,11 @@ says so once per capture, naming the method:
1407
1702
  `bytes`, `cap`), `KUI_E_EVENT_OVERSIZED_SCRUBBING` (evidence
1408
1703
  `eventType`, `atLeast`, `cap` -- no id: the event never reached the
1409
1704
  queue), `KUI_E_NAVIGATION_UNWRAPPED` (evidence `method`) and
1410
- `KUI_E_REQUEST_TERM_FAILED` (evidence `method`, `reason`; below) are
1705
+ `KUI_E_REQUEST_TERM_FAILED` (evidence `method`, `reason`; below) and
1706
+ `KUI_E_BODY_WORKER_UNAVAILABLE` (below) are written with `console.warn`, never `console.error`: the capture goes on,
1707
+ and a page whose tests or error tracker fail on `console.error` must
1708
+ not fail on one. `console.error` is kept for a capture that ENDS (an
1709
+ `init()` refused, a server rejection, both below). They are
1411
1710
  warning-severity entries of the same error corpus as the codes above, and `SDK_WARNINGS` carries a short summary of each and the
1412
1711
  link to its corpus page, where the remedy is; a program that only has the console
1413
1712
  can match the token and parse the JSON after the first `evidence=`
@@ -1428,7 +1727,9 @@ page that sends none never loads it; your bundler resolves it as it
1428
1727
  resolves rrweb. Where it does not load (a Content-Security-Policy, offline,
1429
1728
  a 404), each such request is recorded `body:*`, as a page with no
1430
1729
  SubtleCrypto records it, and the load is not retried for the life of the
1431
- page. At replay `body:*` matches a live request of the same method and
1730
+ page. While the page is leaving, a request is recorded `body:*` the same
1731
+ way if the code has not loaded, without the warning; a load the leave
1732
+ held, not yet failed, is asked for when the leave ends. At replay `body:*` matches a live request of the same method and
1432
1733
  URL whatever its term; a recorded key equal to the live one is chosen
1433
1734
  first. The first
1434
1735
  such request in a capture logs
@@ -1439,6 +1740,24 @@ entry of the same corpus, on one line of the same shape:
1439
1740
  [keploy] KUI_E_REQUEST_TERM_FAILED: recorded a request without its term, or body:*: computing it failed; the request itself was not affected. The capture continues; any further such requests in this capture are recorded that way, silently. evidence={"method":"POST","reason":"RangeError: Maximum call stack size exceeded"}
1440
1741
  ```
1441
1742
 
1743
+ A page that cannot run the SDK's body worker or load its body chunk (see
1744
+ [Install](#install): a Content-Security-Policy that refuses the worker,
1745
+ webpack 4, esbuild without the file copied, a build served from another
1746
+ origin or from a CDN, a page without a bundler that serves
1747
+ `dist/index.mjs` alone) still records every
1748
+ exchange: without the worker it redacts bodies on the main thread and
1749
+ records a body over 64 KiB cut; without the body chunk too, a body the
1750
+ main thread must redact is recorded as not captured, with nothing kept,
1751
+ under `[Body not captured: the redaction code could not load]`. Replay
1752
+ reports a test over a cut or not-captured body `unproven`. It
1753
+ logs `KUI_E_BODY_WORKER_UNAVAILABLE` (evidence `part`: `worker` or
1754
+ `code`, and `reason`: what the browser said), a warning entry of the same
1755
+ corpus, once per page for each part, at its first failure:
1756
+
1757
+ ```
1758
+ [keploy] KUI_E_BODY_WORKER_UNAVAILABLE: could not run the body worker or load the body chunk (evidence.part): without the worker, a body over 64 KiB is recorded cut; without the chunk, a body the main thread must redact is recorded with nothing kept; replay reports a test over a cut body unproven. Allow worker-src 'self' in the page's CSP, use a bundler that emits the worker (or copy dist/body-worker.js beside the bundle), serve it from the page's origin, or serve the SDK's dist/ as it is. Said once per page for each part. evidence={"part":"worker","reason":"the worker's script did not load or run (refused by the page's CSP, a 404, or a script that does not parse)"}
1759
+ ```
1760
+
1442
1761
  ### The last batch
1443
1762
 
1444
1763
  When the page unloads — a navigation, a tab close — whatever is still
@@ -1446,8 +1765,22 @@ queued is sent in one `keepalive` request from the `pagehide` handler.
1446
1765
  Browsers cap the sum of a document's in-flight keepalive bodies at
1447
1766
  64 KiB (MEASURED in Chromium 145: 65,536 bytes accepted, 65,537
1448
1767
  refused), and a request over that is refused before it leaves, losing
1449
- everything in it. So that last request is cut at the first event that
1450
- does not fit, oldest first, and what does not fit stays behind — an
1768
+ everything in it. That quota is the PAGE's as well: a lead form's
1769
+ keepalive POST or an analytics `sendBeacon` is refused while the SDK
1770
+ holds it (MEASURED with a 63 KB upload on the wire: the page's 2 KB
1771
+ beacon refused in Chromium and WebKit, its keepalive fetch in WebKit).
1772
+ So the SDK keeps its own keepalive bodies in flight to half of it,
1773
+ 32 KiB, counting what is still on the wire, and leaves the page the
1774
+ rest. An upload over 32 KiB gzipped goes without `keepalive`, so a
1775
+ navigation before it completes cancels it (a tab close does not). A
1776
+ queue past what the pagehide request can carry is sent at once, as a
1777
+ plain fetch -- never `keepalive`, so the pagehide request keeps the
1778
+ SDK's whole share -- one upload at a time, ending once the queue is back
1779
+ under. Events queued behind an upload still on the wire when the visitor
1780
+ leaves go in the pagehide request, up to 32 KiB; the upload on the wire
1781
+ is cancelled by the navigation (a tab close lets it finish). The
1782
+ pagehide request is cut at 32 KiB, at the first event that does not fit,
1783
+ oldest first, and what does not fit stays behind — an
1451
1784
  event held back is one whose node ids the events after it depend on,
1452
1785
  so shipping past it would be worse than stopping there.
1453
1786
 
@@ -1460,7 +1793,7 @@ sees the session in order.
1460
1793
  What is **not**: a request already on the wire when the document dies.
1461
1794
  A keepalive request survives the document, so it usually arrives — but
1462
1795
  if it does not, the SDK cannot know and cannot resend it. And an event
1463
- whose JSON, with the envelope that wraps it, exceeds the 64 KiB cap
1796
+ whose JSON, with the envelope that wraps it, exceeds the SDK's 32 KiB
1464
1797
  cannot travel this way at all; the SDK posts such an event the moment
1465
1798
  it is queued rather than leaving it to be cut here — but not while the
1466
1799
  browser reports itself offline (`navigator.onLine`, read each time: the
@@ -1496,19 +1829,20 @@ rather than handing back the one that failed.
1496
1829
  The `CaptureError` is for the program, not just the person reading the
1497
1830
  console. Branch on `code`, never on the message:
1498
1831
 
1499
- | `code` | the server answered | what to do (in short; see `remedy.docs`) |
1500
- | --------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1501
- | `KUI_E_INGEST_KEY_REJECTED` | 401 or 403 | the key is missing, unknown, expired, revoked, or not a UI ingest key (a personal access token is refused) — mint one with `POST <api-server>/client/v1/apps/<appId>/ui/ingest-keys` and a personal access token (the MCP tool `uiCaptureSetup` does the same) and pass it as `apiKey` |
1502
- | `KUI_E_INGEST_ENDPOINT_NOT_FOUND` | 404 or 405 | `endpoint` is wrong, not the key — the ingest route is `<api-server>/ui/v1/ingest`. Only a typo under `/ui/v1/` or a same-origin proxy produces this; a wrong endpoint on another origin fails its CORS preflight, which the SDK can only retry as a network error, so silence is not proof the endpoint is right |
1503
- | `KUI_E_SESSION_CONFLICT` | 409 | this session id is already claimed — give each run its own, usually by removing a fixed-value `sessionIdGenerator` |
1504
- | `KUI_E_INGEST_REJECTED` | any other terminal 4xx | read `serverMessage`; `ui session has reached its size limit` means stop and re-init for a new session; a 413 holding neither of the server's sentences is a proxy's own body limit, so raise it to at least 10 MiB; anything else is an SDK/server version mismatch (the SDK checks the session id, clamps `batchSize` and cuts every batch at the 10 MiB body cap before sending, so nothing you configure produces one) and `issues` names the field |
1505
- | `KUI_E_SESSION_ID_INVALID` | nothing — raised before the first byte | `sessionIdGenerator` returned a string outside the server's rule (`evidence.rule`), returned a non-string, or threw — `evidence.received` says which; make it return a string inside the rule, or remove the override |
1506
- | `KUI_E_DOM_RECORDER_UNAVAILABLE` | nothing — raised before anything is sent | rrweb could not be imported in the browser (`evidence.reason` says why) — load the SDK through a bundler, or map `rrweb` with an import map; a blocked chunk (CSP, network) is refused the same way |
1507
- | `KUI_E_PRIVACY_ROUTE_INVALID` | nothing — raised before the first byte | a `privacy.secretRoutes` or `privacy.keepRoutes` entry is no route (`evidence.option`, `evidence.received`, `evidence.rule`) — rewrite it inside the rule (`/invites/:key`) or remove it |
1508
- | `KUI_E_CAPTURE_DECLINED` | nothing — raised before anything is recorded | the browser sent Do Not Track or Global Privacy Control (`evidence.signal`) and `honorPrivacySignals` is on: the person using the page said no, and nothing needs fixing |
1509
- | `KUI_E_PRIVACY_CONFLICT` | nothing — raised before anything is recorded | `privacyMode: "strict"` records no body and `privacy.maskNetworkBodies` is `false`, which asks for them (`evidence.option`): remove that option, or use `"balanced"` if the recording needs bodies |
1510
-
1511
- `onError` receives one of six subclasses of `CaptureError`, and
1832
+ | `code` | the server answered | what to do (in short; see `remedy.docs`) |
1833
+ | ------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1834
+ | `KUI_E_INGEST_KEY_REJECTED` | 401 or 403 | the key is missing, unknown, expired, revoked, or not a UI ingest key (a personal access token is refused) — mint one with `POST <api-server>/client/v1/apps/<appId>/ui/ingest-keys` and a personal access token (the MCP tool `uiCaptureSetup` does the same) and pass it as `apiKey` |
1835
+ | `KUI_E_INGEST_ENDPOINT_NOT_FOUND` | 404 or 405 | `endpoint` is wrong, not the key — the ingest route is `<api-server>/ui/v1/ingest`. Only a typo under `/ui/v1/` or a same-origin proxy produces this; a wrong endpoint on another origin fails its CORS preflight, which the SDK can only retry as a network error, so silence is not proof the endpoint is right |
1836
+ | `KUI_E_SESSION_CONFLICT` | 409 | this session id is already claimed — give each run its own, usually by removing a fixed-value `sessionIdGenerator` |
1837
+ | `KUI_E_INGEST_REJECTED` | any other terminal 4xx | read `serverMessage`; `ui session has reached its size limit` means stop and re-init for a new session; a 413 holding neither of the server's sentences is a proxy's own body limit, so raise it to at least 10 MiB; anything else is an SDK/server version mismatch (the SDK checks the session id, clamps `batchSize` and cuts every batch at the 10 MiB body cap before sending, so nothing you configure produces one) and `issues` names the field |
1838
+ | `KUI_E_SESSION_ID_INVALID` | nothing — raised before the first byte | `sessionIdGenerator` returned a string outside the server's rule (`evidence.rule`), returned a non-string, or threw — `evidence.received` says which; make it return a string inside the rule, or remove the override |
1839
+ | `KUI_E_DOM_RECORDER_UNAVAILABLE` | nothing — raised before anything is sent | rrweb could not be imported in the browser (`evidence.reason` says why) — load the SDK through a bundler, or map `rrweb` with an import map; a blocked chunk (CSP, network) is refused the same way |
1840
+ | `KUI_E_STRICT_ATTRIBUTES_UNAVAILABLE` | nothing — raised before anything is recorded | under `privacyMode: "strict"`, its attribute allow-list (`dist/strict-attributes.mjs`, a chunk only strict loads) could not be loaded (`evidence.reason` says why) — serve every chunk your bundler emits, or, with no bundler, dist/ as it is; a browser keeps a failed import for the page, so reload |
1841
+ | `KUI_E_PRIVACY_ROUTE_INVALID` | nothing — raised before the first byte | a `privacy.secretRoutes` or `privacy.keepRoutes` entry is no route (`evidence.option`, `evidence.received`, `evidence.rule`) — rewrite it inside the rule (`/invites/:key`) or remove it |
1842
+ | `KUI_E_CAPTURE_DECLINED` | nothing — raised before anything is recorded | the browser sent Do Not Track or Global Privacy Control (`evidence.signal`) and `honorPrivacySignals` is on: the person using the page said no, and nothing needs fixing |
1843
+ | `KUI_E_PRIVACY_CONFLICT` | nothing — raised before anything is recorded | `privacyMode: "strict"` records no body and `privacy.maskNetworkBodies` is `false`, which asks for them (`evidence.option`): remove that option, or use `"balanced"` if the recording needs bodies |
1844
+
1845
+ `onError` receives one of seven subclasses of `CaptureError`, and
1512
1846
  branching on `code` narrows to it, so a TypeScript handler can read the
1513
1847
  evidence the remedy names. An `IngestRejection` (the four
1514
1848
  server-answered codes) carries `status`, `serverMessage` (the `error`
@@ -1529,6 +1863,9 @@ is sent, so its `status` is `null` and its evidence is
1529
1863
  and the rule. A `DomRecorderRefusal` (`KUI_E_DOM_RECORDER_UNAVAILABLE`)
1530
1864
  is raised in a browser, before anything is sent, when rrweb cannot be
1531
1865
  imported; its evidence is `{ reason }`, the browser's error. A
1866
+ `StrictAttributesRefusal` (`KUI_E_STRICT_ATTRIBUTES_UNAVAILABLE`) is
1867
+ raised the same way under `strict` when its attribute allow-list cannot
1868
+ be imported, with the same `{ reason }`. A
1532
1869
  `PrivacyRouteRefusal` (`KUI_E_PRIVACY_ROUTE_INVALID`) is raised before
1533
1870
  anything is sent when a declared privacy route is no route; its evidence
1534
1871
  is `{ option, received, rule }`. A `CaptureDeclined`
@@ -1538,7 +1875,7 @@ its evidence is `{ signal }` — `doNotTrack` or `globalPrivacyControl`.
1538
1875
  A `PrivacyConflict` (`KUI_E_PRIVACY_CONFLICT`) is the site's own config
1539
1876
  contradicting itself: its `status` is `null` and its evidence is
1540
1877
  `{ privacyMode, option }` — `"strict"` and the option that asks for
1541
- what strict leaves out. The nine
1878
+ what strict leaves out. The ten
1542
1879
  codes and their evidence are the entries of the same name in
1543
1880
  `@keploy/contract`'s error corpus. The SDK carries each entry's code, a
1544
1881
  short summary of what happened and the link to the entry's page, and
@@ -1546,7 +1883,7 @@ no remedy text, which stays on that page; a test holds the summary, the
1546
1883
  link and the evidence to the corpus. The `docs` pages are published
1547
1884
  with the same docs release as the guide above, and answer 404 until
1548
1885
  then. The status-to-code mapping is
1549
- `spec/sdk-errors.v3.json`; the session-id rule is
1886
+ `spec/sdk-errors.v4.json`; the session-id rule is
1550
1887
  `spec/session-id.v1.json`, the api-server's rule stated once — the
1551
1888
  SDK and the sidecar execute the file today, and the api-server's own
1552
1889
  executor lands with its next vendoring of the corpus. `onError` runs
@@ -1566,7 +1903,10 @@ await KeployCapture.init({
1566
1903
  if (err.code === "KUI_E_CAPTURE_DECLINED") return;
1567
1904
  if (err.code === "KUI_E_SESSION_ID_INVALID")
1568
1905
  fixGenerator(err.evidence.received);
1569
- else if (err.code === "KUI_E_DOM_RECORDER_UNAVAILABLE")
1906
+ else if (
1907
+ err.code === "KUI_E_DOM_RECORDER_UNAVAILABLE" ||
1908
+ err.code === "KUI_E_STRICT_ATTRIBUTES_UNAVAILABLE"
1909
+ )
1570
1910
  report(err.code, err.evidence.reason);
1571
1911
  else if (err.code === "KUI_E_PRIVACY_ROUTE_INVALID")
1572
1912
  report(err.code, err.evidence.option, err.evidence.received);