@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,330 @@
1
+ import type { Script } from 'c15t';
2
+ export declare const RUDDERSTACK_QUEUE_METHODS: readonly ['setDefaultInstanceKey', 'load', 'ready', 'page', 'track', 'identify', 'alias', 'group', 'reset', 'setAnonymousId', 'startSession', 'endSession', 'consent', 'addCustomIntegration'];
3
+ type JsonPrimitive = string | number | boolean | null;
4
+ type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
5
+ /**
6
+ * JSON-serializable object passed to RudderStack's `load()` API.
7
+ */
8
+ export interface JsonObject {
9
+ [key: string]: JsonValue;
10
+ }
11
+ /**
12
+ * RudderStack JavaScript SDK `load()` options.
13
+ *
14
+ * The options are interpolated into a script manifest and passed as the third
15
+ * `rudderanalytics.load(writeKey, dataPlaneUrl, options)` argument. Keep values
16
+ * JSON-serializable: plain objects, arrays, strings, numbers, booleans, and
17
+ * `null`. Functions, class instances, Dates, Maps, Sets, and symbols are not
18
+ * supported.
19
+ */
20
+ export type RudderStackLoadOptions = JsonObject;
21
+ /**
22
+ * Public RudderStack JavaScript SDK API exposed on `window.rudderanalytics`.
23
+ *
24
+ * The official v3 CDN snippet starts as an array-backed queue and the loaded
25
+ * SDK replaces it with an initialized runtime object. Use this interface for
26
+ * calls made after consent has allowed the SDK to load.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * window.rudderanalytics?.track('Signup Completed', { plan: 'pro' });
31
+ * ```
32
+ */
33
+ export interface RudderStackApi {
34
+ /**
35
+ * Sets the default instance key for multi-instance setups.
36
+ *
37
+ * @param key - Instance key to use for subsequent calls.
38
+ * @returns The RudderStack runtime or a promise-like value from the SDK.
39
+ */
40
+ setDefaultInstanceKey: (key: string) => unknown;
41
+ /**
42
+ * Loads and initializes the RudderStack JavaScript SDK.
43
+ *
44
+ * @param writeKey - Source write key from RudderStack.
45
+ * @param dataPlaneUrl - HTTPS data plane URL for the source.
46
+ * @param options - Optional JSON-serializable load options.
47
+ * @returns The RudderStack runtime or a promise-like value from the SDK.
48
+ */
49
+ load: (writeKey: string, dataPlaneUrl: string, options?: RudderStackLoadOptions) => unknown;
50
+ /**
51
+ * Registers a callback that fires when the SDK is ready.
52
+ *
53
+ * @param callback - Function to run once the SDK is ready.
54
+ * @returns The RudderStack runtime or a promise-like value from the SDK.
55
+ */
56
+ ready: (callback: () => void) => unknown;
57
+ /**
58
+ * Tracks a page view with optional category, name, properties, and options.
59
+ *
60
+ * @param category - Optional page category.
61
+ * @param name - Optional page name.
62
+ * @param properties - Optional page metadata payload.
63
+ * @param options - Optional event context or integrations options.
64
+ * @param callback - Optional callback after processing.
65
+ * @returns The RudderStack runtime or a promise-like value from the SDK.
66
+ */
67
+ page: (category?: string, name?: string, properties?: Record<string, unknown>, options?: Record<string, unknown>, callback?: () => void) => unknown;
68
+ /**
69
+ * Tracks a named event.
70
+ *
71
+ * @param event - Event name to record.
72
+ * @param properties - Optional event properties payload.
73
+ * @param options - Optional event context or integrations options.
74
+ * @param callback - Optional callback after processing.
75
+ * @returns The RudderStack runtime or a promise-like value from the SDK.
76
+ */
77
+ track: (event: string, properties?: Record<string, unknown>, options?: Record<string, unknown>, callback?: () => void) => unknown;
78
+ /**
79
+ * Identifies a user and associates traits with that identity.
80
+ *
81
+ * @param userId - Stable user identifier.
82
+ * @param traits - Optional trait map associated with the user.
83
+ * @param options - Optional event context or integrations options.
84
+ * @param callback - Optional callback after processing.
85
+ * @returns The RudderStack runtime or a promise-like value from the SDK.
86
+ */
87
+ identify: (userId: string, traits?: Record<string, unknown>, options?: Record<string, unknown>, callback?: () => void) => unknown;
88
+ /**
89
+ * Aliases one user identifier to another.
90
+ *
91
+ * @param userId - New canonical user identifier.
92
+ * @param previousId - Optional previous identifier.
93
+ * @param options - Optional event context or integrations options.
94
+ * @param callback - Optional callback after processing.
95
+ * @returns The RudderStack runtime or a promise-like value from the SDK.
96
+ */
97
+ alias: (userId: string, previousId?: string, options?: Record<string, unknown>, callback?: () => void) => unknown;
98
+ /**
99
+ * Associates the current user with a group or account.
100
+ *
101
+ * @param groupId - Group or account identifier.
102
+ * @param traits - Optional group trait map.
103
+ * @param options - Optional event context or integrations options.
104
+ * @param callback - Optional callback after processing.
105
+ * @returns The RudderStack runtime or a promise-like value from the SDK.
106
+ */
107
+ group: (groupId: string, traits?: Record<string, unknown>, options?: Record<string, unknown>, callback?: () => void) => unknown;
108
+ /**
109
+ * Clears the current user identity state.
110
+ *
111
+ * @returns The RudderStack runtime or a promise-like value from the SDK.
112
+ */
113
+ reset: () => unknown;
114
+ /**
115
+ * Sets the anonymous ID used for subsequent events.
116
+ *
117
+ * @param anonymousId - Anonymous identifier to assign.
118
+ * @returns The RudderStack runtime or a promise-like value from the SDK.
119
+ */
120
+ setAnonymousId: (anonymousId: string) => unknown;
121
+ /**
122
+ * Starts a session with an optional session identifier.
123
+ *
124
+ * @param sessionId - Optional session identifier.
125
+ * @returns The RudderStack runtime or a promise-like value from the SDK.
126
+ */
127
+ startSession: (sessionId?: string) => unknown;
128
+ /**
129
+ * Ends the current session.
130
+ *
131
+ * @returns The RudderStack runtime or a promise-like value from the SDK.
132
+ */
133
+ endSession: () => unknown;
134
+ /**
135
+ * Transitions the SDK from pre-consent to post-consent behavior.
136
+ *
137
+ * @param consentOptions - Vendor-supported consent options.
138
+ * @returns The RudderStack runtime or a promise-like value from the SDK.
139
+ *
140
+ * @remarks
141
+ * This API is for RudderStack's consent-management flow. In the default
142
+ * (blocked-load) mode it is not a c15t revocation hook; c15t unloads the
143
+ * SDK when measurement consent is revoked. In the opt-in pre-consent mode
144
+ * (`consentManagement` option) c15t calls it with the mapped consent IDs on
145
+ * every consent decision and change.
146
+ */
147
+ consent: (consentOptions?: Record<string, unknown>) => unknown;
148
+ /**
149
+ * Registers a custom device-mode integration. RudderStack only accepts
150
+ * registrations made before `load()` completes, which is why this is part
151
+ * of the pre-load queue.
152
+ *
153
+ * @param name - Integration name.
154
+ * @param integration - Integration implementation object.
155
+ * @returns The RudderStack runtime or a promise-like value from the SDK.
156
+ */
157
+ addCustomIntegration: (name: string, integration: unknown) => unknown;
158
+ }
159
+ declare global {
160
+ interface Window {
161
+ rudderanalytics?: RudderStackApi;
162
+ rudderAnalyticsBuildType?: string;
163
+ RudderSnippetVersion?: string;
164
+ }
165
+ }
166
+ /**
167
+ * RudderStack vendor manifest.
168
+ *
169
+ * Creates RudderStack's v3 `window.rudderanalytics` queue, marks the snippet as
170
+ * seeded, queues the required `load()` call and optional `page()` call, then
171
+ * lets c15t own the script element.
172
+ */
173
+ export declare const rudderstackManifest: {
174
+ readonly kind: "c15t.vendor-manifest";
175
+ readonly schemaVersion: 1;
176
+ readonly vendor: 'rudderstack';
177
+ readonly category: 'measurement';
178
+ readonly bootstrap: [{
179
+ readonly type: 'setGlobal';
180
+ readonly name: 'rudderanalytics';
181
+ readonly value: readonly [];
182
+ readonly ifUndefined: true;
183
+ }, {
184
+ readonly type: 'setGlobal';
185
+ readonly name: 'RudderSnippetVersion';
186
+ readonly value: '3.0.32';
187
+ }, {
188
+ readonly type: 'setGlobal';
189
+ readonly name: 'rudderAnalyticsBuildType';
190
+ readonly value: 'modern';
191
+ }, {
192
+ readonly type: 'setGlobalPath';
193
+ readonly path: ["rudderanalytics", "snippetExecuted"];
194
+ readonly value: true;
195
+ }, {
196
+ readonly type: 'defineQueueMethods';
197
+ readonly target: 'rudderanalytics';
198
+ readonly methods: ["setDefaultInstanceKey", "load", "ready", "page", "track", "identify", "alias", "group", "reset", "setAnonymousId", "startSession", "endSession", "consent", "addCustomIntegration"];
199
+ }];
200
+ readonly install: [{
201
+ readonly type: 'callGlobal';
202
+ readonly global: 'rudderanalytics';
203
+ readonly method: 'load';
204
+ readonly args: ["{{writeKey}}", "{{dataPlaneUrl}}", "{{loadOptions}}"];
205
+ }, {
206
+ readonly type: 'callGlobal';
207
+ readonly global: 'rudderanalytics';
208
+ readonly method: 'page';
209
+ }, {
210
+ readonly type: 'loadScript';
211
+ readonly src: '{{scriptUrl}}';
212
+ readonly async: true;
213
+ readonly attributes: {
214
+ readonly 'data-loader': 'RS_JS_SDK';
215
+ readonly 'data-rsa-write-key': '{{writeKey}}';
216
+ };
217
+ }];
218
+ };
219
+ /**
220
+ * c15t consent categories accepted by the RudderStack consent mapping.
221
+ */
222
+ export type RudderStackConsentCategory = 'necessary' | 'functionality' | 'experience' | 'measurement' | 'marketing';
223
+ /**
224
+ * Opt-in pre-consent mode configuration.
225
+ *
226
+ * When provided, the SDK loads immediately for every visitor in RudderStack's
227
+ * pre-consent state (no persistent storage, events buffered in memory) and
228
+ * c15t signals consent decisions through `rudderanalytics.consent()` with the
229
+ * mapped consent IDs. This preserves pre-consent event attribution for users
230
+ * who go on to consent, at the cost of running vendor code before consent.
231
+ *
232
+ * Every destination in your RudderStack workspace must carry the consent IDs
233
+ * used here — c15t cannot verify that configuration from the browser, which is
234
+ * why this mode is opt-in and blocking the load stays the default.
235
+ */
236
+ export interface RudderStackConsentManagementOptions {
237
+ /**
238
+ * c15t consent category → RudderStack consent IDs.
239
+ *
240
+ * IDs come from your RudderStack destination consent settings. Categories
241
+ * granted in c15t contribute their IDs to `allowedConsentIds`; everything
242
+ * else lands in `deniedConsentIds`.
243
+ *
244
+ * @example
245
+ * ```ts
246
+ * {
247
+ * measurement: ['product-analytics'],
248
+ * marketing: ['ad-destinations'],
249
+ * }
250
+ * ```
251
+ */
252
+ mapping: Partial<Record<RudderStackConsentCategory, string[]>>;
253
+ }
254
+ export interface RudderStackOptions {
255
+ /**
256
+ * RudderStack source write key.
257
+ */
258
+ writeKey: string;
259
+ /**
260
+ * RudderStack HTTPS data plane URL.
261
+ */
262
+ dataPlaneUrl: string;
263
+ /**
264
+ * Opt into RudderStack's pre-consent mode with c15t as the consent
265
+ * provider instead of blocking the SDK load until consent.
266
+ *
267
+ * Defaults to `undefined`, which keeps the safe default: the SDK does not
268
+ * load until `measurement` consent is granted. See
269
+ * {@link RudderStackConsentManagementOptions} for the tradeoffs.
270
+ */
271
+ consentManagement?: RudderStackConsentManagementOptions;
272
+ /**
273
+ * Optional JSON-serializable RudderStack `load()` options.
274
+ *
275
+ * Values must be JSON-serializable because c15t resolves the manifest into
276
+ * script lifecycle callbacks. Do not pass functions, Dates, Maps, Sets,
277
+ * class instances, symbols, or other non-JSON values.
278
+ */
279
+ loadOptions?: RudderStackLoadOptions;
280
+ /**
281
+ * Queue the initial `rudderanalytics.page()` call during setup.
282
+ *
283
+ * @default true
284
+ */
285
+ trackPageView?: boolean;
286
+ /**
287
+ * Optional full loader URL override.
288
+ *
289
+ * @default 'https://cdn.rudderlabs.com/v3/modern/rsa.min.js'
290
+ */
291
+ scriptUrl?: string;
292
+ }
293
+ /**
294
+ * Creates a RudderStack JavaScript SDK script.
295
+ *
296
+ * @see https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/quickstart/
297
+ *
298
+ * @param options - The options for the RudderStack script.
299
+ * @returns The RudderStack script configuration.
300
+ * @throws {Error} When `writeKey` is missing or only whitespace.
301
+ * @throws {Error} When `dataPlaneUrl` is missing, invalid, or not HTTPS.
302
+ *
303
+ * @remarks
304
+ * RudderStack collects customer behavior and sends it to destinations through
305
+ * your configured data plane. By default c15t gates the browser SDK on
306
+ * `measurement` consent and unloads it when that consent is revoked.
307
+ * `loadOptions` is passed directly as the third `load()` argument and must be
308
+ * JSON-serializable.
309
+ *
310
+ * Pass `consentManagement` to opt into RudderStack's pre-consent mode instead:
311
+ * the SDK loads immediately with no persistent storage and buffered events,
312
+ * and c15t signals every consent decision through `rudderanalytics.consent()`
313
+ * with your mapped consent IDs — preserving pre-consent event attribution for
314
+ * users who consent. Requires consent IDs on every RudderStack destination.
315
+ *
316
+ * @example
317
+ * ```ts
318
+ * import { rudderstack } from '@c15t/scripts/rudderstack';
319
+ *
320
+ * rudderstack({
321
+ * writeKey: 'WRITE_KEY',
322
+ * dataPlaneUrl: 'https://example.dataplane.rudderstack.com',
323
+ * loadOptions: {
324
+ * useBeacon: true,
325
+ * },
326
+ * });
327
+ * ```
328
+ */
329
+ export declare function rudderstack({ writeKey, dataPlaneUrl, consentManagement, loadOptions, trackPageView, scriptUrl, }: RudderStackOptions): Script;
330
+ export {};
@@ -0,0 +1,82 @@
1
+ import type { Script } from 'c15t';
2
+ declare global {
3
+ interface Window {
4
+ rybbit?: {
5
+ clearUserId: () => void;
6
+ event: (name: string, properties?: Record<string, unknown>) => void;
7
+ getUserId: () => string | null;
8
+ identify: (userId: string) => void;
9
+ pageview: () => void;
10
+ };
11
+ }
12
+ }
13
+ /**
14
+ * Rybbit Analytics vendor manifest.
15
+ *
16
+ * Rybbit reads its configuration from script data attributes at load time.
17
+ */
18
+ export declare const rybbitAnalyticsManifest: {
19
+ readonly kind: "c15t.vendor-manifest";
20
+ readonly schemaVersion: 1;
21
+ readonly vendor: 'rybbit-analytics';
22
+ readonly category: 'measurement';
23
+ readonly install: [{
24
+ readonly type: 'loadScript';
25
+ readonly src: '{{scriptUrl}}';
26
+ readonly defer: true;
27
+ readonly attributes: {
28
+ readonly 'data-site-id': '{{siteId}}';
29
+ readonly 'data-auto-track-pageview': '{{autoTrackPageview}}';
30
+ readonly 'data-track-spa': '{{trackSpa}}';
31
+ readonly 'data-track-query': '{{trackQuery}}';
32
+ readonly 'data-track-outbound': '{{trackOutbound}}';
33
+ readonly 'data-track-errors': '{{trackErrors}}';
34
+ readonly 'data-session-replay': '{{sessionReplay}}';
35
+ readonly 'data-web-vitals': '{{webVitals}}';
36
+ readonly 'data-skip-patterns': '{{skipPatterns}}';
37
+ readonly 'data-mask-patterns': '{{maskPatterns}}';
38
+ readonly 'data-debounce': '{{debounce}}';
39
+ readonly 'data-api-key': '{{apiKey}}';
40
+ };
41
+ }];
42
+ };
43
+ export interface RybbitAnalyticsOptions {
44
+ /** Your Rybbit site ID. */
45
+ siteId: string | number;
46
+ /** Automatically track pageviews. */
47
+ autoTrackPageview?: boolean;
48
+ /** Enable SPA route tracking. */
49
+ trackSpa?: boolean;
50
+ /** Include query parameters in tracked URLs. */
51
+ trackQuery?: boolean;
52
+ /** Track outbound link clicks. */
53
+ trackOutbound?: boolean;
54
+ /** Track JavaScript errors. */
55
+ trackErrors?: boolean;
56
+ /** Enable session replay. */
57
+ sessionReplay?: boolean;
58
+ /** Enable Web Vitals tracking. */
59
+ webVitals?: boolean;
60
+ /** URL patterns to skip from tracking. */
61
+ skipPatterns?: string[];
62
+ /** URL patterns to mask in tracked data. */
63
+ maskPatterns?: string[];
64
+ /** Debounce interval for pageview tracking. */
65
+ debounce?: number;
66
+ /** API key for authenticated tracking. */
67
+ apiKey?: string;
68
+ /** Override the analytics host URL. */
69
+ analyticsHost?: string;
70
+ /** Custom loader URL. */
71
+ scriptUrl?: string;
72
+ }
73
+ /**
74
+ * Creates a Rybbit Analytics script.
75
+ *
76
+ * @param options - The options for the Rybbit Analytics script.
77
+ * @returns The Rybbit Analytics script.
78
+ * @throws {Error} Throws `rybbitAnalytics: missing siteId` when
79
+ * `options.siteId` is undefined, null, or trims to an empty string. Provide a
80
+ * valid non-empty site ID string to prevent this error.
81
+ */
82
+ export declare function rybbitAnalytics(options: RybbitAnalyticsOptions): Script;
@@ -0,0 +1,158 @@
1
+ import type { Script } from 'c15t';
2
+ /**
3
+ * Public Segment Analytics.js API exposed on `window.analytics`.
4
+ *
5
+ * Use this interface when interacting with Segment calls queued before or after
6
+ * the client library is fully initialized.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * window.analytics.track('Signup', { plan: 'pro' });
11
+ * ```
12
+ */
13
+ export interface SegmentApi {
14
+ /**
15
+ * Queues an event tracking call.
16
+ *
17
+ * @param event - Event name to record.
18
+ * @param properties - Optional event properties payload.
19
+ * @returns `void`.
20
+ *
21
+ * @remarks
22
+ * Calls are queued until Analytics.js initializes.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * window.analytics.track('Signup', { plan: 'pro' });
27
+ * ```
28
+ */
29
+ track: (event: string, properties?: Record<string, unknown>) => void;
30
+ /**
31
+ * Queues a page tracking call.
32
+ *
33
+ * @param name - Optional page name override.
34
+ * @param properties - Optional page metadata payload.
35
+ * @returns `void`.
36
+ *
37
+ * @remarks
38
+ * If no name is passed, Segment infers the current page context.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * window.analytics.page('Pricing');
43
+ * ```
44
+ */
45
+ page: (name?: string, properties?: Record<string, unknown>) => void;
46
+ /**
47
+ * Queues a user identification call.
48
+ *
49
+ * @param userId - Stable user identifier.
50
+ * @param traits - Optional trait map associated with the user.
51
+ * @param options - Optional Segment call options.
52
+ * @returns `void`.
53
+ *
54
+ * @remarks
55
+ * Ensure the client is initialized and use a stable `userId` to avoid
56
+ * fragmented user profiles.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * window.analytics.identify('user_123', { email: 'dev@example.com' });
61
+ * ```
62
+ */
63
+ identify: (userId: string, traits?: Record<string, unknown>, options?: Record<string, unknown>) => void;
64
+ /**
65
+ * Queues a group association call for account-level analytics.
66
+ *
67
+ * @param groupId - Group or account identifier.
68
+ * @param traits - Optional group trait map.
69
+ * @param options - Optional Segment call options.
70
+ * @returns `void`.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * window.analytics.group('acme-inc', { plan: 'enterprise' });
75
+ * ```
76
+ */
77
+ group: (groupId: string, traits?: Record<string, unknown>, options?: Record<string, unknown>) => void;
78
+ /**
79
+ * Queues a user alias call to merge identities.
80
+ *
81
+ * @param userId - New canonical user identifier.
82
+ * @param previousId - Optional previous anonymous or legacy identifier.
83
+ * @param options - Optional Segment call options.
84
+ * @returns `void`.
85
+ *
86
+ * @remarks
87
+ * Use `previousId` only when linking an existing anonymous identity to the
88
+ * new `userId`.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * window.analytics.alias('user_123', 'anon_456');
93
+ * ```
94
+ */
95
+ alias: (userId: string, previousId?: string, options?: Record<string, unknown>) => void;
96
+ /**
97
+ * Queues a reset call that clears current user identity state.
98
+ *
99
+ * @returns `void`.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * window.analytics.reset();
104
+ * ```
105
+ */
106
+ reset: () => void;
107
+ }
108
+ declare global {
109
+ interface Window {
110
+ analytics?: SegmentApi;
111
+ }
112
+ }
113
+ /**
114
+ * Segment vendor manifest.
115
+ *
116
+ * Uses Segment's standard `window.analytics` queue shape and optionally queues
117
+ * the initial `page()` call before the bundle loads.
118
+ */
119
+ export declare const segmentManifest: {
120
+ readonly kind: "c15t.vendor-manifest";
121
+ readonly schemaVersion: 1;
122
+ readonly vendor: 'segment';
123
+ readonly category: 'measurement';
124
+ readonly bootstrap: [{
125
+ readonly type: 'setGlobal';
126
+ readonly name: 'analytics';
127
+ readonly value: readonly [];
128
+ readonly ifUndefined: true;
129
+ }, {
130
+ readonly type: 'defineQueueMethods';
131
+ readonly target: 'analytics';
132
+ readonly methods: ["track", "page", "identify", "group", "alias", "reset"];
133
+ }];
134
+ readonly install: [{
135
+ readonly type: 'callGlobal';
136
+ readonly global: 'analytics';
137
+ readonly method: 'page';
138
+ }, {
139
+ readonly type: 'loadScript';
140
+ readonly src: '{{scriptUrl}}';
141
+ readonly async: true;
142
+ }];
143
+ };
144
+ export interface SegmentOptions {
145
+ /** Your Segment write key. */
146
+ writeKey: string;
147
+ /** Queue the initial `analytics.page()` call during setup. */
148
+ trackPageView?: boolean;
149
+ /** Optional full loader URL override. */
150
+ scriptUrl?: string;
151
+ }
152
+ /**
153
+ * Creates a Segment Analytics.js script.
154
+ *
155
+ * @param options - The options for the Segment script.
156
+ * @returns The Segment script configuration.
157
+ */
158
+ export declare function segment({ writeKey, trackPageView, scriptUrl, }: SegmentOptions): Script;
@@ -0,0 +1,93 @@
1
+ import type { Script } from 'c15t';
2
+ declare global {
3
+ interface Window {
4
+ umami?: {
5
+ identify: (sessionData?: Record<string, unknown> | string) => void;
6
+ track: {
7
+ (payload?: Record<string, unknown>): void;
8
+ (eventName: string, eventData?: Record<string, unknown>): void;
9
+ };
10
+ };
11
+ }
12
+ }
13
+ /**
14
+ * Umami Analytics vendor manifest.
15
+ *
16
+ * Configures Umami entirely through script `data-*` attributes. Umami is a
17
+ * cookieless analytics product, so the script is consent-gated on
18
+ * `measurement` and unloaded when consent is revoked.
19
+ */
20
+ export declare const umamiAnalyticsManifest: {
21
+ readonly kind: "c15t.vendor-manifest";
22
+ readonly schemaVersion: 1;
23
+ readonly vendor: 'umami-analytics';
24
+ readonly category: 'measurement';
25
+ readonly install: [{
26
+ readonly type: 'loadScript';
27
+ readonly src: '{{scriptUrl}}';
28
+ readonly defer: true;
29
+ readonly attributes: {
30
+ readonly 'data-website-id': '{{websiteId}}';
31
+ readonly 'data-host-url': '{{hostUrl}}';
32
+ readonly 'data-auto-track': '{{autoTrackAttribute}}';
33
+ readonly 'data-domains': '{{domains}}';
34
+ readonly 'data-tag': '{{tag}}';
35
+ readonly 'data-before-send': '{{beforeSend}}';
36
+ };
37
+ }];
38
+ };
39
+ export interface UmamiAnalyticsOptions {
40
+ /**
41
+ * Your Umami website ID.
42
+ */
43
+ websiteId: string;
44
+ /**
45
+ * Override the host that receives analytics events.
46
+ */
47
+ hostUrl?: string;
48
+ /**
49
+ * Disable automatic tracking when set to `false`.
50
+ */
51
+ autoTrack?: boolean;
52
+ /**
53
+ * Restrict tracking to specific domains.
54
+ */
55
+ domains?: string[] | string;
56
+ /**
57
+ * Attach a tag to tracked events.
58
+ */
59
+ tag?: string;
60
+ /**
61
+ * Optional global hook name used for Umami's `data-before-send` attribute.
62
+ *
63
+ * Callback functions are intentionally not supported here because the c15t
64
+ * manifest runtime cannot serialize custom JavaScript functions.
65
+ */
66
+ beforeSend?: string;
67
+ /**
68
+ * Custom loader URL.
69
+ * @default 'https://cloud.umami.is/script.js'
70
+ */
71
+ scriptUrl?: string;
72
+ }
73
+ /**
74
+ * Creates an Umami Analytics script.
75
+ *
76
+ * @see https://umami.is/docs/tracker-config
77
+ *
78
+ * @param options - The options for the Umami Analytics script.
79
+ * @returns The Umami Analytics script.
80
+ * @throws {Error} When `websiteId` is missing, empty, or invalid. Provide a
81
+ * valid non-empty `websiteId` string to prevent this error.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * import { umamiAnalytics } from '@c15t/scripts/umami-analytics';
86
+ *
87
+ * umamiAnalytics({
88
+ * websiteId: 'site-abc-123',
89
+ * domains: ['example.com', 'www.example.com'],
90
+ * });
91
+ * ```
92
+ */
93
+ export declare function umamiAnalytics(options: UmamiAnalyticsOptions): Script;