@keploy/capture-sdk 3.1.0-rc.2 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +259 -122
  2. package/dist/body-jobs.d.ts +108 -10
  3. package/dist/body-redact.d.ts +6 -0
  4. package/dist/body-redact.js +1 -1
  5. package/dist/body-redact.js.map +1 -1
  6. package/dist/body-redact.mjs +1 -1
  7. package/dist/body-redact.mjs.map +1 -1
  8. package/dist/body-worker-none.js +1 -1
  9. package/dist/body-worker-none.js.map +1 -1
  10. package/dist/body-worker-none.mjs +1 -1
  11. package/dist/body-worker-none.mjs.map +1 -1
  12. package/dist/body-worker-start.js +1 -1
  13. package/dist/body-worker-start.js.map +1 -1
  14. package/dist/body-worker-start.mjs +1 -1
  15. package/dist/body-worker-start.mjs.map +1 -1
  16. package/dist/body-worker-unbundled.mjs +1 -1
  17. package/dist/body-worker-unbundled.mjs.map +1 -1
  18. package/dist/body-worker.js +1 -1
  19. package/dist/body-worker.js.map +1 -1
  20. package/dist/index.bundler.mjs +1 -1
  21. package/dist/index.bundler.mjs.map +1 -1
  22. package/dist/index.d.ts +76 -14
  23. package/dist/index.js +1 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +1 -1
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/module-of.d.ts +17 -0
  28. package/dist/network.d.ts +51 -34
  29. package/dist/page-stream.d.ts +24 -0
  30. package/dist/privacy.d.ts +4 -1
  31. package/dist/recorder.d.ts +3 -3
  32. package/dist/redact.d.ts +25 -2
  33. package/dist/request-term.js +1 -1
  34. package/dist/request-term.js.map +1 -1
  35. package/dist/request-term.mjs +1 -1
  36. package/dist/request-term.mjs.map +1 -1
  37. package/dist/strict-attributes.js +1 -1
  38. package/dist/strict-attributes.js.map +1 -1
  39. package/dist/strict-attributes.mjs +1 -1
  40. package/dist/strict-attributes.mjs.map +1 -1
  41. package/dist/transport.d.ts +10 -10
  42. package/dist/types.d.ts +27 -6
  43. package/package.json +2 -1
package/dist/index.d.ts CHANGED
@@ -14,11 +14,13 @@ import type { CaptureConfig } from "./types";
14
14
  import { type CaptureIdentity, type IdentityRefusal } from "./identity";
