@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,232 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ matomoAnalytics: ()=>matomoAnalytics,
32
+ matomoAnalyticsManifest: ()=>matomoAnalyticsManifest
33
+ });
34
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
35
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
36
+ const script_url_cjs_namespaceObject = require("../_shared/script-url.cjs");
37
+ function stripProtocol(value) {
38
+ if (value.startsWith('https://')) return value.slice(8);
39
+ if (value.startsWith('http://')) return value.slice(7);
40
+ return value;
41
+ }
42
+ function resolveMatomoOrigin(options) {
43
+ if (options.matomoUrl) return (0, script_url_cjs_namespaceObject.stripTrailingSlashes)(options.matomoUrl);
44
+ if (options.cloudId) {
45
+ const cleanedCloudId = (0, script_url_cjs_namespaceObject.stripTrailingSlashes)(stripProtocol(options.cloudId));
46
+ if (cleanedCloudId.endsWith('.matomo.cloud')) return `https://${cleanedCloudId}`;
47
+ return `https://cdn.matomo.cloud/${cleanedCloudId}`;
48
+ }
49
+ }
50
+ function buildInstallSteps(options) {
51
+ const install = [
52
+ {
53
+ type: 'setGlobal',
54
+ name: '_paq',
55
+ value: [],
56
+ ifUndefined: true
57
+ },
58
+ {
59
+ type: 'pushToQueue',
60
+ queue: '_paq',
61
+ value: [
62
+ 'setTrackerUrl',
63
+ '{{trackerUrl}}'
64
+ ]
65
+ },
66
+ {
67
+ type: 'pushToQueue',
68
+ queue: '_paq',
69
+ value: [
70
+ 'setSiteId',
71
+ '{{siteId}}'
72
+ ]
73
+ }
74
+ ];
75
+ if (options.enableLinkTracking) install.push({
76
+ type: 'pushToQueue',
77
+ queue: '_paq',
78
+ value: [
79
+ 'enableLinkTracking'
80
+ ]
81
+ });
82
+ if (options.disableCookies) install.push({
83
+ type: 'pushToQueue',
84
+ queue: '_paq',
85
+ value: [
86
+ 'disableCookies'
87
+ ]
88
+ });
89
+ if (options.enableConsentMode && !options.consentInitiallyGiven) install.push({
90
+ type: 'pushToQueue',
91
+ queue: '_paq',
92
+ value: [
93
+ 'requireConsent'
94
+ ]
95
+ });
96
+ if (options.enableConsentMode && options.consentInitiallyGiven) {
97
+ install.push({
98
+ type: 'pushToQueue',
99
+ queue: '_paq',
100
+ value: [
101
+ 'setConsentGiven'
102
+ ]
103
+ });
104
+ if (options.trackPageView) install.push({
105
+ type: 'pushToQueue',
106
+ queue: '_paq',
107
+ value: [
108
+ 'trackPageView'
109
+ ]
110
+ });
111
+ }
112
+ if (options.trackPageView && !options.enableConsentMode) install.push({
113
+ type: 'pushToQueue',
114
+ queue: '_paq',
115
+ value: [
116
+ 'trackPageView'
117
+ ]
118
+ });
119
+ install.push({
120
+ type: 'loadScript',
121
+ src: "{{scriptUrl}}",
122
+ async: true
123
+ });
124
+ return install;
125
+ }
126
+ function buildGrantedHooks(options) {
127
+ const onBeforeLoadGranted = [];
128
+ if (options.enableConsentMode && !options.consentInitiallyGiven) onBeforeLoadGranted.push({
129
+ type: 'pushToQueue',
130
+ queue: '_paq',
131
+ value: [
132
+ 'setConsentGiven'
133
+ ]
134
+ });
135
+ if (options.trackPageView && options.enableConsentMode && !options.consentInitiallyGiven) onBeforeLoadGranted.push({
136
+ type: 'pushToQueue',
137
+ queue: '_paq',
138
+ value: [
139
+ 'trackPageView'
140
+ ]
141
+ });
142
+ const onConsentGranted = [];
143
+ if (options.enableConsentMode) {
144
+ onConsentGranted.push({
145
+ type: 'pushToQueue',
146
+ queue: '_paq',
147
+ value: [
148
+ 'setConsentGiven'
149
+ ]
150
+ });
151
+ if (options.trackPageView) onConsentGranted.push({
152
+ type: 'pushToQueue',
153
+ queue: '_paq',
154
+ value: [
155
+ 'trackPageView'
156
+ ]
157
+ });
158
+ }
159
+ return {
160
+ onBeforeLoadGranted,
161
+ onConsentGranted
162
+ };
163
+ }
164
+ function buildDeniedHooks(options) {
165
+ const onConsentDenied = [];
166
+ if (options.enableConsentMode) onConsentDenied.push({
167
+ type: 'pushToQueue',
168
+ queue: '_paq',
169
+ value: [
170
+ 'forgetConsentGiven'
171
+ ]
172
+ });
173
+ return onConsentDenied;
174
+ }
175
+ function createMatomoAnalyticsManifest(options) {
176
+ const { onBeforeLoadGranted, onConsentGranted } = buildGrantedHooks(options);
177
+ let alwaysLoad;
178
+ let persistAfterConsentRevoked;
179
+ if (options.enableConsentMode) {
180
+ alwaysLoad = true;
181
+ persistAfterConsentRevoked = true;
182
+ }
183
+ return {
184
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
185
+ vendor: 'matomo-analytics',
186
+ category: 'measurement',
187
+ alwaysLoad,
188
+ persistAfterConsentRevoked,
189
+ install: buildInstallSteps(options),
190
+ onBeforeLoadGranted,
191
+ onConsentGranted,
192
+ onConsentDenied: buildDeniedHooks(options)
193
+ };
194
+ }
195
+ const matomoAnalyticsManifest = createMatomoAnalyticsManifest({
196
+ enableConsentMode: false,
197
+ consentInitiallyGiven: false,
198
+ enableLinkTracking: false,
199
+ disableCookies: false,
200
+ trackPageView: true
201
+ });
202
+ function matomoAnalytics(options = {}) {
203
+ const origin = resolveMatomoOrigin(options);
204
+ let trackerUrl = options.trackerUrl;
205
+ if (!trackerUrl && origin) trackerUrl = (0, script_url_cjs_namespaceObject.joinUrlPath)(origin, 'matomo.php');
206
+ let scriptUrl = options.scriptUrl;
207
+ if (!scriptUrl && origin) scriptUrl = (0, script_url_cjs_namespaceObject.joinUrlPath)(origin, 'matomo.js');
208
+ if (!trackerUrl || !scriptUrl) throw new Error("matomoAnalytics requires `matomoUrl`, `cloudId`, or explicit `trackerUrl` and `scriptUrl` values.");
209
+ const enableConsentMode = 'required' === options.defaultConsent || 'given' === options.defaultConsent;
210
+ const consentInitiallyGiven = 'given' === options.defaultConsent;
211
+ const manifest = createMatomoAnalyticsManifest({
212
+ enableConsentMode,
213
+ consentInitiallyGiven,
214
+ enableLinkTracking: options.enableLinkTracking ?? false,
215
+ disableCookies: options.disableCookies ?? false,
216
+ trackPageView: options.trackPageView ?? true
217
+ });
218
+ return (0, external_resolve_cjs_namespaceObject.resolveManifest)(manifest, {
219
+ siteId: String(options.siteId ?? 1),
220
+ trackerUrl,
221
+ scriptUrl
222
+ });
223
+ }
224
+ exports.matomoAnalytics = __webpack_exports__.matomoAnalytics;
225
+ exports.matomoAnalyticsManifest = __webpack_exports__.matomoAnalyticsManifest;
226
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
227
+ "matomoAnalytics",
228
+ "matomoAnalyticsManifest"
229
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
230
+ Object.defineProperty(exports, '__esModule', {
231
+ value: true
232
+ });
@@ -0,0 +1,191 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ import { joinUrlPath, stripTrailingSlashes } from "../_shared/script-url.js";
4
+ function stripProtocol(value) {
5
+ if (value.startsWith('https://')) return value.slice(8);
6
+ if (value.startsWith('http://')) return value.slice(7);
7
+ return value;
8
+ }
9
+ function resolveMatomoOrigin(options) {
10
+ if (options.matomoUrl) return stripTrailingSlashes(options.matomoUrl);
11
+ if (options.cloudId) {
12
+ const cleanedCloudId = stripTrailingSlashes(stripProtocol(options.cloudId));
13
+ if (cleanedCloudId.endsWith('.matomo.cloud')) return `https://${cleanedCloudId}`;
14
+ return `https://cdn.matomo.cloud/${cleanedCloudId}`;
15
+ }
16
+ }
17
+ function buildInstallSteps(options) {
18
+ const install = [
19
+ {
20
+ type: 'setGlobal',
21
+ name: '_paq',
22
+ value: [],
23
+ ifUndefined: true
24
+ },
25
+ {
26
+ type: 'pushToQueue',
27
+ queue: '_paq',
28
+ value: [
29
+ 'setTrackerUrl',
30
+ '{{trackerUrl}}'
31
+ ]
32
+ },
33
+ {
34
+ type: 'pushToQueue',
35
+ queue: '_paq',
36
+ value: [
37
+ 'setSiteId',
38
+ '{{siteId}}'
39
+ ]
40
+ }
41
+ ];
42
+ if (options.enableLinkTracking) install.push({
43
+ type: 'pushToQueue',
44
+ queue: '_paq',
45
+ value: [
46
+ 'enableLinkTracking'
47
+ ]
48
+ });
49
+ if (options.disableCookies) install.push({
50
+ type: 'pushToQueue',
51
+ queue: '_paq',
52
+ value: [
53
+ 'disableCookies'
54
+ ]
55
+ });
56
+ if (options.enableConsentMode && !options.consentInitiallyGiven) install.push({
57
+ type: 'pushToQueue',
58
+ queue: '_paq',
59
+ value: [
60
+ 'requireConsent'
61
+ ]
62
+ });
63
+ if (options.enableConsentMode && options.consentInitiallyGiven) {
64
+ install.push({
65
+ type: 'pushToQueue',
66
+ queue: '_paq',
67
+ value: [
68
+ 'setConsentGiven'
69
+ ]
70
+ });
71
+ if (options.trackPageView) install.push({
72
+ type: 'pushToQueue',
73
+ queue: '_paq',
74
+ value: [
75
+ 'trackPageView'
76
+ ]
77
+ });
78
+ }
79
+ if (options.trackPageView && !options.enableConsentMode) install.push({
80
+ type: 'pushToQueue',
81
+ queue: '_paq',
82
+ value: [
83
+ 'trackPageView'
84
+ ]
85
+ });
86
+ install.push({
87
+ type: 'loadScript',
88
+ src: "{{scriptUrl}}",
89
+ async: true
90
+ });
91
+ return install;
92
+ }
93
+ function buildGrantedHooks(options) {
94
+ const onBeforeLoadGranted = [];
95
+ if (options.enableConsentMode && !options.consentInitiallyGiven) onBeforeLoadGranted.push({
96
+ type: 'pushToQueue',
97
+ queue: '_paq',
98
+ value: [
99
+ 'setConsentGiven'
100
+ ]
101
+ });
102
+ if (options.trackPageView && options.enableConsentMode && !options.consentInitiallyGiven) onBeforeLoadGranted.push({
103
+ type: 'pushToQueue',
104
+ queue: '_paq',
105
+ value: [
106
+ 'trackPageView'
107
+ ]
108
+ });
109
+ const onConsentGranted = [];
110
+ if (options.enableConsentMode) {
111
+ onConsentGranted.push({
112
+ type: 'pushToQueue',
113
+ queue: '_paq',
114
+ value: [
115
+ 'setConsentGiven'
116
+ ]
117
+ });
118
+ if (options.trackPageView) onConsentGranted.push({
119
+ type: 'pushToQueue',
120
+ queue: '_paq',
121
+ value: [
122
+ 'trackPageView'
123
+ ]
124
+ });
125
+ }
126
+ return {
127
+ onBeforeLoadGranted,
128
+ onConsentGranted
129
+ };
130
+ }
131
+ function buildDeniedHooks(options) {
132
+ const onConsentDenied = [];
133
+ if (options.enableConsentMode) onConsentDenied.push({
134
+ type: 'pushToQueue',
135
+ queue: '_paq',
136
+ value: [
137
+ 'forgetConsentGiven'
138
+ ]
139
+ });
140
+ return onConsentDenied;
141
+ }
142
+ function createMatomoAnalyticsManifest(options) {
143
+ const { onBeforeLoadGranted, onConsentGranted } = buildGrantedHooks(options);
144
+ let alwaysLoad;
145
+ let persistAfterConsentRevoked;
146
+ if (options.enableConsentMode) {
147
+ alwaysLoad = true;
148
+ persistAfterConsentRevoked = true;
149
+ }
150
+ return {
151
+ ...vendorManifestContract,
152
+ vendor: 'matomo-analytics',
153
+ category: 'measurement',
154
+ alwaysLoad,
155
+ persistAfterConsentRevoked,
156
+ install: buildInstallSteps(options),
157
+ onBeforeLoadGranted,
158
+ onConsentGranted,
159
+ onConsentDenied: buildDeniedHooks(options)
160
+ };
161
+ }
162
+ const matomoAnalyticsManifest = createMatomoAnalyticsManifest({
163
+ enableConsentMode: false,
164
+ consentInitiallyGiven: false,
165
+ enableLinkTracking: false,
166
+ disableCookies: false,
167
+ trackPageView: true
168
+ });
169
+ function matomoAnalytics(options = {}) {
170
+ const origin = resolveMatomoOrigin(options);
171
+ let trackerUrl = options.trackerUrl;
172
+ if (!trackerUrl && origin) trackerUrl = joinUrlPath(origin, 'matomo.php');
173
+ let scriptUrl = options.scriptUrl;
174
+ if (!scriptUrl && origin) scriptUrl = joinUrlPath(origin, 'matomo.js');
175
+ if (!trackerUrl || !scriptUrl) throw new Error("matomoAnalytics requires `matomoUrl`, `cloudId`, or explicit `trackerUrl` and `scriptUrl` values.");
176
+ const enableConsentMode = 'required' === options.defaultConsent || 'given' === options.defaultConsent;
177
+ const consentInitiallyGiven = 'given' === options.defaultConsent;
178
+ const manifest = createMatomoAnalyticsManifest({
179
+ enableConsentMode,
180
+ consentInitiallyGiven,
181
+ enableLinkTracking: options.enableLinkTracking ?? false,
182
+ disableCookies: options.disableCookies ?? false,
183
+ trackPageView: options.trackPageView ?? true
184
+ });
185
+ return resolveManifest(manifest, {
186
+ siteId: String(options.siteId ?? 1),
187
+ trackerUrl,
188
+ scriptUrl
189
+ });
190
+ }
191
+ export { matomoAnalytics, matomoAnalyticsManifest };
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ clarity: ()=>clarity,
32
+ clarityManifest: ()=>clarityManifest
33
+ });
34
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
35
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
36
+ function toClarityConsentState(value) {
37
+ if (true === value) return 'granted';
38
+ if (false === value) return 'denied';
39
+ if ('string' != typeof value) return;
40
+ const normalized = value.toLowerCase();
41
+ if ('granted' === normalized || 'true' === normalized) return 'granted';
42
+ if ('denied' === normalized || 'false' === normalized) return 'denied';
43
+ }
44
+ function getConsentValue(value, keys) {
45
+ for (const key of keys){
46
+ const consent = toClarityConsentState(value[key]);
47
+ if (consent) return consent;
48
+ }
49
+ }
50
+ function getConsentPayloadFromState(consents) {
51
+ let adStorage;
52
+ adStorage = consents.marketing ? 'granted' : 'denied';
53
+ let analyticsStorage;
54
+ analyticsStorage = consents.measurement ? 'granted' : 'denied';
55
+ return {
56
+ ad_Storage: adStorage,
57
+ analytics_Storage: analyticsStorage
58
+ };
59
+ }
60
+ function getClarityConsentPayload(consents, defaultConsent) {
61
+ const fallback = getConsentPayloadFromState(consents);
62
+ if (void 0 === defaultConsent) return fallback;
63
+ const booleanConsent = toClarityConsentState(defaultConsent);
64
+ if (booleanConsent) return {
65
+ ad_Storage: booleanConsent,
66
+ analytics_Storage: booleanConsent
67
+ };
68
+ if (null !== defaultConsent && 'object' == typeof defaultConsent) return {
69
+ ad_Storage: getConsentValue(defaultConsent, [
70
+ 'ad_Storage',
71
+ 'ad_storage',
72
+ 'marketing'
73
+ ]) ?? fallback.ad_Storage,
74
+ analytics_Storage: getConsentValue(defaultConsent, [
75
+ 'analytics_Storage',
76
+ 'analytics_storage',
77
+ 'measurement',
78
+ 'analytics'
79
+ ]) ?? fallback.analytics_Storage
80
+ };
81
+ return fallback;
82
+ }
83
+ function syncClarityConsent(info, defaultConsent) {
84
+ window.clarity?.('consentv2', getClarityConsentPayload(info.consents, defaultConsent));
85
+ }
86
+ const clarityManifest = {
87
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
88
+ vendor: 'microsoft-clarity',
89
+ category: 'measurement',
90
+ persistAfterConsentRevoked: true,
91
+ bootstrap: [
92
+ {
93
+ type: 'defineStubFunction',
94
+ name: 'clarity',
95
+ queue: {
96
+ property: 'q'
97
+ },
98
+ queueFormat: 'array',
99
+ ifUndefined: true
100
+ }
101
+ ],
102
+ install: [
103
+ {
104
+ type: 'loadScript',
105
+ src: "{{scriptUrl}}",
106
+ async: true
107
+ }
108
+ ]
109
+ };
110
+ function clarity({ id, defaultConsent, scriptUrl }) {
111
+ const normalizedId = id.trim();
112
+ if (void 0 === scriptUrl && 0 === normalizedId.length) throw new Error(`Invalid Clarity id value "${id}". A non-empty id is required to construct the Clarity loader URL when scriptUrl is not provided.`);
113
+ const resolved = (0, external_resolve_cjs_namespaceObject.resolveManifest)(clarityManifest, {
114
+ scriptUrl: scriptUrl ?? `https://www.clarity.ms/tag/${normalizedId}`
115
+ });
116
+ const onBeforeLoad = resolved.onBeforeLoad;
117
+ const onConsentChange = resolved.onConsentChange;
118
+ return {
119
+ ...resolved,
120
+ onBeforeLoad: (info)=>{
121
+ onBeforeLoad?.(info);
122
+ syncClarityConsent(info, defaultConsent);
123
+ },
124
+ onConsentChange: (info)=>{
125
+ onConsentChange?.(info);
126
+ syncClarityConsent(info);
127
+ }
128
+ };
129
+ }
130
+ exports.clarity = __webpack_exports__.clarity;
131
+ exports.clarityManifest = __webpack_exports__.clarityManifest;
132
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
133
+ "clarity",
134
+ "clarityManifest"
135
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
136
+ Object.defineProperty(exports, '__esModule', {
137
+ value: true
138
+ });
@@ -0,0 +1,97 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ function toClarityConsentState(value) {
4
+ if (true === value) return 'granted';
5
+ if (false === value) return 'denied';
6
+ if ('string' != typeof value) return;
7
+ const normalized = value.toLowerCase();
8
+ if ('granted' === normalized || 'true' === normalized) return 'granted';
9
+ if ('denied' === normalized || 'false' === normalized) return 'denied';
10
+ }
11
+ function getConsentValue(value, keys) {
12
+ for (const key of keys){
13
+ const consent = toClarityConsentState(value[key]);
14
+ if (consent) return consent;
15
+ }
16
+ }
17
+ function getConsentPayloadFromState(consents) {
18
+ let adStorage;
19
+ adStorage = consents.marketing ? 'granted' : 'denied';
20
+ let analyticsStorage;
21
+ analyticsStorage = consents.measurement ? 'granted' : 'denied';
22
+ return {
23
+ ad_Storage: adStorage,
24
+ analytics_Storage: analyticsStorage
25
+ };
26
+ }
27
+ function getClarityConsentPayload(consents, defaultConsent) {
28
+ const fallback = getConsentPayloadFromState(consents);
29
+ if (void 0 === defaultConsent) return fallback;
30
+ const booleanConsent = toClarityConsentState(defaultConsent);
31
+ if (booleanConsent) return {
32
+ ad_Storage: booleanConsent,
33
+ analytics_Storage: booleanConsent
34
+ };
35
+ if (null !== defaultConsent && 'object' == typeof defaultConsent) return {
36
+ ad_Storage: getConsentValue(defaultConsent, [
37
+ 'ad_Storage',
38
+ 'ad_storage',
39
+ 'marketing'
40
+ ]) ?? fallback.ad_Storage,
41
+ analytics_Storage: getConsentValue(defaultConsent, [
42
+ 'analytics_Storage',
43
+ 'analytics_storage',
44
+ 'measurement',
45
+ 'analytics'
46
+ ]) ?? fallback.analytics_Storage
47
+ };
48
+ return fallback;
49
+ }
50
+ function syncClarityConsent(info, defaultConsent) {
51
+ window.clarity?.('consentv2', getClarityConsentPayload(info.consents, defaultConsent));
52
+ }
53
+ const clarityManifest = {
54
+ ...vendorManifestContract,
55
+ vendor: 'microsoft-clarity',
56
+ category: 'measurement',
57
+ persistAfterConsentRevoked: true,
58
+ bootstrap: [
59
+ {
60
+ type: 'defineStubFunction',
61
+ name: 'clarity',
62
+ queue: {
63
+ property: 'q'
64
+ },
65
+ queueFormat: 'array',
66
+ ifUndefined: true
67
+ }
68
+ ],
69
+ install: [
70
+ {
71
+ type: 'loadScript',
72
+ src: "{{scriptUrl}}",
73
+ async: true
74
+ }
75
+ ]
76
+ };
77
+ function clarity({ id, defaultConsent, scriptUrl }) {
78
+ const normalizedId = id.trim();
79
+ if (void 0 === scriptUrl && 0 === normalizedId.length) throw new Error(`Invalid Clarity id value "${id}". A non-empty id is required to construct the Clarity loader URL when scriptUrl is not provided.`);
80
+ const resolved = resolveManifest(clarityManifest, {
81
+ scriptUrl: scriptUrl ?? `https://www.clarity.ms/tag/${normalizedId}`
82
+ });
83
+ const onBeforeLoad = resolved.onBeforeLoad;
84
+ const onConsentChange = resolved.onConsentChange;
85
+ return {
86
+ ...resolved,
87
+ onBeforeLoad: (info)=>{
88
+ onBeforeLoad?.(info);
89
+ syncClarityConsent(info, defaultConsent);
90
+ },
91
+ onConsentChange: (info)=>{
92
+ onConsentChange?.(info);
93
+ syncClarityConsent(info);
94
+ }
95
+ };
96
+ }
97
+ export { clarity, clarityManifest };