@c15t/scripts 2.0.1 → 2.2.0-canary-20260727202135

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 (182) hide show
  1. package/AGENTS.md +62 -0
  2. package/README.md +41 -29
  3. package/dist/e2e-test-utils.cjs +51 -10
  4. package/dist/e2e-test-utils.js +37 -3
  5. package/dist/engine/compile.cjs +9 -5
  6. package/dist/engine/runtime.cjs +111 -17
  7. package/dist/engine/runtime.js +102 -12
  8. package/dist/registry.cjs +423 -0
  9. package/dist/registry.js +372 -0
  10. package/dist/resolve.cjs +9 -5
  11. package/dist/types.cjs +32 -10
  12. package/dist/types.js +10 -1
  13. package/dist/vendors/_shared/attributes.cjs +55 -0
  14. package/dist/vendors/_shared/attributes.js +14 -0
  15. package/dist/vendors/_shared/google-consent.cjs +69 -0
  16. package/dist/vendors/_shared/google-consent.js +27 -0
  17. package/dist/vendors/_shared/install-builders.cjs +59 -0
  18. package/dist/vendors/_shared/install-builders.js +21 -0
  19. package/dist/vendors/_shared/script-url.cjs +78 -0
  20. package/dist/vendors/_shared/script-url.js +28 -0
  21. package/dist/{linkedin-insights.cjs → vendors/ads-and-pixels/linkedin-insights.cjs} +11 -7
  22. package/dist/{linkedin-insights.js → vendors/ads-and-pixels/linkedin-insights.js} +2 -2
  23. package/dist/vendors/ads-and-pixels/meta-pixel.cjs +206 -0
  24. package/dist/vendors/ads-and-pixels/meta-pixel.js +153 -0
  25. package/dist/{microsoft-uet.cjs → vendors/ads-and-pixels/microsoft-uet.cjs} +42 -21
  26. package/dist/{microsoft-uet.js → vendors/ads-and-pixels/microsoft-uet.js} +31 -14
  27. package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +151 -0
  28. package/dist/vendors/ads-and-pixels/reddit-pixel.js +107 -0
  29. package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +131 -0
  30. package/dist/vendors/ads-and-pixels/snapchat-pixel.js +87 -0
  31. package/dist/{tiktok-pixel.cjs → vendors/ads-and-pixels/tiktok-pixel.cjs} +11 -7
  32. package/dist/{tiktok-pixel.js → vendors/ads-and-pixels/tiktok-pixel.js} +2 -2
  33. package/dist/{x-pixel.cjs → vendors/ads-and-pixels/x-pixel.cjs} +15 -8
  34. package/dist/{x-pixel.js → vendors/ads-and-pixels/x-pixel.js} +6 -3
  35. package/dist/vendors/analytics/adobe-analytics.cjs +90 -0
  36. package/dist/vendors/analytics/adobe-analytics.js +49 -0
  37. package/dist/vendors/analytics/ahrefs-analytics.cjs +68 -0
  38. package/dist/vendors/analytics/ahrefs-analytics.js +27 -0
  39. package/dist/vendors/analytics/amplitude.cjs +193 -0
  40. package/dist/vendors/analytics/amplitude.js +134 -0
  41. package/dist/vendors/analytics/clearbit.cjs +69 -0
  42. package/dist/vendors/analytics/clearbit.js +28 -0
  43. package/dist/vendors/analytics/cloudflare-web-analytics.cjs +73 -0
  44. package/dist/vendors/analytics/cloudflare-web-analytics.js +32 -0
  45. package/dist/{databuddy.cjs → vendors/analytics/databuddy.cjs} +14 -10
  46. package/dist/{databuddy.js → vendors/analytics/databuddy.js} +3 -3
  47. package/dist/vendors/analytics/fathom-analytics.cjs +76 -0
  48. package/dist/vendors/analytics/fathom-analytics.js +35 -0
  49. package/dist/{google-tag.cjs → vendors/analytics/google-tag.cjs} +18 -35
  50. package/dist/{google-tag.js → vendors/analytics/google-tag.js} +7 -28
  51. package/dist/vendors/analytics/heap.cjs +181 -0
  52. package/dist/vendors/analytics/heap.js +134 -0
  53. package/dist/vendors/analytics/hightouch.cjs +153 -0
  54. package/dist/vendors/analytics/hightouch.js +109 -0
  55. package/dist/vendors/analytics/hotjar.cjs +85 -0
  56. package/dist/vendors/analytics/hotjar.js +44 -0
  57. package/dist/vendors/analytics/logrocket.cjs +99 -0
  58. package/dist/vendors/analytics/logrocket.js +58 -0
  59. package/dist/vendors/analytics/matomo-analytics.cjs +232 -0
  60. package/dist/vendors/analytics/matomo-analytics.js +191 -0
  61. package/dist/vendors/analytics/microsoft-clarity.cjs +138 -0
  62. package/dist/vendors/analytics/microsoft-clarity.js +97 -0
  63. package/dist/vendors/analytics/mixpanel-analytics.cjs +134 -0
  64. package/dist/vendors/analytics/mixpanel-analytics.js +93 -0
  65. package/dist/vendors/analytics/pirsch.cjs +108 -0
  66. package/dist/vendors/analytics/pirsch.js +67 -0
  67. package/dist/vendors/analytics/plausible-analytics.cjs +122 -0
  68. package/dist/vendors/analytics/plausible-analytics.js +81 -0
  69. package/dist/vendors/analytics/posthog.cjs +204 -0
  70. package/dist/vendors/analytics/posthog.js +163 -0
  71. package/dist/vendors/analytics/promptwatch.cjs +70 -0
  72. package/dist/vendors/analytics/promptwatch.js +29 -0
  73. package/dist/vendors/analytics/rudderstack.cjs +227 -0
  74. package/dist/vendors/analytics/rudderstack.js +183 -0
  75. package/dist/vendors/analytics/rybbit-analytics.cjs +104 -0
  76. package/dist/vendors/analytics/rybbit-analytics.js +63 -0
  77. package/dist/vendors/analytics/segment.cjs +97 -0
  78. package/dist/vendors/analytics/segment.js +56 -0
  79. package/dist/vendors/analytics/umami-analytics.cjs +80 -0
  80. package/dist/vendors/analytics/umami-analytics.js +39 -0
  81. package/dist/vendors/analytics/vercel-analytics.cjs +94 -0
  82. package/dist/vendors/analytics/vercel-analytics.js +53 -0
  83. package/dist/vendors/functional/crisp.cjs +143 -0
  84. package/dist/vendors/functional/crisp.js +102 -0
  85. package/dist/vendors/functional/intercom.cjs +89 -0
  86. package/dist/vendors/functional/intercom.js +45 -0
  87. package/dist/{google-tag-manager.cjs → vendors/tag-managers/google-tag-manager.cjs} +17 -34
  88. package/dist/{google-tag-manager.js → vendors/tag-managers/google-tag-manager.js} +6 -27
  89. package/dist-types/__tests__/helpers.d.ts +141 -0
  90. package/dist-types/engine/runtime.d.ts +1 -1
  91. package/dist-types/registry.d.ts +440 -0
  92. package/dist-types/types.d.ts +53 -2
  93. package/dist-types/vendors/_shared/attributes.d.ts +35 -0
  94. package/dist-types/vendors/_shared/google-consent.d.ts +47 -0
  95. package/dist-types/vendors/_shared/install-builders.d.ts +30 -0
  96. package/dist-types/vendors/_shared/script-url.d.ts +75 -0
  97. package/dist-types/vendors/ads-and-pixels/linkedin-insights.d.ts +92 -0
  98. package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +289 -0
  99. package/dist-types/{microsoft-uet.d.ts → vendors/ads-and-pixels/microsoft-uet.d.ts} +45 -34
  100. package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +211 -0
  101. package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +171 -0
  102. package/dist-types/{tiktok-pixel.d.ts → vendors/ads-and-pixels/tiktok-pixel.d.ts} +48 -33
  103. package/dist-types/{x-pixel.d.ts → vendors/ads-and-pixels/x-pixel.d.ts} +34 -17
  104. package/dist-types/vendors/analytics/adobe-analytics.d.ts +75 -0
  105. package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +62 -0
  106. package/dist-types/vendors/analytics/amplitude.d.ts +234 -0
  107. package/dist-types/vendors/analytics/clearbit.d.ts +60 -0
  108. package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +67 -0
  109. package/dist-types/{databuddy.d.ts → vendors/analytics/databuddy.d.ts} +25 -25
  110. package/dist-types/vendors/analytics/fathom-analytics.d.ts +90 -0
  111. package/dist-types/{google-tag.d.ts → vendors/analytics/google-tag.d.ts} +21 -24
  112. package/dist-types/vendors/analytics/heap.d.ts +316 -0
  113. package/dist-types/vendors/analytics/hightouch.d.ts +285 -0
  114. package/dist-types/vendors/analytics/hotjar.d.ts +73 -0
  115. package/dist-types/vendors/analytics/logrocket.d.ts +101 -0
  116. package/dist-types/vendors/analytics/matomo-analytics.d.ts +41 -0
  117. package/dist-types/vendors/analytics/microsoft-clarity.d.ts +98 -0
  118. package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +113 -0
  119. package/dist-types/vendors/analytics/pirsch.d.ts +96 -0
  120. package/dist-types/vendors/analytics/plausible-analytics.d.ts +122 -0
  121. package/dist-types/vendors/analytics/posthog.d.ts +154 -0
  122. package/dist-types/vendors/analytics/promptwatch.d.ts +36 -0
  123. package/dist-types/vendors/analytics/rudderstack.d.ts +330 -0
  124. package/dist-types/vendors/analytics/rybbit-analytics.d.ts +82 -0
  125. package/dist-types/vendors/analytics/segment.d.ts +158 -0
  126. package/dist-types/vendors/analytics/umami-analytics.d.ts +93 -0
  127. package/dist-types/vendors/analytics/vercel-analytics.d.ts +66 -0
  128. package/dist-types/vendors/functional/crisp.d.ts +78 -0
  129. package/dist-types/vendors/functional/intercom.d.ts +135 -0
  130. package/dist-types/{google-tag-manager.d.ts → vendors/tag-managers/google-tag-manager.d.ts} +22 -25
  131. package/docs/README.md +62 -0
  132. package/docs/frameworks/javascript/script-loader.md +354 -0
  133. package/docs/frameworks/next/script-loader.md +499 -0
  134. package/docs/frameworks/react/script-loader.md +553 -0
  135. package/docs/integrations/adobe-analytics.md +160 -0
  136. package/docs/integrations/ahrefs-analytics.md +157 -0
  137. package/docs/integrations/amplitude.md +230 -0
  138. package/docs/integrations/building-integrations.md +239 -0
  139. package/docs/integrations/clearbit.md +130 -0
  140. package/docs/integrations/cloudflare-web-analytics.md +126 -0
  141. package/docs/integrations/crisp.md +140 -0
  142. package/docs/integrations/databuddy.md +205 -0
  143. package/docs/integrations/fathom-analytics.md +150 -0
  144. package/docs/integrations/google-maps.md +263 -0
  145. package/docs/integrations/google-tag-manager.md +154 -0
  146. package/docs/integrations/google-tag.md +134 -0
  147. package/docs/integrations/heap.md +219 -0
  148. package/docs/integrations/hightouch.md +199 -0
  149. package/docs/integrations/hotjar.md +143 -0
  150. package/docs/integrations/intercom.md +144 -0
  151. package/docs/integrations/linkedin-insights.md +161 -0
  152. package/docs/integrations/logrocket.md +175 -0
  153. package/docs/integrations/matomo-analytics.md +171 -0
  154. package/docs/integrations/meta-pixel.md +412 -0
  155. package/docs/integrations/microsoft-clarity.md +173 -0
  156. package/docs/integrations/microsoft-uet.md +156 -0
  157. package/docs/integrations/mixpanel-analytics.md +130 -0
  158. package/docs/integrations/overview.md +149 -0
  159. package/docs/integrations/pirsch.md +142 -0
  160. package/docs/integrations/plausible-analytics.md +154 -0
  161. package/docs/integrations/posthog.md +258 -0
  162. package/docs/integrations/promptwatch.md +121 -0
  163. package/docs/integrations/reddit-pixel.md +241 -0
  164. package/docs/integrations/rudderstack.md +271 -0
  165. package/docs/integrations/rybbit-analytics.md +143 -0
  166. package/docs/integrations/segment.md +146 -0
  167. package/docs/integrations/snapchat-pixel.md +163 -0
  168. package/docs/integrations/tiktok-pixel.md +123 -0
  169. package/docs/integrations/umami-analytics.md +148 -0
  170. package/docs/integrations/vercel-analytics.md +141 -0
  171. package/docs/integrations/x-pixel.md +157 -0
  172. package/docs/integrations/youtube.md +193 -0
  173. package/docs/shared/react/guides/script-loader.md +309 -0
  174. package/package.json +223 -8
  175. package/readme.json +8 -4
  176. package/dist/meta-pixel.cjs +0 -129
  177. package/dist/meta-pixel.js +0 -89
  178. package/dist/posthog.cjs +0 -137
  179. package/dist/posthog.js +0 -100
  180. package/dist-types/linkedin-insights.d.ts +0 -79
  181. package/dist-types/meta-pixel.d.ts +0 -185
  182. package/dist-types/posthog.d.ts +0 -112
