@keploy/capture-sdk 3.0.1 → 3.1.0-rc.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.
- package/README.md +1269 -122
- package/dist/errors.d.ts +192 -28
- package/dist/index.d.ts +23 -28
- package/dist/index.js +11 -2354
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +11 -2297
- package/dist/index.mjs.map +1 -0
- package/dist/module-of.d.ts +13 -0
- package/dist/network.d.ts +147 -3
- package/dist/privacy.d.ts +365 -11
- package/dist/recorder.d.ts +279 -63
- package/dist/redact.d.ts +48 -6
- package/dist/request-term.d.ts +21 -0
- package/dist/request-term.js +2 -0
- package/dist/request-term.js.map +1 -0
- package/dist/request-term.mjs +2 -0
- package/dist/request-term.mjs.map +1 -0
- package/dist/term-candidate.d.ts +16 -0
- package/dist/transport.d.ts +237 -130
- package/dist/types.d.ts +132 -5
- package/package.json +9 -3
- package/request-term/package.json +6 -0
package/README.md
CHANGED
|
@@ -1,57 +1,53 @@
|
|
|
1
1
|
# @keploy/capture-sdk
|
|
2
2
|
|
|
3
|
-
The browser SDK for [Keploy UI
|
|
3
|
+
The browser SDK for [Keploy UI Capture](https://keploy.io/docs/running-keploy/ui-capture/).
|
|
4
4
|
It records what a real user does in your web app — the DOM through
|
|
5
5
|
[rrweb](https://github.com/rrweb-io/rrweb), and every `fetch` and
|
|
6
6
|
`XMLHttpRequest` exchange the page makes — masks personal data before
|
|
7
7
|
anything leaves the browser, and posts the recording in batches to
|
|
8
|
-
Keploy. Keploy turns the recordings into deduplicated flows
|
|
9
|
-
|
|
8
|
+
Keploy. Keploy turns the recordings into deduplicated flows; turning
|
|
9
|
+
flows into Playwright tests that replay against recorded mocks is the
|
|
10
|
+
next step of the product and not in this release (see below).
|
|
10
11
|
|
|
11
12
|
This package runs inside your bundle, on your users' machines, which is
|
|
12
13
|
why it is **Apache-2.0** while the rest of the product is proprietary.
|
|
13
|
-
It is the only part of UI
|
|
14
|
-
|
|
14
|
+
It is the only part of Keploy UI Capture on npm.
|
|
15
|
+
|
|
16
|
+
> The UI Capture guide and the two screenshots below are published with
|
|
17
|
+
> the docs release that accompanies this SDK release; until then those
|
|
18
|
+
> links answer 404.
|
|
15
19
|
|
|
16
20
|
## What ships today
|
|
17
21
|
|
|
18
22
|
**The version is the git tag's** -- the committed manifest says
|
|
19
23
|
`0.0.0-tag` and the release lane writes the tag's version in before it
|
|
20
24
|
publishes (`RELEASING.md` in the repository; `sdk.version` on every
|
|
21
|
-
batch is that number).
|
|
22
|
-
|
|
23
|
-
records, masks and posts as this page
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
server
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
lands, they 404; [support@keploy.io](mailto:support@keploy.io) has the
|
|
37
|
-
current state.
|
|
25
|
+
batch is that number).
|
|
26
|
+
|
|
27
|
+
What works end to end: this SDK records, masks and posts as this page
|
|
28
|
+
describes; Keploy's API server accepts the recording with an app's UI
|
|
29
|
+
ingest key; a visit becomes **UI flows** once it has been idle for the
|
|
30
|
+
server's window (30 minutes by default) -- the steps a user took and the
|
|
31
|
+
network calls they made -- and you read them in the Keploy dashboard,
|
|
32
|
+
over the REST API (`/client/v1/apps/<appId>/ui/capture-status` and
|
|
33
|
+
`/ui/flows`), or from an AI agent through the Keploy MCP server
|
|
34
|
+
(`uiCaptureSetup`, `uiCaptureStatus`, `listUIFlows`). The
|
|
35
|
+
[UI Capture guide](https://keploy.io/docs/running-keploy/ui-capture/)
|
|
36
|
+
walks through all three.
|
|
37
|
+
|
|
38
|
+
Not in this release: generating Playwright tests from flows and running
|
|
39
|
+
them. Flows are what you get today.
|
|
38
40
|
|
|
39
41
|
## What you get
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
Each visit becomes flows, listed per app in the Keploy dashboard:
|
|
42
44
|
|
|
43
|
-

|
|
44
46
|
|
|
45
47
|
Each flow is the sequence of steps a user took, with every network call
|
|
46
48
|
those steps made recorded beside them:
|
|
47
49
|
|
|
48
|
-
:
|
|
53
|
-
|
|
54
|
-

|
|
50
|
+

|
|
55
51
|
|
|
56
52
|
## Install
|
|
57
53
|
|
|
@@ -62,11 +58,39 @@ npm install @keploy/capture-sdk
|
|
|
62
58
|
A runtime dependency, not a dev one: it runs in production, on the
|
|
63
59
|
page. Its only dependency is `rrweb`, which your bundler resolves; there
|
|
64
60
|
are no peer dependencies. The package ships ESM and CommonJS
|
|
65
|
-
(`dist/index.mjs`, `dist/index.js`) with types. The bundle is
|
|
66
|
-
(decimal) gzipped with rrweb excluded
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
(`dist/index.mjs`, `dist/index.js`) with types. The bundle is 41.4 kB
|
|
62
|
+
(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`);
|
|
65
|
+
the published build carries its version in place of the placeholder,
|
|
66
|
+
which moves both figures by a few bytes either way (MEASURED for
|
|
67
|
+
3.1.0-rc.1: 2 B more on each build). It is fully minified, so its
|
|
68
|
+
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,
|
|
75
|
+
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
|
|
78
|
+
script-tag build: the only way in is an `import`, and the SDK loads
|
|
79
|
+
`rrweb` with `import("rrweb")`, which a bundler resolves. Without one,
|
|
80
|
+
map the
|
|
81
|
+
specifier with an import map (`<script type="importmap">{"imports":
|
|
82
|
+
{"rrweb": "<url of rrweb's dist/rrweb.js>"}}</script>`) before the SDK
|
|
83
|
+
loads; if rrweb cannot be loaded in a browser the capture ends before
|
|
84
|
+
anything is sent and says so (`KUI_E_DOM_RECORDER_UNAVAILABLE`) rather
|
|
85
|
+
than recording nothing in silence.
|
|
86
|
+
|
|
87
|
+
A bundler that ignores a package's `exports` map -- webpack 4, as under
|
|
88
|
+
Create React App 4, or Parcel 2 by default -- resolves the SDK's
|
|
89
|
+
`request-term` subpath through the `request-term/package.json` the
|
|
90
|
+
package ships. **Parcel 2 needs the `buffer` package installed** (`npm
|
|
91
|
+
install buffer`): rrweb's build reads Node's `Buffer`, and Parcel
|
|
92
|
+
polyfills no Node built-in it is not given. That is rrweb's need, not
|
|
93
|
+
new in this version; 3.0.1 has it too.
|
|
70
94
|
|
|
71
95
|
## Use
|
|
72
96
|
|
|
@@ -91,26 +115,28 @@ any other kind of Keploy credential here.
|
|
|
91
115
|
Those two are the only required fields. The others, with the value the
|
|
92
116
|
SDK uses when you leave them out:
|
|
93
117
|
|
|
94
|
-
| option
|
|
95
|
-
|
|
|
96
|
-
| `privacyMode`
|
|
97
|
-
| `sampleRate`
|
|
98
|
-
| `networkCapture`
|
|
99
|
-
| `maxSessionDuration`
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
108
|
-
| `
|
|
118
|
+
| option | default | what it does |
|
|
119
|
+
| --------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
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) |
|
|
121
|
+
| `sampleRate` | `1` | fraction of sessions recorded, decided once when a session starts. `0.1` records one visitor in ten; the rest never start |
|
|
122
|
+
| `networkCapture` | `true` | record `fetch` and `XMLHttpRequest` exchanges. `false` records the DOM only |
|
|
123
|
+
| `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 |
|
|
124
|
+
| `continuous` | `false` | keep capturing for the life of the page, one session at a time: a session that ends (at `maxSessionDuration`, or because the server completed or filled it) is followed by a new one at the visitor's next click, tap or key press, so an idle tab posts nothing. Has no effect with a `sessionIdGenerator`: that id is yours, and a second session under it would be refused — see [Single-page apps](#single-page-apps) |
|
|
125
|
+
| `batchSize` | `50` | events per POST, as a ceiling: clamped to 5000, the most the ingest server accepts in one batch, and a batch is also cut at the server's 10 MiB body cap, so large events make more, smaller POSTs rather than one the server would refuse |
|
|
126
|
+
| `batchInterval` | `5000` | milliseconds between flushes. Each flush sends ONE batch, so a backlog drains at a batch per interval (after an outage, the first upload accepted sends it all) |
|
|
127
|
+
| `maxQueueSize` | `5000` | events held in memory while waiting to send; past this, or past 16 MiB of them, the oldest are dropped |
|
|
128
|
+
| `maxBodySize` | `524288` | how much of a request or response body is recorded (512 KB), counted in UTF-16 code units — see [What a large body looks like](#what-a-large-body-looks-like) |
|
|
129
|
+
| `maskSelectors` | — | CSS selectors whose matched elements have their text masked, including every text node below them. Input values are decided by `privacyMode` alone |
|
|
130
|
+
| `unmaskSelectors` | — | CSS selectors whose text is left in the clear, overriding `maskSelectors` and `"strict"` for the subtree below them. It cannot unmask an input value |
|
|
131
|
+
| `privacy` | — | a `Partial<PrivacyConfig>`: `maskSelectors`, `unmaskSelectors`, `blockSelectors`, `maskNetworkBodies`, `sensitiveHeaders`, `piiPatterns`, `secretRoutes`, `keepRoutes` — see [Privacy](#privacy) |
|
|
132
|
+
| `sessionIdGenerator` | — | supply your own session id instead of the SDK's UUID v4, to correlate with your own systems. It must be a string of 1-200 characters of letters, digits, dot, dash and underscore with no empty dot-separated segment (`tenant-7.user_42.run-3`; encode a `user:42/session 1` first) — the SDK checks what the generator produces before sending and refuses to start on anything else, a throw included (`KUI_E_SESSION_ID_INVALID`). Two live sessions with one id are refused by the server (a terminal `409`) |
|
|
133
|
+
| `honorPrivacySignals` | `true` | when the browser sends Do Not Track (`navigator.doNotTrack === "1"`) or Global Privacy Control (`navigator.globalPrivacyControl === true`), `init()` records, patches and sends nothing and reports `KUI_E_CAPTURE_DECLINED` to `onError` on every declined `init()` and by `console.info` once per page. `false` records regardless — only where the site has its own lawful basis and says so in its privacy policy |
|
|
134
|
+
| `onError` | — | called once when a terminal condition ends the capture — see [When the server rejects a batch](#when-the-server-rejects-a-batch) |
|
|
109
135
|
|
|
110
136
|
After `init`, the static surface is:
|
|
111
137
|
|
|
112
138
|
```ts
|
|
113
|
-
KeployCapture.pause(); // keep the session,
|
|
139
|
+
KeployCapture.pause(); // keep the session, record nothing more
|
|
114
140
|
KeployCapture.resume();
|
|
115
141
|
KeployCapture.getSessionId(); // "" when no session is live
|
|
116
142
|
KeployCapture.getCaptureIdentity(); // the browser half of the backend join, or why there is none
|
|
@@ -120,17 +146,205 @@ KeployCapture.stop(); // stop recording and send what is queued
|
|
|
120
146
|
`init` returns the same instance on a second call; `stop` clears it so
|
|
121
147
|
a later `init` starts a new session.
|
|
122
148
|
|
|
149
|
+
### Single-page apps
|
|
150
|
+
|
|
151
|
+
A route change without a page load -- `history.pushState`, the visitor
|
|
152
|
+
going back or forward, a hash router's `#/route` -- is recorded the way
|
|
153
|
+
rrweb records a load, as a Meta event with the new URL, so each step
|
|
154
|
+
belongs to the page it happened on. A change of the query alone --
|
|
155
|
+
pushed, replaced or traversed, a router syncing filter or search state
|
|
156
|
+
-- is not a page change and records nothing, so a search box that
|
|
157
|
+
pushes `?q=` per keystroke records no navigation of its own. The URL
|
|
158
|
+
recorded is always the one the page is on: the snapshot a returning tab
|
|
159
|
+
or `resume()` takes carries the query as it is, so a query the page
|
|
160
|
+
changed in the meantime starts the flow after it at that exact URL --
|
|
161
|
+
the one its replay has to open. An in-page anchor (`#reviews`) is not a
|
|
162
|
+
page change either.
|
|
163
|
+
|
|
164
|
+
Each route change's Meta event also says what moved the page, as
|
|
165
|
+
`cause`: `push` or `replace` (a navigation that added or replaced a history
|
|
166
|
+
entry: `history.pushState`, a `replaceState` that changes the path -- a
|
|
167
|
+
redirect), `traverse` (a move through the session history: the browser's
|
|
168
|
+
Back or Forward, or the page's own `history.back()` or `go()`) or `hash` (a
|
|
169
|
+
fragment navigation the History API did not make: a link to `#/route`,
|
|
170
|
+
`location.hash = ...`). rrweb's own Meta, written with every full snapshot
|
|
171
|
+
(a load, a returning tab, `resume()`), has none. Where the browser has the
|
|
172
|
+
Navigation API, the route Meta also carries `userInitiated`, as its
|
|
173
|
+
`navigate` event said it. The standard makes it `true` when the visitor
|
|
174
|
+
started the move -- the browser's Back or Forward, a click on a link, a
|
|
175
|
+
form submitted -- and `false` when the page's script did (an in-app Back
|
|
176
|
+
button calling `history.back()`, a `pushState`). Engines differ, and the
|
|
177
|
+
SDK records what each says without correcting it. MEASURED with
|
|
178
|
+
Playwright 1.63's builds: a click on a plain link is `true` in Chromium,
|
|
179
|
+
Firefox and WebKit; a `pushState` or `history.back()` made in a click
|
|
180
|
+
handler is `false` in Chromium and Firefox and `true` in WebKit (it
|
|
181
|
+
reads the click's user activation); Playwright's `page.goBack()` is
|
|
182
|
+
`true` in Chromium and `false` in Firefox and WebKit (a real Back button
|
|
183
|
+
was not measured). So neither value alone tells an in-app Back from the
|
|
184
|
+
browser's own in every engine. The field is absent where the browser has
|
|
185
|
+
no Navigation API, for a move found late (below), and when the navigate
|
|
186
|
+
event named another URL than the one the page moved to: never guessed.
|
|
187
|
+
|
|
188
|
+
A traversal the page's own script asked for -- `history.back()`,
|
|
189
|
+
`forward()` or `go()`, as an in-app Back button calls them, or the
|
|
190
|
+
Navigation API's `navigation.back()`, `forward()` or `traverseTo()` --
|
|
191
|
+
also carries `initiator: "script"`, so a recording tells it from the
|
|
192
|
+
browser's Back in every engine that has the Navigation API, WebKit
|
|
193
|
+
included. The SDK wraps those methods as it wraps `pushState`: a call
|
|
194
|
+
notes the entry it names in `navigation.entries()` (`traverseTo()` names
|
|
195
|
+
its key), and a traversal the `navigate` event announces to a noted entry
|
|
196
|
+
is the call's. Calls made before the first has moved count as each engine
|
|
197
|
+
moves them, MEASURED: Chromium and Firefox move once per call, each counted
|
|
198
|
+
on from the entry the call before it named, so two `history.back()` in one
|
|
199
|
+
handler move twice and both moves carry `initiator: "script"`; a call
|
|
200
|
+
counted on to the entry the page is on moves nothing, and Chromium drops a
|
|
201
|
+
call that names no entry from where the page is (`back()` then `forward()`
|
|
202
|
+
from the last entry moves back, the script's). WebKit moves once, to the
|
|
203
|
+
entry the last call named from where the page was, and that move carries
|
|
204
|
+
it. A move to an entry an earlier call of several named is credited only
|
|
205
|
+
when its `navigate` event says `userInitiated: false`, as Chromium and
|
|
206
|
+
Firefox say of the page's moves; a call made while another wrapped call
|
|
207
|
+
runs (a polyfill's `navigation.back()` calling `history.back()`) is the
|
|
208
|
+
outer call's. A `pushState` in the task of a call drops the entries after
|
|
209
|
+
the current one alone, and MEASURED, Chromium and WebKit still move to an
|
|
210
|
+
entry before it that the call named (`back()` then a push in one handler,
|
|
211
|
+
as a page closes a modal and routes), so that move carries it too; a call
|
|
212
|
+
made after the push counts from the pushed entry. A `go()` given a
|
|
213
|
+
string reads it as the browser does (`go("-1")`). The field is absent
|
|
214
|
+
otherwise: for the browser's own Back and Forward, where the browser has no
|
|
215
|
+
Navigation API, for a `go()` given an object or a `traverseTo()` given
|
|
216
|
+
anything but a string, for a call that names no entry of the page's, for a
|
|
217
|
+
call whose entry a push dropped, and for a `back()` a router kept from
|
|
218
|
+
before `init()`, which passes no wrapper. The limits, MEASURED: a note no
|
|
219
|
+
traversal's `navigate` event spends stays for the next one; past a push, a
|
|
220
|
+
queued one stays while its entry is before the current one. A call whose
|
|
221
|
+
traversal fires the page none -- the browser applies it to another frame's history
|
|
222
|
+
(an iframe that navigated since, or the parent's when the page is itself a
|
|
223
|
+
frame), or drops it -- leaves its note so, and a traversal the browser
|
|
224
|
+
makes to the entry a call named, before the call's own move, takes it:
|
|
225
|
+
each is then recorded as the script's. MEASURED in Chromium, Firefox and
|
|
226
|
+
WebKit: after an in-app Back moved a same-origin iframe's history,
|
|
227
|
+
Playwright's `page.goBack()` to the entry it named is recorded with
|
|
228
|
+
`initiator: "script"`. The next call also counts on from such a call's
|
|
229
|
+
entry, as from a pending one's: after that in-app Back, a second one's move
|
|
230
|
+
is the script's but leaves the entry before it noted, and a later traversal
|
|
231
|
+
there that says `userInitiated: false` is the script's. MEASURED in
|
|
232
|
+
Firefox, where `page.goBack()` says `false`: it is recorded with
|
|
233
|
+
`initiator: "script"`. And the calls WebKit drops: its one move for
|
|
234
|
+
overlapping calls made with no user gesture says `userInitiated: false`, as
|
|
235
|
+
Chromium's first of several does, and calls whose last names no entry from
|
|
236
|
+
where the page is move nothing, so the entries the dropped calls named stay
|
|
237
|
+
noted, and a later traversal to one that says `false` is the script's.
|
|
238
|
+
MEASURED in WebKit: after two `history.back()` from a timer 1.5 s after a
|
|
239
|
+
click, which WebKit runs with no user gesture, and after `back()` then
|
|
240
|
+
`forward()` from the last entry in a click handler, `page.goBack()` (which
|
|
241
|
+
says `false` there) is recorded with `initiator: "script"`. During a user
|
|
242
|
+
gesture WebKit says `true` for its one move, and the notes go with it. And
|
|
243
|
+
where Chromium and Firefox count differently, after a call that names no
|
|
244
|
+
entry from where the page is, the SDK counts as Chromium does: a move of
|
|
245
|
+
Firefox's that it did not count, and an earlier move of the same calls to
|
|
246
|
+
the same entry, are recorded with no `initiator`. MEASURED in Firefox:
|
|
247
|
+
`back()`, `forward()`, `back()` from the last entry moves to the entry
|
|
248
|
+
before it twice, and `back()`, `back()`, `forward()` moves to the two
|
|
249
|
+
entries before it and forward again; those moves to the entry before the
|
|
250
|
+
last carry no `initiator`. And Firefox drops the calls pending at a
|
|
251
|
+
`pushState` in their task (with a push a task later it moves too), which
|
|
252
|
+
nothing tells from Chromium's move to come when the push is made. Their
|
|
253
|
+
notes stay at the head of the queue until its next traversal, which spends
|
|
254
|
+
them, and the notes of calls queued behind them, unless it goes straight to
|
|
255
|
+
such an entry and says `userInitiated: false`. MEASURED in Firefox: after
|
|
256
|
+
`back()` then a push, `page.goBack()` (to the entry before the pushed one)
|
|
257
|
+
carries no `initiator`, and of two `back()` in a later click the first move
|
|
258
|
+
carries it and the second does not. A fragment push in the calls' task
|
|
259
|
+
(`location.hash`, `navigation.navigate("#x")`) moves Firefox one back from
|
|
260
|
+
the pushed entry, which no call named, with no `initiator`, and a push a
|
|
261
|
+
`popstate` listener makes before Firefox's next move commits spends that
|
|
262
|
+
move's credit. WebKit also drops the calls pending at an intercepted
|
|
263
|
+
`navigation.navigate()`, and their notes stay. And WebKit's move for overlapping
|
|
264
|
+
calls with no user gesture, when it goes past the first note, loses its
|
|
265
|
+
note at a push, which says `false` then: `go(-1)`, `go(-2)` and a push from a
|
|
266
|
+
timer carry no `initiator`.
|
|
267
|
+
|
|
268
|
+
Where the browser has the
|
|
269
|
+
Navigation API (the Chromium, Firefox and WebKit builds Playwright 1.63
|
|
270
|
+
ships all do), its `currententrychange` decides: it comes
|
|
271
|
+
before `popstate`, so Back is a `traverse` even when a router re-stamps or
|
|
272
|
+
redirects from its own `popstate` listener (the redirect is then a
|
|
273
|
+
`replace` of its own), and it also reports a navigation that calls no
|
|
274
|
+
`pushState`, such as one an app intercepts with `navigation.navigate()`.
|
|
275
|
+
Without it, the History API calls and the `popstate` and `hashchange`
|
|
276
|
+
events decide. The SDK's listeners are capture listeners, which the DOM
|
|
277
|
+
standard runs before every non-capture listener the page added (Firefox
|
|
278
|
+
and WebKit do), so Back is still a `traverse` before a router's redirect;
|
|
279
|
+
a History API call at the URL Back reached, from a listener that ran
|
|
280
|
+
first, is read as Back too. Chromium runs the listeners at the window in
|
|
281
|
+
the order they were added, which matters only without the Navigation API,
|
|
282
|
+
and every Chromium that ships has it. And a fragment navigation, which fires `popstate` before
|
|
283
|
+
`hashchange` as Back between two fragments does, reads as `traverse` --
|
|
284
|
+
`hash` is recorded only where the browser has the Navigation API. The SDK
|
|
285
|
+
wraps `pushState` and `replaceState` (and `back`, `forward` and `go`, and
|
|
286
|
+
`navigation.back`, `forward` and `traverseTo`) once per page and records a
|
|
287
|
+
change only once the URL has changed; a router that wraps any of them
|
|
288
|
+
after the SDK keeps its wrapper when the capture stops, and so does a page
|
|
289
|
+
that made the SDK's wrapper impossible to put back. It wraps all of them
|
|
290
|
+
or none, so that a route Meta without `initiator` means the same on every
|
|
291
|
+
page: a page that made one impossible to replace and put back before
|
|
292
|
+
`init()` (an own property neither writable nor configurable, a `history`
|
|
293
|
+
or `navigation` that takes no new property) gets no wrapper at all, and
|
|
294
|
+
the capture says so once on the console as `KUI_E_NAVIGATION_UNWRAPPED`
|
|
295
|
+
(below). Its route changes are still recorded, from its navigation events,
|
|
296
|
+
with less detail: no traversal carries `initiator`; where the browser has
|
|
297
|
+
the Navigation API, a `pushState` to a fragment reads as `hash`; where it
|
|
298
|
+
has none, a `pushState` or `replaceState` is found only at the next
|
|
299
|
+
recorded event, as a `push`, two before it read as one, and a credential
|
|
300
|
+
the page pushed into its URL and hid again before that event is not
|
|
301
|
+
collected, so it is not scrubbed. A router that calls a
|
|
302
|
+
`pushState` or `replaceState` it kept from before `init()` (SvelteKit
|
|
303
|
+
does) passes no wrapper: the Navigation API still reports the move, and
|
|
304
|
+
without it the move is found when the next event is recorded and is
|
|
305
|
+
recorded before that event: as a `traverse` when that event comes inside
|
|
306
|
+
a `popstate` (a listener the page runs before the SDK's re-rendered),
|
|
307
|
+
otherwise as a `push`, a `replace` included (it can no longer be told
|
|
308
|
+
from one).
|
|
309
|
+
|
|
310
|
+
One page load can stay open for hours, and a capture otherwise ends at
|
|
311
|
+
`maxSessionDuration`. Set `continuous: true` to keep recording it in
|
|
312
|
+
sessions of that length; each becomes flows on its own. A session the
|
|
313
|
+
server says it has completed or filled (the refusal's `reason` is
|
|
314
|
+
`session_completed` or `session_full`, which the ingest server sends
|
|
315
|
+
from the api-server release that stores UI capture data in its own
|
|
316
|
+
collections) is followed the same way; a server that predates that
|
|
317
|
+
field keeps the refusal terminal. With a `sessionIdGenerator`,
|
|
318
|
+
`continuous` has no effect: the capture ends at `maxSessionDuration`
|
|
319
|
+
and at those refusals as it does without it, because the id is yours --
|
|
320
|
+
usually one per visit -- and a second session under it would be
|
|
321
|
+
refused. A
|
|
322
|
+
`KeployCapture.pause()` in force when a session ends -- or made while
|
|
323
|
+
the next one waits -- carries into the next one, which records nothing
|
|
324
|
+
until `resume()`, even when that next one is started by an explicit
|
|
325
|
+
`init()`. `stop()` ends the capture for good, waiting included.
|
|
326
|
+
|
|
123
327
|
A hidden tab pauses DOM recording and nothing else — the exchanges the
|
|
124
328
|
page makes are still recorded, because the page still makes them and
|
|
125
329
|
they are what a replay needs. When the tab comes back, the SDK takes a
|
|
126
330
|
fresh full snapshot **only if the paused recording dropped something**:
|
|
127
331
|
rrweb has no pause, so it kept observing while the tab was hidden, and
|
|
128
332
|
the mutations that were dropped would otherwise leave the events after
|
|
129
|
-
them naming nodes the recording never showed
|
|
333
|
+
them naming nodes the recording never showed -- or if a snapshot the
|
|
334
|
+
recording is still waiting for (one too big to send, retried on its
|
|
335
|
+
backoff) has not been sent. While uploads to the ingest are failing, or after
|
|
336
|
+
an event was dropped while the browser said it was offline, that snapshot
|
|
337
|
+
waits until the outage ends. A hide that dropped
|
|
130
338
|
nothing has nothing to re-baseline and takes none, so a visitor who
|
|
131
339
|
alt-tabs thirty times on a page that is not mutating uploads no
|
|
132
|
-
snapshots for it. `pause()` is the stronger one
|
|
133
|
-
and
|
|
340
|
+
snapshots for it. `pause()` is the stronger one: nothing more is
|
|
341
|
+
recorded -- no DOM event, and no network exchange that starts or is
|
|
342
|
+
answered while paused, even one whose answer arrives after `resume()` --
|
|
343
|
+
and `resume()` re-snapshots under the same condition. An exchange still
|
|
344
|
+
reading its body at `pause()` (a stream, a long download) is recorded
|
|
345
|
+
then, with what had arrived, cut and marked `...[truncated]` as when the
|
|
346
|
+
page leaves, and nothing of it after, `resume()` included; the page's
|
|
347
|
+
own read of it goes on untouched.
|
|
134
348
|
|
|
135
349
|
What network capture **is** gated on is the rrweb import. `init()`
|
|
136
350
|
awaits `import("rrweb")` before it patches `fetch` and
|
|
@@ -141,6 +355,40 @@ in that window is not recorded at all, in a hidden tab exactly as in a
|
|
|
141
355
|
visible one. Calling `init()` as early in startup as you can narrows
|
|
142
356
|
that window; nothing closes it.
|
|
143
357
|
|
|
358
|
+
An `init()` called while the browser is offline is the exception: it
|
|
359
|
+
does not ask for rrweb until the browser is back online (a browser keeps
|
|
360
|
+
a failed module import for the life of the page), patches `fetch` and
|
|
361
|
+
`XMLHttpRequest` at once, and sends nothing it records until rrweb has
|
|
362
|
+
loaded -- if it cannot, the capture is refused with
|
|
363
|
+
`KUI_E_DOM_RECORDER_UNAVAILABLE` and what was recorded meanwhile is
|
|
364
|
+
dropped. That the browser is back is heard as the `online` event or
|
|
365
|
+
read, once a second while the capture waits, from `navigator.onLine`: a
|
|
366
|
+
page whose own listener stops the event (`stopImmediatePropagation`) is
|
|
367
|
+
recorded all the same. Unless a service worker controls the page
|
|
368
|
+
(`navigator.serviceWorker.controller`): a worker can answer the import
|
|
369
|
+
with no network, and a page that starts offline at all is most often
|
|
370
|
+
one a worker served, so there `init()` asks for rrweb at once and
|
|
371
|
+
records what the visitor does offline. Precache rrweb's chunk with the
|
|
372
|
+
rest of the app. ANY worker in control counts, one with no `fetch`
|
|
373
|
+
handler included: an `init()` called offline under it asks at once, a
|
|
374
|
+
worker that cannot answer fails the import, and the capture is refused
|
|
375
|
+
at `init()` -- and again at an `init()` made once the browser is back
|
|
376
|
+
online (MEASURED in review, in Chromium, with a push-only worker, 4
|
|
377
|
+
times of 4): the browser keeps the failed import until the page is
|
|
378
|
+
loaded again.
|
|
379
|
+
|
|
380
|
+
Once rrweb has loaded, what was held is sent in order, one batch
|
|
381
|
+
(`batchSize` events) per round trip, and a visitor who leaves while
|
|
382
|
+
more is still waiting than one unload request carries (64 KiB, below)
|
|
383
|
+
loses the first event that does not fit and everything behind it: a
|
|
384
|
+
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
|
|
386
|
+
after the network came back: a 141 KB snapshot behind the requests a
|
|
387
|
+
page made offline was lost 4 times of 4 (an ingest answering in
|
|
388
|
+
150 ms), and a 51 KB one 3 times of 3 behind 95 requests, where behind
|
|
389
|
+
30 it arrived 3 of 3; a 53 KB one behind 95 requests, with the visitor
|
|
390
|
+
leaving 0.8 s after the network came back, arrived 4 of 4.
|
|
391
|
+
|
|
144
392
|
## Privacy
|
|
145
393
|
|
|
146
394
|
Masking happens in the browser, before transport. Nothing here can be
|
|
@@ -193,6 +441,21 @@ only: nothing you can name a selector for will un-mask an input value.
|
|
|
193
441
|
Each has a top-level spelling and a `privacy.` one, and the two lists
|
|
194
442
|
are merged rather than one taking precedence.
|
|
195
443
|
|
|
444
|
+
**Editors.** Text typed into a `contenteditable` — TipTap, Quill,
|
|
445
|
+
Lexical, ProseMirror — is typed text: masked under `balanced` and
|
|
446
|
+
`strict` as an input's value is, whatever `unmaskSelectors` says, and
|
|
447
|
+
recorded under `off`.
|
|
448
|
+
|
|
449
|
+
**Privacy signals.** Do Not Track and Global Privacy Control are
|
|
450
|
+
honoured by default: when the browser sends either, nothing is
|
|
451
|
+
recorded, patched or sent, and the SDK says so once with
|
|
452
|
+
`KUI_E_CAPTURE_DECLINED` (see `honorPrivacySignals`). The values that
|
|
453
|
+
count are `navigator.doNotTrack === "1"` -- or as older browsers spell
|
|
454
|
+
it: `"yes"` (Firefox before 32), `window.doNotTrack === "1"` (Safari,
|
|
455
|
+
IE 11), `navigator.msDoNotTrack === "1"` (IE 10) -- and
|
|
456
|
+
`navigator.globalPrivacyControl === true`; `onError` hears every
|
|
457
|
+
declined `init()`, and the console line is written once per page.
|
|
458
|
+
|
|
196
459
|
**On the network.** For every recorded exchange:
|
|
197
460
|
|
|
198
461
|
- Headers named in `privacy.sensitiveHeaders` have their values
|
|
@@ -200,34 +463,703 @@ are merged rather than one taking precedence.
|
|
|
200
463
|
`set-cookie`, `x-api-key`, `x-auth-token` and `proxy-authorization`;
|
|
201
464
|
a list you pass **extends** it and cannot shrink it: those six are
|
|
202
465
|
redacted whatever you configure, because no redacted header value is
|
|
203
|
-
ever needed for replay.
|
|
204
|
-
|
|
466
|
+
ever needed for replay. So is any header whose NAME reads as a
|
|
467
|
+
credential's, as a body's key does (`X-Access-Token`, `X-Csrf-Token`,
|
|
468
|
+
`Api-Key`, `X-Goog-Api-Key`, `X-Amz-Security-Token`, `Token`,
|
|
469
|
+
`X-Password`, `X-Secret`), or whose last word does (a token, an auth,
|
|
470
|
+
a secret, a password (`pass`, `pwd`, `passcode`), a PIN, a JWT, a
|
|
471
|
+
credential, an authorization or an authentication, a bearer, a
|
|
472
|
+
session, a `sid`, a CSRF or XSRF value, a cookie, a signature, an
|
|
473
|
+
HMAC, an OTP or TOTP; a session id in one word; a `key` after a word
|
|
474
|
+
such as auth, secret, access, API or subscription; a `code` after a
|
|
475
|
+
word such as MFA, OTP, SMS, auth, reset or verification; an `id`
|
|
476
|
+
after a session or a token -- `X-Auth`,
|
|
477
|
+
`X-Auth-Key`, `X-Forwarded-Authorization`, `X-Session-Id`,
|
|
478
|
+
`X-Auth-Token-V2`, `Ocp-Apim-Subscription-Key`, `X-Mfa-Code`). A word
|
|
479
|
+
that only describes one stays (`X-Session-Timeout`,
|
|
480
|
+
`X-Tokens-Remaining`, `X-Password-Policy`, `X-Error-Code`), and so
|
|
481
|
+
does a CORS header (`Access-Control-Allow-Credentials`); a mock keeps
|
|
482
|
+
`content-type` and `cache-control` alone, and the replay key is the
|
|
483
|
+
method, the URL and, for a GraphQL body, the operation it names (its
|
|
484
|
+
`requestTerm`, below). A header that is or carries a URL —
|
|
485
|
+
`Location`, `Content-Location`, each `<...>` of a `Link`, the `url=` of
|
|
486
|
+
a `Refresh` — has that URL's query values redacted as a request URL's
|
|
487
|
+
are (see the URL bullet below). Every other header value is scanned for the
|
|
488
|
+
PII patterns below, and is otherwise recorded as it is: a header your
|
|
489
|
+
own code fills with what a person typed is yours to name in
|
|
490
|
+
`privacy.sensitiveHeaders`. Under `strict` that is not left to you:
|
|
491
|
+
only the values of headers that describe the exchange rather than the
|
|
492
|
+
person are kept — `accept`, `accept-encoding`, `accept-ranges`, `age`,
|
|
493
|
+
`cache-control`, `connection`, `content-encoding`, `content-language`,
|
|
494
|
+
`content-length`, `content-type`, `date`, `etag`, `expires`,
|
|
495
|
+
`keep-alive`, `last-modified`, `pragma`, `transfer-encoding` and
|
|
496
|
+
`vary` — and every other value is replaced with `[REDACTED]`, its
|
|
497
|
+
name kept.
|
|
498
|
+
- Names. One rule reads every name the SDK records a value under: a
|
|
499
|
+
JSON body's key, a form's field, a multipart part's name, a
|
|
500
|
+
`name=value` pair in a text body, a header's name, and a query or
|
|
501
|
+
fragment parameter of every URL the SDK records (below).
|
|
502
|
+
A credential's names are `token`, `password`, `passwd`, `pwd`,
|
|
503
|
+
`secret`, `apikey`, `authorization`, `auth`, `session`, `cookie`,
|
|
504
|
+
`pin`, `code_verifier`, `private_key`, `passphrase`, `ssn`,
|
|
505
|
+
`cardnumber`, `cvv`, `rawKey` (the field Keploy's api-server returns a
|
|
506
|
+
freshly minted API, ingest or service-account key in) and the like; a
|
|
507
|
+
one-time code's (`invite_code`, `reset_code`, `verification_code`,
|
|
508
|
+
`auth_code`, `oobCode` and the like; never a bare `code`, `zip_code`
|
|
509
|
+
or `country_code`); any name ending in `token`, `secret`, `password`
|
|
510
|
+
(and its confirmation fields, `password_confirmation`, `password2`),
|
|
511
|
+
`passwd`, `signature`, `apikey`, `privatekey`, `passphrase`,
|
|
512
|
+
`sessionid`, `jwt`, `otp`, `credential` or `curl` (a recorded curl
|
|
513
|
+
command carries its `Authorization` header and form body) — an
|
|
514
|
+
`auth_token`, an `email_otp`, S3's `X-Amz-Signature`, Magic's
|
|
515
|
+
`magic_credential`, a `JSESSIONID`; SAML's `SAMLResponse`,
|
|
516
|
+
WordPress's `confirm_key`, Supabase's `token_hash`, Clerk's
|
|
517
|
+
`__clerk_ticket`, a sign-in link's `nonce`, `hmac`, `login_hash`,
|
|
518
|
+
`magic_link`, `PHPSESSID` and `oauth_verifier`, and Azure's SAS `sig`;
|
|
519
|
+
and a card's expiry by a card's own name (`exp_month`, `ccExp`). A name
|
|
520
|
+
is read percent-decoded, at each `[...]` (`user[password]`),
|
|
521
|
+
lower-cased and without `-`, `_`, `$`, `+` and whitespace, and — but
|
|
522
|
+
for a JSON key, whose dots are part of one flat key
|
|
523
|
+
(`"auth.login.title"`) — at each `.` (`user.password`); a name of more
|
|
524
|
+
than one part is also read as one word (`api[key]` is an `apikey`). A
|
|
525
|
+
flag under a credential's name is kept: it holds no secret, and
|
|
526
|
+
`"[REDACTED]"` in its place reads as true. Under `credentials`,
|
|
527
|
+
`authentication` and `pass`, which an app's data uses as often for a
|
|
528
|
+
list, a method or a count, only a string goes; any other value is read
|
|
529
|
+
on, its own credentials redacted. KNOWN OVER-REDACTION: a few names the
|
|
530
|
+
rule takes are some apps' public or plain data -- Adyen's public
|
|
531
|
+
`clientKey`, a `tokenId`, Twilio's `sid` -- and their value is
|
|
532
|
+
recorded as `[REDACTED]`, an object or a list under them as that
|
|
533
|
+
string, so a replay serves the string where the app had its value. A paging
|
|
534
|
+
cursor is never a credential (`pageToken`, `nextPageToken`,
|
|
535
|
+
`NextToken`, `continuationToken`, `syncToken`, OData's `$skiptoken`
|
|
536
|
+
and the like): a response's `nextPageToken` is recorded as sent, so a
|
|
537
|
+
replayed page asks for the next page the recording holds. Two
|
|
538
|
+
exceptions, each for a reason: the page's own URL and every URL its
|
|
539
|
+
DOM holds keep `auth`, `session`, `cookie`, `pin` and `sig` by name, as
|
|
540
|
+
an app's own parameters (`?auth=1`, a talk's `?session=`), and scrub
|
|
541
|
+
such a value when it looks generated; and a text body reads as a
|
|
542
|
+
pair's name only letters, digits, `_`, `-`, `%` and closed brackets
|
|
543
|
+
(below).
|
|
205
544
|
- Request and response bodies are redacted structurally: JSON is
|
|
206
|
-
parsed and every value under a
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
545
|
+
parsed and every value under a credential's name (Names, above) is
|
|
546
|
+
replaced, and the JSON stays valid; a card's bare `expiry` /
|
|
547
|
+
`expirationDate` goes only beside a card field (`cardNumber`, `cvv`),
|
|
548
|
+
so a token's or a cookie's expiry keeps its value. Under `otp`,
|
|
549
|
+
`totp`, `passcode` and a name ending in `otp`, which settings use too,
|
|
550
|
+
only a string or a number goes: a flag stays, and an object is read
|
|
551
|
+
on, where its `code` goes (`{"totp":{"enabled":true}}` and
|
|
552
|
+
`{"email_otp":{"enabled":true}}` are kept). The redaction is made in the body's own text: only
|
|
553
|
+
the values it replaces change, and every other byte — numbers (a
|
|
554
|
+
64-bit id past 2^53 included), whitespace, key order, escapes — is
|
|
555
|
+
recorded as the server sent it. A string value that is itself JSON (a
|
|
556
|
+
test case's `header` or `body` stored as text) is redacted the same
|
|
557
|
+
way, and any other string has its pairs read by the text pair rule
|
|
558
|
+
below, with a string's own leads only: its start, a `?`, a `&`, or a
|
|
559
|
+
`#` after a path (`"see /cb?token=… now"`, a stored
|
|
560
|
+
`"grant_type=password&password=…"`, `"Location: /cb#access_token=…"`).
|
|
561
|
+
A credential's value there runs to the next `&` or the string's end,
|
|
562
|
+
its spaces and line breaks its own (`"password=correct horse battery
|
|
563
|
+
staple"` records `"password=[REDACTED]"`, a PEM key goes whole), so
|
|
564
|
+
what follows it before the next `&` goes with it; one that starts
|
|
565
|
+
where a text body's value cannot -- a space, a quote, a backtick, a
|
|
566
|
+
bracket, `<`, `>`, `,`, `;` or a backslash -- is code's and is kept
|
|
567
|
+
(`fetch('/api?token='+t)`), and so is a quoted one
|
|
568
|
+
(`"password=\"correct horse\""`). A string's
|
|
569
|
+
content-type says nothing of what it holds, and code and SQL keep
|
|
570
|
+
their bytes (`let a=1;token=getToken()`, `SET password=?`, a class's
|
|
571
|
+
`#token=null`) -- so a pair a string's prose starts after a `;`, a
|
|
572
|
+
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
|
|
574
|
+
line of a JSON string, a form value or a body that starts with a URL
|
|
575
|
+
(`https://…?…`, `./cb#…`, `cb?jwt=…`, `/cart;jsessionid=…`), read
|
|
576
|
+
whole to the line's end — a raw space in a query is its value's, and a
|
|
577
|
+
credential's value runs to the next pair, a space in it its own; in a
|
|
578
|
+
text body that is not read as a form it ends at its first space, `,`,
|
|
579
|
+
`;`, quote, `<`, `>`, backslash or backtick, or a `)`, `]` or `}` it
|
|
580
|
+
does not open (`?sig=(…)` is one value), and in a form at its first
|
|
581
|
+
space, as a form's value is then read to its `&`; in a text the
|
|
582
|
+
line's text after it
|
|
583
|
+
kept (a CSV row's later columns, CSS's `);color:red}`), so a value
|
|
584
|
+
that holds one of those keeps what follows it (`?password=a,b`
|
|
585
|
+
records `password=[REDACTED],b`), and one that starts with one is
|
|
586
|
+
kept whole (`?token="abc"`, `?sig=,1`); what it leaves is read as a
|
|
587
|
+
text, each URL of a list its own (`?token=…,https://b/y?next=…`
|
|
588
|
+
scrubs the second URL too) — and in any text — a JSON string's prose, an HTML, XML, RSC, CSS
|
|
589
|
+
or text body, a multipart part — each URL with a scheme and an
|
|
590
|
+
authority (`https://`, `wss://`, `myapp://`), each URL a link's
|
|
591
|
+
attribute (`href`, `src`, …), a URL any other attribute's quoted value
|
|
592
|
+
holds (`data-next="/x?…"`: a `/`, `./`, `../`, `?`, `#` or a scheme as
|
|
593
|
+
below first -- a style's value is CSS, not a URL), a meta refresh's `url=`
|
|
594
|
+
or a CSS `url()` holds (after a property's name too, or as an
|
|
595
|
+
attribute's whole value, `background="url(…)"`), to its first
|
|
596
|
+
space or, outside a quoted attribute, the first `)` or `]` it does not
|
|
597
|
+
open (CSS's `url(/x?token=…);color:red` keeps its `);color:red`), and
|
|
598
|
+
each URL a
|
|
599
|
+
script or JavaScript writes with its slashes escaped
|
|
600
|
+
(`"https:\/\/app\/cb#…"`, `\u002f`), to its first space, quote,
|
|
601
|
+
parenthesis, bracket or a plain `/` that closes a regular expression
|
|
602
|
+
(`/https:\/\/x\/cb#access_token=([^&]+)/` keeps its group and its
|
|
603
|
+
closing `/`), read unescaped, only the stretch from its first change to
|
|
604
|
+
its last written anew;
|
|
605
|
+
a URL in a template literal ends at its `${` (code, not a value); a
|
|
606
|
+
scheme at a line's start is one a `/` follows, one whose name holds a
|
|
607
|
+
`.` or `+`, `localhost` and its port (`localhost:3000/`), or one of a
|
|
608
|
+
list with no authority (`mailto:`, `tel:`, `xmpp:`, `intent:`, `data:`
|
|
609
|
+
…), never a CSS property's name (`grid-area:1/2` either); a relative URL inside prose is not told from the
|
|
610
|
+
prose, and is not read, nor is another attribute's unquoted value. A
|
|
611
|
+
nested URL is written back as it came, raw or encoded, or its value
|
|
612
|
+
replaced whole where its encoding cannot be kept. A form value written
|
|
613
|
+
encoded is redacted in place, or replaced whole where its encoded text
|
|
614
|
+
cannot be. A presigned S3, GCS or Azure link has
|
|
615
|
+
its signing parameters replaced (`X-Amz-Signature`, `X-Amz-Credential`,
|
|
616
|
+
`X-Amz-Security-Token`, `sig`), every other byte kept, and a pagination
|
|
617
|
+
link's `pageToken` is not touched. Such a link is no longer the one the
|
|
618
|
+
server sent, so replaying a request for it relies on the replay key
|
|
619
|
+
treating a redacted value as a wildcard. JSON inside a form value or a
|
|
620
|
+
multipart part (a GraphQL upload's `operations`) is redacted by key in
|
|
621
|
+
its own text when it was written as it is; a URL-encoded one with
|
|
622
|
+
anything in it to redact — a password, an email — is replaced whole,
|
|
623
|
+
since its encoded text cannot be redacted in place.
|
|
624
|
+
A name/value pair whose name is a secret's — `{key: "Authorization",
|
|
625
|
+
expected, actual}`, a header list `[{name: "Set-Cookie", value}]` —
|
|
626
|
+
has its `value`, `values`, `expected` and `actual` replaced. A body
|
|
627
|
+
that is not
|
|
628
|
+
JSON gets the same rule (Names) for its `name=value` pairs — a form post, an
|
|
629
|
+
OAuth token request, `FormData` (passed directly or inside a
|
|
630
|
+
`Request`), `URLSearchParams` or an XHR string body: a value under a sensitive name — or under a name with a
|
|
631
|
+
sensitive part, like `password[0]` or `user[password_confirmation]` —
|
|
632
|
+
becomes `[REDACTED]`. In a FORM — a body sent as
|
|
633
|
+
`application/x-www-form-urlencoded` or `multipart/form-data`, or one
|
|
634
|
+
made only of such pairs with no raw spaces in them — that value runs
|
|
635
|
+
to the next `&`, spaces and all, and every other value is scanned for
|
|
636
|
+
the patterns below, raw and URL-decoded; a pair nothing matched is
|
|
637
|
+
kept byte for byte. `FormData` and `URLSearchParams` bodies are
|
|
638
|
+
recorded encoded, so they are forms whatever their content-type, but
|
|
639
|
+
one: sent under a JSON content-type the body is read as JSON, does not
|
|
640
|
+
parse, and is refused whole as `[UNPARSEABLE_BODY_NOT_REDACTED]`. ANY
|
|
641
|
+
OTHER BODY — HTML, XML, prose, or pairs with raw spaces in them posted
|
|
642
|
+
without a form content-type (the browser sends a string as
|
|
643
|
+
`text/plain`) — is kept byte for byte except for a URL it holds
|
|
644
|
+
(above) and a pair that starts
|
|
645
|
+
the body or follows `?`, `&`, `;`, a newline, a tag's `>`
|
|
646
|
+
(`<p>password=...</p>`), a `#` (`Location: /cb#access_token=…`) or a
|
|
647
|
+
space that follows no bracket and no `var`, `let` or `const`
|
|
648
|
+
(`user=bob; password=...` is found; neither a JavaScript body nor a
|
|
649
|
+
`<script>`'s text has a space or a tag start one, nor a `#` after
|
|
650
|
+
anything but a path's character or after a block comment's close,
|
|
651
|
+
`static` or `accessor` -- a class's `#token=` and `static#token=` are
|
|
652
|
+
private fields, and
|
|
653
|
+
`location.replace("/cb#access_token=…")` loses its token; nor is a
|
|
654
|
+
template literal's `${…}` part of a value, which ends before it
|
|
655
|
+
(`` `/api?token=abc${t}` `` records `` `/api?token=[REDACTED]${t}` ``); a body is JavaScript by its content-type, so `f(a, token=1)` in
|
|
656
|
+
`text/plain` loses its default) directly, and whose name is made only
|
|
657
|
+
of letters, digits, `_`, `-`, `%` and closed brackets (so minified
|
|
658
|
+
JavaScript's `e.token=t` and CSS's `[data-token=x]` are left alone);
|
|
659
|
+
its value ends at the first space, quote, backtick, bracket,
|
|
660
|
+
backslash, `&`, `;` or comma. So in such a body
|
|
661
|
+
`password=correct horse` records `password=[REDACTED] horse`, and
|
|
662
|
+
`user.password=`, `new+password=` and `"token=..."` are not found at
|
|
663
|
+
all: post a form with its content-type. A credential pair inside a form VALUE — a
|
|
664
|
+
redirect URL's `?token=` — is found the same way, raw and URL-decoded.
|
|
665
|
+
A multipart body written out by hand as a string (or served as a
|
|
666
|
+
response) under a `multipart/form-data` content-type is read part by
|
|
667
|
+
part: a part under a sensitive name, and any file part, has its value
|
|
668
|
+
replaced whole, and every other part is scanned like other text, every
|
|
669
|
+
other byte kept. A body under that content-type that is neither
|
|
670
|
+
multipart text nor a `FormData`'s fields — its boundary not the
|
|
671
|
+
declared one, or plain text — is recorded as `[Unreadable body]`,
|
|
672
|
+
never as it came. Every body that is not JSON
|
|
673
|
+
is then scanned as text for JWTs, email addresses, SSNs, phone
|
|
674
|
+
numbers, IPv4 addresses and card numbers; inside JSON the patterns
|
|
675
|
+
run on each string value. An OAuth token exchange's `code` goes too,
|
|
676
|
+
and a device flow's `device_code`, in a form and in JSON alike: in a
|
|
677
|
+
body (or a JSON object) with `grant_type=authorization_code` or the
|
|
678
|
+
device code grant, a `code_verifier`, or a code beside a
|
|
679
|
+
`redirect_uri`, a `client_id` or a `verification_uri`, or a code of
|
|
680
|
+
10 characters or more beside a generated `state` (16 or more of a
|
|
681
|
+
token's characters, letters with a digit or both cases, no word or
|
|
682
|
+
slug; that state goes too) -- a SPA
|
|
683
|
+
finishing a PKCE flow posts the code it was handed. Elsewhere `code`
|
|
684
|
+
is an app's own (`?code=US`, a promo code) and stays. A RESPONSE body
|
|
685
|
+
is redacted the same way,
|
|
686
|
+
and a replay serves what was recorded: a token the app reads from a
|
|
687
|
+
redacted pair and sends back later replays as `[REDACTED]`. A body cut
|
|
688
|
+
at `maxBodySize` is read as a form when its cut-off end could be one,
|
|
689
|
+
so it may lose everything from its first sensitive `=` to the cut;
|
|
690
|
+
that is the price of never keeping half a credential the cut split.
|
|
691
|
+
`privacy.maskNetworkBodies: true` replaces every body wholesale with
|
|
692
|
+
`[MASKED]` instead (a request that had no body keeps `null`).
|
|
693
|
+
`privacyMode: "strict"` forces that: no body is recorded, and an
|
|
694
|
+
explicit `privacy.maskNetworkBodies: false` beside it is refused with
|
|
695
|
+
`KUI_E_PRIVACY_CONFLICT` before anything is recorded — neither option
|
|
696
|
+
silently wins.
|
|
697
|
+
- Every network event carries `requestTerm` in EVERY privacy mode,
|
|
698
|
+
strict included: the GraphQL operation a request body runs, as its
|
|
699
|
+
`operationName` and 16 hex of SHA-256 over its document with every
|
|
700
|
+
string and number literal blanked first (`graphql:GetApps#…`), `""` for
|
|
701
|
+
a body that is no GraphQL, or `body:*` for one the SDK could not read
|
|
702
|
+
or hash. It is computed over the body before redaction and never holds
|
|
703
|
+
a variable or a literal: it is what replay tells GraphQL calls apart by
|
|
704
|
+
(spec/canonical-key.v2.json).
|
|
705
|
+
- One rule reads every URL the SDK records: a request's URL and every
|
|
706
|
+
URL its request and response headers carry (`Location`,
|
|
707
|
+
`Content-Location`, `Link` and `Refresh` -- its delay first or not --
|
|
708
|
+
as a request's URL is, the page's next request; any other header's, a
|
|
709
|
+
`Referer` or a CSP's `report-uri`, by a credential's name, its own
|
|
710
|
+
value ended as a text body's is, so a list's next URL and a CSP's next
|
|
711
|
+
directive are kept -- and a
|
|
712
|
+
header's pairs, a relative URL's among
|
|
713
|
+
them, where its start, a `?`, a `&`, a `;`, a `,`, a space or a `#`
|
|
714
|
+
after a path leads one: `a=1, token=…`, `0; url=/next?a=1;sig=…`),
|
|
715
|
+
every URL a body holds (above), the page's own URL and every URL its
|
|
716
|
+
DOM holds (a link attribute's, and any other attribute's whose value
|
|
717
|
+
is wholly a URL: a scheme, `/`, `./` or `../` first and a query, a
|
|
718
|
+
fragment or a `;` parameter in it, or a `?` or `#` first, with no
|
|
719
|
+
space, a scheme being one a line's start takes (above) -- `data-next="/x?…"`,
|
|
720
|
+
an input's `value`; a path alone, `data-reset="/reset-password/<token>"`,
|
|
721
|
+
and CSS, `data-s="background:url(…)"`, are not read as one). A URL's path is kept — it is what
|
|
722
|
+
the replay key is computed from — and a value is redacted where its
|
|
723
|
+
name is a credential's (Names, above): a query's pair after `&`, or
|
|
724
|
+
after a `;` a `name=` follows; a fragment's (an OAuth implicit grant's
|
|
725
|
+
`#access_token=…`, a hash route's `#/cb?token=…` or `#/cb&token=…`);
|
|
726
|
+
a path's `;jsessionid=`; and a URL nested or
|
|
727
|
+
encoded in a value (`?next=/reset?token=…`,
|
|
728
|
+
`?redirect=https%3A%2F%2F…%3Ftoken%3D…`, `?a=1%26token%3D…`, a second
|
|
729
|
+
`?`), one level down. Deeper, and in a value encoded more than once
|
|
730
|
+
(`?redirect=https%253A%252F%252F…`), the value is replaced whole when a
|
|
731
|
+
credential's name is in it, decoded up to four times and escape by
|
|
732
|
+
escape, so a malformed escape beside it (`%25zz`) hides nothing; in the page's URL
|
|
733
|
+
and the DOM's a URL nested deeper with a query of its own is replaced
|
|
734
|
+
whole, unread. A URL's user name and password are dropped. Every scheme is
|
|
735
|
+
read so — `https:`, `wss:`, `myapp://`, `mailto:`,
|
|
736
|
+
`com.example.app:/oauth2redirect#access_token=…` — but for a script's or an
|
|
737
|
+
inline object's (`javascript:`, `data:`, `blob:`), which is kept. In a
|
|
738
|
+
request's URL a pair
|
|
739
|
+
runs from `&` to `&`, as the replay key reads one, and a credential
|
|
740
|
+
anywhere in it (`?a=1;auth_token=…`, a nested URL's) replaces the
|
|
741
|
+
pair's whole value; elsewhere only the credential's own value goes. A request's own fragment
|
|
742
|
+
(`#...`) is dropped entirely: it never reaches a server, so no replay
|
|
743
|
+
needs it, and single-page routers put user state there.
|
|
744
|
+
Under `privacyMode: "strict"` every query value is replaced, whatever
|
|
745
|
+
its name, and every name kept: `/search?q=ada%40example.com&page=2`
|
|
746
|
+
is recorded as `/search?q=[REDACTED]&page=[REDACTED]`; an empty value
|
|
747
|
+
and a bare name (`?flag`, recorded as written, whatever it holds) are
|
|
748
|
+
kept. Replaying such a request needs a replay key that matches a value
|
|
749
|
+
redacted at record against any live value (canonical-key.v2, not yet
|
|
750
|
+
specified in spec/); with
|
|
751
|
+
it, two requests that differ only in a redacted value
|
|
752
|
+
(`?session=morning` and `?session=evening`, two `?pin=`s) are one
|
|
753
|
+
request to the replay, answered in the order they were recorded.
|
|
754
|
+
Under canonical-key.v1, which generated tests use today, a request
|
|
755
|
+
whose redacted value v1 does not leave out of its key does not match
|
|
756
|
+
at replay.
|
|
757
|
+
- The PAGE's URL -- what every recorded page change carries, rrweb's
|
|
758
|
+
own included, the session's starting URL and its referrer -- is read
|
|
759
|
+
by the same rule. A value in the query
|
|
760
|
+
is redacted up to the next `&`, `;` or `#`, and one in the path
|
|
761
|
+
(matrix parameters, `/reset;token=`) or in a route up to the next `?`
|
|
762
|
+
as well, so a token holding `/` goes whole. A credential that itself
|
|
763
|
+
holds a literal `;` or `&` is cut there, and the rest is recorded
|
|
764
|
+
unless the value scrub below finds it. The page's own fragment is
|
|
765
|
+
kept only when it is a hash router's route (`#/cart`, `#!/cart`), up
|
|
766
|
+
to a second `#`, with the route's own pairs redacted the same way; any
|
|
767
|
+
other fragment, an OAuth implicit-flow `#access_token=...` included,
|
|
768
|
+
is dropped.
|
|
769
|
+
- A credential the page's URL carries is scrubbed from every event the
|
|
770
|
+
SDK sends, wherever the page or rrweb copies it: rrweb makes every
|
|
771
|
+
link absolute against the page and builds a CSS `url()` by cutting the
|
|
772
|
+
page URL at a `/`, a share link copies the page URL encoded, and the
|
|
773
|
+
page puts tokens in its DOM and its requests. So the VALUE is replaced
|
|
774
|
+
with `[REDACTED]` in the DATA of every event -- DOM, network and the
|
|
775
|
+
rest -- as written, percent-decoded (the way `decodeURIComponent` and
|
|
776
|
+
`URLSearchParams` read it, `+` as a space), percent-encoded, and cut
|
|
777
|
+
at each of its last four `/` (where rrweb's CSS `url()` cuts it). The
|
|
778
|
+
names an event is built of are left as its reader reads them: a name is
|
|
779
|
+
touched only where the page or you wrote it, only for a
|
|
780
|
+
generated-looking value, and never one rrweb writes for itself (`rr_*`,
|
|
781
|
+
`_cssText`) -- in a DOM event, an element's attribute or a style's
|
|
782
|
+
property so named is DROPPED, since no attribute or property name holds
|
|
783
|
+
`[REDACTED]`; a request's or response's header and a custom event's
|
|
784
|
+
payload key are RENAMED. rrweb's tag names, a style declaration's
|
|
785
|
+
property, the values of attributes HTML defines a vocabulary for
|
|
786
|
+
(`type`, `rel`, `role` and the like) and the network record's `method`
|
|
787
|
+
and `type` are never scrubbed; CSS -- a style attribute, a `<style>`'s
|
|
788
|
+
text whenever it is written, a stylesheet's rules and its `replace()` --
|
|
789
|
+
is scrubbed inside its `url()`s, quoted strings and comments, and of a
|
|
790
|
+
generated-looking value anywhere. A request or response body that is
|
|
791
|
+
JSON, and any other string that is a JSON object or array, is scrubbed
|
|
792
|
+
token by token, so it still parses: a value inside a JSON string is
|
|
793
|
+
replaced there (and a JSON text inside that string is scrubbed as JSON
|
|
794
|
+
again), a JSON number a value is found in becomes the string
|
|
795
|
+
`"[REDACTED]"`, a string a value is found in is written again as
|
|
796
|
+
`JSON.stringify` writes it, and every other token is kept byte for
|
|
797
|
+
byte; two names of one object that become one are both kept, the
|
|
798
|
+
second suffixed `#2`. The credential is
|
|
799
|
+
collected from each URL the SDK sees the page on. In a browser without
|
|
800
|
+
the Navigation API it does not see a URL the page reaches with a
|
|
801
|
+
`pushState` it has not wrapped -- one a router kept from before `init()`
|
|
802
|
+
(SvelteKit does), or any on a page whose methods it could not wrap (see
|
|
803
|
+
[Single-page apps](#single-page-apps)) -- and leaves again before the
|
|
804
|
+
next recorded event, so that URL's credential is not collected.
|
|
805
|
+
- The values scrubbed are the ones named above, an OAuth callback's
|
|
806
|
+
`code` and `state` (a code of at least 10 characters beside a
|
|
807
|
+
generated-looking state, or a generated-looking code of at least 20
|
|
808
|
+
alone on a callback's path -- one with `callback` or `oauth` in it, or
|
|
809
|
+
a segment that is `cb`, `auth`, `sso`, `signin`, `sign-in`,
|
|
810
|
+
`authorize(d)` or `redirect`, in the path or a hash router's route --
|
|
811
|
+
as GitHub and a PKCE callback send it), a CAS `ticket` (`ST-`, `PT-`, `TGT-`),
|
|
812
|
+
Supabase's `token_hash`, Clerk's `__clerk_ticket`, Magic's
|
|
813
|
+
`magic_credential`, a link page's `key`, `t`, `hash` and `code`
|
|
814
|
+
whatever they look like, in its own URL and in a link to one (and
|
|
815
|
+
WordPress's `wp-login.php?action=rp&key=...`), Auth0's
|
|
816
|
+
`?invitation=` beside an `organization`, a link's path token,
|
|
817
|
+
and each of those inside a URL nested in a parameter (a
|
|
818
|
+
`returnTo=%2Faccept-invite%3Ftoken%3D...`, two levels deep).
|
|
819
|
+
- A link's path token is told from an app's own id by the words of the
|
|
820
|
+
segment it follows and by its own shape, in the path or in a hash
|
|
821
|
+
router's route. Every word of that segment must be a link's own (a
|
|
822
|
+
file extension, as in `reset.php`, is not a word). A STRONG segment
|
|
823
|
+
names the act: reset, verify, unlock, activate, invite, forgot,
|
|
824
|
+
recover, a magic or login link, set or create a password
|
|
825
|
+
(`/set-password/<t>`), accept an invitation, or confirm an
|
|
826
|
+
email, account, registration or sign-up, named in its segment or the
|
|
827
|
+
one before it (`/reset-password/<t>`, `/password_resets/<t>/edit`,
|
|
828
|
+
`/forgotten-password/<t>`, `/accept-invitation/<id>`,
|
|
829
|
+
`/confirm-email/<t>`, `/email/confirm/<t>`). A WEAK one names a thing
|
|
830
|
+
a token or an id may follow: a confirmation, an invitation, a
|
|
831
|
+
verification, an activation, a password, a sign-up, a log-in
|
|
832
|
+
(`/users/confirm/<t>`, `/users/log-in/<t>`, `/passwords/<t>/edit`).
|
|
833
|
+
An ID is digits, a UUID, a 24-hex ObjectId, a ULID or a cuid (each in
|
|
834
|
+
its own case), or a user's uid (Django's and Djoser's base64 pk,
|
|
835
|
+
whatever the pk) where one is expected -- before a token, or after a
|
|
836
|
+
strong segment; a TOKEN-SHAPED value is any other generated-looking one
|
|
837
|
+
of 16 characters or more, 20 after a weak segment. A shape a token can
|
|
838
|
+
take is a token's: a prefixed id (`inv_…`, a TypeID) after a link word
|
|
839
|
+
is scrubbed, because 1-4% of real nanoid and base64url tokens take
|
|
840
|
+
that shape too -- keep your own with `privacy.keepRoutes`. The token is the first token-shaped value after the segment,
|
|
841
|
+
past short ids, ids and the link's own words
|
|
842
|
+
(`/password/reset/confirm/<uid>/<t>`,
|
|
843
|
+
`/reset-password/<ObjectId>/<JWT>`, `/account/reset/<customerId>/<t>`).
|
|
844
|
+
When the path ends with ids alone after a strong segment, the last of
|
|
845
|
+
them is the token (`/invite/<uuid>`) -- not when a word follows them
|
|
846
|
+
(`/invite/<uuid>/members`). After a weak segment an id is the token
|
|
847
|
+
only when an accept or join acts on it (`/invitations/<uuid>/accept`).
|
|
848
|
+
After an invitation's segment, a shorter generated-looking code --
|
|
849
|
+
`Ab3dE5gH` -- is a token wherever an id would be one
|
|
850
|
+
(`/invite/<code>`, `/invitations/<code>/accept`); after any other
|
|
851
|
+
link word a short segment stays. A word that names a credential
|
|
852
|
+
outright -- set, create, reset, forgot or lost password, verify email
|
|
853
|
+
-- hands on the next segment whatever its length or shape, in the
|
|
854
|
+
page's URL and in a link a visitor follows (an `<a>`'s or `<area>`'s
|
|
855
|
+
`href`, a form's `action` or `formaction`); what a page loads, an
|
|
856
|
+
image or a stylesheet, keeps the token-shape rule, so a replay can
|
|
857
|
+
load `/img/set-password/hero`. A page of the link stays (`sent`,
|
|
858
|
+
`done`, `success`, `complete`, `confirm`, `confirmed`, `new`,
|
|
859
|
+
`error`, `expired`, `failed`, `invalid`), and so do a file
|
|
860
|
+
(`hero.png`), a step of the link (`/reset-password/confirm/<t>`) and
|
|
861
|
+
an id with more path after it (`/verify-email/42/<hash>`). Any other
|
|
862
|
+
word there goes (`/reset-password/pending`), and
|
|
863
|
+
`privacy.keepRoutes` keeps it. Unless it looks generated, such a
|
|
864
|
+
segment is held there alone: `pending` is not taken out of the page.
|
|
865
|
+
So `/admin/invitations/<uuid>/edit`, `/order/confirmation/<uuid>`,
|
|
866
|
+
`/settings/verification/<id>`, `/login/<uuid>`,
|
|
867
|
+
`/products/apple-magic-mouse/<id>` and `/order-confirmation/<id>` are
|
|
868
|
+
an app's own resources, and their ids, which appear in its requests,
|
|
869
|
+
are kept.
|
|
870
|
+
- Only a GENERATED-LOOKING value is scrubbed everywhere: 8 characters or
|
|
871
|
+
more mixing two of lower case, upper case and digits, not a
|
|
872
|
+
capitalised word and not a slug of words and numbers
|
|
873
|
+
(`annual-meeting-2024-berlin`) -- every form of it included (decoded,
|
|
874
|
+
encoded, cut at a `/`). A word -- `delivered`, `California`, `required`,
|
|
875
|
+
`two-factor-authentication` -- also appears in the page's own text,
|
|
876
|
+
classes and requests, and so do digits alone (an order number, a
|
|
877
|
+
price), so an app's own `?code=ORD-2024-000123&state=delivered` or
|
|
878
|
+
`/settings/activate/two-factor-authentication` is recorded as it is,
|
|
879
|
+
and a credential value that is a word, digits alone, or shorter than
|
|
880
|
+
8 characters is redacted only in the URL that names it (above) --
|
|
881
|
+
unless a route you declare names it (below). A
|
|
882
|
+
value that is a URL is never a credential, nor is an OAuth `code` or
|
|
883
|
+
`state` that is a path (a `state` carrying the return URL); a value a
|
|
884
|
+
credential's name shows is one even when it begins with `/`, as a
|
|
885
|
+
standard-base64 token can. No part of the page's own origin is ever
|
|
886
|
+
scrubbed.
|
|
887
|
+
- The values are kept for the life of the page, not for as long as the
|
|
888
|
+
address bar shows them: an auth library or a reset page that hides the
|
|
889
|
+
token with `history.replaceState` still holds it, so the URL the page
|
|
890
|
+
was LOADED with is read too (even when the token was hidden before
|
|
891
|
+
`init()`), and so is every URL the page moves to while a capture is
|
|
892
|
+
open -- pushed, replaced or reached by the visitor going back or
|
|
893
|
+
forward, paused or not -- and the session's URL and referrer are
|
|
894
|
+
recorded without any of them. A continuous capture keeps collecting
|
|
895
|
+
them between its sessions; once `stop()` has settled (at most a
|
|
896
|
+
second, while exchanges already answered finish their bodies) nothing
|
|
897
|
+
watches the page, so a URL it moves to and away from before the next
|
|
898
|
+
capture starts is never read. Routes a later capture declares are applied to the newest
|
|
899
|
+
64 URLs already read (512 KB of them at most) as well as to the one
|
|
900
|
+
the page loaded with. The newest 256 forms are kept, 64 KB of them at
|
|
901
|
+
most, and the forms of the URL the page is on now are always kept; a
|
|
902
|
+
value is cut at its last four `/` only, where rrweb's CSS url() cuts
|
|
903
|
+
it.
|
|
904
|
+
- A CRAFTED URL is recorded as its origin and `/[REDACTED]`: one whose
|
|
905
|
+
path, query and route are longer than 64 KiB (it is then not read,
|
|
906
|
+
but for the values your declared routes name in its path and route),
|
|
907
|
+
or that carries more than 32 credential values. The values your
|
|
908
|
+
declared routes name in the URL's own path and route are always held;
|
|
909
|
+
32 more at most -- the rest of the URL's, declared ones in a nested
|
|
910
|
+
URL included, and each other segment a declared value is named after
|
|
911
|
+
(a link's spellings of one segment, in any case and encoding, are
|
|
912
|
+
one) -- are held and scrubbed, so a link cannot make every event pay
|
|
913
|
+
for thousands. A value past those 32 is NOT held: the page's URL is
|
|
914
|
+
still recorded as its origin, but a link, a request or a text that
|
|
915
|
+
carries that value again is recorded with it (measured: a 33rd
|
|
916
|
+
`…_token=` value in the page's URL stays in every link rrweb resolves
|
|
917
|
+
against that URL). Declare the route of any value that must never be
|
|
918
|
+
recorded: a declared value in the URL's own path is held whatever
|
|
919
|
+
else the URL carries. A
|
|
920
|
+
fragment that is no route (a playground's `#code/…`) is not recorded
|
|
921
|
+
and does not count toward 64 KiB, but it is read, in linear time, for
|
|
922
|
+
the credentials it hands the page (`#access_token=…`). Each URL is
|
|
923
|
+
read once, in time linear in its length, for as long as the page is
|
|
924
|
+
on it.
|
|
925
|
+
- The scrub reads an event's JSON and never the integrator's own objects:
|
|
926
|
+
a custom event that is cyclic, frozen or has a throwing getter is left
|
|
927
|
+
to the transport, which drops what JSON refuses. Two names that become
|
|
928
|
+
one are both kept (the second suffixed `#2`), and an event the scrub
|
|
929
|
+
cannot read is dropped rather than sent.
|
|
930
|
+
- THIS IS RECOGNITION, NOT A GUARANTEE. A credential the URL carries in
|
|
931
|
+
a shape the rules above do not recognise -- an unusual parameter name,
|
|
932
|
+
a token that is a dictionary word or digits alone, a token shorter than
|
|
933
|
+
16 characters in a path (Discourse's 10-character `/invites/<key>`), a
|
|
934
|
+
token that is a UUID or an ObjectId after a weak segment
|
|
935
|
+
(`/invitations/<uuid>`) -- is recorded; and an app's own id right after
|
|
936
|
+
a strong link segment (`/teams/invite/<id>`, `/devices/reset/<uuid>`),
|
|
937
|
+
a generated id of no known shape after a weak one (a nanoid, a KSUID,
|
|
938
|
+
a prefixed id or a Firestore id in `/invitations/<id>`) or a
|
|
939
|
+
link page's `?code=` that is a promo code (`/signup?code=FRIEND10`)
|
|
940
|
+
is scrubbed, because neither the words nor the shape tell the two
|
|
941
|
+
apart. Where they cannot, a credential wins: an id scrubbed by mistake
|
|
942
|
+
is kept by a declared route, a credential recorded by mistake is not
|
|
943
|
+
taken back. DECLARE THEM: see
|
|
944
|
+
the next item. Name a credential parameter like one (anything ending
|
|
945
|
+
in `token`) or keep it out of the URL. And a request that carries the
|
|
946
|
+
page's credential is recorded with it redacted, so its replay key
|
|
947
|
+
cannot match a live request carrying a real one -- which a one-time
|
|
948
|
+
token never would anyway.
|
|
949
|
+
- `privacy.secretRoutes` names the routes whose segments are
|
|
950
|
+
credentials the rules above miss, and `privacy.keepRoutes` the routes
|
|
951
|
+
whose segments are your app's own ids they would take for one:
|
|
952
|
+
|
|
953
|
+
```ts
|
|
954
|
+
await KeployCapture.init({
|
|
955
|
+
endpoint,
|
|
956
|
+
apiKey,
|
|
957
|
+
privacy: {
|
|
958
|
+
secretRoutes: ["/invites/:key", "/*/change-email/:token"],
|
|
959
|
+
keepRoutes: ["/teams/invite/:teamId", "/invites/settings"],
|
|
960
|
+
},
|
|
961
|
+
});
|
|
962
|
+
```
|
|
963
|
+
|
|
964
|
+
A route is `/`-separated segments from the path's start (empty ones
|
|
965
|
+
ignored), each a literal (matched in any case, decoded), `*` (any one
|
|
966
|
+
segment) or `:name` (the value the route names); it matches a path
|
|
967
|
+
that begins with it -- the page's path, a hash router's route (`#/…`
|
|
968
|
+
or `#!/…`), and a URL nested in a parameter -- and a segment's matrix
|
|
969
|
+
parameters (`;jsessionid=…`) are not part of its value. A SECRET
|
|
970
|
+
route names at least one `:name`. What it names is kept out of the
|
|
971
|
+
recorded URL and every event -- the DOM, inputs, requests and
|
|
972
|
+
responses, their URLs and bodies -- each form of it (as the URL
|
|
973
|
+
spells it, decoded, encoded) by the rule its own text calls for. A
|
|
974
|
+
value that holds no letter or digit once decoded -- read through up to
|
|
975
|
+
sixteen encodings -- is not held at all: `/`, `%2f`, `-~_`, `$$$$$$`,
|
|
976
|
+
`€€€€€€`, emoji, a full-width space. No credential is spelt that way,
|
|
977
|
+
and such a value would otherwise match every separator or symbol of
|
|
978
|
+
the page; one still encoded after sixteen decodings is not held
|
|
979
|
+
either. The rules:
|
|
980
|
+
- generated-looking (above): as it is, wherever it appears, and in any
|
|
981
|
+
case where no ASCII letter or digit touches it;
|
|
982
|
+
- any other of at least 6 characters, decoded, WHATEVER ITS LETTERS (`QX7P2K`,
|
|
983
|
+
`482913`, `QxPkZmA`, `notifications`): in any case, wherever no
|
|
984
|
+
ASCII letter or digit touches it -- `{"code":"QX7P2K"}`,
|
|
985
|
+
`Code: QX7P2K.`, `?code=qx7p2k`, after a string's escape
|
|
986
|
+
(`\nQX7P2K`, `%5CnQX7P2K`), as a JSON writer escapes it
|
|
987
|
+
(`Q\u00e9X7P2`), a share link encoding the page URL up to three
|
|
988
|
+
times (any number of times for a code of ASCII letters and digits,
|
|
989
|
+
which encoding leaves as it is); a JSON number holding one becomes
|
|
990
|
+
the string `"[REDACTED]"`, so the body still parses. No shape tells
|
|
991
|
+
a random code from a word
|
|
992
|
+
(`qxpkzm` from `create`), so a credential wins: a page of your own
|
|
993
|
+
that a secret route also matches (`/invites/notifications` under
|
|
994
|
+
`/invites/:key`) has its name scrubbed as a credential from every
|
|
995
|
+
event of the page from then on -- a single-page app keeps it after
|
|
996
|
+
navigating away, so `/api/notifications` and the text
|
|
997
|
+
`Notifications` are `[REDACTED]` on every later route -- until you
|
|
998
|
+
declare it as a keep route (`/invites/notifications`), and then it is
|
|
999
|
+
your page again;
|
|
1000
|
+
- a shorter value, decoded (`new`, `Edit`, `ab-cd`, `新規` however
|
|
1001
|
+
long its encoded form): only as the path segment
|
|
1002
|
+
after the one its route puts before it (`invites/new`), after every
|
|
1003
|
+
such segment the routes name, in any case, separated by `/`, `\/` or
|
|
1004
|
+
a `/` encoded up to three times, and ended by any character that
|
|
1005
|
+
cannot continue a word (`.json`, a `)` closing a CSS `url()`, a
|
|
1006
|
+
space). A short value is also your app's own text, so `new` in the
|
|
1007
|
+
page and `/projects/new` stay; that also means it is NOT scrubbed
|
|
1008
|
+
from a request body or the page's text, nor from a URL that does not
|
|
1009
|
+
put its route's segment before it, so a credential of fewer than 6
|
|
1010
|
+
characters is held in URLs alone. A route whose `:name` is the
|
|
1011
|
+
path's first segment (`/:space`) holds it as any whole segment after
|
|
1012
|
+
a `/`.
|
|
1013
|
+
|
|
1014
|
+
A KEEP route has at least one literal: what its `:name`s name is never
|
|
1015
|
+
taken for a token by the rules above (a value a credential's name
|
|
1016
|
+
shows, `?token=`, or a secret route names too, is still a
|
|
1017
|
+
credential). A keep route's literal is your app's own name for its
|
|
1018
|
+
position, so no secret route takes it for a value there:
|
|
1019
|
+
`/invites/settings` keeps `/invites/settings` and
|
|
1020
|
+
`/invites/settings/billing` from `/invites/:key`. A keep route of
|
|
1021
|
+
literals alone also names ONE page, the path it spells and not the
|
|
1022
|
+
pages under it, where no segment is taken for a token either --
|
|
1023
|
+
`/account` keeps `/account` and not `/account/reset/<token>`; a value
|
|
1024
|
+
a credential's name shows is still redacted. A route outside the rule refuses to start the
|
|
1025
|
+
capture (`KUI_E_PRIVACY_ROUTE_INVALID`): one the SDK cannot match would
|
|
1026
|
+
protect nothing -- on every load, whatever `sampleRate` leaves out.
|
|
1027
|
+
Routes are declared when a capture starts and kept for the page; a
|
|
1028
|
+
second `init()` while a capture is live returns that capture, and its
|
|
1029
|
+
routes are not added.
|
|
1030
|
+
|
|
1031
|
+
KNOWN LIMIT, with declared routes only: scrubbing a string costs time
|
|
1032
|
+
in proportion to its length times the number of long declared values
|
|
1033
|
+
(longer than `[REDACTED]`) it holds, and a crafted link can declare up
|
|
1034
|
+
to 32. That is the bound: 32 passes over an event's strings, which end
|
|
1035
|
+
at the 10 MiB cap. MEASURED in Node 24 on a link with 31 nested values,
|
|
1036
|
+
each a run of one digit, beside a longer run of that digit: a page of
|
|
1037
|
+
110 relative links (0.96 MB of link text) scrubbed in 6 ms without the
|
|
1038
|
+
nested values and in 0.9 s with them, and one of 1,100 (9.6 MB, just
|
|
1039
|
+
under the cap) in 64 ms and in 9.3 s. In Chromium, in review, 300 such
|
|
1040
|
+
links made `init()` take 2.6 s where it took 0.18 s without the nested
|
|
1041
|
+
values -- and a snapshot dropped for size is retaken on a backoff.
|
|
1042
|
+
Reading every long value in one pass over the string is the planned
|
|
1043
|
+
fix.
|
|
1044
|
+
|
|
1045
|
+
- Beside the rules above, and never undoing what they keep, the page's
|
|
1046
|
+
URL -- the session's URL and referrer and every Meta event's -- and
|
|
1047
|
+
the URLs in the DOM listed below are scrubbed by their shape: in a
|
|
1048
|
+
query and in a route's or a fragment's pairs (a `;` followed by a
|
|
1049
|
+
`name=` separates pairs as `&` does), a value is replaced
|
|
1050
|
+
when it is shaped like a token (a JWT, or 32 or more letters and
|
|
1051
|
+
digits that are not a slug; a canonical UUID, and any value under an
|
|
1052
|
+
`*id` name, is taken for an id and kept) or when a PII pattern matches
|
|
1053
|
+
it (`?email=ada%40x.com`). A URL inside a value -- absolute, or a path
|
|
1054
|
+
with its own query -- is scrubbed the same way, one level deep, and a
|
|
1055
|
+
URL inside that one which carries a query or a fragment of its own is
|
|
1056
|
+
replaced whole; a JWT
|
|
1057
|
+
path segment is replaced; user name and password never leave. An
|
|
1058
|
+
OAuth authorization response is redacted in every mode: every `code`
|
|
1059
|
+
and `state` (and `session_state`), when a code is not a path and
|
|
1060
|
+
either the URL's path or route is a callback's (a segment with
|
|
1061
|
+
`callback` or `oauth` in it, or `cb`, `auth`, `sso`, `signin`,
|
|
1062
|
+
`authorize(d)` or `redirect`) or a state is not a plain word (letters,
|
|
1063
|
+
or words joined by `-` or `_`, of at most 16 characters, or longer
|
|
1064
|
+
camelCase or joined words); a `state` beside an id, access or refresh
|
|
1065
|
+
token, which go by name; and OAuth 1.0a's `oauth_verifier`. An app's
|
|
1066
|
+
`?code=ORD-2024-000123&state=delivered` or `?code=US&state=CA` stays.
|
|
1067
|
+
This scrub runs on what the page holds, before the credential scrub,
|
|
1068
|
+
and knows the page URL's credentials by their values: a CSS
|
|
1069
|
+
`url(img.png)` rrweb resolved against a page reached with `?token=`
|
|
1070
|
+
loses the token and keeps its file name, under any name, unless a PII
|
|
1071
|
+
pattern touches what follows it. A `[REDACTED]` the page
|
|
1072
|
+
itself wrote is text like any other, and shields nothing. Under
|
|
1073
|
+
`privacyMode: "strict"` every query value and fragment-pair value is
|
|
1074
|
+
replaced and every name kept, since a search box puts what was typed
|
|
1075
|
+
in `?q=` -- so a page with a query is recorded under a URL it never
|
|
1076
|
+
had (`?page=[REDACTED]`). The DOM's URLs -- `href`, `src`, `action`,
|
|
1077
|
+
`formaction`, each `srcset` and `imagesrcset` candidate, `poster`,
|
|
1078
|
+
`cite`, `data`, `xlink:href`, `background`, `longdesc`, each URL of a
|
|
1079
|
+
`ping`, a lazy loader's `data-src`, `data-srcset` and `data-href`, each
|
|
1080
|
+
`url(...)` or `@import` in an inline `style`, in a `<style>`'s text
|
|
1081
|
+
and in the stylesheet rrweb inlines for a `<link>`, a `<meta http-equiv=refresh>`
|
|
1082
|
+
target and a `content` that is a URL (`og:url`), in the full snapshot
|
|
1083
|
+
and in every node a mutation adds or attribute it changes -- are also
|
|
1084
|
+
scrubbed by the page URL's names, plus the code and hash names of
|
|
1085
|
+
verification, reset and sign-in links (`verification_code`,
|
|
1086
|
+
`reset_code`, `invite_code`, `mfa_code`, `nonce`, `hmac`,
|
|
1087
|
+
`magic_link`), so a reset
|
|
1088
|
+
link's `?token=` or a signed media URL's signature on the page is
|
|
1089
|
+
recorded scrubbed. A token a link carries in its PATH after a reset,
|
|
1090
|
+
invite, verify or magic-link word (`/reset-password/<token>`,
|
|
1091
|
+
`/invitations/<uuid>/accept`) is replaced when the page URL rule would
|
|
1092
|
+
replace it in the page's own URL and it is shaped like a token (a
|
|
1093
|
+
UUID, or a part of 8 characters or more that looks generated, an
|
|
1094
|
+
invitation's short code among them) or, in a link a visitor follows,
|
|
1095
|
+
comes after a word that names a credential outright, `;` parameters
|
|
1096
|
+
after it or not, so an app's own ids and slugs stay
|
|
1097
|
+
(`/order/confirmation/<uuid>`, `/products/apple-magic-mouse/<id>`,
|
|
1098
|
+
`/login/apple-iphone-15-pro-max-256gb`). An `iframe`'s `srcdoc` is
|
|
1099
|
+
read as a browser reads it -- comments and raw text (`<script>`,
|
|
1100
|
+
`<textarea>`, `<title>`) passed over, character references decoded
|
|
1101
|
+
however they are written -- with each of those attributes and its CSS
|
|
1102
|
+
scrubbed in its own markup, and then read again for any URL, style or
|
|
1103
|
+
srcdoc attribute the first read passed over (an SVG `<title>` holds
|
|
1104
|
+
markup). CSS -- a style attribute (or a style a script sets through
|
|
1105
|
+
`element.style`, which rrweb records as an object), a `<style>`'s
|
|
1106
|
+
text, the stylesheet rrweb inlines for a `<link>`, and what changes
|
|
1107
|
+
after the snapshot: a `<style>`'s text, a rule a script inserts or
|
|
1108
|
+
replaces through the CSSOM, a declaration it sets, an adopted
|
|
1109
|
+
stylesheet, a font it loads -- has each URL in a `url()`, closed or
|
|
1110
|
+
not, and in a quoted string (`@import`, `image-set()`) scrubbed the
|
|
1111
|
+
same way, read through its escapes (a `url(` whose name is escaped
|
|
1112
|
+
included) and past its comments. A `javascript:`, `data:` or `blob:`
|
|
1113
|
+
URL is kept; a URL with
|
|
1114
|
+
nothing to scrub is recorded exactly as it was, and an event the scrub
|
|
1115
|
+
cannot read is dropped rather than sent, as one the credential scrub
|
|
1116
|
+
cannot read is. A test holds a 50,000-node page with 20,000 such URLs
|
|
1117
|
+
under a second.
|
|
1118
|
+
- The page's TEXT -- each text node of the full snapshot and of a node
|
|
1119
|
+
added after it, each text change, a value typed under `off`, a
|
|
1120
|
+
`srcdoc`'s markup -- has every JWT and provider-prefixed key in it
|
|
1121
|
+
(the token patterns below: a Keploy `kep_` key, GitHub, Stripe, AWS
|
|
1122
|
+
and the rest) replaced with `[REDACTED]`, in every mode: the dashboard
|
|
1123
|
+
shows a freshly minted key as text, once. Text nodes side by side
|
|
1124
|
+
are read together, in a snapshot and in the nodes one mutation adds,
|
|
1125
|
+
so a key rendered in pieces goes too. Other text is recorded as
|
|
1126
|
+
the privacy mode masks it; under `privacyMode: "strict"` that includes
|
|
1127
|
+
a `srcdoc`'s text, between tags and in a `<title>`, `<textarea>` or
|
|
1128
|
+
`<xmp>`, masked as rrweb masks a text node's. Every attribute's value
|
|
1129
|
+
is read for those tokens too, and one that holds text -- `title`,
|
|
1130
|
+
`alt`, `placeholder`, `label`, `summary`, `abbr`, `aria-label` and the
|
|
1131
|
+
other `aria-*` text, a `data-*` that is no URL, a meta `content`, the
|
|
1132
|
+
`value` of an element that is no field (a button's, an option's) --
|
|
1133
|
+
for every built-in pattern below as well; a field's value is what the
|
|
1134
|
+
mask map above decides, and any other attribute (an `id`, an SVG
|
|
1135
|
+
path's numbers, a URL, CSS, a `srcdoc`) is read for tokens alone.
|
|
1136
|
+
rrweb's own `rr_*` attributes (a canvas's image data) are left alone.
|
|
1137
|
+
|
|
1138
|
+
The built-in patterns match JWTs (starting at a token boundary: one
|
|
1139
|
+
glued straight onto a preceding `-` is not seen), tokens whose provider
|
|
1140
|
+
prefix names them (Keploy `kep_` keys, GitHub, GitLab, Slack, Stripe,
|
|
1141
|
+
OpenAI and Anthropic keys, npm tokens, webhook signing secrets, AWS
|
|
1142
|
+
access key ids, Google API keys), email addresses, US
|
|
1143
|
+
phone numbers, US social-security numbers and IPv4 addresses, each in
|
|
1144
|
+
time linear in the text it scans, since they run on the page's main
|
|
1145
|
+
thread; card numbers are detected structurally (issuer prefix, length
|
|
1146
|
+
and Luhn), because a length-only pattern matched every 13-digit
|
|
1147
|
+
timestamp. The same set runs over header values, over string values
|
|
1148
|
+
inside JSON bodies, over form bodies as sent and decoded, and over
|
|
1149
|
+
other bodies as a whole — one scanner, four places.
|
|
226
1150
|
|
|
227
1151
|
`privacy.piiPatterns: [{ name, pattern }]` adds your own, and they run
|
|
228
1152
|
wherever that scanner does. Every occurrence is replaced whether or not
|
|
229
1153
|
your pattern carries `g`, and never a JSON key or a number, so the body
|
|
230
|
-
still parses.
|
|
1154
|
+
still parses. In a form body they run over the whole body, as it was
|
|
1155
|
+
sent and decoded, so a pattern may span `name=value` or several fields,
|
|
1156
|
+
and one written against a decoded value (`dob=01/02/1990` in a
|
|
1157
|
+
`FormData`) matches it. Every pattern and every built-in detector runs
|
|
1158
|
+
over the original text, never over another's result: a pattern whose
|
|
1159
|
+
match holds an email or a phone number hides its whole match, and
|
|
1160
|
+
overlapping matches become one `[REDACTED]`. An empty match replaces
|
|
1161
|
+
nothing (a `\d*` adds no marker between characters), and text no
|
|
1162
|
+
pattern matched is kept exactly as it was.
|
|
231
1163
|
|
|
232
1164
|
They do **not** run over URLs, and that is deliberate: the path and the
|
|
233
1165
|
query values are what the replay key is computed from, so rewriting
|
|
@@ -243,6 +1175,85 @@ import { PrivacyEngine } from "@keploy/capture-sdk";
|
|
|
243
1175
|
new PrivacyEngine().maskText("contact user@example.com now"); // "contact [REDACTED] now"
|
|
244
1176
|
```
|
|
245
1177
|
|
|
1178
|
+
## Your page's own network
|
|
1179
|
+
|
|
1180
|
+
With network capture on, `fetch()` resolves when the response's headers
|
|
1181
|
+
arrive, exactly as without the SDK, and the body reaches the page as the
|
|
1182
|
+
network delivers it: a streamed response -- SSE over `fetch`, NDJSON, an
|
|
1183
|
+
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
|
|
1185
|
+
the page; it reads ahead of the page only until it has the recording
|
|
1186
|
+
(the whole body, or `maxBodySize` of it), so a body the page reads slowly
|
|
1187
|
+
is not buffered for it, and a page that cancels (`reader.cancel()`, a
|
|
1188
|
+
`for await` `break`, an aborted pipe) or aborts (`AbortSignal`) stops
|
|
1189
|
+
the download at once. A body the page never reads is still recorded. A
|
|
1190
|
+
page that stops reading before the body has ended (and before
|
|
1191
|
+
`maxBodySize`) is recorded with exactly what it read; once the SDK has
|
|
1192
|
+
the whole body, the whole body is what is recorded. A body that fails
|
|
1193
|
+
part-way -- an abort, a dropped connection, a navigation (Firefox and
|
|
1194
|
+
WebKit abort a page's fetches as it leaves) -- is recorded with what had
|
|
1195
|
+
arrived, cut and marked `...[truncated]`; the SDK may have read that far
|
|
1196
|
+
ahead of the page. Each of these, whole or cut, is redacted exactly as
|
|
1197
|
+
any other recorded body is.
|
|
1198
|
+
|
|
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
|
|
1207
|
+
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.
|
|
1211
|
+
|
|
1212
|
+
The Response your page gets is one the SDK built around that body. Its
|
|
1213
|
+
`url`, `redirected`, `type`, `headers` and `clone()` answer as the
|
|
1214
|
+
network's do, and `instanceof Response`, `bodyUsed` and BYOB readers
|
|
1215
|
+
behave as usual. Three things differ:
|
|
1216
|
+
|
|
1217
|
+
- A **Cache API** round trip (`cache.put()`, then `cache.match()`) keeps
|
|
1218
|
+
the body, status and headers but not the network's `url` and `type`:
|
|
1219
|
+
they come back `""` and `"default"`. That is the platform's limit, not
|
|
1220
|
+
a choice: the Cache API stores a Response's internal URL list and type,
|
|
1221
|
+
which a Response built in JavaScript cannot be given, and a clone --
|
|
1222
|
+
the only way to keep the network's own object -- cannot keep the
|
|
1223
|
+
page's backpressure in Chromium. MEASURED in Chromium, the same page
|
|
1224
|
+
with and without the SDK: every other member equal, these two not.
|
|
1225
|
+
`WebAssembly.instantiateStreaming()` likewise does not see the
|
|
1226
|
+
response's URL (it still compiles).
|
|
1227
|
+
- A **streamed upload built into a `Request`** (`new Request(url, { body:
|
|
1228
|
+
stream, duplex: "half" })`) that the server answers early is pulled
|
|
1229
|
+
further than without the SDK -- up to the chunk that crosses
|
|
1230
|
+
`3 x maxBodySize + 4` bytes (about `maxBodySize` bytes for ASCII). The
|
|
1231
|
+
SDK records a Request's body from a copy of it, and that copy reads the
|
|
1232
|
+
page's stream until it has what the recording keeps -- all of it for
|
|
1233
|
+
one declared `multipart/form-data`, which is parsed into its fields
|
|
1234
|
+
whole, as a FormData's is, so that it is redacted by name. That is
|
|
1235
|
+
the platform's limit, not a choice: no API says how much of a body the
|
|
1236
|
+
network consumed, a Request built on a stream cannot be told from one
|
|
1237
|
+
built on a Blob or FormData, and handing the network a relay instead
|
|
1238
|
+
would turn every ordinary Blob or FormData POST into a streamed upload,
|
|
1239
|
+
which Chromium refuses over HTTP/1.1. MEASURED in Chromium over HTTP/2,
|
|
1240
|
+
a server answering 413 after the first 64 KiB chunk: 3 chunks pulled
|
|
1241
|
+
without the SDK, 10 with it at the default cap. A stream passed as
|
|
1242
|
+
`init.body` is not read at all (recorded `[ReadableStream]`) and is
|
|
1243
|
+
pulled exactly as without the SDK; only Chromium streams request bodies.
|
|
1244
|
+
- A **`fetch` wrapper installed before the SDK** that reads or clones the
|
|
1245
|
+
network's Response later than the moment it hands it on finds its body
|
|
1246
|
+
already taken by the SDK. Wrappers that clone at once (most APM and
|
|
1247
|
+
error-tracking SDKs) are unaffected; initialise this SDK first if
|
|
1248
|
+
yours does not.
|
|
1249
|
+
|
|
1250
|
+
`KeployCapture.stop()` waits up to one second for exchanges already
|
|
1251
|
+
answered to finish their bodies, and records any still open then (an
|
|
1252
|
+
endless stream) cut at that point and marked `...[truncated]` -- as it
|
|
1253
|
+
does for exchanges still open when the page leaves. `KeployCapture.pause()`
|
|
1254
|
+
cuts them the same way at once, with no wait: a pause records nothing
|
|
1255
|
+
more.
|
|
1256
|
+
|
|
246
1257
|
## What a large body looks like
|
|
247
1258
|
|
|
248
1259
|
`maxBodySize` is a bound on what is recorded, not an exact byte
|
|
@@ -287,8 +1298,14 @@ Over the bound, there are three answers, not one:
|
|
|
287
1298
|
`responseType` makes `responseText` throw. No size: the response
|
|
288
1299
|
is there in a form this note does not measure.
|
|
289
1300
|
- `[Unreadable body]` — the fail-closed answer: a body that could not
|
|
290
|
-
be read at all is never passed through
|
|
291
|
-
|
|
1301
|
+
be read at all is never passed through, and neither is a body sent
|
|
1302
|
+
as `multipart/form-data` that does not parse into its fields. No
|
|
1303
|
+
size: nothing here was read as a body, so there was nothing to
|
|
1304
|
+
measure.
|
|
1305
|
+
|
|
1306
|
+
A file inside `FormData` is not one of these: the body is still
|
|
1307
|
+
recorded, and that field's value is `[File: name, N bytes]`, URL-encoded
|
|
1308
|
+
with the rest of the form. The file's bytes are never read.
|
|
292
1309
|
|
|
293
1310
|
Lower `maxBodySize` to save bandwidth and you will get the second
|
|
294
1311
|
answer for most large JSON, not a shorter body. If you need the shape
|
|
@@ -307,6 +1324,12 @@ origin, a start timestamp, and a nonce minted with
|
|
|
307
1324
|
is still made; it is just not joinable). Payloads are gzipped when the
|
|
308
1325
|
browser has `CompressionStream`.
|
|
309
1326
|
|
|
1327
|
+
Each input event rrweb records carries `userTriggered`, from the
|
|
1328
|
+
browser event's `isTrusted`: `true` for the visitor's own input, `false`
|
|
1329
|
+
for a value the page's script wrote (a form cleared after a submit) and
|
|
1330
|
+
for any other change no trusted event made, such as the other radios of
|
|
1331
|
+
a group or a date picker's write.
|
|
1332
|
+
|
|
310
1333
|
The metadata and the capture identity ride on **every** batch, not just
|
|
311
1334
|
the first. A batch is the only thing the server is guaranteed to
|
|
312
1335
|
receive, and either of them arriving only with the first one is lost
|
|
@@ -334,16 +1357,88 @@ notice — which is why it carries a code and its evidence:
|
|
|
334
1357
|
[keploy] KUI_E_EVENT_OVERSIZED: dropped an event: 11059200 bytes in a body, over the ingest server's 10485760-byte cap, so no batch could carry it. The capture continues; any further such events in this capture are dropped silently. evidence={"eventId":"7","eventType":"dom","bytes":11059200,"cap":10485760}
|
|
335
1358
|
```
|
|
336
1359
|
|
|
1360
|
+
An event is dropped the same way, and said once per capture as
|
|
1361
|
+
`KUI_E_EVENT_OVERSIZED_SCRUBBING`, when scrubbing the page URL's
|
|
1362
|
+
credentials out of it (below) would write more than that cap: the SDK
|
|
1363
|
+
stops as it writes, once what it has written -- less what a later
|
|
1364
|
+
replacement can still take off it -- passes the cap -- before
|
|
1365
|
+
reading a string at all when what that string must write cannot fit, at
|
|
1366
|
+
each place it replaces a credential in a string that could pass the cap
|
|
1367
|
+
or that holds an escape, after each token of JSON text and after each
|
|
1368
|
+
piece of CSS -- rather than spend the page's time and memory on an event
|
|
1369
|
+
no batch could carry. A credential is replaced by `[REDACTED]`, so
|
|
1370
|
+
a short declared value repeated through a crafted URL makes every link,
|
|
1371
|
+
`srcset` and `url()` rrweb resolves against that URL grow; `atLeast` is
|
|
1372
|
+
the size the scrubbed event was certain to reach when the SDK stopped.
|
|
1373
|
+
A dropped DOM event -- dropped here, refused at the queue for its size,
|
|
1374
|
+
or evicted when `maxQueueSize` or the 16 MiB cap on what is held unsent
|
|
1375
|
+
is passed -- leaves the recording without
|
|
1376
|
+
the nodes it showed, so rrweb's later DOM changes and interactions,
|
|
1377
|
+
which name nodes by it, are held until a full snapshot is sent again:
|
|
1378
|
+
sent, a click on a node only the dropped snapshot held would have been
|
|
1379
|
+
recorded as a click on the page body. The SDK retakes one at once when
|
|
1380
|
+
the event dropped was a change (a snapshot of the page may well fit),
|
|
1381
|
+
and 5 s after a dropped snapshot, then at doubling waits up to every 60
|
|
1382
|
+
s, because the page has to shrink before one fits and each attempt
|
|
1383
|
+
serialises the whole document; showing the tab or resuming takes one
|
|
1384
|
+
too. While uploads to the ingest fail, or the browser says it is offline
|
|
1385
|
+
and an event is dropped, none of these is taken: the hold stays, and ONE snapshot is taken when the outage ends, so an outage costs the
|
|
1386
|
+
page one re-serialisation, not one per dropped event -- except on a page
|
|
1387
|
+
whose only traffic is DOM events: there the queue can run empty, the
|
|
1388
|
+
outage then ends without an upload, and the snapshot is taken again
|
|
1389
|
+
each time the 16 MiB cap refills. rrweb's DOM changes still queued behind a dropped one are dropped
|
|
1390
|
+
with it, up to the next snapshot; page, network and custom events stay.
|
|
1391
|
+
A page whose snapshot never fits records no DOM changes or interactions
|
|
1392
|
+
at all, and is serialised again every 60 s for as long as it stays that
|
|
1393
|
+
big -- the console line above is the notice, and nothing in the
|
|
1394
|
+
recording itself marks the hold.
|
|
1395
|
+
|
|
1396
|
+
Two more console lines drop nothing. When the page made a History or
|
|
1397
|
+
Navigation API method the SDK wraps impossible to replace and put back,
|
|
1398
|
+
the SDK wraps none of them (see [Single-page apps](#single-page-apps)) and
|
|
1399
|
+
says so once per capture, naming the method:
|
|
1400
|
+
|
|
1401
|
+
```
|
|
1402
|
+
[keploy] KUI_E_NAVIGATION_UNWRAPPED: the page made a History or Navigation API method impossible to replace and put back, so the SDK wrapped none of them. The capture continues: route changes are still recorded, with less detail, and none says that the page's script asked for it. evidence={"method":"history.back"}
|
|
1403
|
+
```
|
|
1404
|
+
|
|
337
1405
|
`KUI_E_EVENT_UNSERIALISABLE` (evidence `eventId`, `eventType`,
|
|
338
|
-
`reason`)
|
|
339
|
-
`
|
|
340
|
-
|
|
341
|
-
|
|
1406
|
+
`reason`), `KUI_E_EVENT_OVERSIZED` (evidence `eventId`, `eventType`,
|
|
1407
|
+
`bytes`, `cap`), `KUI_E_EVENT_OVERSIZED_SCRUBBING` (evidence
|
|
1408
|
+
`eventType`, `atLeast`, `cap` -- no id: the event never reached the
|
|
1409
|
+
queue), `KUI_E_NAVIGATION_UNWRAPPED` (evidence `method`) and
|
|
1410
|
+
`KUI_E_REQUEST_TERM_FAILED` (evidence `method`, `reason`; below) are
|
|
1411
|
+
warning-severity entries of the same error corpus as the codes above, and `SDK_WARNINGS` carries a short summary of each and the
|
|
1412
|
+
link to its corpus page, where the remedy is; a program that only has the console
|
|
342
1413
|
can match the token and parse the JSON after the first `evidence=`
|
|
343
1414
|
(the line is one line, and nothing before the marker is yours: the
|
|
344
1415
|
event's id and type are in the JSON, not in the prose). A new
|
|
345
1416
|
`init()` starts a new count: once per capture, not once per page.
|
|
346
1417
|
|
|
1418
|
+
A request whose GraphQL term the SDK could not compute (the term is
|
|
1419
|
+
what replay tells GraphQL operations apart by; computing it threw: the
|
|
1420
|
+
SDK's own lexer or parser, or the page's SubtleCrypto) is still
|
|
1421
|
+
recorded, without the term, as an SDK older than the term records it, and
|
|
1422
|
+
the page's own request is never affected; at replay, in a recording where
|
|
1423
|
+
another call carries a term, it keys as `body:*`, and in one where none
|
|
1424
|
+
does it is answered by order as before. The term code is a chunk of its own
|
|
1425
|
+
(`dist/request-term`, the package's `./request-term` export), which the
|
|
1426
|
+
SDK loads, once, the first time a body could be a GraphQL request, so a
|
|
1427
|
+
page that sends none never loads it; your bundler resolves it as it
|
|
1428
|
+
resolves rrweb. Where it does not load (a Content-Security-Policy, offline,
|
|
1429
|
+
a 404), each such request is recorded `body:*`, as a page with no
|
|
1430
|
+
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
|
|
1432
|
+
URL whatever its term; a recorded key equal to the live one is chosen
|
|
1433
|
+
first. The first
|
|
1434
|
+
such request in a capture logs
|
|
1435
|
+
`KUI_E_REQUEST_TERM_FAILED` (evidence `method`, `reason`), a warning
|
|
1436
|
+
entry of the same corpus, on one line of the same shape:
|
|
1437
|
+
|
|
1438
|
+
```
|
|
1439
|
+
[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
|
+
```
|
|
1441
|
+
|
|
347
1442
|
### The last batch
|
|
348
1443
|
|
|
349
1444
|
When the page unloads — a navigation, a tab close — whatever is still
|
|
@@ -368,9 +1463,12 @@ if it does not, the SDK cannot know and cannot resend it. And an event
|
|
|
368
1463
|
whose JSON, with the envelope that wraps it, exceeds the 64 KiB cap
|
|
369
1464
|
cannot travel this way at all; the SDK posts such an event the moment
|
|
370
1465
|
it is queued rather than leaving it to be cut here — but not while the
|
|
371
|
-
browser reports itself offline.
|
|
372
|
-
`online`
|
|
373
|
-
|
|
1466
|
+
browser reports itself offline (`navigator.onLine`, read each time: the
|
|
1467
|
+
`online` and `offline` events are when the SDK acts, not what it
|
|
1468
|
+
believes). The post is deferred then until the browser is back: to the
|
|
1469
|
+
`online` event or, on a page that stops that event, to the next timed
|
|
1470
|
+
flush, either of which then drains the queue rather than sending one
|
|
1471
|
+
batch. A navigation before that still runs
|
|
374
1472
|
the unload flush, and this event is precisely what that flush cannot
|
|
375
1473
|
carry: it is lost, with everything queued behind it and anything ahead
|
|
376
1474
|
of it that does not fit the single batch that flush sends — the
|
|
@@ -382,7 +1480,11 @@ post that did go out. `maxBodySize` bounds a network event's size, and
|
|
|
382
1480
|
## When the server rejects a batch
|
|
383
1481
|
|
|
384
1482
|
A `4xx` other than `429` is terminal: a revoked key, a key for another
|
|
385
|
-
app, or a second run claiming a session id that is already live
|
|
1483
|
+
app, or a second run claiming a session id that is already live (with
|
|
1484
|
+
`continuous` and session ids the SDK minted, a refusal whose `reason`
|
|
1485
|
+
is `session_completed` or `session_full` is not: the server completed
|
|
1486
|
+
or filled that session, and the next one starts at the visitor's next
|
|
1487
|
+
interaction). The
|
|
386
1488
|
SDK ends the CAPTURE — recording stops, `fetch` and `XMLHttpRequest`
|
|
387
1489
|
are unpatched, and the singleton is released — logs a `console.error`
|
|
388
1490
|
carrying the server's own explanation, and calls `onError` once with a
|
|
@@ -394,34 +1496,57 @@ rather than handing back the one that failed.
|
|
|
394
1496
|
The `CaptureError` is for the program, not just the person reading the
|
|
395
1497
|
console. Branch on `code`, never on the message:
|
|
396
1498
|
|
|
397
|
-
| `code` | the server answered
|
|
398
|
-
| --------------------------------- |
|
|
399
|
-
| `KUI_E_INGEST_KEY_REJECTED` | 401 or 403
|
|
400
|
-
| `KUI_E_INGEST_ENDPOINT_NOT_FOUND` | 404 or 405
|
|
401
|
-
| `KUI_E_SESSION_CONFLICT` | 409
|
|
402
|
-
| `KUI_E_INGEST_REJECTED` | any other terminal 4xx
|
|
403
|
-
| `KUI_E_SESSION_ID_INVALID` | nothing — raised before the first byte
|
|
404
|
-
|
|
405
|
-
`
|
|
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
|
|
406
1512
|
branching on `code` narrows to it, so a TypeScript handler can read the
|
|
407
1513
|
evidence the remedy names. An `IngestRejection` (the four
|
|
408
1514
|
server-answered codes) carries `status`, `serverMessage` (the `error`
|
|
409
1515
|
field of the server's JSON body, or the body's text, or `null`),
|
|
410
1516
|
`issues` (the server's `[{ path, message }]` when its body had them — a
|
|
411
|
-
400 says which field — or `null`), `remedy` (`{ command, manual }`
|
|
412
|
-
`
|
|
413
|
-
|
|
1517
|
+
400 says which field — or `null`), `remedy` (`{ command, manual, docs }`
|
|
1518
|
+
— `docs` is the error's page in the Keploy docs, where the remedy is;
|
|
1519
|
+
`manual`, deprecated, holds the same link (3.0 carried the remedy's
|
|
1520
|
+
prose there); and `command` is `null`
|
|
1521
|
+
on every code, because no `keploy` CLI verb mints a key, edits the
|
|
1522
|
+
endpoint or rotates a session), and `evidence`
|
|
414
1523
|
(`{ status, serverMessage, endpoint, sessionId }` plus `issues` when
|
|
415
1524
|
sent, exactly the fields the corpus declares). A `SessionIdRefusal`
|
|
416
1525
|
(`KUI_E_SESSION_ID_INVALID`) is raised by the SDK itself before anything
|
|
417
1526
|
is sent, so its `status` is `null` and its evidence is
|
|
418
1527
|
`{ sessionId, received, rule }` — the string the generator returned or
|
|
419
1528
|
`null`, what it produced (`number 42`, `object {}`, `threw Error: boom`),
|
|
420
|
-
and the rule.
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
1529
|
+
and the rule. A `DomRecorderRefusal` (`KUI_E_DOM_RECORDER_UNAVAILABLE`)
|
|
1530
|
+
is raised in a browser, before anything is sent, when rrweb cannot be
|
|
1531
|
+
imported; its evidence is `{ reason }`, the browser's error. A
|
|
1532
|
+
`PrivacyRouteRefusal` (`KUI_E_PRIVACY_ROUTE_INVALID`) is raised before
|
|
1533
|
+
anything is sent when a declared privacy route is no route; its evidence
|
|
1534
|
+
is `{ option, received, rule }`. A `CaptureDeclined`
|
|
1535
|
+
(`KUI_E_CAPTURE_DECLINED`) is the browser's privacy signal, not a
|
|
1536
|
+
failure: it is logged with `console.info`, its `status` is `null`, and
|
|
1537
|
+
its evidence is `{ signal }` — `doNotTrack` or `globalPrivacyControl`.
|
|
1538
|
+
A `PrivacyConflict` (`KUI_E_PRIVACY_CONFLICT`) is the site's own config
|
|
1539
|
+
contradicting itself: its `status` is `null` and its evidence is
|
|
1540
|
+
`{ privacyMode, option }` — `"strict"` and the option that asks for
|
|
1541
|
+
what strict leaves out. The nine
|
|
1542
|
+
codes and their evidence are the entries of the same name in
|
|
1543
|
+
`@keploy/contract`'s error corpus. The SDK carries each entry's code, a
|
|
1544
|
+
short summary of what happened and the link to the entry's page, and
|
|
1545
|
+
no remedy text, which stays on that page; a test holds the summary, the
|
|
1546
|
+
link and the evidence to the corpus. The `docs` pages are published
|
|
1547
|
+
with the same docs release as the guide above, and answer 404 until
|
|
1548
|
+
then. The status-to-code mapping is
|
|
1549
|
+
`spec/sdk-errors.v3.json`; the session-id rule is
|
|
425
1550
|
`spec/session-id.v1.json`, the api-server's rule stated once — the
|
|
426
1551
|
SDK and the sidecar execute the file today, and the api-server's own
|
|
427
1552
|
executor lands with its next vendoring of the corpus. `onError` runs
|
|
@@ -435,26 +1560,39 @@ await KeployCapture.init({
|
|
|
435
1560
|
endpoint,
|
|
436
1561
|
apiKey,
|
|
437
1562
|
onError: (err) => {
|
|
1563
|
+
// The person using the page said no (Do Not Track or Global Privacy
|
|
1564
|
+
// Control). Not a failure: keep it out of your error tracker --
|
|
1565
|
+
// Brave and DuckDuckGo send GPC by default.
|
|
1566
|
+
if (err.code === "KUI_E_CAPTURE_DECLINED") return;
|
|
438
1567
|
if (err.code === "KUI_E_SESSION_ID_INVALID")
|
|
439
1568
|
fixGenerator(err.evidence.received);
|
|
1569
|
+
else if (err.code === "KUI_E_DOM_RECORDER_UNAVAILABLE")
|
|
1570
|
+
report(err.code, err.evidence.reason);
|
|
1571
|
+
else if (err.code === "KUI_E_PRIVACY_ROUTE_INVALID")
|
|
1572
|
+
report(err.code, err.evidence.option, err.evidence.received);
|
|
1573
|
+
else if (err.code === "KUI_E_PRIVACY_CONFLICT")
|
|
1574
|
+
fixConfig(err.evidence.option);
|
|
440
1575
|
else if (err.code === "KUI_E_INGEST_KEY_REJECTED") rotateKeyAndReload();
|
|
441
1576
|
else
|
|
442
|
-
report(
|
|
443
|
-
err.code,
|
|
444
|
-
err.serverMessage,
|
|
445
|
-
err.evidence.issues,
|
|
446
|
-
err.remedy.manual,
|
|
447
|
-
);
|
|
1577
|
+
report(err.code, err.serverMessage, err.evidence.issues, err.remedy.docs);
|
|
448
1578
|
},
|
|
449
1579
|
});
|
|
450
1580
|
```
|
|
451
1581
|
|
|
452
|
-
A `429`, a `5xx` or a network failure gets three attempts:
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
1582
|
+
A `429`, a `5xx` or a network failure gets three attempts: up to 1 s
|
|
1583
|
+
between the first and the second, up to 2 s between the second and the
|
|
1584
|
+
third, and then the batch goes back to the front of the queue. From then
|
|
1585
|
+
on uploads are failing: each later batch gets ONE attempt, and the timer,
|
|
1586
|
+
a filled batch and a large event start none until 2 s, then 4, 8, 16, 32
|
|
1587
|
+
and at most 60 s (each up to half again, at random) have passed since the
|
|
1588
|
+
last failure, so a dead ingest gets about one request a minute (a page whose only
|
|
1589
|
+
traffic is DOM events also restarts the wait each time its queue runs
|
|
1590
|
+
empty). `stop()`,
|
|
1591
|
+
a hidden tab, `online` and the page's unload still send at once. The
|
|
1592
|
+
first batch accepted ends it: what piled up is sent, and if DOM events were dropped meanwhile, one fresh snapshot is taken. What is held unsent is
|
|
1593
|
+
capped at 16 MiB as well as at `maxQueueSize`; past either, the oldest
|
|
1594
|
+
is dropped (a batch that failed and goes back to the queue past
|
|
1595
|
+
`maxQueueSize` drops the newest queued events instead).
|
|
458
1596
|
|
|
459
1597
|
## What it deliberately does not do
|
|
460
1598
|
|
|
@@ -464,13 +1602,17 @@ than an attempt.
|
|
|
464
1602
|
- **No `Math.random` fallback for the session nonce**, so a recording
|
|
465
1603
|
is either joinable or says why it is not.
|
|
466
1604
|
- **No sampling by user.** `sampleRate` is decided per session start.
|
|
1605
|
+
- **No guessing which generic field holds a secret.** A name/value pair
|
|
1606
|
+
is read by its `key`, `name` or `header`; a pair spelled otherwise
|
|
1607
|
+
(`{field, val}`), or one whose name is not a secret's own (an
|
|
1608
|
+
extracted variable called `x` holding a bearer token), is left to the
|
|
1609
|
+
pattern detectors. Name such a field in `privacy.piiPatterns` if its
|
|
1610
|
+
values need to go.
|
|
467
1611
|
|
|
468
1612
|
## Docs and help
|
|
469
1613
|
|
|
470
|
-
- [UI
|
|
471
|
-
|
|
472
|
-
- [Installing the SDK](https://keploy.io/docs/ui-capture/install-sdk/) — this page, in
|
|
473
|
-
more detail
|
|
1614
|
+
- [UI Capture guide](https://keploy.io/docs/running-keploy/ui-capture/) — set up capture
|
|
1615
|
+
from the dashboard, the REST API or an AI agent, and read the flows
|
|
474
1616
|
- [Keploy documentation](https://keploy.io/docs/)
|
|
475
1617
|
- [Keploy community Slack](https://join.slack.com/t/keploy/shared_invite/zt-3zcnuqfgl-WYK1NMhslVHsCtNcA1ULwA)
|
|
476
1618
|
- <support@keploy.io>
|
|
@@ -478,5 +1620,10 @@ than an attempt.
|
|
|
478
1620
|
## License
|
|
479
1621
|
|
|
480
1622
|
Apache-2.0. The full text ships in this package: see
|
|
481
|
-
[LICENSE](./LICENSE). The rest of Keploy UI
|
|
1623
|
+
[LICENSE](./LICENSE). The rest of Keploy UI Capture is
|
|
482
1624
|
proprietary; this package is the part that runs in your own bundle.
|
|
1625
|
+
The bundle inlines one file from outside this package, the
|
|
1626
|
+
credential-name rule shared with Keploy's replay
|
|
1627
|
+
(`packages/contract/src/privacy.ts` in the source repository), and that
|
|
1628
|
+
file is Apache-2.0 too: its text, with its SPDX header, is in the
|
|
1629
|
+
source maps beside the bundle.
|