@tagadapay/headless-sdk 1.16.0 → 1.17.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 (150) hide show
  1. package/dist/core/client.d.ts +5 -0
  2. package/dist/core/client.d.ts.map +1 -1
  3. package/dist/core/client.js +6 -1
  4. package/dist/core/client.js.map +1 -1
  5. package/dist/core/http.d.ts +2 -0
  6. package/dist/core/http.d.ts.map +1 -1
  7. package/dist/core/http.js +21 -5
  8. package/dist/core/http.js.map +1 -1
  9. package/dist/core/index.d.ts +4 -0
  10. package/dist/core/index.d.ts.map +1 -1
  11. package/dist/core/index.js +2 -0
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/core/modules/checkout.d.ts.map +1 -1
  14. package/dist/core/modules/checkout.js +12 -0
  15. package/dist/core/modules/checkout.js.map +1 -1
  16. package/dist/core/modules/commerce.d.ts +4 -0
  17. package/dist/core/modules/commerce.d.ts.map +1 -0
  18. package/dist/core/modules/commerce.js +5 -0
  19. package/dist/core/modules/commerce.js.map +1 -0
  20. package/dist/core/modules/customer.d.ts +47 -1
  21. package/dist/core/modules/customer.d.ts.map +1 -1
  22. package/dist/core/modules/customer.js +60 -3
  23. package/dist/core/modules/customer.js.map +1 -1
  24. package/dist/core/modules/experiments.d.ts +21 -0
  25. package/dist/core/modules/experiments.d.ts.map +1 -0
  26. package/dist/core/modules/experiments.js +85 -0
  27. package/dist/core/modules/experiments.js.map +1 -0
  28. package/dist/core/modules/funnel.d.ts +2 -1
  29. package/dist/core/modules/funnel.d.ts.map +1 -1
  30. package/dist/core/modules/funnel.js +6 -1
  31. package/dist/core/modules/funnel.js.map +1 -1
  32. package/dist/core/modules/lazyCommerce.d.ts +16 -0
  33. package/dist/core/modules/lazyCommerce.d.ts.map +1 -0
  34. package/dist/core/modules/lazyCommerce.js +20 -0
  35. package/dist/core/modules/lazyCommerce.js.map +1 -0
  36. package/dist/core/modules/offers.d.ts +30 -5
  37. package/dist/core/modules/offers.d.ts.map +1 -1
  38. package/dist/core/modules/offers.js +66 -7
  39. package/dist/core/modules/offers.js.map +1 -1
  40. package/dist/core/modules/portal/index.d.ts +102 -0
  41. package/dist/core/modules/portal/index.d.ts.map +1 -0
  42. package/dist/core/modules/portal/index.js +166 -0
  43. package/dist/core/modules/portal/index.js.map +1 -0
  44. package/dist/core/modules/portal/types.d.ts +617 -0
  45. package/dist/core/modules/portal/types.d.ts.map +1 -0
  46. package/dist/core/modules/portal/types.js +11 -0
  47. package/dist/core/modules/portal/types.js.map +1 -0
  48. package/dist/core/modules/track.d.ts +8 -0
  49. package/dist/core/modules/track.d.ts.map +1 -1
  50. package/dist/core/modules/track.js +49 -8
  51. package/dist/core/modules/track.js.map +1 -1
  52. package/dist/core/types.d.ts +11 -0
  53. package/dist/core/types.d.ts.map +1 -1
  54. package/dist/core/types.js +0 -3
  55. package/dist/core/types.js.map +1 -1
  56. package/dist/core/version.d.ts +1 -1
  57. package/dist/core/version.js +1 -1
  58. package/dist/pixels/pixelTracker.d.ts.map +1 -1
  59. package/dist/pixels/pixelTracker.js +4 -2
  60. package/dist/pixels/pixelTracker.js.map +1 -1
  61. package/dist/tagada-headless-commerce.min.js +8 -0
  62. package/dist/tagada-headless-commerce.min.js.map +7 -0
  63. package/dist/tagada-headless-react.min.js +2 -2
  64. package/dist/tagada-headless-react.min.js.map +4 -4
  65. package/dist/tagada-headless.js +299 -288
  66. package/dist/tagada-headless.min.js +2 -2
  67. package/dist/tagada-headless.min.js.map +4 -4
  68. package/dist/tagada-pixels.min.js +2 -2
  69. package/dist/tagada-pixels.min.js.map +3 -3
  70. package/dist/tgd/contract/attribution.d.ts +28 -0
  71. package/dist/tgd/contract/attribution.d.ts.map +1 -0
  72. package/dist/tgd/contract/attribution.js +44 -0
  73. package/dist/tgd/contract/attribution.js.map +1 -0
  74. package/dist/tgd/contract/browser-api.d.ts +57 -0
  75. package/dist/tgd/contract/browser-api.d.ts.map +1 -0
  76. package/dist/tgd/contract/browser-api.js +2 -0
  77. package/dist/tgd/contract/browser-api.js.map +1 -0
  78. package/dist/tgd/contract/canvas.d.ts +120 -0
  79. package/dist/tgd/contract/canvas.d.ts.map +1 -0
  80. package/dist/tgd/contract/canvas.js +12 -0
  81. package/dist/tgd/contract/canvas.js.map +1 -0
  82. package/dist/tgd/contract/dedup-keys.d.ts +24 -0
  83. package/dist/tgd/contract/dedup-keys.d.ts.map +1 -0
  84. package/dist/tgd/contract/dedup-keys.js +23 -0
  85. package/dist/tgd/contract/dedup-keys.js.map +1 -0
  86. package/dist/tgd/contract/destination-names.d.ts +4 -0
  87. package/dist/tgd/contract/destination-names.d.ts.map +1 -0
  88. package/dist/tgd/contract/destination-names.js +66 -0
  89. package/dist/tgd/contract/destination-names.js.map +1 -0
  90. package/dist/tgd/contract/destinations.d.ts +124 -0
  91. package/dist/tgd/contract/destinations.d.ts.map +1 -0
  92. package/dist/tgd/contract/destinations.js +63 -0
  93. package/dist/tgd/contract/destinations.js.map +1 -0
  94. package/dist/tgd/contract/envelope.d.ts +203 -0
  95. package/dist/tgd/contract/envelope.d.ts.map +1 -0
  96. package/dist/tgd/contract/envelope.js +103 -0
  97. package/dist/tgd/contract/envelope.js.map +1 -0
  98. package/dist/tgd/contract/experiments.d.ts +87 -0
  99. package/dist/tgd/contract/experiments.d.ts.map +1 -0
  100. package/dist/tgd/contract/experiments.js +2 -0
  101. package/dist/tgd/contract/experiments.js.map +1 -0
  102. package/dist/tgd/contract/index.d.ts +20 -0
  103. package/dist/tgd/contract/index.d.ts.map +1 -0
  104. package/dist/tgd/contract/index.js +20 -0
  105. package/dist/tgd/contract/index.js.map +1 -0
  106. package/dist/tgd/contract/is-test.d.ts +2 -0
  107. package/dist/tgd/contract/is-test.d.ts.map +1 -0
  108. package/dist/tgd/contract/is-test.js +3 -0
  109. package/dist/tgd/contract/is-test.js.map +1 -0
  110. package/dist/tgd/contract/junk-ids.d.ts +4 -0
  111. package/dist/tgd/contract/junk-ids.d.ts.map +1 -0
  112. package/dist/tgd/contract/junk-ids.js +7 -0
  113. package/dist/tgd/contract/junk-ids.js.map +1 -0
  114. package/dist/tgd/contract/limits.d.ts +19 -0
  115. package/dist/tgd/contract/limits.d.ts.map +1 -0
  116. package/dist/tgd/contract/limits.js +20 -0
  117. package/dist/tgd/contract/limits.js.map +1 -0
  118. package/dist/tgd/contract/names.d.ts +13 -0
  119. package/dist/tgd/contract/names.d.ts.map +1 -0
  120. package/dist/tgd/contract/names.js +15 -0
  121. package/dist/tgd/contract/names.js.map +1 -0
  122. package/dist/tgd/contract/registry.d.ts +116 -0
  123. package/dist/tgd/contract/registry.d.ts.map +1 -0
  124. package/dist/tgd/contract/registry.js +59 -0
  125. package/dist/tgd/contract/registry.js.map +1 -0
  126. package/dist/tgd/contract/signed-ids.d.ts +33 -0
  127. package/dist/tgd/contract/signed-ids.d.ts.map +1 -0
  128. package/dist/tgd/contract/signed-ids.js +26 -0
  129. package/dist/tgd/contract/signed-ids.js.map +1 -0
  130. package/dist/tgd/contract/snapshots.d.ts +69 -0
  131. package/dist/tgd/contract/snapshots.d.ts.map +1 -0
  132. package/dist/tgd/contract/snapshots.js +2 -0
  133. package/dist/tgd/contract/snapshots.js.map +1 -0
  134. package/dist/tgd/contract/time.d.ts +9 -0
  135. package/dist/tgd/contract/time.d.ts.map +1 -0
  136. package/dist/tgd/contract/time.js +9 -0
  137. package/dist/tgd/contract/time.js.map +1 -0
  138. package/dist/tgd/contract/unions.d.ts +21 -0
  139. package/dist/tgd/contract/unions.d.ts.map +1 -0
  140. package/dist/tgd/contract/unions.js +17 -0
  141. package/dist/tgd/contract/unions.js.map +1 -0
  142. package/dist/tgd/contract/unit.d.ts +12 -0
  143. package/dist/tgd/contract/unit.d.ts.map +1 -0
  144. package/dist/tgd/contract/unit.js +18 -0
  145. package/dist/tgd/contract/unit.js.map +1 -0
  146. package/dist/tgd/contract/wire.d.ts +59 -0
  147. package/dist/tgd/contract/wire.d.ts.map +1 -0
  148. package/dist/tgd/contract/wire.js +2 -0
  149. package/dist/tgd/contract/wire.js.map +1 -0
  150. package/package.json +3 -3
