@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
@@ -69,9 +69,23 @@ export interface XPixelEvent {
69
69
  twclid?: string;
70
70
  /**
71
71
  * Status of the conversion event
72
- * @example completed
72
+ * Should be set to values like "started" or "completed".
73
+ * @example "completed"
73
74
  */
74
- status?: boolean;
75
+ status?: 'started' | 'completed';
76
+ /**
77
+ * Email address used for user matching.
78
+ * The X Pixel hashes this value before transmission.
79
+ * @example "[email protected]"
80
+ */
81
+ email_address?: string;
82
+ /**
83
+ * Phone number used for user matching.
84
+ * Include country code in E.164 format (for example, +11234567890).
85
+ * The X Pixel hashes this value before transmission.
86
+ * @example "+11234567890"
87
+ */
88
+ phone_number?: string;
75
89
  /**
76
90
  * Content/products associated with the conversion event
77
91
  * @example [{content_id: 'OT001', content_name: 'bird seed', content_price: 50, num_items: 1}]
@@ -91,31 +105,31 @@ declare global {
91
105
  * No consent API — the script simply loads or doesn't based on consent.
92
106
  */
93
107
  export declare const xPixelManifest: {
94
- readonly vendor: "x-pixel";
95
- readonly category: "marketing";
108
+ readonly kind: "c15t.vendor-manifest";
109
+ readonly schemaVersion: 1;
110
+ readonly vendor: 'x-pixel';
111
+ readonly category: 'marketing';
96
112
  readonly bootstrap: [{
97
- readonly type: "defineStubFunction";
98
- readonly name: "twq";
113
+ readonly type: 'defineStubFunction';
114
+ readonly name: 'twq';
99
115
  readonly queue: {
100
- readonly property: "queue";
116
+ readonly property: 'queue';
101
117
  };
102
- readonly dispatchProperty: "exe";
118
+ readonly dispatchProperty: 'exe';
103
119
  readonly properties: {
104
- readonly version: "1.1";
120
+ readonly version: '1.1';
105
121
  };
106
122
  readonly ifUndefined: true;
107
123
  }];
108
124
  readonly install: [{
109
- readonly type: "callGlobal";
110
- readonly global: "twq";
125
+ readonly type: 'callGlobal';
126
+ readonly global: 'twq';
111
127
  readonly args: ["config", "{{pixelId}}"];
112
128
  }, {
113
- readonly type: "loadScript";
114
- readonly src: "{{scriptSrc}}";
129
+ readonly type: 'loadScript';
130
+ readonly src: '{{scriptSrc}}';
115
131
  readonly async: true;
116
132
  }];
117
- readonly kind: "c15t.vendor-manifest";
118
- readonly schemaVersion: 1;
119
133
  };
120
134
  export interface XPixelOptions {
121
135
  /**
@@ -141,7 +155,7 @@ export interface XPixelOptions {
141
155
  * });
142
156
  * ```
143
157
  *
144
- * @see {@link https://ads.twitter.com/help/article/x-pixel} X Pixel documentation
158
+ * @see {@link https://business.x.com/en/help/campaign-measurement-and-analytics/conversion-tracking-for-websites} X conversion tracking documentation
145
159
  */
146
160
  export declare function xPixel({ pixelId, scriptSrc }: XPixelOptions): Script;
147
161
  /**
@@ -162,5 +176,8 @@ export declare function xPixel({ pixelId, scriptSrc }: XPixelOptions): Script;
162
176
  * ```
163
177
  *
164
178
  * @see {@link https://business.x.com/en/help/campaign-measurement-and-analytics/conversion-tracking-for-websites#event-types-and-parameters}
179
+ * @throws {Error} Throws when `window` is unavailable or `window.twq` is not a
180
+ * function. Ensure marketing consent is granted and the X Pixel has loaded
181
+ * before calling this helper.
165
182
  */
166
- export declare const xPixelEvent: (eventId: string, metadata?: XPixelEvent) => void | undefined;
183
+ export declare const xPixelEvent: (eventId: string, metadata?: XPixelEvent) => void;
@@ -0,0 +1,75 @@
1
+ import type { Script } from 'c15t';
2
+ import { type VendorManifest } from '../../types';
3
+ declare global {
4
+ interface Window {
5
+ adobeDataLayer?: unknown[];
6
+ _satellite?: Record<string, unknown>;
7
+ }
8
+ }
9
+ /**
10
+ * Adobe Analytics vendor manifest.
11
+ *
12
+ * Loads the Adobe Experience Platform Data Collection Tags embed script for a
13
+ * specific property environment. Adobe does not provide a generic public
14
+ * loader; each customer copies their own environment URL from Data Collection,
15
+ * commonly hosted at `https://assets.adobedtm.com/.../launch-*.min.js`.
16
+ */
17
+ export declare const adobeAnalyticsManifest: VendorManifest;
18
+ export interface AdobeAnalyticsOptions {
19
+ /**
20
+ * Adobe Experience Platform Data Collection web property embed URL.
21
+ *
22
+ * This must be the full `https:` URL from your Adobe Tags environment embed
23
+ * code, commonly shaped like
24
+ * `https://assets.adobedtm.com/{org}/{property}/launch-{env}.min.js`.
25
+ * Self-hosted Launch/Tags embeds are supported as long as they use `https:`.
26
+ */
27
+ scriptUrl: string;
28
+ /**
29
+ * Load the Adobe Tags library asynchronously.
30
+ *
31
+ * Adobe recommends asynchronous deployment for most web properties. Set this
32
+ * to `false` only for legacy synchronous setups that require ordered blocking
33
+ * behavior.
34
+ * @default true
35
+ */
36
+ async?: boolean;
37
+ /**
38
+ * Seed the Adobe Client Data Layer queue before the Tags library loads.
39
+ *
40
+ * When enabled, c15t creates `window.adobeDataLayer = []` only when the
41
+ * global is still undefined. This matches Adobe Client Data Layer's default
42
+ * object name and is harmless for properties that do not use the extension.
43
+ * @default true
44
+ */
45
+ seedAdobeDataLayer?: boolean;
46
+ }
47
+ /**
48
+ * Creates an Adobe Analytics script.
49
+ *
50
+ * @see https://experienceleague.adobe.com/en/docs/experience-platform/tags/publish/environments/environments
51
+ * @see https://experienceleague.adobe.com/en/docs/experience-platform/tags/extensions/client/client-data-layer/overview
52
+ *
53
+ * @param options - The options for the Adobe Analytics script.
54
+ * @returns The Adobe Analytics script.
55
+ * @throws {Error} When `scriptUrl` is missing, empty, invalid, or not `https:`.
56
+ * Copy the full web property embed URL from Adobe Data Collection and pass it
57
+ * as `scriptUrl`.
58
+ *
59
+ * @remarks
60
+ * Adobe Analytics is commonly deployed through Adobe Experience Platform Data
61
+ * Collection Tags (formerly Launch). The loaded property may in turn load Adobe
62
+ * Analytics, Web SDK, or other extensions and rules, so configure those Adobe
63
+ * rules to respect your consent model too.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * import { adobeAnalytics } from '@c15t/scripts/adobe-analytics';
68
+ *
69
+ * adobeAnalytics({
70
+ * scriptUrl:
71
+ * 'https://assets.adobedtm.com/YOUR_ORG/YOUR_PROPERTY/launch-production.min.js',
72
+ * });
73
+ * ```
74
+ */
75
+ export declare function adobeAnalytics(options: AdobeAnalyticsOptions): Script;
@@ -0,0 +1,62 @@
1
+ import type { Script } from 'c15t';
2
+ declare global {
3
+ interface Window {
4
+ AhrefsAnalytics?: {
5
+ sendEvent: (name: string, options?: {
6
+ props?: Record<string, string>;
7
+ meta?: Record<string, unknown>;
8
+ }) => void;
9
+ };
10
+ }
11
+ }
12
+ /**
13
+ * Ahrefs Analytics vendor manifest.
14
+ *
15
+ * Loads Ahrefs Web Analytics and passes the project key via `data-key`. Ahrefs
16
+ * Web Analytics is cookieless, so the script is consent-gated on `measurement`
17
+ * and unloaded when consent is revoked.
18
+ */
19
+ export declare const ahrefsAnalyticsManifest: {
20
+ readonly kind: "c15t.vendor-manifest";
21
+ readonly schemaVersion: 1;
22
+ readonly vendor: 'ahrefs-analytics';
23
+ readonly category: 'measurement';
24
+ readonly install: [{
25
+ readonly type: 'loadScript';
26
+ readonly src: '{{scriptUrl}}';
27
+ readonly async: true;
28
+ readonly attributes: {
29
+ readonly 'data-key': '{{key}}';
30
+ };
31
+ }];
32
+ };
33
+ export interface AhrefsAnalyticsOptions {
34
+ /**
35
+ * Your Ahrefs Web Analytics project key.
36
+ */
37
+ key: string;
38
+ /**
39
+ * Custom loader URL.
40
+ * @default 'https://analytics.ahrefs.com/analytics.js'
41
+ */
42
+ scriptUrl?: string;
43
+ }
44
+ /**
45
+ * Creates an Ahrefs Analytics script.
46
+ *
47
+ * The Ahrefs SDK exposes its runtime API on `window.AhrefsAnalytics` after
48
+ * load. This helper only models the serializable script manifest.
49
+ *
50
+ * @see https://ahrefs.com/web-analytics
51
+ *
52
+ * @param options - The options for the Ahrefs Analytics script.
53
+ * @returns The Ahrefs Analytics script.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * import { ahrefsAnalytics } from '@c15t/scripts/ahrefs-analytics';
58
+ *
59
+ * ahrefsAnalytics({ key: 'YOUR_PROJECT_KEY' });
60
+ * ```
61
+ */
62
+ export declare function ahrefsAnalytics(options: AhrefsAnalyticsOptions): Script;
@@ -0,0 +1,234 @@
1
+ import type { Script } from 'c15t';
2
+ /**
3
+ * Browser SDK 2 version used by the default Amplitude CDN loader URL.
4
+ *
5
+ * The Amplitude Browser SDK 2 public bundle path is versioned. A
6
+ * `analytics-browser-latest-min.js.gz` path is not publicly available, so c15t
7
+ * pins a known Browser SDK 2 version by default and lets callers override the
8
+ * loader through `scriptUrl`.
9
+ */
10
+ export declare const DEFAULT_AMPLITUDE_BROWSER_SDK_VERSION = "2.44.4";
11
+ /**
12
+ * Default Amplitude Browser SDK 2 loader URL.
13
+ */
14
+ export declare const DEFAULT_AMPLITUDE_SCRIPT_URL = "https://cdn.amplitude.com/libs/analytics-browser-2.44.4-min.js.gz";
15
+ /**
16
+ * Core Amplitude Browser SDK 2 methods queued before the real SDK loads.
17
+ *
18
+ * These methods use Amplitude's Browser SDK 2 snippet queue contract:
19
+ * `window.amplitude._q` receives `{ name, args, resolve }` records, and the
20
+ * loaded SDK drains that queue when `window.amplitude.invoked` is true.
21
+ */
22
+ export declare const AMPLITUDE_PROMISE_QUEUE_METHODS: readonly ['init', 'track', 'identify', 'flush'];
23
+ /**
24
+ * Queue methods Amplitude's snippet treats as synchronous — they queue the
25
+ * call but return nothing.
26
+ */
27
+ export declare const AMPLITUDE_SYNC_QUEUE_METHODS: readonly ['setUserId', 'setOptOut'];
28
+ export declare const AMPLITUDE_QUEUE_METHODS: readonly ["init", "track", "identify", "flush", "setUserId", "setOptOut"];
29
+ /**
30
+ * Amplitude Identify helper methods queued before the real SDK loads.
31
+ */
32
+ export declare const AMPLITUDE_IDENTIFY_METHODS: readonly ['set', 'setOnce', 'add', 'append', 'prepend', 'preInsert', 'postInsert', 'remove', 'unset', 'clearAll', 'getUserProperties'];
33
+ /**
34
+ * Queue entry consumed by Amplitude Browser SDK 2 at load time.
35
+ */
36
+ export interface AmplitudeQueueEntry {
37
+ /** Name of the Amplitude method to invoke after the SDK loads. */
38
+ name: (typeof AMPLITUDE_QUEUE_METHODS)[number];
39
+ /** Arguments originally passed to the queued method. */
40
+ args: unknown[];
41
+ /** Promise resolver called by the SDK after the queued method runs. */
42
+ resolve: (value: unknown) => void;
43
+ }
44
+ /**
45
+ * Queue entry stored by an Amplitude Identify helper created before load.
46
+ */
47
+ export interface AmplitudeIdentifyQueueEntry {
48
+ /** Identify helper method to replay after the SDK loads. */
49
+ name: (typeof AMPLITUDE_IDENTIFY_METHODS)[number];
50
+ /** Arguments originally passed to the helper method. */
51
+ args: unknown[];
52
+ }
53
+ /**
54
+ * Pre-load Amplitude Identify helper.
55
+ */
56
+ export interface AmplitudeIdentify {
57
+ /** Queued Identify helper operations. */
58
+ _q?: AmplitudeIdentifyQueueEntry[];
59
+ /** Queue a `$set` identify operation. */
60
+ set: (property: string, value: unknown) => this;
61
+ /** Queue a `$setOnce` identify operation. */
62
+ setOnce: (property: string, value: unknown) => this;
63
+ /** Queue an `$add` identify operation. */
64
+ add: (property: string, value: number) => this;
65
+ /** Queue an `$append` identify operation. */
66
+ append: (property: string, value: unknown) => this;
67
+ /** Queue a `$prepend` identify operation. */
68
+ prepend: (property: string, value: unknown) => this;
69
+ /** Queue a `$preInsert` identify operation. */
70
+ preInsert: (property: string, value: unknown) => this;
71
+ /** Queue a `$postInsert` identify operation. */
72
+ postInsert: (property: string, value: unknown) => this;
73
+ /** Queue a `$remove` identify operation. */
74
+ remove: (property: string, value: unknown) => this;
75
+ /** Queue an `$unset` identify operation. */
76
+ unset: (property: string) => this;
77
+ /** Queue a `$clearAll` identify operation. */
78
+ clearAll: () => this;
79
+ /** Queue a read of the accumulated user property operations. */
80
+ getUserProperties: () => this;
81
+ }
82
+ /**
83
+ * Minimal public Amplitude Browser SDK 2 API exposed on `window.amplitude`.
84
+ *
85
+ * The real SDK replaces the pre-load stub with these methods after the loader
86
+ * executes. Calls made before load return promises that resolve once the SDK
87
+ * replays them.
88
+ */
89
+ export interface AmplitudeApi {
90
+ /** Amplitude Browser SDK 2 pre-load queue. */
91
+ _q?: AmplitudeQueueEntry[];
92
+ /** Named-instance queue registry used by the official snippet contract. */
93
+ _iq?: Record<string, unknown>;
94
+ /** Marker that tells the SDK to replay snippet-queued calls. */
95
+ invoked?: boolean;
96
+ /** Pre-load Identify helper constructor. */
97
+ Identify?: new () => AmplitudeIdentify;
98
+ /** Initialize the default Amplitude instance. */
99
+ init: (apiKey: string, options?: Record<string, unknown>) => Promise<unknown> | unknown;
100
+ /** Track an event with optional event properties. */
101
+ track: (eventInput: string | Record<string, unknown>, eventProperties?: Record<string, unknown>) => Promise<unknown> | unknown;
102
+ /** Send an identify call. */
103
+ identify: (identifyPayload: AmplitudeIdentify, eventOptions?: Record<string, unknown>) => Promise<unknown> | unknown;
104
+ /** Set the current user identifier. */
105
+ setUserId: (userId: string | undefined) => Promise<unknown> | unknown;
106
+ /** Toggle runtime opt-out. */
107
+ setOptOut: (optOut: boolean) => Promise<unknown> | unknown;
108
+ /** Flush pending events. */
109
+ flush: () => Promise<unknown> | unknown;
110
+ }
111
+ declare global {
112
+ interface Window {
113
+ amplitude?: AmplitudeApi;
114
+ }
115
+ }
116
+ /**
117
+ * Amplitude vendor manifest.
118
+ *
119
+ * Implements the essential Browser SDK 2 script-loader contract with
120
+ * `window.amplitude.invoked`, an `_q` method-call queue, and an `_iq` registry
121
+ * for named instances. It also defines the `Identify` queued helper used by
122
+ * pre-load `identify()` calls. c15t gates the loader on `measurement` consent,
123
+ * queues `init(apiKey, initOptions)` before the bundle loads, and uses
124
+ * `setOptOut(false)` / `setOptOut(true)` for runtime consent changes after the
125
+ * SDK has loaded.
126
+ */
127
+ export declare const amplitudeManifest: {
128
+ readonly kind: "c15t.vendor-manifest";
129
+ readonly schemaVersion: 1;
130
+ readonly vendor: 'amplitude';
131
+ readonly category: 'measurement';
132
+ readonly install: [{
133
+ readonly type: 'setGlobal';
134
+ readonly name: 'amplitude';
135
+ readonly value: {
136
+ readonly _q: readonly [];
137
+ readonly _iq: {};
138
+ readonly invoked: true;
139
+ };
140
+ readonly ifUndefined: true;
141
+ }, {
142
+ readonly type: 'defineQueueClass';
143
+ readonly target: 'amplitude';
144
+ readonly name: 'Identify';
145
+ readonly queueProperty: '_q';
146
+ readonly methods: ["set", "setOnce", "add", "append", "prepend", "preInsert", "postInsert", "remove", "unset", "clearAll", "getUserProperties"];
147
+ }, {
148
+ readonly type: 'defineQueueMethods';
149
+ readonly target: 'amplitude';
150
+ readonly queue: {
151
+ readonly property: '_q';
152
+ };
153
+ readonly queueFormat: 'wrappedMethodCall';
154
+ readonly methods: ["init", "track", "identify", "flush"];
155
+ }, {
156
+ readonly type: 'defineQueueMethods';
157
+ readonly target: 'amplitude';
158
+ readonly queue: {
159
+ readonly property: '_q';
160
+ };
161
+ readonly queueFormat: 'voidMethodCall';
162
+ readonly methods: ["setUserId", "setOptOut"];
163
+ }, {
164
+ readonly type: 'callGlobal';
165
+ readonly global: 'amplitude';
166
+ readonly method: 'init';
167
+ readonly args: ["{{apiKey}}", "{{initOptions}}"];
168
+ }, {
169
+ readonly type: 'loadScript';
170
+ readonly src: '{{scriptUrl}}';
171
+ readonly async: true;
172
+ }];
173
+ readonly onLoadDenied: [{
174
+ readonly type: 'callGlobal';
175
+ readonly global: 'amplitude';
176
+ readonly method: 'setOptOut';
177
+ readonly args: [true];
178
+ }];
179
+ readonly onConsentGranted: [{
180
+ readonly type: 'callGlobal';
181
+ readonly global: 'amplitude';
182
+ readonly method: 'setOptOut';
183
+ readonly args: [false];
184
+ }];
185
+ readonly onConsentDenied: [{
186
+ readonly type: 'callGlobal';
187
+ readonly global: 'amplitude';
188
+ readonly method: 'setOptOut';
189
+ readonly args: [true];
190
+ }];
191
+ };
192
+ export interface AmplitudeOptions {
193
+ /** Amplitude project API key. */
194
+ apiKey: string;
195
+ /**
196
+ * Amplitude Browser SDK 2 initialization options.
197
+ *
198
+ * Values are serialized into the manifest, so use JSON-serializable values
199
+ * only: plain objects, arrays, strings, numbers, booleans, and `null`.
200
+ */
201
+ initOptions?: Record<string, unknown>;
202
+ /**
203
+ * Optional Amplitude loader URL override.
204
+ *
205
+ * @default 'https://cdn.amplitude.com/libs/analytics-browser-2.44.4-min.js.gz'
206
+ */
207
+ scriptUrl?: string;
208
+ }
209
+ /**
210
+ * Creates an Amplitude Browser SDK 2 script.
211
+ *
212
+ * @param options - The options for the Amplitude script.
213
+ * @returns The Amplitude script configuration.
214
+ * @throws {Error} When `apiKey` is missing or only whitespace.
215
+ *
216
+ * @remarks
217
+ * The generated script is gated on `measurement` consent. It does not load the
218
+ * Amplitude SDK until measurement consent is granted; after the SDK is loaded,
219
+ * later consent changes call `amplitude.setOptOut(false)` or
220
+ * `amplitude.setOptOut(true)`.
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * import { amplitude } from '@c15t/scripts/amplitude';
225
+ *
226
+ * const script = amplitude({
227
+ * apiKey: 'AMPLITUDE_API_KEY',
228
+ * initOptions: {
229
+ * autocapture: false,
230
+ * },
231
+ * });
232
+ * ```
233
+ */
234
+ export declare function amplitude({ apiKey, initOptions, scriptUrl, }: AmplitudeOptions): Script;
@@ -0,0 +1,60 @@
1
+ import type { Script } from 'c15t';
2
+ /**
3
+ * Clearbit vendor manifest.
4
+ *
5
+ * Loads Clearbit's visitor and company enrichment tag from the account-keyed
6
+ * `tags.js` endpoint. Clearbit enrichment can identify visitors and companies,
7
+ * so the default consent category is `marketing` rather than `measurement`.
8
+ * The GitHub issue left the category open between measurement and marketing;
9
+ * c15t treats enrichment and intent profiling as marketing-sensitive.
10
+ */
11
+ export declare const clearbitManifest: {
12
+ readonly kind: "c15t.vendor-manifest";
13
+ readonly schemaVersion: 1;
14
+ readonly vendor: 'clearbit';
15
+ readonly category: 'marketing';
16
+ readonly install: [{
17
+ readonly type: 'loadScript';
18
+ readonly src: '{{scriptUrl}}';
19
+ readonly attributes: {
20
+ readonly referrerpolicy: 'strict-origin-when-cross-origin';
21
+ };
22
+ }];
23
+ };
24
+ export interface ClearbitOptions {
25
+ /**
26
+ * Your Clearbit publishable key.
27
+ */
28
+ publishableKey: string;
29
+ /**
30
+ * Custom loader URL.
31
+ * @default `https://tag.clearbitscripts.com/v1/{publishableKey}/tags.js`
32
+ */
33
+ scriptUrl?: string;
34
+ }
35
+ /**
36
+ * Creates a Clearbit enrichment script.
37
+ *
38
+ * @see https://help.clearbit.com/hc/en-us/articles/4420022080783 — installing the Clearbit tag
39
+ *
40
+ * @param options - The options for the Clearbit script.
41
+ * @returns The Clearbit script.
42
+ * @throws {Error} When `publishableKey` is missing, empty, or invalid.
43
+ * Provide a valid non-empty `publishableKey` string to prevent this error.
44
+ *
45
+ * @remarks
46
+ * Clearbit identifies visitors and companies for enrichment and intent use
47
+ * cases. This helper therefore uses the `marketing` consent category by
48
+ * default even though Clearbit is listed with analytics integrations for
49
+ * discovery.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * import { clearbit } from '@c15t/scripts/clearbit';
54
+ *
55
+ * clearbit({
56
+ * publishableKey: 'YOUR_PUBLISHABLE_KEY',
57
+ * });
58
+ * ```
59
+ */
60
+ export declare function clearbit(options: ClearbitOptions): Script;
@@ -0,0 +1,67 @@
1
+ import type { Script } from 'c15t';
2
+ declare global {
3
+ interface Window {
4
+ __cfBeacon?: {
5
+ spa?: boolean;
6
+ token: string;
7
+ };
8
+ }
9
+ }
10
+ /**
11
+ * Cloudflare Web Analytics vendor manifest.
12
+ *
13
+ * Serializes Cloudflare's beacon config into the `data-cf-beacon` attribute.
14
+ * Cloudflare Web Analytics is cookieless, so the script is consent-gated on
15
+ * `measurement` and unloaded when consent is revoked.
16
+ */
17
+ export declare const cloudflareWebAnalyticsManifest: {
18
+ readonly kind: "c15t.vendor-manifest";
19
+ readonly schemaVersion: 1;
20
+ readonly vendor: 'cloudflare-web-analytics';
21
+ readonly category: 'measurement';
22
+ readonly install: [{
23
+ readonly type: 'loadScript';
24
+ readonly src: '{{scriptUrl}}';
25
+ readonly defer: true;
26
+ readonly attributes: {
27
+ readonly 'data-cf-beacon': '{{beaconConfig}}';
28
+ };
29
+ }];
30
+ };
31
+ export interface CloudflareWebAnalyticsOptions {
32
+ /**
33
+ * Your Cloudflare Web Analytics token.
34
+ */
35
+ token: string;
36
+ /**
37
+ * Enable Cloudflare's SPA route tracking.
38
+ * @default true
39
+ */
40
+ spa?: boolean;
41
+ /**
42
+ * Custom loader URL.
43
+ * @default 'https://static.cloudflareinsights.com/beacon.min.js'
44
+ */
45
+ scriptUrl?: string;
46
+ }
47
+ /**
48
+ * Creates a Cloudflare Web Analytics script.
49
+ *
50
+ * @see https://developers.cloudflare.com/analytics/web-analytics/get-started/
51
+ *
52
+ * @param options - The options for the Cloudflare Web Analytics script.
53
+ * @returns The Cloudflare Web Analytics script.
54
+ * @throws {Error} Throws `cloudflareWebAnalytics: missing token` when
55
+ * `options.token` is missing, invalid, or trims to an empty string.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * import { cloudflareWebAnalytics } from '@c15t/scripts/cloudflare-web-analytics';
60
+ *
61
+ * cloudflareWebAnalytics({
62
+ * token: 'abc123...',
63
+ * spa: true,
64
+ * });
65
+ * ```
66
+ */
67
+ export declare function cloudflareWebAnalytics(options: CloudflareWebAnalyticsOptions): Script;
@@ -27,63 +27,63 @@ declare global {
27
27
  * Config is seeded via `window.databuddyConfig` before the script loads.
28
28
  */
29
29
  export declare const databuddyManifest: {
30
- readonly vendor: "databuddy";
31
- readonly category: "measurement";
30
+ readonly kind: "c15t.vendor-manifest";
31
+ readonly schemaVersion: 1;
32
+ readonly vendor: 'databuddy';
33
+ readonly category: 'measurement';
32
34
  readonly alwaysLoad: true;
33
35
  readonly install: [{
34
- readonly type: "loadScript";
35
- readonly src: "{{scriptUrl}}";
36
+ readonly type: 'loadScript';
37
+ readonly src: '{{scriptUrl}}';
36
38
  readonly async: true;
37
39
  readonly attributes: {
38
- readonly crossorigin: "anonymous";
39
- readonly 'data-client-id': "{{clientId}}";
40
- readonly 'data-api-url': "{{apiUrl}}";
40
+ readonly crossorigin: 'anonymous';
41
+ readonly 'data-client-id': '{{clientId}}';
42
+ readonly 'data-api-url': '{{apiUrl}}';
41
43
  };
42
44
  }];
43
45
  readonly onBeforeLoadGranted: [{
44
- readonly type: "setGlobal";
45
- readonly name: "databuddyConfig";
46
- readonly value: "{{configWhenGranted}}";
46
+ readonly type: 'setGlobal';
47
+ readonly name: 'databuddyConfig';
48
+ readonly value: '{{configWhenGranted}}';
47
49
  readonly ifUndefined: true;
48
50
  }];
49
51
  readonly onBeforeLoadDenied: [{
50
- readonly type: "setGlobal";
51
- readonly name: "databuddyConfig";
52
- readonly value: "{{configWhenDenied}}";
52
+ readonly type: 'setGlobal';
53
+ readonly name: 'databuddyConfig';
54
+ readonly value: '{{configWhenDenied}}';
53
55
  readonly ifUndefined: true;
54
56
  }];
55
57
  readonly onLoadGranted: [{
56
- readonly type: "setGlobalPath";
58
+ readonly type: 'setGlobalPath';
57
59
  readonly path: ["databuddy", "options", "disabled"];
58
60
  readonly value: false;
59
61
  }];
60
62
  readonly onLoadDenied: [{
61
- readonly type: "setGlobalPath";
63
+ readonly type: 'setGlobalPath';
62
64
  readonly path: ["databuddy", "options", "disabled"];
63
65
  readonly value: true;
64
66
  }];
65
67
  readonly onConsentGranted: [{
66
- readonly type: "setGlobal";
67
- readonly name: "databuddyConfig";
68
- readonly value: "{{configWhenGranted}}";
68
+ readonly type: 'setGlobal';
69
+ readonly name: 'databuddyConfig';
70
+ readonly value: '{{configWhenGranted}}';
69
71
  readonly ifUndefined: false;
70
72
  }, {
71
- readonly type: "setGlobalPath";
73
+ readonly type: 'setGlobalPath';
72
74
  readonly path: ["databuddy", "options", "disabled"];
73
75
  readonly value: false;
74
76
  }];
75
77
  readonly onConsentDenied: [{
76
- readonly type: "setGlobal";
77
- readonly name: "databuddyConfig";
78
- readonly value: "{{configWhenDenied}}";
78
+ readonly type: 'setGlobal';
79
+ readonly name: 'databuddyConfig';
80
+ readonly value: '{{configWhenDenied}}';
79
81
  readonly ifUndefined: false;
80
82
  }, {
81
- readonly type: "setGlobalPath";
83
+ readonly type: 'setGlobalPath';
82
84
  readonly path: ["databuddy", "options", "disabled"];
83
85
  readonly value: true;
84
86
  }];
85
- readonly kind: "c15t.vendor-manifest";
86
- readonly schemaVersion: 1;
87
87
  };
88
88
  export interface DatabuddyConsentOptions {
89
89
  /**