stitchkit 0.80.1 → 0.81.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 (177) hide show
  1. package/dist/agent-runtime/provider-failure.d.ts.map +1 -1
  2. package/dist/agent-runtime-coding-tools.js +1 -1
  3. package/dist/agent-runtime-harness.js +7 -5
  4. package/dist/agent-runtime.js +15 -19
  5. package/dist/application/notification-outbox.d.ts +80 -0
  6. package/dist/application/notification-outbox.d.ts.map +1 -0
  7. package/dist/application/process-lifecycle.d.ts +166 -0
  8. package/dist/application/process-lifecycle.d.ts.map +1 -0
  9. package/dist/application/state-store.d.ts +18 -0
  10. package/dist/application/state-store.d.ts.map +1 -0
  11. package/dist/application.d.ts +3 -0
  12. package/dist/application.d.ts.map +1 -1
  13. package/dist/application.js +568 -11
  14. package/dist/browser/http.d.ts +14 -0
  15. package/dist/browser/http.d.ts.map +1 -1
  16. package/dist/browser/resumable.d.ts +6 -0
  17. package/dist/browser/resumable.d.ts.map +1 -1
  18. package/dist/cli.js +9 -7
  19. package/dist/contract/define.d.ts +27 -4
  20. package/dist/contract/define.d.ts.map +1 -1
  21. package/dist/contract/errors-factory.d.ts +22 -3
  22. package/dist/contract/errors-factory.d.ts.map +1 -1
  23. package/dist/contract/index.d.ts +2 -2
  24. package/dist/contract/index.d.ts.map +1 -1
  25. package/dist/contract/index.js +1 -1
  26. package/dist/geo/index.d.ts +4 -0
  27. package/dist/geo/index.d.ts.map +1 -0
  28. package/dist/geo/maxmind.d.ts +4 -0
  29. package/dist/geo/maxmind.d.ts.map +1 -0
  30. package/dist/geo/resolver.d.ts +9 -0
  31. package/dist/geo/resolver.d.ts.map +1 -0
  32. package/dist/geo/types.d.ts +59 -0
  33. package/dist/geo/types.d.ts.map +1 -0
  34. package/dist/geo.d.ts +3 -0
  35. package/dist/geo.d.ts.map +1 -0
  36. package/dist/geo.js +245 -0
  37. package/dist/{index-9s6z8vgf.js → index-1dd82z59.js} +1 -1
  38. package/dist/{index-vwp69871.js → index-27487ay5.js} +4 -4
  39. package/dist/{index-7ag81v2f.js → index-27gm3d6g.js} +10 -321
  40. package/dist/{index-y01f4223.js → index-2bxcmqkb.js} +127 -43
  41. package/dist/{index-dxesg10d.js → index-3ds42w1w.js} +3 -3
  42. package/dist/index-3xwxfj4z.js +334 -0
  43. package/dist/{index-egaabxkz.js → index-5z8tezpx.js} +2 -2
  44. package/dist/{index-fxz0v7vg.js → index-7evdsyez.js} +1 -83
  45. package/dist/{index-xcetq6j3.js → index-90d7h2cr.js} +32 -13
  46. package/dist/{index-t0z5p5w6.js → index-apn8repm.js} +1 -1
  47. package/dist/{index-758zx2ha.js → index-dggwnnjv.js} +2 -2
  48. package/dist/{index-dwf1f2ap.js → index-f9mb610r.js} +1 -62
  49. package/dist/{index-5mtc969c.js → index-fwbkp2jn.js} +1 -1
  50. package/dist/index-p13mwz16.js +16 -0
  51. package/dist/{index-m9kzax52.js → index-p18f59zy.js} +21 -5
  52. package/dist/{index-hb5pf3s4.js → index-qmgs7y68.js} +1 -1
  53. package/dist/{index-2rwwmr7v.js → index-s4ckmrac.js} +1 -1
  54. package/dist/{index-h4pj6fta.js → index-s8cnx02s.js} +8 -5
  55. package/dist/{index-k9ay6v6d.js → index-vchzar7e.js} +74 -23
  56. package/dist/index-vsbzgd7b.js +84 -0
  57. package/dist/{index-dxjjv399.js → index-xbppf54a.js} +95 -15
  58. package/dist/index-y91ry9h2.js +4 -0
  59. package/dist/index-zcgf3gqf.js +83 -0
  60. package/dist/index.js +17 -13
  61. package/dist/internal/error-message.d.ts +3 -0
  62. package/dist/internal/error-message.d.ts.map +1 -0
  63. package/dist/internal/media-type.d.ts +8 -0
  64. package/dist/internal/media-type.d.ts.map +1 -0
  65. package/dist/internal/route-pattern.d.ts +21 -0
  66. package/dist/internal/route-pattern.d.ts.map +1 -1
  67. package/dist/node.js +9 -6
  68. package/dist/observability/audit.d.ts +28 -1
  69. package/dist/observability/audit.d.ts.map +1 -1
  70. package/dist/observability/bounded-logger.d.ts +20 -0
  71. package/dist/observability/bounded-logger.d.ts.map +1 -0
  72. package/dist/observability/context.d.ts +12 -3
  73. package/dist/observability/context.d.ts.map +1 -1
  74. package/dist/observability/index.d.ts +3 -2
  75. package/dist/observability/index.d.ts.map +1 -1
  76. package/dist/observability/index.js +138 -8
  77. package/dist/observability/sanitize.d.ts +17 -0
  78. package/dist/observability/sanitize.d.ts.map +1 -1
  79. package/dist/primitives.js +1 -1
  80. package/dist/react/query-client.d.ts +33 -0
  81. package/dist/react/query-client.d.ts.map +1 -0
  82. package/dist/react.d.ts +1 -0
  83. package/dist/react.d.ts.map +1 -1
  84. package/dist/react.js +83 -1
  85. package/dist/realtime/registry.d.ts +93 -0
  86. package/dist/realtime/registry.d.ts.map +1 -0
  87. package/dist/release/header.d.ts +9 -0
  88. package/dist/release/header.d.ts.map +1 -0
  89. package/dist/release/marker.d.ts +39 -0
  90. package/dist/release/marker.d.ts.map +1 -0
  91. package/dist/release/socket.d.ts +44 -0
  92. package/dist/release/socket.d.ts.map +1 -0
  93. package/dist/release/watcher.d.ts +66 -0
  94. package/dist/release/watcher.d.ts.map +1 -0
  95. package/dist/release.d.ts +15 -0
  96. package/dist/release.d.ts.map +1 -0
  97. package/dist/release.js +196 -0
  98. package/dist/remote.js +12 -7
  99. package/dist/server/context.d.ts +2 -1
  100. package/dist/server/context.d.ts.map +1 -1
  101. package/dist/server/create.d.ts.map +1 -1
  102. package/dist/server/error-hook.d.ts +17 -16
  103. package/dist/server/error-hook.d.ts.map +1 -1
  104. package/dist/server/file-state-store.d.ts +23 -0
  105. package/dist/server/file-state-store.d.ts.map +1 -0
  106. package/dist/server/implement.d.ts.map +1 -1
  107. package/dist/server/index.d.ts +5 -2
  108. package/dist/server/index.d.ts.map +1 -1
  109. package/dist/server/index.js +469 -11
  110. package/dist/server/middleware/cookies.d.ts +33 -1
  111. package/dist/server/middleware/cookies.d.ts.map +1 -1
  112. package/dist/server/middleware/cors.d.ts +16 -1
  113. package/dist/server/middleware/cors.d.ts.map +1 -1
  114. package/dist/server/openapi.d.ts.map +1 -1
  115. package/dist/server/release-signal.d.ts +35 -0
  116. package/dist/server/release-signal.d.ts.map +1 -0
  117. package/dist/server/router.d.ts.map +1 -1
  118. package/dist/server/types.d.ts +26 -2
  119. package/dist/server/types.d.ts.map +1 -1
  120. package/dist/testing/surface-manifest.d.ts.map +1 -1
  121. package/dist/testing.js +7 -4
  122. package/dist/tool-invoker.js +8 -6
  123. package/dist/tools/download-core.d.ts.map +1 -1
  124. package/dist/tools/remote.d.ts.map +1 -1
  125. package/dist/tools/view-file.d.ts.map +1 -1
  126. package/dist/tools.js +20 -16
  127. package/dist/tracking/attribution.d.ts +51 -0
  128. package/dist/tracking/attribution.d.ts.map +1 -0
  129. package/dist/tracking/beacon.d.ts +14 -0
  130. package/dist/tracking/beacon.d.ts.map +1 -0
  131. package/dist/tracking/clicks.d.ts +46 -0
  132. package/dist/tracking/clicks.d.ts.map +1 -0
  133. package/dist/tracking/client.d.ts +121 -0
  134. package/dist/tracking/client.d.ts.map +1 -0
  135. package/dist/tracking/contract.d.ts +46 -0
  136. package/dist/tracking/contract.d.ts.map +1 -0
  137. package/dist/tracking/delivery.d.ts +24 -0
  138. package/dist/tracking/delivery.d.ts.map +1 -0
  139. package/dist/tracking/host.d.ts +43 -0
  140. package/dist/tracking/host.d.ts.map +1 -0
  141. package/dist/tracking/once-per-page.d.ts +17 -0
  142. package/dist/tracking/once-per-page.d.ts.map +1 -0
  143. package/dist/tracking/outbox-storage-indexeddb.d.ts +12 -0
  144. package/dist/tracking/outbox-storage-indexeddb.d.ts.map +1 -0
  145. package/dist/tracking/outbox-storage-memory.d.ts +12 -0
  146. package/dist/tracking/outbox-storage-memory.d.ts.map +1 -0
  147. package/dist/tracking/outbox.d.ts +98 -0
  148. package/dist/tracking/outbox.d.ts.map +1 -0
  149. package/dist/tracking/schemas.d.ts +183 -0
  150. package/dist/tracking/schemas.d.ts.map +1 -0
  151. package/dist/tracking/scroll.d.ts +22 -0
  152. package/dist/tracking/scroll.d.ts.map +1 -0
  153. package/dist/tracking/sequence-reserve.d.ts +34 -0
  154. package/dist/tracking/sequence-reserve.d.ts.map +1 -0
  155. package/dist/tracking/server/active-interval.d.ts +26 -0
  156. package/dist/tracking/server/active-interval.d.ts.map +1 -0
  157. package/dist/tracking/server/bot.d.ts +9 -0
  158. package/dist/tracking/server/bot.d.ts.map +1 -0
  159. package/dist/tracking/server/disposition.d.ts +55 -0
  160. package/dist/tracking/server/disposition.d.ts.map +1 -0
  161. package/dist/tracking/server/hash.d.ts +13 -0
  162. package/dist/tracking/server/hash.d.ts.map +1 -0
  163. package/dist/tracking/server/presence.d.ts +27 -0
  164. package/dist/tracking/server/presence.d.ts.map +1 -0
  165. package/dist/tracking/server/visit-lease.d.ts +92 -0
  166. package/dist/tracking/server/visit-lease.d.ts.map +1 -0
  167. package/dist/tracking/visible-time.d.ts +38 -0
  168. package/dist/tracking/visible-time.d.ts.map +1 -0
  169. package/dist/tracking-server.d.ts +14 -0
  170. package/dist/tracking-server.d.ts.map +1 -0
  171. package/dist/tracking-server.js +173 -0
  172. package/dist/tracking.d.ts +24 -0
  173. package/dist/tracking.d.ts.map +1 -0
  174. package/dist/tracking.js +1090 -0
  175. package/llms-full.txt +938 -29
  176. package/llms.txt +4 -0
  177. package/package.json +25 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/tracking/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,mBAAmB,EAEzB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EACV,kBAAkB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CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IACtC,eAAe,CAAC,EAAE,sBAAsB,CAAC;IACzC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iFAAiF;IACjF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACtD;AAED,MAAM,WAAW,cAAc,CAAC,SAAS,SAAS,MAAM;IACtD,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1B,sFAAsF;IACtF,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACnD,yEAAyE;IACzE,KAAK,IAAI,MAAM,IAAI,CAAC;IACpB,OAAO,IAAI,MAAM,GAAG,IAAI,CAAC;IACzB,eAAe,IAAI,MAAM,GAAG,IAAI,CAAC;IACjC,8FAA8F;IAC9F,WAAW,IAAI,mBAAmB,GAAG,IAAI,CAAC;CAC3C;AAaD,wBAAgB,oBAAoB,CAClC,SAAS,SAAS,MAAM,EACxB,MAAM,SAAS,qBAAqB,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,qBAAqB,CACpF,MAAM,SAAS,GAAG,MAAM,CACzB,EACD,MAAM,EAAE,oBAAoB,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,cAAc,CAAC,SAAS,CAAC,CAkY5E"}