@@ -0,0 +1,20 @@
1
+ // packages/tgd-core/src/contract/limits.ts
2
+ export const CONTRACT_VERSION = 1;
3
+ export const COLLECT_PATH = '/api/public/v2/e';
4
+ export const MAX_BATCH_EVENTS = 50;
5
+ export const MAX_CLIENT_BATCH_BYTES = 48 * 1024; // tgd.js splits a batch before it reaches this size
6
+ export const MAX_SERVER_BODY_BYTES = 64 * 1024; // collector answers 413 above this, before JSON.parse
7
+ export const MAX_PROPS_BYTES = 8192; // JSON.stringify(props) in UTF-8 bytes
8
+ export const MAX_PROPS_KEYS = 64; // top-level keys
9
+ export const MAX_PROP_KEY_CHARS = 64;
10
+ export const MAX_PROP_STRING_CHARS = 1024;
11
+ export const MAX_URL_CHARS = 2048;
12
+ export const MAX_TITLE_CHARS = 512;
13
+ export const MAX_CUSTOM_NAME_CHARS = 120;
14
+ export const MAX_EXTERNAL_ID_CHARS = 200;
15
+ export const MAX_ID_VALUE_CHARS = 512; // each TgdBrowserIds value
16
+ export const LATE_AFTER_MS = 72 * 3600 * 1000;
17
+ export const SKEW_DEADBAND_MS = 5000;
18
+ export const FUTURE_ID_TOLERANCE_MS = 60000; // a UUIDv7 id may be at most 60 s in the future
19
+ export const NIL_UUID = '00000000-0000-0000-0000-000000000000';
20
+ //# sourceMappingURL=limits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.js","sourceRoot":"","sources":["../../../src/tgd/contract/limits.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAU,CAAC;AAC3C,MAAM,CAAC,MAAM,YAAY,GAAG,kBAA2B,CAAC;AACxD,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,CAAC,CAAG,oDAAoD;AACvG,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,CAAC,CAAI,sDAAsD;AACzG,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,CAAe,uCAAuC;AAC1F,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC,CAAkB,iBAAiB;AACpE,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AACrC,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;AAClC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AACnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC,CAAa,2BAA2B;AAC9E,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AACrC,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAM,CAAC,CAAM,gDAAgD;AACnG,MAAM,CAAC,MAAM,QAAQ,GAAG,sCAAsC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export declare const COOKIE_VID = "tgd_vid";
2
+ export declare const COOKIE_VID_REFRESH = "tgd_vr";
3
+ export declare const COOKIE_SDK_BOOTSTRAP = "tgd_xb";
4
+ export declare const STORAGE_CID = "tgd_cid";
5
+ export declare const QUERY_ENTRY_TEST = "_tgx";
6
+ export declare const QUERY_VID_HANDOFF = "_tgv";
7
+ export declare const QUERY_DEBUG = "tgd_debug";
8
+ export declare const FUNNEL_SESSION_COOKIE = "tgd-funnel-session-id";
9
+ export declare const ptSnapshotKey: (funnelId: string, stepId: string) => string;
10
+ export declare const sdkSnapshotKey: (storeId: string) => string;
11
+ export declare const fsVidKey: (funnelSessionId: string) => string;
12
+ export declare const kvFsVid: (funnelSessionId: string) => string;
13
+ //# sourceMappingURL=names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../../../src/tgd/contract/names.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,UAAU,YAAY,CAAC;AACpC,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAC3C,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,eAAO,MAAM,WAAW,YAAY,CAAC;AACrC,eAAO,MAAM,gBAAgB,SAAS,CAAC;AACvC,eAAO,MAAM,iBAAiB,SAAS,CAAC;AACxC,eAAO,MAAM,WAAW,cAAc,CAAC;AACvC,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAE7D,eAAO,MAAM,aAAa,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,WAAuC,CAAC;AACtG,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,WAA6B,CAAC;AAC5E,eAAO,MAAM,QAAQ,GAAI,iBAAiB,MAAM,WAAmC,CAAC;AACpF,eAAO,MAAM,OAAO,oBADsB,MAAM,WACjB,CAAC"}
@@ -0,0 +1,15 @@
1
+ // packages/tgd-core/src/contract/names.ts
2
+ export const COOKIE_VID = 'tgd_vid'; // host-only, 400 days, set by the edge only (A9)
3
+ export const COOKIE_VID_REFRESH = 'tgd_vr'; // daily re-issue marker
4
+ export const COOKIE_SDK_BOOTSTRAP = 'tgd_xb'; // base64url(JSON) of XbCookieV1 (sdk-api.md §4.3, A17)
5
+ export const STORAGE_CID = 'tgd_cid'; // localStorage UUIDv7 on hosts Tagada does not serve
6
+ export const QUERY_ENTRY_TEST = '_tgx';
7
+ export const QUERY_VID_HANDOFF = '_tgv';
8
+ export const QUERY_DEBUG = 'tgd_debug';
9
+ export const FUNNEL_SESSION_COOKIE = 'tgd-funnel-session-id'; // plugin-sdk cookie, read-only
10
+ // (packages/plugin-sdk/src/v2/core/utils/sessionStorage.ts:6)
11
+ export const ptSnapshotKey = (funnelId, stepId) => `av2:exp:pt:${funnelId}:${stepId}`; // ab-engine.md §1.5
12
+ export const sdkSnapshotKey = (storeId) => `av2:exp:sdk:${storeId}`; // ab-engine.md §1.5, sdk-api.md
13
+ export const fsVidKey = (funnelSessionId) => `av2:fsvid:${funnelSessionId}`; // identity-sessions.md §10.3
14
+ export const kvFsVid = fsVidKey; // spelling of identity-sessions.md §1.1; code imports fsVidKey
15
+ //# sourceMappingURL=names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"names.js","sourceRoot":"","sources":["../../../src/tgd/contract/names.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,CAAY,iDAAiD;AACjG,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,CAAK,wBAAwB;AACxE,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC,CAAG,uDAAuD;AACvG,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,CAAW,qDAAqD;AACrG,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACxC,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC;AACvC,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC,CAAC,+BAA+B;AAC9B,8DAA8D;AAC7H,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAE,MAAc,EAAE,EAAE,CAAC,cAAc,QAAQ,IAAI,MAAM,EAAE,CAAC,CAAC,oBAAoB;AAC3H,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,eAAe,OAAO,EAAE,CAAC,CAA8B,gCAAgC;AAC1I,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,eAAuB,EAAE,EAAE,CAAC,aAAa,eAAe,EAAE,CAAC,CAAqB,6BAA6B;AACtI,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,+DAA+D"}
@@ -0,0 +1,116 @@
1
+ import type { TgdEventV1, TgdBrowserIds, JsonScalar } from './envelope.js';
2
+ export declare const EMAIL_EVENT_NAMES: readonly ["email_sent", "email_delivered", "email_bounced", "email_complained", "email_opened", "email_clicked", "email_unsubscribed"];
3
+ export declare const EMAIL_REQUIRED_PROPS: readonly ["message_id", "campaign_id", "template_id", "variant", "email_sha256", "provider"];
4
+ export interface EmailBaseProps {
5
+ message_id: string;
6
+ campaign_id: string;
7
+ template_id: string;
8
+ variant: string;
9
+ email_sha256: string;
10
+ provider: 'resend';
11
+ exp_id?: string;
12
+ provider_message_id?: string;
13
+ }
14
+ export declare const EVENT_NAMES: readonly ["page_view", "page_leave", "outbound_click", "web_vital", "funnel_session_linked", "funnel_session_started", "funnel_step_viewed", "funnel_step_entered", "checkout_started", "checkout_email_entered", "payment_attempted", "order_completed", "subscription_created", "subscription_canceled", "subscription_rebilled", "experiment_exposed", "feature_flag_called", "identify", "custom", "email_sent", "email_delivered", "email_bounced", "email_complained", "email_opened", "email_clicked", "email_unsubscribed"];
15
+ export type EventName = (typeof EVENT_NAMES)[number];
16
+ export declare const COLLECTABLE_EVENT_NAMES: readonly ["page_view", "page_leave", "outbound_click", "web_vital", "funnel_session_linked", "experiment_exposed", "feature_flag_called", "identify", "custom"];
17
+ export declare const SERVER_ONLY_EVENT_NAMES: readonly ["funnel_session_started", "funnel_step_viewed", "funnel_step_entered", "checkout_started", "checkout_email_entered", "payment_attempted", "order_completed", "subscription_created", "subscription_canceled", "subscription_rebilled", "email_sent", "email_delivered", "email_bounced", "email_complained", "email_opened", "email_clicked", "email_unsubscribed"];
18
+ /** node-sdk /server-events accepts only these. */
19
+ export declare const SERVER_EVENTS_ACCEPTED_NAMES: readonly ["custom", "identify", "experiment_exposed", "feature_flag_called"];
20
+ /** track(name) with one of these names is refused by the SDKs (debug log only) and never becomes custom_name. */
21
+ export declare const RESERVED_EVENT_NAMES: readonly ["page_view", "page_leave", "outbound_click", "web_vital", "funnel_session_linked", "funnel_session_started", "funnel_step_viewed", "funnel_step_entered", "checkout_started", "checkout_email_entered", "payment_attempted", "order_completed", "subscription_created", "subscription_canceled", "subscription_rebilled", "experiment_exposed", "feature_flag_called", "identify", "custom", "email_sent", "email_delivered", "email_bounced", "email_complained", "email_opened", "email_clicked", "email_unsubscribed"];
22
+ export interface EventSpec {
23
+ class: 'behavior' | 'fact' | 'both';
24
+ collectable: boolean;
25
+ requiredFields: readonly (keyof TgdEventV1)[];
26
+ requiredProps: readonly string[];
27
+ }
28
+ export declare const EVENT_REGISTRY: {
29
+ readonly [N in EventName]: EventSpec;
30
+ };
31
+ export interface EventPropsMap {
32
+ page_view: {
33
+ ids?: TgdBrowserIds;
34
+ prev_page_view_id?: string;
35
+ prev_path?: string;
36
+ prev_duration_s?: number;
37
+ };
38
+ page_leave: {
39
+ engaged_ms: number;
40
+ max_scroll_pct: number;
41
+ };
42
+ outbound_click: {
43
+ href: string;
44
+ target_host: string;
45
+ };
46
+ web_vital: {
47
+ metric: 'LCP' | 'INP' | 'CLS';
48
+ value: number;
49
+ rating: 'good' | 'needs-improvement' | 'poor';
50
+ };
51
+ funnel_session_linked: {
52
+ previous_funnel_session_id?: string;
53
+ };
54
+ funnel_session_started: {
55
+ entry: true;
56
+ funnel_variant_id?: string;
57
+ };
58
+ funnel_step_viewed: {
59
+ is_entry: boolean;
60
+ funnel_variant_id?: string;
61
+ };
62
+ funnel_step_entered: {
63
+ nav_path: 'sync' | 'async' | 'qstash' | 'action';
64
+ };
65
+ checkout_started: {
66
+ ids: TgdBrowserIds;
67
+ };
68
+ checkout_email_entered: {
69
+ email_sha256: string;
70
+ };
71
+ payment_attempted: {
72
+ outcome: 'succeeded' | 'declined' | 'rejected';
73
+ processor_type?: string;
74
+ error_code?: string;
75
+ };
76
+ order_completed: {
77
+ is_returning?: boolean;
78
+ line_count?: number;
79
+ kind?: 'first_order' | 'upsell' | 'rebill';
80
+ };
81
+ subscription_created: {
82
+ price_id?: string;
83
+ };
84
+ subscription_canceled: {
85
+ cancel_reason?: string;
86
+ };
87
+ subscription_rebilled: Record<string, never>;
88
+ experiment_exposed: {
89
+ surface: 'canvas' | 'entry' | 'sdk' | 'node' | 'email';
90
+ exp_key?: string;
91
+ };
92
+ feature_flag_called: {
93
+ flag: string;
94
+ value: string | boolean;
95
+ has_payload?: boolean;
96
+ };
97
+ identify: {
98
+ email_sha256?: string;
99
+ phone_sha256?: string;
100
+ traits?: Record<string, JsonScalar>;
101
+ };
102
+ custom: Record<string, JsonScalar | JsonScalar[]>;
103
+ email_sent: EmailBaseProps;
104
+ email_delivered: EmailBaseProps;
105
+ email_bounced: EmailBaseProps & {
106
+ bounce_type: 'Permanent' | 'Transient';
107
+ };
108
+ email_complained: EmailBaseProps;
109
+ email_opened: EmailBaseProps;
110
+ email_clicked: EmailBaseProps & {
111
+ link_index: number;
112
+ target_host: string;
113
+ };
114
+ email_unsubscribed: EmailBaseProps;
115
+ }
116
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/tgd/contract/registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3E,eAAO,MAAM,iBAAiB,wIAGpB,CAAC;AACX,eAAO,MAAM,oBAAoB,8FAEvB,CAAC;AAEX,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,WAAW,qgBAMd,CAA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ACtF,QAAQ,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;KAAE,CAAC;IAChG,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,EAAE,CAAC,CAAC;IAClD,UAAU,EAAE,cAAc,CAAC;IAC3B,eAAe,EAAE,cAAc,CAAC;IAChC,aAAa,EAAE,cAAc,GAAG;QAAE,WAAW,EAAE,WAAW,GAAG,WAAW,CAAA;KAAE,CAAC;IAC3E,gBAAgB,EAAE,cAAc,CAAC;IACjC,YAAY,EAAE,cAAc,CAAC;IAC7B,aAAa,EAAE,cAAc,GAAG;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5E,kBAAkB,EAAE,cAAc,CAAC;CACpC"}
@@ -0,0 +1,59 @@
1
+ export const EMAIL_EVENT_NAMES = [
2
+ 'email_sent', 'email_delivered', 'email_bounced', 'email_complained',
3
+ 'email_opened', 'email_clicked', 'email_unsubscribed',
4
+ ];
5
+ export const EMAIL_REQUIRED_PROPS = [
6
+ 'message_id', 'campaign_id', 'template_id', 'variant', 'email_sha256', 'provider',
7
+ ];
8
+ export const EVENT_NAMES = [
9
+ 'page_view', 'page_leave', 'outbound_click', 'web_vital', 'funnel_session_linked',
10
+ 'funnel_session_started', 'funnel_step_viewed', 'funnel_step_entered', 'checkout_started',
11
+ 'checkout_email_entered', 'payment_attempted', 'order_completed', 'subscription_created',
12
+ 'subscription_canceled', 'subscription_rebilled', 'experiment_exposed', 'feature_flag_called',
13
+ 'identify', 'custom', ...EMAIL_EVENT_NAMES,
14
+ ];
15
+ export const COLLECTABLE_EVENT_NAMES = [
16
+ 'page_view', 'page_leave', 'outbound_click', 'web_vital', 'funnel_session_linked',
17
+ 'experiment_exposed', 'feature_flag_called', 'identify', 'custom',
18
+ ];
19
+ export const SERVER_ONLY_EVENT_NAMES = [
20
+ 'funnel_session_started', 'funnel_step_viewed', 'funnel_step_entered', 'checkout_started',
21
+ 'checkout_email_entered', 'payment_attempted', 'order_completed', 'subscription_created',
22
+ 'subscription_canceled', 'subscription_rebilled',
23
+ ...EMAIL_EVENT_NAMES,
24
+ ];
25
+ /** node-sdk /server-events accepts only these. */
26
+ export const SERVER_EVENTS_ACCEPTED_NAMES = ['custom', 'identify', 'experiment_exposed', 'feature_flag_called'];
27
+ /** track(name) with one of these names is refused by the SDKs (debug log only) and never becomes custom_name. */
28
+ export const RESERVED_EVENT_NAMES = EVENT_NAMES;
29
+ const b = (requiredFields, requiredProps = []) => ({ class: 'behavior', collectable: true, requiredFields, requiredProps });
30
+ const f = (requiredFields, requiredProps = []) => ({ class: 'fact', collectable: false, requiredFields, requiredProps });
31
+ export const EVENT_REGISTRY = {
32
+ page_view: b(['url', 'page_view_id']), // props.ids required from tgd.js only (P1-L7 test), not from headless/loadgen
33
+ page_leave: b(['page_view_id', 'url'], ['engaged_ms', 'max_scroll_pct']),
34
+ outbound_click: b(['page_view_id'], ['href', 'target_host']),
35
+ web_vital: b(['page_view_id'], ['metric', 'value', 'rating']),
36
+ funnel_session_linked: b(['funnel_session_id']),
37
+ funnel_session_started: f(['funnel_session_id', 'funnel_id', 'step_id'], ['entry']),
38
+ funnel_step_viewed: f(['funnel_session_id', 'funnel_id', 'step_id'], ['is_entry']),
39
+ funnel_step_entered: f(['funnel_session_id', 'funnel_id', 'step_id'], ['nav_path']),
40
+ checkout_started: f(['checkout_session_id'], ['ids']),
41
+ checkout_email_entered: f(['checkout_session_id', 'customer_id'], ['email_sha256']),
42
+ payment_attempted: f(['payment_id', 'value_minor', 'currency'], ['outcome']),
43
+ order_completed: f(['order_id', 'payment_id', 'value_minor', 'currency']),
44
+ subscription_created: f(['subscription_id']),
45
+ subscription_canceled: f(['subscription_id']),
46
+ subscription_rebilled: f(['subscription_id', 'payment_id', 'value_minor', 'currency']),
47
+ experiment_exposed: { class: 'both', collectable: true, requiredFields: ['exp_id', 'exp_phase', 'arm', 'unit_type'], requiredProps: ['surface'] },
48
+ feature_flag_called: b([], ['flag', 'value']),
49
+ identify: b(['external_id']),
50
+ custom: b(['custom_name']),
51
+ email_sent: f([], EMAIL_REQUIRED_PROPS),
52
+ email_delivered: f([], EMAIL_REQUIRED_PROPS),
53
+ email_bounced: f([], [...EMAIL_REQUIRED_PROPS, 'bounce_type']),
54
+ email_complained: f([], EMAIL_REQUIRED_PROPS),
55
+ email_opened: f([], EMAIL_REQUIRED_PROPS),
56
+ email_clicked: f(['url'], [...EMAIL_REQUIRED_PROPS, 'link_index', 'target_host']),
57
+ email_unsubscribed: f([], EMAIL_REQUIRED_PROPS),
58
+ };
59
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/tgd/contract/registry.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,kBAAkB;IACpE,cAAc,EAAE,eAAe,EAAE,oBAAoB;CAC7C,CAAC;AACX,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU;CACzE,CAAC;AAaX,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,uBAAuB;IACjF,wBAAwB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,kBAAkB;IACzF,wBAAwB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,sBAAsB;IACxF,uBAAuB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,qBAAqB;IAC7F,UAAU,EAAE,QAAQ,EAAE,GAAG,iBAAiB;CAClC,CAAC;AAGX,MAAM,CAAC,MAAM,uBAAu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EAAE;IACjJ,mBAAmB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,QAAQ,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;IAC5B,MAAM,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;IAC1B,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,oBAAoB,CAAC;IACvC,eAAe,EAAE,CAAC,CAAC,EAAE,EAAE,oBAAoB,CAAC;IAC5C,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,oBAAoB,EAAE,aAAa,CAAC,CAAC;IAC9D,gBAAgB,EAAE,CAAC,CAAC,EAAE,EAAE,oBAAoB,CAAC;IAC7C,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,oBAAoB,CAAC;IACzC,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,oBAAoB,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;IACjF,kBAAkB,EAAE,CAAC,CAAC,EAAE,EAAE,oBAAoB,CAAC;CAChD,CAAC"}
@@ -0,0 +1,33 @@
1
+ export declare const vidSigningInput: (vid: string) => string;
2
+ export declare const tgxSigningInput: (expId: string, phase: number, arm: string, vid: string) => string;
3
+ export declare const tgvSigningInput: (vid: string, expSec: number) => string;
4
+ export declare function formatVid(vid: string, mac: string): string;
5
+ export declare function parseVid(raw: string): {
6
+ vid: string;
7
+ mac: string;
8
+ } | null;
9
+ export declare function formatTgx(p: {
10
+ expId: string;
11
+ phase: number;
12
+ arm: string;
13
+ vid: string;
14
+ mac: string;
15
+ }): string;
16
+ export declare function parseTgx(raw: string): {
17
+ expId: string;
18
+ phase: number;
19
+ arm: string;
20
+ vid: string;
21
+ mac: string;
22
+ } | null;
23
+ export declare function formatTgv(p: {
24
+ vid: string;
25
+ expSec: number;
26
+ mac: string;
27
+ }): string;
28
+ export declare function parseTgv(raw: string): {
29
+ vid: string;
30
+ expSec: number;
31
+ mac: string;
32
+ } | null;
33
+ //# sourceMappingURL=signed-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signed-ids.d.ts","sourceRoot":"","sources":["../../../src/tgd/contract/signed-ids.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,WAAwB,CAAC;AACpE,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,WACxC,CAAC;AAC/C,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,EAAE,QAAQ,MAAM,WAAkC,CAAC;AAI9F,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAA+B;AAC1F,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAGzE;AACD,wBAAgB,SAAS,CAAC,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAE5G;AACD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAIpH;AACD,wBAAgB,SAAS,CAAC,CAAC,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAA4C;AAC9H,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAGzF"}
@@ -0,0 +1,26 @@
1
+ // packages/tgd-core/src/contract/signed-ids.ts
2
+ export const vidSigningInput = (vid) => `tgd_vid|v1|${vid}`;
3
+ export const tgxSigningInput = (expId, phase, arm, vid) => `tgd_tgx|v1|${expId}|${phase}|${arm}|${vid}`;
4
+ export const tgvSigningInput = (vid, expSec) => `tgd_tgv|v1|${vid}|${expSec}`;
5
+ const VID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
6
+ const MAC_RE = /^[A-Za-z0-9_-]{22}$/;
7
+ export function formatVid(vid, mac) { return `v1.${vid}.${mac}`; }
8
+ export function parseVid(raw) {
9
+ const p = raw.split('.');
10
+ return p.length === 3 && p[0] === 'v1' && VID_RE.test(p[1]) && MAC_RE.test(p[2]) ? { vid: p[1], mac: p[2] } : null;
11
+ }
12
+ export function formatTgx(p) {
13
+ return `${p.expId}.${p.phase}.${p.arm}.${p.vid}.${p.mac}`;
14
+ }
15
+ export function parseTgx(raw) {
16
+ const p = raw.split('.');
17
+ if (p.length !== 5 || !/^[a-z0-9]+_[0-9a-f]{12}$/.test(p[0]) || !/^[1-9][0-9]*$/.test(p[1]) || !Number.isSafeInteger(Number(p[1])) || !/^[a-z0-9_-]{1,32}$/.test(p[2]) || !VID_RE.test(p[3]) || !MAC_RE.test(p[4]))
18
+ return null;
19
+ return { expId: p[0], phase: Number(p[1]), arm: p[2], vid: p[3], mac: p[4] };
20
+ }
21
+ export function formatTgv(p) { return `${p.vid}.${p.expSec}.${p.mac}`; }
22
+ export function parseTgv(raw) {
23
+ const p = raw.split('.');
24
+ return p.length === 3 && VID_RE.test(p[0]) && /^[0-9]{1,12}$/.test(p[1]) && MAC_RE.test(p[2]) ? { vid: p[0], expSec: Number(p[1]), mac: p[2] } : null;
25
+ }
26
+ //# sourceMappingURL=signed-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signed-ids.js","sourceRoot":"","sources":["../../../src/tgd/contract/signed-ids.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,cAAc,GAAG,EAAE,CAAC;AACpE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAa,EAAE,KAAa,EAAE,GAAW,EAAE,GAAW,EAAE,EAAE,CACxF,cAAc,KAAK,IAAI,KAAK,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;AAC/C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,MAAc,EAAE,EAAE,CAAC,cAAc,GAAG,IAAI,MAAM,EAAE,CAAC;AAE9F,MAAM,MAAM,GAAG,uEAAuE,CAAC;AACvF,MAAM,MAAM,GAAG,qBAAqB,CAAC;AACrC,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,GAAW,IAAY,OAAO,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;AAC1F,MAAM,UAAU,QAAQ,CAAC,GAAW;IACnC,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACpH,CAAC;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ACnC,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACvJ,CAAC"}
@@ -0,0 +1,69 @@
1
+ import type { TargetingCondition } from './experiments.js';
2
+ import type { JsonValue } from './envelope.js';
3
+ export interface PageTestSnapshot {
4
+ v: 1;
5
+ experimentId: string;
6
+ funnelId: string;
7
+ stepId: string;
8
+ status: 'running' | 'shipped';
9
+ phase: number;
10
+ seed: string;
11
+ controlArm: string;
12
+ shippedArm: string | null;
13
+ arms: Array<{
14
+ key: string;
15
+ weightBp: number;
16
+ nodeId: string;
17
+ path: string;
18
+ productionPath: string | null;
19
+ }>;
20
+ holdoutBp: number;
21
+ targeting: TargetingCondition[];
22
+ namespace: {
23
+ name: string;
24
+ startBp: number;
25
+ endBp: number;
26
+ } | null;
27
+ publishedAt: string;
28
+ }
29
+ export interface SdkSnapshot {
30
+ v: 1;
31
+ storeId: string;
32
+ hashVersion: 2;
33
+ publishedAt: string;
34
+ experiments: Array<{
35
+ id: string;
36
+ key: string;
37
+ status: 'running' | 'shipped';
38
+ phase: number;
39
+ seed: string;
40
+ unitType: 'visitor' | 'external';
41
+ controlArm: string;
42
+ shippedArm: string | null;
43
+ arms: Array<{
44
+ key: string;
45
+ weightBp: number;
46
+ payload: JsonValue | null;
47
+ }>;
48
+ holdoutBp: number;
49
+ namespace: {
50
+ name: string;
51
+ startBp: number;
52
+ endBp: number;
53
+ } | null;
54
+ targeting: TargetingCondition[];
55
+ }>;
56
+ flags: Array<{
57
+ id: string;
58
+ key: string;
59
+ kind: 'boolean' | 'multivariate';
60
+ rolloutBp: number;
61
+ conditions: TargetingCondition[];
62
+ variants: Array<{
63
+ key: string;
64
+ weightBp: number;
65
+ payload: JsonValue | null;
66
+ }>;
67
+ }>;
68
+ }
69
+ //# sourceMappingURL=snapshots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshots.d.ts","sourceRoot":"","sources":["../../../src/tgd/contract/snapshots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,WAAW,gBAAgB;IAC/B,CAAC,EAAE,CAAC,CAAC;IACL,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,KAAK,CAAC;QACV,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;KAC/B,CAAC,CAAC;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,SAAS,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAA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;SAAE,CAAC,CAAC;KAC/E,CAAC,CAAC;CACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=snapshots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshots.js","sourceRoot":"","sources":["../../../src/tgd/contract/snapshots.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ export declare function correctTimestamp(input: {
2
+ createdAt: number;
3
+ sentAt: number;
4
+ receivedAt: number;
5
+ }): {
6
+ ts: number;
7
+ isLate: 0 | 1;
8
+ };
9
+ //# sourceMappingURL=time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../src/tgd/contract/time.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC/F;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAA;CAAE,CAK9B"}
@@ -0,0 +1,9 @@
1
+ // packages/tgd-core/src/contract/time.ts
2
+ import { SKEW_DEADBAND_MS, LATE_AFTER_MS } from './limits.js';
3
+ export function correctTimestamp(input) {
4
+ const rawSkew = input.receivedAt - input.sentAt;
5
+ const skew = Math.abs(rawSkew) <= SKEW_DEADBAND_MS ? 0 : rawSkew;
6
+ const ts = Math.min(input.createdAt + skew, input.receivedAt);
7
+ return { ts, isLate: input.receivedAt - ts > LATE_AFTER_MS ? 1 : 0 };
8
+ }
9
+ //# sourceMappingURL=time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.js","sourceRoot":"","sources":["../../../src/tgd/contract/time.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9D,MAAM,UAAU,gBAAgB,CAAC,KAAgE;IAE/F,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC;IAChD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACjE,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,UAAU,GAAG,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACvE,CAAC"}
@@ -0,0 +1,21 @@
1
+ export declare const SOURCES: readonly ["browser", "headless", "server", "legacy", "loadgen", "seed", "synthetic"];
2
+ export declare const ID_KINDS: readonly ["edge", "client", "external", "legacy", "none"];
3
+ export declare const SESSION_ORIGINS: readonly ["browser", "server"];
4
+ export declare const EVENT_CLASSES: readonly ["behavior", "fact"];
5
+ export declare const SDK_NAMES: readonly ["tgd", "headless", "node", "loadgen", "emit_fact", "ledger", "v1_adapter", "backfill", "seed", "synthetic"];
6
+ export declare const TRAFFIC_CLASSES: readonly ["human", "bot", "ai_agent", "automation", "prefetch"];
7
+ export declare const BOT_CATEGORIES: readonly ["", "search_crawler", "ai_crawler", "monitoring", "seo_crawler", "social_crawler", "http_client", "ai_assistant", "headless_browser", "ai_search", "no_user_agent", "ip_range", "unknown_bot", "prefetch"];
8
+ export declare const UNIT_TYPES: readonly ["visitor", "customer", "funnel_session", "external"];
9
+ export declare const GOAL_KINDS: readonly ["paid_order", "next_step_reached", "step_reached", "revenue", "upsell_accepted", "event_count", "event_value_sum"];
10
+ export declare const GUARDRAIL_KINDS: readonly ["payment_failure_rate", "refund_rate", "dispute_rate", "bounce_rate", "complaint_rate", "unsubscribe_rate"];
11
+ export type Source = (typeof SOURCES)[number];
12
+ export type IdKind = (typeof ID_KINDS)[number];
13
+ export type SessionOrigin = (typeof SESSION_ORIGINS)[number];
14
+ export type EventClass = (typeof EVENT_CLASSES)[number];
15
+ export type SdkName = (typeof SDK_NAMES)[number];
16
+ export type TrafficClass = (typeof TRAFFIC_CLASSES)[number];
17
+ export type BotCategory = (typeof BOT_CATEGORIES)[number];
18
+ export type UnitType = (typeof UNIT_TYPES)[number];
19
+ export type GoalKind = (typeof GOAL_KINDS)[number];
20
+ export type GuardrailKind = (typeof GUARDRAIL_KINDS)[number];
21
+ //# sourceMappingURL=unions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unions.d.ts","sourceRoot":"","sources":["../../../src/tgd/contract/unions.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,sFAAuF,CAAC;AAC5G,eAAO,MAAM,QAAQ,2DAA4D,CAAC;AAClF,eAAO,MAAM,eAAe,gCAAiC,CAAC;AAC9D,eAAO,MAAM,aAAa,+BAAgC,CAAC;AAC3D,eAAO,MAAM,SAAS,uHAAwH,CAAC;AAC/I,eAAO,MAAM,eAAe,iEAAkE,CAAC;AAC/F,eAAO,MAAM,cAAc,sNAGjB,CAAC;AACX,eAAO,MAAM,UAAU,gEAAiE,CAAC;AACzF,eAAO,MAAM,UAAU,8HAEb,CAAC;AACX,eAAO,MAAM,eAAe,uHAAwH,CAAC;AAErJ,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAC9C,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAC/C,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAC7D,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AACxD,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AACjD,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAC5D,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAC1D,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AACnD,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AACnD,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ // packages/tgd-core/src/contract/unions.ts
2
+ export const SOURCES = ['browser', 'headless', 'server', 'legacy', 'loadgen', 'seed', 'synthetic'];
3
+ export const ID_KINDS = ['edge', 'client', 'external', 'legacy', 'none'];
4
+ export const SESSION_ORIGINS = ['browser', 'server'];
5
+ export const EVENT_CLASSES = ['behavior', 'fact'];
6
+ export const SDK_NAMES = ['tgd', 'headless', 'node', 'loadgen', 'emit_fact', 'ledger', 'v1_adapter', 'backfill', 'seed', 'synthetic'];
7
+ export const TRAFFIC_CLASSES = ['human', 'bot', 'ai_agent', 'automation', 'prefetch'];
8
+ export const BOT_CATEGORIES = [
9
+ '', 'search_crawler', 'ai_crawler', 'monitoring', 'seo_crawler', 'social_crawler', 'http_client',
10
+ 'ai_assistant', 'headless_browser', 'ai_search', 'no_user_agent', 'ip_range', 'unknown_bot', 'prefetch',
11
+ ];
12
+ export const UNIT_TYPES = ['visitor', 'customer', 'funnel_session', 'external'];
13
+ export const GOAL_KINDS = [
14
+ 'paid_order', 'next_step_reached', 'step_reached', 'revenue', 'upsell_accepted', 'event_count', 'event_value_sum',
15
+ ];
16
+ export const GUARDRAIL_KINDS = ['payment_failure_rate', 'refund_rate', 'dispute_rate', 'bounce_rate', 'complaint_rate', 'unsubscribe_r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BAAiB,EAAE,aAAa,EAAE,iBAAiB;CACzG,CAAC;AACX,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,sBAAsB,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,kBAAkB,CAAU,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { UnitType } from './unions.js';
2
+ export interface UnitInput {
3
+ tgdVid?: string | null;
4
+ customerId?: string | null;
5
+ funnelSessionId?: string | null;
6
+ externalId?: string | null;
7
+ }
8
+ export declare function resolveExperimentUnit(i: UnitInput): {
9
+ unitType: UnitType;
10
+ unitId: string;
11
+ } | null;
12
+ //# sourceMappingURL=unit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit.d.ts","sourceRoot":"","sources":["../../../src/tgd/contract/unit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,SAAS;IAAG,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE;AAG9I,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,SAAS,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAMjG"}
@@ -0,0 +1,18 @@
1
+ import { isJunkId } from './junk-ids.js';
2
+ const pick = (v) => typeof v === 'string' && v.trim() !== '' && !isJunkId(v) ? v.trim() : null;
3
+ export function resolveExperimentUnit(i) {
4
+ const vid = pick(i.tgdVid);
5
+ if (vid)
6
+ return { unitType: 'visitor', unitId: vid.toLowerCase() };
7
+ const cus = pick(i.customerId);
8
+ if (cus)
9
+ return { unitType: 'customer', unitId: cus };
10
+ const fs = pick(i.funnelSessionId);
11
+ if (fs)
12
+ return { unitType: 'funnel_session', unitId: fs };
13
+ const ext = pick(i.externalId);
14
+ if (ext)
15
+ return { unitType: 'external', unitId: ext };
16
+ return null;
17
+ }
18
+ //# sourceMappingURL=unit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit.js","sourceRoot":"","sources":["../../../src/tgd/contract/unit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,IAAI,GAAG,CAAC,CAAiB,EAAiB,EAAE,CAChD,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7E,MAAM,UAAU,qBAAqB,CAAC,CAAY;IAChD,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAAC,IAAI,GAAG;QAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC;IAC/F,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAAC,IAAI,GAAG;QAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IACtF,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;IAAC,IAAI,EAAE;QAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAC9F,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAAC,IAAI,GAAG;QAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IACtF,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,59 @@
1
+ import type { JsonValue } from './envelope.js';
2
+ import type { SdkSnapshot } from './snapshots.js';
3
+ export interface AssignResponse {
4
+ enabled: boolean;
5
+ /** experiment key -> arm, and flag key -> variant key, or null ("render your default"): ab-engine.md §2.5, example ab-engine.md §11.1 */
6
+ variants: Record<string, string | null>;
7
+ experiments: Record<string, {
8
+ id: string;
9
+ phase: number;
10
+ arm: string | null;
11
+ inExperiment: boolean;
12
+ unitType: 'visitor' | 'external';
13
+ payload: JsonValue | null;
14
+ }>;
15
+ flags: Record<string, {
16
+ id: string;
17
+ enabled: boolean;
18
+ variant: string | null;
19
+ payload: JsonValue | null;
20
+ }>;
21
+ }
22
+ export interface ExperimentsConfigResponse {
23
+ enabled: boolean;
24
+ experiments: SdkSnapshot['experiments'];
25
+ flags: SdkSnapshot['flags'];
26
+ publishedAt?: string;
27
+ }
28
+ export interface ServerEventsBatchV1 {
29
+ v: 1;
30
+ batch_id: string;
31
+ sent_at: number;
32
+ store_id: string;
33
+ sdk: {
34
+ name: 'node';
35
+ version: string;
36
+ };
37
+ events: Array<{
38
+ event_id?: string;
39
+ idempotency_key?: string;
40
+ event_name: 'custom' | 'identify' | 'experiment_exposed' | 'feature_flag_called';
41
+ custom_name?: string;
42
+ created_at: number;
43
+ external_id?: string;
44
+ exp_id?: string;
45
+ exp_phase?: number;
46
+ arm?: string;
47
+ unit_type?: 'external';
48
+ ip?: string;
49
+ user_agent?: string;
50
+ props?: Record<string, JsonValue>;
51
+ }>;
52
+ }
53
+ export type LoaderConfigResponse = {
54
+ enabled: false;
55
+ } | {
56
+ enabled: true;
57
+ script: string;
58
+ };
59
+ //# sourceMappingURL=wire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../../src/tgd/contract/wire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAA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