@@ -0,0 +1,90 @@
1
+ import type { Script } from 'c15t';
2
+ declare global {
3
+ interface Window {
4
+ fathom?: {
5
+ blockTrackingForMe: () => void;
6
+ enableTrackingForMe: () => void;
7
+ trackEvent: (eventName: string, opts?: {
8
+ _value?: number;
9
+ }) => void;
10
+ trackGoal: (goalId: string, cents: number) => void;
11
+ trackPageview: (opts?: {
12
+ url: string;
13
+ referrer?: string;
14
+ }) => void;
15
+ };
16
+ }
17
+ }
18
+ /**
19
+ * Fathom Analytics vendor manifest.
20
+ *
21
+ * Configures Fathom via script `data-*` attributes. Fathom is a cookieless
22
+ * analytics product, so the script is consent-gated on `measurement` and
23
+ * unloaded when consent is revoked.
24
+ */
25
+ export declare const fathomAnalyticsManifest: {
26
+ readonly kind: "c15t.vendor-manifest";
27
+ readonly schemaVersion: 1;
28
+ readonly vendor: 'fathom-analytics';
29
+ readonly category: 'measurement';
30
+ readonly install: [{
31
+ readonly type: 'loadScript';
32
+ readonly src: '{{scriptUrl}}';
33
+ readonly defer: true;
34
+ readonly attributes: {
35
+ readonly 'data-site': '{{site}}';
36
+ readonly 'data-spa': '{{spa}}';
37
+ readonly 'data-auto': '{{autoAttribute}}';
38
+ readonly 'data-canonical': '{{canonicalAttribute}}';
39
+ readonly 'data-honor-dnt': '{{honorDntAttribute}}';
40
+ };
41
+ }];
42
+ };
43
+ export interface FathomAnalyticsOptions {
44
+ /**
45
+ * Your Fathom Analytics site ID.
46
+ */
47
+ site: string;
48
+ /**
49
+ * The SPA tracking mode. When undefined, SPA auto-routing is disabled and
50
+ * the `data-spa` attribute is omitted.
51
+ */
52
+ spa?: 'auto' | 'history' | 'hash';
53
+ /**
54
+ * Automatically track page views.
55
+ */
56
+ auto?: boolean;
57
+ /**
58
+ * Enable canonical URL tracking.
59
+ */
60
+ canonical?: boolean;
61
+ /**
62
+ * Honor Do Not Track requests.
63
+ */
64
+ honorDnt?: boolean;
65
+ /**
66
+ * Custom loader URL.
67
+ * @default 'https://cdn.usefathom.com/script.js'
68
+ */
69
+ scriptUrl?: string;
70
+ }
71
+ /**
72
+ * Creates a Fathom Analytics script.
73
+ *
74
+ * @see https://usefathom.com/docs/script/script-settings
75
+ *
76
+ * @param options - The options for the Fathom Analytics script.
77
+ * @returns The Fathom Analytics script.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * import { fathomAnalytics } from '@c15t/scripts/fathom-analytics';
82
+ *
83
+ * fathomAnalytics({
84
+ * site: 'SITE123',
85
+ * spa: 'history',
86
+ * canonical: true,
87
+ * });
88
+ * ```
89
+ */
90
+ export declare function fathomAnalytics(options: FathomAnalyticsOptions): Script;
@@ -12,44 +12,41 @@ declare global {
12
12
  * Uses the same Consent Mode v2 mapping.
13
13
  */
14
14
  export declare const gtagManifest: {
15
- readonly vendor: "gtag";
16
- readonly category: "{{category}}";
15
+ readonly kind: "c15t.vendor-manifest";
16
+ readonly schemaVersion: 1;
17
+ readonly vendor: 'gtag';
18
+ readonly category: '{{category}}';
17
19
  readonly alwaysLoad: true;
18
20
  readonly persistAfterConsentRevoked: true;
19
21
  readonly bootstrap: [{
20
- readonly type: "setGlobal";
21
- readonly name: "dataLayer";
22
+ readonly type: 'setGlobal';
23
+ readonly name: 'dataLayer';
22
24
  readonly value: readonly [];
23
25
  readonly ifUndefined: true;
24
26
  }, {
25
- readonly type: "defineQueueFunction";
26
- readonly name: "gtag";
27
- readonly queue: "dataLayer";
27
+ readonly type: 'defineQueueFunction';
28
+ readonly name: 'gtag';
29
+ readonly queue: 'dataLayer';
28
30
  readonly ifUndefined: true;
29
31
  }];
30
32
  readonly install: [{
31
- readonly type: "callGlobal";
32
- readonly global: "gtag";
33
- readonly args: ["js", "{{loadTime}}"];
33
+ readonly type: 'callGlobal';
34
+ readonly global: 'gtag';
35
+ readonly args: ["js", {
36
+ readonly kind: "c15t.runtime-value";
37
+ readonly value: 'date';
38
+ }];
34
39
  }, {
35
- readonly type: "callGlobal";
36
- readonly global: "gtag";
40
+ readonly type: 'callGlobal';
41
+ readonly global: 'gtag';
37
42
  readonly args: ["config", "{{id}}"];
38
43
  }, {
39
- readonly type: "loadScript";
40
- readonly src: "https://www.googletagmanager.com/gtag/js?id={{id}}";
44
+ readonly type: 'loadScript';
45
+ readonly src: 'https://www.googletagmanager.com/gtag/js?id={{id}}';
41
46
  readonly async: true;
42
47
  }];
43
- readonly consentMapping: {
44
- readonly necessary: ["security_storage"];
45
- readonly functionality: ["functionality_storage"];
46
- readonly measurement: ["analytics_storage"];
47
- readonly marketing: ["ad_storage", "ad_user_data", "ad_personalization"];
48
- readonly experience: ["personalization_storage"];
49
- };
50
- readonly consentSignal: "gtag";
51
- readonly kind: "c15t.vendor-manifest";
52
- readonly schemaVersion: 1;
48
+ readonly consentMapping: Record<string, string[]>;
49
+ readonly consentSignal: 'gtag';
53
50
  };
54
51
  export interface GtagOptions {
55
52
  /**
@@ -0,0 +1,316 @@
1
+ import type { Script } from 'c15t';
2
+ /**
3
+ * Default Heap config-loader base URL.
4
+ *
5
+ * Heap's current web installation snippet loads account configuration from a
6
+ * per-environment `heap_config.js` URL. That configuration then chain-loads the
7
+ * versioned heap.js runtime selected for the environment.
8
+ */
9
+ export declare const DEFAULT_HEAP_CONFIG_BASE_URL = "https://cdn.us.heap-api.com/config";
10
+ /**
11
+ * Current heap.js v5 method stubs from Heap's official web snippet.
12
+ *
13
+ * These methods do not push `[method, args]` tuples into `window.heap`. They
14
+ * push `{ name, fn }` records into `window.heapReadyCb`; each callback replays
15
+ * the original call against the loaded `window.heap` runtime.
16
+ */
17
+ export declare const HEAP_QUEUE_METHODS: readonly ['init', 'startTracking', 'stopTracking', 'track', 'resetIdentity', 'identify', 'identifyHashed', 'getSessionId', 'getUserId', 'getIdentity', 'addUserProperties', 'addEventProperties', 'removeEventProperty', 'clearEventProperties', 'addAccountProperties', 'addAdapter', 'addTransformer', 'addTransformerFn', 'onReady', 'addPageviewProperties', 'removePageviewProperty', 'clearPageviewProperties', 'trackPageview'];
18
+ type JsonPrimitive = string | number | boolean | null;
19
+ type JsonValue = JsonPrimitive | JsonValue[] | {
20
+ [key: string]: JsonValue;
21
+ };
22
+ type JsonRecord = {
23
+ [key: string]: JsonValue;
24
+ };
25
+ export interface HeapReadyCallback {
26
+ /** Heap method name captured by the pre-load snippet stub. */
27
+ name: (typeof HEAP_QUEUE_METHODS)[number];
28
+ /** Callback invoked by heap.js after the runtime is ready. */
29
+ fn: () => void;
30
+ }
31
+ /**
32
+ * Minimal public heap.js API exposed on `window.heap`.
33
+ *
34
+ * Before the real SDK loads, c15t creates an array-backed stub with these
35
+ * methods. The config loader calls `heap.init(envId, clientConfig,
36
+ * serverConfig)`, and heap.js drains `window.heapReadyCb` by invoking each
37
+ * stored callback.
38
+ */
39
+ export interface HeapApi {
40
+ /** Environment/app id selected for this Heap installation. */
41
+ envId?: string;
42
+ /** Legacy alias used by some Heap runtime paths. */
43
+ appid?: string;
44
+ /** Client configuration passed into `heap.load()`. */
45
+ clientConfig?: JsonRecord;
46
+ /** Server configuration assigned by `heap_config.js` before heap.js loads. */
47
+ serverConfig?: Record<string, unknown>;
48
+ /**
49
+ * Initializes the heap.js runtime.
50
+ *
51
+ * @param envId - Heap environment/app id.
52
+ * @param clientConfig - Client-side configuration options.
53
+ * @param serverConfig - Server-side configuration loaded by Heap.
54
+ * @returns Vendor-specific runtime result.
55
+ */
56
+ init: (envId: string, clientConfig?: JsonRecord, serverConfig?: Record<string, unknown>) => unknown;
57
+ /**
58
+ * Starts Heap autocapture and event delivery.
59
+ *
60
+ * @returns Vendor-specific runtime result.
61
+ */
62
+ startTracking: () => unknown;
63
+ /**
64
+ * Stops Heap tracking for the current runtime session.
65
+ *
66
+ * @returns Vendor-specific runtime result.
67
+ */
68
+ stopTracking: () => unknown;
69
+ /**
70
+ * Tracks a custom Heap event.
71
+ *
72
+ * @param event - Event name to record.
73
+ * @param properties - Optional event properties.
74
+ * @returns Vendor-specific runtime result.
75
+ */
76
+ track: (event: string, properties?: Record<string, unknown>) => unknown;
77
+ /**
78
+ * Clears the current Heap identity.
79
+ *
80
+ * @returns Vendor-specific runtime result.
81
+ */
82
+ resetIdentity: () => unknown;
83
+ /**
84
+ * Identifies the current user.
85
+ *
86
+ * @param identity - Stable user identity.
87
+ * @returns Vendor-specific runtime result.
88
+ */
89
+ identify: (identity: string) => unknown;
90
+ /**
91
+ * Identifies the current user with a hashed identity.
92
+ *
93
+ * @param identity - Hashed user identity.
94
+ * @returns Vendor-specific runtime result.
95
+ */
96
+ identifyHashed: (identity: string) => unknown;
97
+ /**
98
+ * Reads the current Heap session id.
99
+ *
100
+ * @returns Current session id when available.
101
+ */
102
+ getSessionId: () => unknown;
103
+ /**
104
+ * Reads the current Heap user id.
105
+ *
106
+ * @returns Current Heap user id when available.
107
+ */
108
+ getUserId: () => unknown;
109
+ /**
110
+ * Reads the current Heap identity.
111
+ *
112
+ * @returns Current identity when available.
113
+ */
114
+ getIdentity: () => unknown;
115
+ /**
116
+ * Adds properties to the current user.
117
+ *
118
+ * @param properties - User properties to merge.
119
+ * @returns Vendor-specific runtime result.
120
+ */
121
+ addUserProperties: (properties: Record<string, unknown>) => unknown;
122
+ /**
123
+ * Adds properties to every subsequent event.
124
+ *
125
+ * @param properties - Event properties to merge.
126
+ * @returns Vendor-specific runtime result.
127
+ */
128
+ addEventProperties: (properties: Record<string, unknown>) => unknown;
129
+ /**
130
+ * Removes a single persisted event property.
131
+ *
132
+ * @param property - Event property name to remove.
133
+ * @returns Vendor-specific runtime result.
134
+ */
135
+ removeEventProperty: (property: string) => unknown;
136
+ /**
137
+ * Clears persisted event properties.
138
+ *
139
+ * @returns Vendor-specific runtime result.
140
+ */
141
+ clearEventProperties: () => unknown;
142
+ /**
143
+ * Adds properties to the current account.
144
+ *
145
+ * @param properties - Account properties to merge.
146
+ * @returns Vendor-specific runtime result.
147
+ */
148
+ addAccountProperties: (properties: Record<string, unknown>) => unknown;
149
+ /**
150
+ * Adds a Heap adapter.
151
+ *
152
+ * @param adapter - Adapter implementation accepted by heap.js.
153
+ * @returns Vendor-specific runtime result.
154
+ */
155
+ addAdapter: (adapter: unknown) => unknown;
156
+ /**
157
+ * Adds a Heap event transformer.
158
+ *
159
+ * @param transformer - Transformer implementation accepted by heap.js.
160
+ * @returns Vendor-specific runtime result.
161
+ */
162
+ addTransformer: (transformer: unknown) => unknown;
163
+ /**
164
+ * Adds a Heap transformer function.
165
+ *
166
+ * @param transformer - Transformer callback accepted by heap.js.
167
+ * @returns Vendor-specific runtime result.
168
+ */
169
+ addTransformerFn: (transformer: (...args: unknown[]) => unknown) => unknown;
170
+ /**
171
+ * Registers a callback for Heap readiness.
172
+ *
173
+ * @param callback - Function to call once Heap is ready.
174
+ * @returns Vendor-specific runtime result.
175
+ */
176
+ onReady: (callback: () => void) => unknown;
177
+ /**
178
+ * Adds properties to subsequent pageview events.
179
+ *
180
+ * @param properties - Pageview properties to merge.
181
+ * @returns Vendor-specific runtime result.
182
+ */
183
+ addPageviewProperties: (properties: Record<string, unknown>) => unknown;
184
+ /**
185
+ * Removes a single persisted pageview property.
186
+ *
187
+ * @param property - Pageview property name to remove.
188
+ * @returns Vendor-specific runtime result.
189
+ */
190
+ removePageviewProperty: (property: string) => unknown;
191
+ /**
192
+ * Clears persisted pageview properties.
193
+ *
194
+ * @returns Vendor-specific runtime result.
195
+ */
196
+ clearPageviewProperties: () => unknown;
197
+ /**
198
+ * Tracks a pageview event.
199
+ *
200
+ * @param properties - Optional pageview properties.
201
+ * @returns Vendor-specific runtime result.
202
+ */
203
+ trackPageview: (properties?: Record<string, unknown>) => unknown;
204
+ }
205
+ declare global {
206
+ interface Window {
207
+ heap?: HeapApi;
208
+ heapReadyCb?: HeapReadyCallback[];
209
+ }
210
+ }
211
+ /**
212
+ * Heap vendor manifest.
213
+ *
214
+ * Reproduces the heap.js v5 snippet contract consumed by
215
+ * `heap_config.js`: `window.heapReadyCb` receives `{ name, fn }` callback
216
+ * records, `window.heap` stores `envId`/`appid` and `clientConfig`, and the
217
+ * Heap configuration script chain-loads the versioned heap.js runtime.
218
+ *
219
+ * Heap does not document a browser opt-out API that can make an already loaded
220
+ * runtime inert for c15t's purposes, so c15t gates the load on `measurement`
221
+ * consent and unloads the script when that consent is revoked.
222
+ */
223
+ export declare const heapManifest: {
224
+ readonly kind: "c15t.vendor-manifest";
225
+ readonly schemaVersion: 1;
226
+ readonly vendor: 'heap';
227
+ readonly category: 'measurement';
228
+ readonly install: [{
229
+ readonly type: 'setGlobal';
230
+ readonly name: 'heapReadyCb';
231
+ readonly value: readonly [];
232
+ readonly ifUndefined: true;
233
+ }, {
234
+ readonly type: 'setGlobal';
235
+ readonly name: 'heap';
236
+ readonly value: readonly [];
237
+ readonly ifUndefined: true;
238
+ }, {
239
+ readonly type: 'setGlobalPath';
240
+ readonly path: ["heap", "envId"];
241
+ readonly value: '{{envId}}';
242
+ }, {
243
+ readonly type: 'setGlobalPath';
244
+ readonly path: ["heap", "appid"];
245
+ readonly value: '{{envId}}';
246
+ }, {
247
+ readonly type: 'setGlobalPath';
248
+ readonly path: ["heap", "clientConfig"];
249
+ readonly value: '{{clientConfig}}';
250
+ }, {
251
+ readonly type: 'defineQueueMethods';
252
+ readonly target: 'heap';
253
+ readonly queue: {
254
+ readonly global: 'heapReadyCb';
255
+ };
256
+ readonly queueFormat: 'callback';
257
+ readonly methods: ["init", "startTracking", "stopTracking", "track", "resetIdentity", "identify", "identifyHashed", "getSessionId", "getUserId", "getIdentity", "addUserProperties", "addEventProperties", "removeEventProperty", "clearEventProperties", "addAccountProperties", "addAdapter", "addTransformer", "addTransformerFn", "onReady", "addPageviewProperties", "removePageviewProperty", "clearPageviewProperties", "trackPageview"];
258
+ }, {
259
+ readonly type: 'loadScript';
260
+ readonly src: '{{scriptUrl}}';
261
+ readonly async: true;
262
+ }];
263
+ };
264
+ export interface HeapOptions {
265
+ /**
266
+ * Heap environment/app id.
267
+ *
268
+ * Heap's app UI commonly shows this as a numeric string. c15t validates only
269
+ * that the value is a non-empty string after trimming because Heap's public
270
+ * install docs describe it generically as `YOUR_APP_ID`.
271
+ */
272
+ envId: string;
273
+ /**
274
+ * Optional heap.js client configuration.
275
+ *
276
+ * Values must be JSON-serializable: plain objects, arrays, strings, finite
277
+ * numbers, booleans, and `null`. c15t adds `shouldFetchServerConfig: false`
278
+ * to match Heap's current web installation snippet.
279
+ */
280
+ clientConfig?: Record<string, unknown>;
281
+ /**
282
+ * Optional full Heap config-loader URL override.
283
+ *
284
+ * @default 'https://cdn.us.heap-api.com/config/{envId}/heap_config.js'
285
+ */
286
+ scriptUrl?: string;
287
+ }
288
+ /**
289
+ * Creates a Heap web analytics script.
290
+ *
291
+ * @see https://developers.heap.io/docs/web
292
+ *
293
+ * @param options - The options for the Heap script.
294
+ * @returns The Heap script configuration.
295
+ * @throws {Error} When `envId` is missing or only whitespace.
296
+ * @throws {TypeError} When `clientConfig` contains non-JSON values.
297
+ *
298
+ * @remarks
299
+ * Heap autocaptures interactions as soon as heap.js loads. c15t therefore
300
+ * gates the config loader on `measurement` consent and unloads the script when
301
+ * that consent is revoked.
302
+ *
303
+ * @example
304
+ * ```ts
305
+ * import { heap } from '@c15t/scripts/heap';
306
+ *
307
+ * const script = heap({
308
+ * envId: '123456789',
309
+ * clientConfig: {
310
+ * disableTextCapture: true,
311
+ * },
312
+ * });
313
+ * ```
314
+ */
315
+ export declare function heap({ envId, clientConfig, scriptUrl }: HeapOptions): Script;
316
+ export {};