15
15
  export declare class KeployCapture {
16
16
  private static instance;
17
+ private static ending;
17
18
  private recorder;
18
19
  private network;
19
20
  private transport;
20
21
  private config;
21
22
  private started;
23
+ private holdOpen;
22
24
  private identity;
23
25
  private constructor();
24
26
  /**
@@ -77,22 +79,82 @@ export declare class KeployCapture {
77
79
  private start;
78
80
  private stop;
79
81
  /**
80
- * The capture was declined by a privacy signal: the capture ended,
81
- * then onError -- on EVERY declined init(), so each handler learns its
82
- * capture did not start (a silent init() looks like success) -- and
83
- * the console line ONCE PER PAGE, since the signal does not change and
84
- * a page that re-inits (React StrictMode's double effect, a re-init per
85
- * route) would otherwise repeat it. Logged as information: nothing
86
- * failed.
82
+ * The capture will not start. Its console line, ONCE PER PAGE per code
83
+ * (the signal or the config does not change, and a page that re-inits --
84
+ * React StrictMode's double effect, a re-init per route -- would
85
+ * otherwise repeat it); the capture ended and the singleton released;
86
+ * THEN onError, IN A TASK OF ITS OWN, PACED PER CODE -- so a handler that
87
+ * fixes what was refused and calls init() again gets a fresh capture,
88
+ * not this dead one. Resolves once the handler has run: start() returns
89
+ * it, and so init() does. onError hears every refused init() but one
90
+ * that comes while 16 of its code wait (below), in order, so each handler
91
+ * learns its capture did not start (a silent init() looks like success).
92
+ *
93
+ * Never inside the init() that raised it. Handed over inside init() --
94
+ * synchronously for a decline or a conflict, in init()'s microtasks for
95
+ * the rest -- a handler that called init() again for every code (the
96
+ * README said it may) recursed until the stack ran out, or looped in
97
+ * microtasks and froze the page: the next init() fails the same way. A
98
+ * timer task breaks the nesting, but not the loop. MEASURED (a naive
99
+ * `onError: () => init(config)`, Chromium/Firefox/WebKit): 120-240
100
+ * rounds a second at +4 to +28 points of a core, and 5,750 a second at
101
+ * 1.3 cores in Chromium for the strict allow-list's refusal, which
102
+ * follows a network task, so no timer clamp applies.
103
+ *
104
+ * So a code has at most ONE hand-over scheduled: a refusal of a code
105
+ * whose hand-over is pending joins it, and that task tells each, in the
106
+ * order they came. A hand-over scheduled while its code's last one is
107
+ * recent waits twice the wait before that one: 50 ms first, doubling to
108
+ * at most 30 s, counted from when that one RAN -- once per task, never
109
+ * per refusal, so no refused init() is scheduled more than 30 s out however often
110
+ * the page calls it. A code quiet for its wait plus a second starts
111
+ * over: a page's own later init() (a route change, a remount) is told in
112
+ * the next task. Time only paces: a handler that re-inits on every code
113
+ * goes round 11 times in its first minute, then twice a minute. Per
114
+ * code, two numbers and the refusals waiting; per refusal waiting, its
115
+ * error's class and evidence (the error is built at the hand-over), the
116
+ * handler, and init()'s resolver -- which keeps what that init()
117
+ * resolves with, the refused capture, until then. So the capture is
118
+ * hollowed once its stop has settled: its recorder, interceptor and
119
+ * transport, stopped and never used again, go. MEASURED (a declined
120
+ * page calling init() every 16 ms, 1,599 refusals waiting at the 25.6 s
121
+ * wait, with the bound below lifted): 5,487 B a waiting refusal, 1,318 B
122
+ * hollowed.
123
+ *
124
+ * And at most MOST_WAITING (16) refusals of a code wait: one that comes
125
+ * while 16 wait resolves its init() at once, untold (its code's console
126
+ * line has been written), and nothing of it is kept. Pacing alone only
127
+ * put off a handler that re-inits TWICE a refusal -- through two calls,
128
+ * an await or two timers, each a later init() of the page's own: each
129
+ * hand-over told twice the refusals of the last, and round 17 (~3.9 min)
130
+ * would have told ~65,000 in one task. Now a hand-over task runs at most
131
+ * 16 handlers, at most 16 refusals of a code are kept, and every refused
132
+ * init() resolves within 30 s while its code's hand-over timer runs.
133
+ *
134
+ * "A hand-over is pending" is read from the refusals waiting, so a lost
135
+ * timer held its code for the page's life: every later refusal joined a
136
+ * hand-over that never ran, and sixteen init()s never resolved, told
137
+ * nothing. So each refusal reads the clock, and one that finds its code's
138
+ * hand-over unrun more than 31 s past due, or due more than 31 s ahead (a
139
+ * clock that went back), hands over what waits in the next task, from a
140
+ * new entry, so a timer that was only late delivers nothing. The init()s
141
+ * waiting on a lost timer resolve when a refusal of their code comes more
142
+ * than 31 s past its due time; until then the lost timer holds them.
143
+ *
144
+ * Declined by a privacy signal (`info`): logged as information, since
145
+ * nothing failed. Refused: the configured sessionIdGenerator did not
146
+ * produce a session id -- a string outside the server's rule, a
147
+ * non-string, or a throw (KUI_E_SESSION_ID_INVALID); a declared privacy
148
+ * route is no route (KUI_E_PRIVACY_ROUTE_INVALID); two privacy options
149
+ * contradict each other (KUI_E_PRIVACY_CONFLICT); or, in a browser,
150
+ * rrweb could not be imported (KUI_E_DOM_RECORDER_UNAVAILABLE), or under
151
+ * strict its attribute allow-list (KUI_E_STRICT_ATTRIBUTES_UNAVAILABLE).
152
+ * Nothing has been sent (a late import's refusal comes after the
153
+ * capture started, and it ends that capture), but the singleton is
154
+ * set, so this takes the path a server rejection takes, in its order.
87
155
  */
88
- private decline;
89
- private refuse;
156
+ private refuseInit;
90
157
  private endCapture;
91
- /** Cancels a continuous capture's wait for the visitor's next interaction. */
92
- private static cancelNextSession;
93
- private static nextSessionPaused;
94
- private static ending;
95
- private static restartPending;
96
158
  private endSession;
97
159
  private pause;
98
160
  private resume;