@@ -0,0 +1,46 @@
1
+ import type { z } from 'zod';
2
+ import { type ContractDef } from '../contract/index.js';
3
+ import { type TrackingEventShape, type TrackingSchemas, type TrackingSchemasConfig } from './schemas.js';
4
+ export interface TrackingContractConfig<TType extends string, TExtras extends z.ZodRawShape | undefined, TScope extends string> extends TrackingSchemasConfig<TType, TExtras> {
5
+ /** Route prefix; default `tracking`. */
6
+ prefix?: string;
7
+ /**
8
+ * Almost always the application's public scope: the landing page and the
9
+ * sign-in page are read by anonymous visitors, and their path is part of the
10
+ * funnel. Identity, when there is one, comes from the cookie on the server
11
+ * side; the client claims nothing about itself.
12
+ */
13
+ scope: TScope;
14
+ /** Byte ceiling for one batch; default 256 KiB. */
15
+ maxJsonBodyBytes?: number;
16
+ }
17
+ /** The two operations every tracking surface has, typed by the application's schemas. */
18
+ export type TrackingContractEndpoints<TSchemas extends TrackingSchemas<z.ZodObject>> = {
19
+ bootstrap: {
20
+ method: 'POST';
21
+ path: '/visit';
22
+ expose: readonly ['HTTP'];
23
+ desc: string;
24
+ input: TSchemas['entry'];
25
+ output: TSchemas['bootstrap'];
26
+ };
27
+ track: {
28
+ method: 'POST';
29
+ path: '/events';
30
+ desc: string;
31
+ input: TSchemas['request'];
32
+ output: TSchemas['response'];
33
+ safelistedBody: true;
34
+ maxJsonBodyBytes: number;
35
+ };
36
+ };
37
+ /**
38
+ * `bootstrap` issues or renews a visit lease; `track` receives a batch. `track`
39
+ * declares `safelistedBody` because the page-leave event is sent by
40
+ * `sendUnloadBeacon` with a string body — the only body a document that is
41
+ * being unloaded can deliver to another origin (ADR 0165) — and the server
42
+ * therefore needs an explicit `cors.origin` allow-list for it to arrive.
43
+ */
44
+ export declare function createTrackingContract<TType extends string, TScope extends string>(config: TrackingContractConfig<TType, undefined, TScope>): ContractDef<TrackingContractEndpoints<TrackingSchemas<z.ZodObject<TrackingEventShape<TType>>>>, TScope>;
45
+ export declare function createTrackingContract<TType extends string, TExtras extends z.ZodRawShape, TScope extends string>(config: TrackingContractConfig<TType, TExtras, TScope>): ContractDef<TrackingContractEndpoints<TrackingSchemas<z.ZodObject<TrackingEventShape<TType> & TExtras>>>, TScope>;
46
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,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BAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,EAChF,MAAM,EAAE,sBAAsB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,GACvD,WAAW,CACZ,yBAAyB,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAClF,MAAM,CACP,CAAC;AACF,wBAAgB,sBAAsB,CACpC,KAAK,SAAS,MAAM,EACpB,OAAO,SAAS,CAAC,CAAC,WAAW,EAC7B,MAAM,SAAS,MAAM,EAErB,MAAM,EAAE,sBAAsB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,GACrD,WAAW,CACZ,yBAAyB,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC5F,MAAM,CACP,CAAC"}
@@ -0,0 +1,24 @@
1
+ export type TrackingDeliveryOutcome = 'delivered' | 'failed' | 'auth-invalidated';
2
+ export interface TrackingDeliveryOptions {
3
+ request: () => Promise<unknown>;
4
+ onFailure: (error: unknown) => void;
5
+ /**
6
+ * A `401` or `403` means the session the batch was sent under is gone or
7
+ * may no longer write. When given,
8
+ * this is asked to recover it (re-authenticate, refresh); `true` retries the
9
+ * batch once, `false` reports `auth-invalidated` and the batch stays queued
10
+ * for a flush under the next session.
11
+ */
12
+ onUnauthorized?: () => Promise<boolean>;
13
+ wait?: (delayMs: number) => Promise<void>;
14
+ retryDelayMs?: number;
15
+ }
16
+ /**
17
+ * One batch, one bounded retry. A network failure or a `5xx` earns a single
18
+ * second attempt after `retryDelayMs`; anything else is reported once. Nothing
19
+ * is lost on `failed`: the batch is still in the outbox, the next flush sends
20
+ * the same events with the same ids, and the server answers `duplicate` for
21
+ * whatever it had already accepted.
22
+ */
23
+ export declare function deliverTrackingBatch({ request, onFailure, onUnauthorized, wait, retryDelayMs, }: TrackingDeliveryOptions): Promise<TrackingDeliveryOutcome>;
24
+ //# sourceMappingURL=delivery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../../src/tracking/delivery.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,QAAQ,GAAG,kBAAkB,CAAC;AAElF,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAUD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,EACzC,OAAO,EACP,SAAS,EACT,cAAc,EACd,IAA0E,EAC1E,YAAkB,GACnB,EAAE,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAqB5D"}
@@ -0,0 +1,43 @@
1
+ import type { AttributionStorage } from './attribution.js';
2
+ import type { ClickTarget } from './clicks.js';
3
+ /** What the client reads about the current page. */
4
+ export interface TrackingPageContext {
5
+ pathname: string;
6
+ /** With the leading `?`, or empty. */
7
+ search: string;
8
+ origin: string;
9
+ hostname: string;
10
+ title: string;
11
+ referrer: string;
12
+ viewportWidth: number;
13
+ viewportHeight: number;
14
+ screenWidth: number;
15
+ screenHeight: number;
16
+ displayMode: 'browser' | 'standalone';
17
+ }
18
+ /**
19
+ * Everything the tracking client takes from a browser, behind one interface,
20
+ * so the client is a plain object that can be driven by a test without a
21
+ * DOM — and so a host that is not a browser tab (a WebView, a worker) can
22
+ * supply its own. `browserTrackingHost()` is the tab.
23
+ */
24
+ export interface TrackingHost {
25
+ page(): TrackingPageContext;
26
+ visible(): boolean;
27
+ /** Current scroll depth, 0–100. */
28
+ scrollDepth(): number;
29
+ /** Subscribe; returns the unsubscribe. */
30
+ on(event: 'pagehide' | 'visibilitychange' | 'online' | 'scroll', handler: () => void): () => void;
31
+ /** Clicks, capture phase — a link navigates before bubbling reaches it. */
32
+ onClick(handler: (target: ClickTarget | null) => void): () => void;
33
+ interval(handler: () => void, ms: number): () => void;
34
+ /** Monotonic clock, ms. */
35
+ now(): number;
36
+ wallClock(): number;
37
+ randomUUID(): string;
38
+ /** Where attribution persists; `null` when there is none. */
39
+ storage: AttributionStorage | null;
40
+ }
41
+ /** The host a browser tab provides. Reads `window` and `document` lazily, never at import. */
42
+ export declare function browserTrackingHost(): TrackingHost;
43
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/tracking/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,oDAAoD;AACpD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,SAAS,GAAG,YAAY,CAAC;CACvC;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,IAAI,mBAAmB,CAAC;IAC5B,OAAO,IAAI,OAAO,CAAC;IACnB,mCAAmC;IACnC,WAAW,IAAI,MAAM,CAAC;IACtB,0CAA0C;IAC1C,EAAE,CACA,KAAK,EAAE,UAAU,GAAG,kBAAkB,GAAG,QAAQ,GAAG,QAAQ,EAC5D,OAAO,EAAE,MAAM,IAAI,GAClB,MAAM,IAAI,CAAC;IACd,2EAA2E;IAC3E,OAAO,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACnE,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,IAAI,CAAC;IACtD,2BAA2B;IAC3B,GAAG,IAAI,MAAM,CAAC;IACd,SAAS,IAAI,MAAM,CAAC;IACpB,UAAU,IAAI,MAAM,CAAC;IACrB,6DAA6D;IAC7D,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAC;CACpC;AAED,8FAA8F;AAC9F,wBAAgB,mBAAmB,IAAI,YAAY,CAmDlD"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * One fact per key per page within a window.
3
+ *
4
+ * A component that records "opened X" can mount twice on the same page —
5
+ * StrictMode, an RSC tree refresh, a layout re-render — and each mount has its
6
+ * own fresh refs, so a guard inside the component cannot see the first one.
7
+ * The memory lives at document scope instead: the same key on the same page
8
+ * within the window is the same fact. A different page is a new one.
9
+ */
10
+ export interface OncePerPage {
11
+ should(key: string, page: string): boolean;
12
+ }
13
+ export declare function createOncePerPage(options?: {
14
+ windowMs?: number;
15
+ now?: () => number;
16
+ }): OncePerPage;
17
+ //# sourceMappingURL=once-per-page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"once-per-page.d.ts","sourceRoot":"","sources":["../../src/tracking/once-per-page.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5C;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO,GACtD,WAAW,CAcb"}
@@ -0,0 +1,12 @@
1
+ import type { TrackingOutboxStorage, TrackingQueuedEvent } from './outbox.js';
2
+ /**
3
+ * The outbox in IndexedDB — the store every tab of one origin shares, which is
4
+ * what makes the sequence counter and the flush lease lineage-wide. Each
5
+ * `transact` is one `readwrite` transaction over both object stores; the
6
+ * database is opened per transaction and closed after it, so a tab holds no
7
+ * connection open across the page's life.
8
+ *
9
+ * `factory` is injectable so the adapter can be exercised outside a browser.
10
+ */
11
+ export declare function indexedDbOutboxStorage<TEvent extends TrackingQueuedEvent = TrackingQueuedEvent>(name: string, factory?: () => IDBFactory): TrackingOutboxStorage<TEvent>;
12
+ //# sourceMappingURL=outbox-storage-indexeddb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox-storage-indexeddb.d.ts","sourceRoot":"","sources":["../../src/tracking/outbox-storage-indexeddb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAsDlB;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,SAAS,mBAAmB,GAAG,mBAAmB,EACxD,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,UAA4B,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAyC1F"}
@@ -0,0 +1,12 @@
1
+ import type { TrackingOutboxStorage, TrackingQueuedEvent } from './outbox.js';
2
+ /**
3
+ * The outbox over two maps. Transactions are serialised through one promise
4
+ * chain and are all-or-nothing: `fn` works on copies that replace the store
5
+ * only when it returns, so two concurrent `reserveSequences` see each other
6
+ * exactly as they would through IndexedDB, and one that throws leaves
7
+ * nothing behind. For tests, and for a browser whose IndexedDB is
8
+ * unavailable — then it is one tab's private queue, which is what the
9
+ * `unavailable` health state tells the server.
10
+ */
11
+ export declare function memoryOutboxStorage<TEvent extends TrackingQueuedEvent = TrackingQueuedEvent>(): TrackingOutboxStorage<TEvent>;
12
+ //# sourceMappingURL=outbox-storage-memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox-storage-memory.d.ts","sourceRoot":"","sources":["../../src/tracking/outbox-storage-memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAElB;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,SAAS,mBAAmB,GAAG,mBAAmB,KACrD,qBAAqB,CAAC,MAAM,CAAC,CAiCjC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * A bounded, tab-shared outbox for browser events.
3
+ *
4
+ * Every event is written here before it is sent, so a batch the network drops
5
+ * is sent again on the next flush and a page the user leaves does not lose the
6
+ * facts it recorded. The server's dispositions are all terminal, so an
7
+ * acknowledged event is simply deleted — the outbox never re-sends what the
8
+ * server has already answered.
9
+ *
10
+ * Two things here are the difference between an outbox that works and one
11
+ * that quietly loses the page-leave event, and both are consumer scars:
12
+ *
13
+ * - **Sequences are reserved, not assigned at write time.** On `pagehide`
14
+ * there is no time to wait for a storage transaction, so the event's number
15
+ * has to exist before the event is written anywhere. `reserveSequences`
16
+ * hands out a block atomically; a tab spends it synchronously.
17
+ * - **The flush lease is short and is released on `pagehide`.** A ten-second
18
+ * lease that a dying document did not release delayed the next document's
19
+ * first flush by the whole ten seconds — the time it takes a person to leave
20
+ * again. The lease guards against two tabs flushing at once, not against
21
+ * retries, which the server answers with `duplicate` anyway.
22
+ *
23
+ * Storage is an interface: IndexedDB in a browser, memory in a test or as the
24
+ * degraded mode when IndexedDB is unavailable. → ADR 0166.
25
+ */
26
+ /** The least an event needs for the outbox to order and acknowledge it. */
27
+ export interface TrackingQueuedEvent {
28
+ eventId: string;
29
+ browserSequence: number;
30
+ }
31
+ export interface TrackingOutboxRecord<TEvent extends TrackingQueuedEvent = TrackingQueuedEvent> {
32
+ event: TEvent;
33
+ enqueuedAt: number;
34
+ }
35
+ /** A key/value store inside one atomic transaction. */
36
+ export interface TrackingOutboxMeta {
37
+ get(key: string): Promise<unknown>;
38
+ put(key: string, value: unknown): void;
39
+ delete(key: string): void;
40
+ }
41
+ /** The event store inside the same transaction. */
42
+ export interface TrackingOutboxEvents<TEvent extends TrackingQueuedEvent = TrackingQueuedEvent> {
43
+ put(record: TrackingOutboxRecord<TEvent>): void;
44
+ delete(eventId: string): void;
45
+ /** Every record, ordered by `browserSequence`. */
46
+ all(): Promise<TrackingOutboxRecord<TEvent>[]>;
47
+ count(): Promise<number>;
48
+ }
49
+ /**
50
+ * One atomic read-modify-write over both stores. Atomicity is the whole
51
+ * contract: two tabs reserving sequences or racing for the lease must see each
52
+ * other's writes, which is what a single IndexedDB `readwrite` transaction —
53
+ * and the memory adapter's serialised queue — provide.
54
+ */
55
+ export interface TrackingOutboxStorage<TEvent extends TrackingQueuedEvent = TrackingQueuedEvent> {
56
+ transact<T>(fn: (tx: {
57
+ meta: TrackingOutboxMeta;
58
+ events: TrackingOutboxEvents<TEvent>;
59
+ }) => Promise<T>,
60
+ /** `readonly` for a pure read, so one tab's reads do not queue behind another's writes. */
61
+ mode?: 'readonly' | 'readwrite'): Promise<T>;
62
+ }
63
+ export interface TrackingOutboxOptions {
64
+ /** Records kept; the oldest beyond it are dropped and counted. Default 1000. */
65
+ maxEvents?: number;
66
+ /** Age beyond which a record is dropped and counted. Default 7 days. */
67
+ maxAgeMs?: number;
68
+ /** Flush lease duration. Default 3 s — short, because it is released on leave. */
69
+ leaseMs?: number;
70
+ /** Wall clock; injectable for tests. */
71
+ now?: () => number;
72
+ randomUUID?: () => string;
73
+ }
74
+ export interface TrackingOutboxHealth {
75
+ state: 'available' | 'unavailable';
76
+ queued: number;
77
+ dropped: number;
78
+ }
79
+ export interface TrackingOutbox<TEvent extends TrackingQueuedEvent = TrackingQueuedEvent> {
80
+ /** Browser lineage — shared by every tab, survives reload and login. */
81
+ streamId(): Promise<string>;
82
+ /** Atomically reserve `count` consecutive sequence numbers. */
83
+ reserveSequences(count: number): Promise<number[]>;
84
+ /** Write an event that already carries its identity, then trim. */
85
+ enqueue(event: TEvent): Promise<void>;
86
+ /** One flusher per lineage: tabs compete for a renewable lease. */
87
+ acquireLease(owner: string): Promise<boolean>;
88
+ /** Give the lease back on leave so the next document flushes at once. */
89
+ releaseLease(owner: string): Promise<void>;
90
+ /** The oldest `limit` events in sequence order. */
91
+ readBatch(limit?: number): Promise<TEvent[]>;
92
+ /** Delete the events the server answered — every disposition is terminal. */
93
+ acknowledge(eventIds: readonly string[]): Promise<void>;
94
+ /** Queue depth and drops; `unavailable` when storage throws. */
95
+ health(): Promise<TrackingOutboxHealth>;
96
+ }
97
+ export declare function createTrackingOutbox<TEvent extends TrackingQueuedEvent>(storage: TrackingOutboxStorage<TEvent>, options?: TrackingOutboxOptions): TrackingOutbox<TEvent>;
98
+ //# sourceMappingURL=outbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox.d.ts","sourceRoot":"","sources":["../../src/tracking/outbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,2EAA2E;AAC3E,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB,CACnC,MAAM,SAAS,mBAAmB,GAAG,mBAAmB;IAExD,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,uDAAuD;AACvD,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,GAAG,CAAC,GAAG,EA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AM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc,CAAC,MAAM,SAAS,mBAAmB,GAAG,mBAAmB;IACtF,wEAAwE;IACxE,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,+DAA+D;IAC/D,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACnD,mEAAmE;IACnE,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,mEAAmE;IACnE,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9C,yEAAyE;IACzE,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,mDAAmD;IACnD,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C,6EAA6E;IAC7E,WAAW,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,gEAAgE;IAChE,MAAM,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACzC;AAoBD,wBAAgB,oBAAoB,CAAC,MAAM,SAAS,mBAAmB,EACrE,OAAO,EAAE,qBAAqB,CAAC,MAAM,CAAC,EACtC,OAAO,GAAE,qBAA0B,GAClC,cAAc,CAAC,MAAM,CAAC,CAiFxB"}
@@ -0,0 +1,183 @@
1
+ /**
2
+ * The shapes two consuming applications arrived at independently, word for
3
+ * word — an event envelope, a batch, its dispositions, a visit's entry context
4
+ * and lease. They carry no domain: the event *types* and any extra per-event
5
+ * fields are the application's, handed in as parameters. → ADR 0166.
6
+ */
7
+ import { z } from 'zod';
8
+ /** Campaign tags. Every field optional — `utm_source` alone is a legal entry. */
9
+ export declare const UtmDataSchema: z.ZodObject<{
10
+ source: z.ZodOptional<z.ZodString>;
11
+ medium: z.ZodOptional<z.ZodString>;
12
+ campaign: z.ZodOptional<z.ZodString>;
13
+ content: z.ZodOptional<z.ZodString>;
14
+ term: z.ZodOptional<z.ZodString>;
15
+ }, z.core.$strip>;
16
+ export type UtmData = z.infer<typeof UtmDataSchema>;
17
+ export declare const AttributionDataSchema: z.ZodObject<{
18
+ utm: z.ZodOptional<z.ZodObject<{
19
+ source: z.ZodOptional<z.ZodString>;
20
+ medium: z.ZodOptional<z.ZodString>;
21
+ campaign: z.ZodOptional<z.ZodString>;
22
+ content: z.ZodOptional<z.ZodString>;
23
+ term: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strip>>;
25
+ referrer: z.ZodOptional<z.ZodString>;
26
+ landingPage: z.ZodOptional<z.ZodString>;
27
+ }, z.core.$strip>;
28
+ export type AttributionData = z.infer<typeof AttributionDataSchema>;
29
+ /**
30
+ * The build that produced an event: a git SHA, or `dev`. Shared by both
31
+ * consumers already; `createTrackingSchemas({ buildIdPattern })` overrides it.
32
+ */
33
+ export declare const DEFAULT_BUILD_ID_PATTERN: RegExp;
34
+ /**
35
+ * What the server decided about one event. Every value is terminal — the
36
+ * outbox drops the event on any of them — because a retry would produce the
37
+ * same answer: `duplicate` is the answer a re-sent accepted event gets, an
38
+ * `identity-invalid` event belongs to a visit this browser does not own, and a
39
+ * bot's events are never written.
40
+ */
41
+ export declare const TrackingDispositionStatusSchema: z.ZodEnum<{
42
+ accepted: "accepted";
43
+ duplicate: "duplicate";
44
+ "excluded-bot": "excluded-bot";
45
+ "identity-invalid": "identity-invalid";
46
+ }>;
47
+ export type TrackingDispositionStatus = z.infer<typeof TrackingDispositionStatusSchema>;
48
+ export declare const TrackingDispositionSchema: z.ZodObject<{
49
+ eventId: z.ZodUUID;
50
+ status: z.ZodEnum<{
51
+ accepted: "accepted";
52
+ duplicate: "duplicate";
53
+ "excluded-bot": "excluded-bot";
54
+ "identity-invalid": "identity-invalid";
55
+ }>;
56
+ }, z.core.$strip>;
57
+ export type TrackingDisposition = z.infer<typeof TrackingDispositionSchema>;
58
+ export declare const TrackEventsResponseSchema: z.ZodObject<{
59
+ accepted: z.ZodNumber;
60
+ dispositions: z.ZodArray<z.ZodObject<{
61
+ eventId: z.ZodUUID;
62
+ status: z.ZodEnum<{
63
+ accepted: "accepted";
64
+ duplicate: "duplicate";
65
+ "excluded-bot": "excluded-bot";
66
+ "identity-invalid": "identity-invalid";
67
+ }>;
68
+ }, z.core.$strip>>;
69
+ }, z.core.$strip>;
70
+ export type TrackEventsResponse = z.infer<typeof TrackEventsResponseSchema>;
71
+ export declare const VisitBootstrapResponseSchema: z.ZodObject<{
72
+ visitId: z.ZodUUID;
73
+ expiresAt: z.ZodISODateTime;
74
+ }, z.core.$strip>;
75
+ export type VisitBootstrapResponse = z.infer<typeof VisitBootstrapResponseSchema>;
76
+ /** The state of the browser-side outbox, reported with every visit bootstrap. */
77
+ export declare const TrackingOutboxStateSchema: z.ZodEnum<{
78
+ available: "available";
79
+ unavailable: "unavailable";
80
+ }>;
81
+ export type TrackingOutboxState = z.infer<typeof TrackingOutboxStateSchema>;
82
+ declare function trackingEventShape<TType extends string>(eventTypes: readonly [TType, ...TType[]]): {
83
+ /** Client-minted, the idempotency key of the event. */
84
+ eventId: z.ZodUUID;
85
+ visitId: z.ZodUUID;
86
+ /** Browser lineage — shared by every tab, survives reload and login. */
87
+ browserStreamId: z.ZodUUID;
88
+ /** Monotonic per lineage; reserved before the event is written anywhere. */
89
+ browserSequence: z.ZodNumber;
90
+ type: z.ZodEnum<{ [k in TType]: k; } extends infer T ? { [k in keyof T]: T[k]; } : never>;
91
+ page: z.ZodString;
92
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
93
+ clientTimestamp: z.ZodNumber;
94
+ };
95
+ export type TrackingEventShape<TType extends string> = ReturnType<typeof trackingEventShape<TType>>;
96
+ /**
97
+ * The envelope every browser event travels in, before the application's extras.
98
+ *
99
+ * Written out rather than inferred: `z.infer` over a generic enum emits the
100
+ * `type` field into the declaration as a mapped type the compiler cannot prove
101
+ * is a `string`, and every generic constrained on this envelope then fails in
102
+ * `dist/*.d.ts` while passing in `src` — the defect class of ADR 0161, caught
103
+ * by `check-declarations-strict`. The schema stays the source of truth:
104
+ * `tests/tracking-browser.test.ts` holds this type equal to its inference.
105
+ */
106
+ export interface TrackingEventEnvelope<TType extends string = string> {
107
+ eventId: string;
108
+ visitId: string;
109
+ browserStreamId: string;
110
+ browserSequence: number;
111
+ type: TType;
112
+ page: string;
113
+ metadata?: Record<string, unknown> | undefined;
114
+ clientTimestamp: number;
115
+ }
116
+ /** A batch as the client sends it. */
117
+ export interface TrackEventsRequest<TEvent extends TrackingEventEnvelope = TrackingEventEnvelope> {
118
+ buildId: string;
119
+ events: TEvent[];
120
+ utm?: UtmData;
121
+ }
122
+ declare function visitEntryContextShape(buildIdPattern: RegExp): {
123
+ browserStreamId: z.ZodUUID;
124
+ previousVisitId: z.ZodOptional<z.ZodUUID>;
125
+ origin: z.ZodURL;
126
+ landingPath: z.ZodString;
127
+ referrer: z.ZodOptional<z.ZodURL>;
128
+ utm: z.ZodOptional<z.ZodObject<{
129
+ source: z.ZodOptional<z.ZodString>;
130
+ medium: z.ZodOptional<z.ZodString>;
131
+ campaign: z.ZodOptional<z.ZodString>;
132
+ content: z.ZodOptional<z.ZodString>;
133
+ term: z.ZodOptional<z.ZodString>;
134
+ }, z.core.$strip>>;
135
+ displayMode: z.ZodEnum<{
136
+ browser: "browser";
137
+ standalone: "standalone";
138
+ }>;
139
+ screenWidth: z.ZodNumber;
140
+ screenHeight: z.ZodNumber;
141
+ buildId: z.ZodString;
142
+ outboxState: z.ZodEnum<{
143
+ available: "available";
144
+ unavailable: "unavailable";
145
+ }>;
146
+ outboxQueued: z.ZodNumber;
147
+ outboxDropped: z.ZodNumber;
148
+ };
149
+ export type VisitEntryContextShape = ReturnType<typeof visitEntryContextShape>;
150
+ export type VisitEntryContext = z.infer<z.ZodObject<VisitEntryContextShape>>;
151
+ export interface TrackingSchemasConfig<TType extends string, TExtras extends z.ZodRawShape | undefined> {
152
+ /** The event types the browser may write. Server-side types are not on this list. */
153
+ eventTypes: readonly [TType, ...TType[]];
154
+ /** Extra per-event fields the application carries beside the envelope. */
155
+ eventExtras?: TExtras extends z.ZodRawShape ? z.ZodObject<TExtras> : undefined;
156
+ /** Default {@link DEFAULT_BUILD_ID_PATTERN}. */
157
+ buildIdPattern?: RegExp;
158
+ /** Events per batch; default 50 — the outbox reads batches of this size. */
159
+ maxEventsPerBatch?: number;
160
+ }
161
+ /** Every schema of one tracking surface, built from the application's event types. */
162
+ export interface TrackingSchemas<TEvent extends z.ZodObject> {
163
+ event: TEvent;
164
+ request: z.ZodObject<{
165
+ buildId: z.ZodString;
166
+ events: z.ZodArray<TEvent>;
167
+ utm: z.ZodOptional<typeof UtmDataSchema>;
168
+ }>;
169
+ response: typeof TrackEventsResponseSchema;
170
+ disposition: typeof TrackingDispositionSchema;
171
+ entry: z.ZodObject<VisitEntryContextShape>;
172
+ bootstrap: typeof VisitBootstrapResponseSchema;
173
+ }
174
+ /**
175
+ * The schemas of one tracking surface. Two overloads rather than a conditional
176
+ * spread: a shape that TypeScript keeps internal while checking `src` is
177
+ * written into the declaration as a union zod's shape constraint rejects
178
+ * (0.78.0, 0.79.0 — ADR 0161), so the two cases are two signatures.
179
+ */
180
+ export declare function createTrackingSchemas<TType extends string>(config: TrackingSchemasConfig<TType, undefined>): TrackingSchemas<z.ZodObject<TrackingEventShape<TType>>>;
181
+ export declare function createTrackingSchemas<TType extends string, TExtras extends z.ZodRawShape>(config: TrackingSchemasConfig<TType, TExtras>): TrackingSchemas<z.ZodObject<TrackingEventShape<TType> & TExtras>>;
182
+ export {};
183
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/tracking/schemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,M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CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Scroll depth as a percentage of the scrollable range — 0 at the top, 100 at
3
+ * the bottom, 0 for a page shorter than its viewport (nothing to scroll).
4
+ */
5
+ export declare function scrollDepthPercent(view: {
6
+ scrollHeight: number;
7
+ innerHeight: number;
8
+ scrollY: number;
9
+ }): number;
10
+ export interface ScrollMilestones {
11
+ /** Record a depth without firing — the scroll listener's job. */
12
+ record(percent: number): void;
13
+ /** Record a depth and return the milestones newly reached, ascending. */
14
+ observe(percent: number): number[];
15
+ /** The deepest point seen since the last reset. */
16
+ max(): number;
17
+ /** A new page. */
18
+ reset(): void;
19
+ }
20
+ /** Milestones fire once each per page, in order, from the deepest point seen. */
21
+ export declare function createScrollMilestones(milestones?: readonly number[]): ScrollMilestones;
22
+ //# sourceMappingURL=scroll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll.d.ts","sourceRoot":"","sources":["../../src/tracking/scroll.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,MAAM,CAIT;AAED,MAAM,WAAW,gBAAgB;IAC/B,iEAAiE;IACjE,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,yEAAyE;IACzE,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACnC,mDAAmD;IACnD,GAAG,IAAI,MAAM,CAAC;IACd,kBAAkB;IAClB,KAAK,IAAI,IAAI,CAAC;CACf;AAED,iFAAiF;AACjF,wBAAgB,sBAAsB,CACpC,UAAU,GAAE,SAAS,MAAM,EAAsB,GAChD,gBAAgB,CAyBlB"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * A pool of reserved sequence numbers a tab can spend **synchronously**.
3
+ *
4
+ * The page-leave event is materialised inside `pagehide`, where awaiting a
5
+ * storage transaction means the document dies first. So the tab keeps a block
6
+ * reserved ahead of time and refills it below a low-water mark; uniqueness
7
+ * across tabs comes from the atomic reservation, not from the moment of use.
8
+ *
9
+ * When the reservation source fails (no IndexedDB), the pool switches to a
10
+ * per-tab fallback: a random base plus a counter — the honest minimum, and the
11
+ * event then goes straight to the network without a queue.
12
+ */
13
+ export interface SequenceReserveOptions {
14
+ /** Numbers reserved per refill. Default 16. */
15
+ blockSize?: number;
16
+ /** Refill when fewer than this remain. Default 4. */
17
+ lowWater?: number;
18
+ /** Called once when the source fails and the fallback takes over. */
19
+ onUnavailable?: (error: unknown) => void;
20
+ /** Random base for the fallback; injectable for tests. */
21
+ fallbackBase?: () => number;
22
+ }
23
+ export interface SequenceReserve {
24
+ /** The next number, or `null` when the pool is empty and a refill is pending. */
25
+ take(): number | null;
26
+ /** Reserve a block now; resolves when the pool is refilled (or the fallback engaged). */
27
+ refill(): Promise<void>;
28
+ /** Whether numbers still come from the shared source. */
29
+ shared(): boolean;
30
+ /** Forget the fallback and the pool — the shared source is back. */
31
+ reset(): void;
32
+ }
33
+ export declare function createSequenceReserve(reserve: (count: number) => Promise<number[]>, options?: SequenceReserveOptions): SequenceReserve;
34
+ //# sourceMappingURL=sequence-reserve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequence-reserve.d.ts","sourceRoot":"","sources":["../../src/tracking/sequence-reserve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,eAAe;IAC9B,iFAAiF;IACjF,IAAI,IAAI,MAAM,GAAG,IAAI,CAAC;IACtB,yFAAyF;IACzF,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,yDAAyD;IACzD,MAAM,IAAI,OAAO,CAAC;IAClB,oEAAoE;IACpE,KAAK,IAAI,IAAI,CAAC;CACf;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,EAC7C,OAAO,GAAE,sBAA2B,GACnC,eAAe,CAkDjB"}
@@ -0,0 +1,26 @@
1
+ export interface ActiveTimeInterval {
2
+ intervalId: string;
3
+ page: string;
4
+ deltaMs: number;
5
+ startedAt: Date;
6
+ endedAt: Date;
7
+ }
8
+ export interface ActiveIntervalOptions {
9
+ /** Longest interval a client may claim. Default 30 minutes. */
10
+ maxMs?: number;
11
+ /** The event types that carry an interval. Default `PAGE_LEAVE` and `SESSION_HEARTBEAT`. */
12
+ types?: readonly string[];
13
+ }
14
+ /**
15
+ * The visible-time interval an event carries, dated by the **server**: the
16
+ * client reports only a duration, its `intervalStartedAt` is carried for the
17
+ * timeline and never used — a client's clock is not admitted to the record.
18
+ * `null` when the event has no interval, an unshaped one, or one longer than
19
+ * a tab could plausibly have been visible.
20
+ */
21
+ export declare function activeIntervalOf(event: {
22
+ type: string;
23
+ page: string;
24
+ metadata?: Record<string, unknown> | undefined;
25
+ }, serverNow: Date, { maxMs, types, }?: ActiveIntervalOptions): ActiveTimeInterval | null;
26
+ //# sourceMappingURL=active-interval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"active-interval.d.ts","sourceRoot":"","sources":["../../../src/tracking/server/active-interval.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,IAAI,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4FAA4F;IAC5F,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;CAAE,EACrF,SAAS,EAAE,IAAI,EACf,EACE,KAAsB,EACtB,KAA2C,GAC5C,GAAE,qBAA0B,GAC5B,kBAAkB,GAAG,IAAI,CAgB3B"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Crawlers and monitors are not visitors. The pattern is the one two
3
+ * consuming applications converged on; it includes `headlesschrome`, so an
4
+ * agent's browser is a bot too — probe with a real user agent, set at browser
5
+ * launch (a context override does not reach `sendBeacon`).
6
+ */
7
+ export declare const DEFAULT_BOT_USER_AGENT_PATTERN: RegExp;
8
+ export declare function isBotUserAgent(userAgent: string | null | undefined, pattern?: RegExp): boolean;
9
+ //# sourceMappingURL=bot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../../../src/tracking/server/bot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,QACwH,CAAC;AAEpK,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,MAAuC,GAC/C,OAAO,CAET"}