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