@c15t/scripts 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/README.md +9 -9
  2. package/dist/e2e-test-utils.cjs +125 -0
  3. package/dist/e2e-test-utils.js +67 -0
  4. package/dist/engine/runtime.cjs +19 -9
  5. package/dist/engine/runtime.js +19 -9
  6. package/dist/registry.cjs +338 -0
  7. package/dist/registry.js +292 -0
  8. package/dist/types.cjs +18 -0
  9. package/dist/types.js +10 -1
  10. package/dist/vendors/_shared/attributes.cjs +51 -0
  11. package/dist/vendors/_shared/attributes.js +14 -0
  12. package/dist/vendors/_shared/google-consent.cjs +64 -0
  13. package/dist/vendors/_shared/google-consent.js +27 -0
  14. package/dist/vendors/_shared/install-builders.cjs +55 -0
  15. package/dist/vendors/_shared/install-builders.js +21 -0
  16. package/dist/vendors/_shared/script-url.cjs +74 -0
  17. package/dist/vendors/_shared/script-url.js +28 -0
  18. package/dist/{linkedin-insights.cjs → vendors/ads-and-pixels/linkedin-insights.cjs} +2 -2
  19. package/dist/{linkedin-insights.js → vendors/ads-and-pixels/linkedin-insights.js} +2 -2
  20. package/dist/vendors/ads-and-pixels/meta-pixel.cjs +202 -0
  21. package/dist/vendors/ads-and-pixels/meta-pixel.js +153 -0
  22. package/dist/{microsoft-uet.cjs → vendors/ads-and-pixels/microsoft-uet.cjs} +31 -14
  23. package/dist/{microsoft-uet.js → vendors/ads-and-pixels/microsoft-uet.js} +31 -14
  24. package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +147 -0
  25. package/dist/vendors/ads-and-pixels/reddit-pixel.js +107 -0
  26. package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +127 -0
  27. package/dist/vendors/ads-and-pixels/snapchat-pixel.js +87 -0
  28. package/dist/{tiktok-pixel.cjs → vendors/ads-and-pixels/tiktok-pixel.cjs} +2 -2
  29. package/dist/{tiktok-pixel.js → vendors/ads-and-pixels/tiktok-pixel.js} +2 -2
  30. package/dist/{x-pixel.cjs → vendors/ads-and-pixels/x-pixel.cjs} +6 -3
  31. package/dist/{x-pixel.js → vendors/ads-and-pixels/x-pixel.js} +6 -3
  32. package/dist/vendors/analytics/ahrefs-analytics.cjs +64 -0
  33. package/dist/vendors/analytics/ahrefs-analytics.js +27 -0
  34. package/dist/vendors/analytics/cloudflare-web-analytics.cjs +69 -0
  35. package/dist/vendors/analytics/cloudflare-web-analytics.js +32 -0
  36. package/dist/{databuddy.cjs → vendors/analytics/databuddy.cjs} +3 -3
  37. package/dist/{databuddy.js → vendors/analytics/databuddy.js} +3 -3
  38. package/dist/vendors/analytics/fathom-analytics.cjs +72 -0
  39. package/dist/vendors/analytics/fathom-analytics.js +35 -0
  40. package/dist/{google-tag.cjs → vendors/analytics/google-tag.cjs} +7 -28
  41. package/dist/{google-tag.js → vendors/analytics/google-tag.js} +7 -28
  42. package/dist/vendors/analytics/hotjar.cjs +81 -0
  43. package/dist/vendors/analytics/hotjar.js +44 -0
  44. package/dist/vendors/analytics/matomo-analytics.cjs +228 -0
  45. package/dist/vendors/analytics/matomo-analytics.js +191 -0
  46. package/dist/vendors/analytics/microsoft-clarity.cjs +110 -0
  47. package/dist/vendors/analytics/microsoft-clarity.js +73 -0
  48. package/dist/vendors/analytics/mixpanel-analytics.cjs +119 -0
  49. package/dist/vendors/analytics/mixpanel-analytics.js +82 -0
  50. package/dist/vendors/analytics/plausible-analytics.cjs +118 -0
  51. package/dist/vendors/analytics/plausible-analytics.js +81 -0
  52. package/dist/{posthog.cjs → vendors/analytics/posthog.cjs} +69 -6
  53. package/dist/vendors/analytics/posthog.js +163 -0
  54. package/dist/vendors/analytics/promptwatch.cjs +66 -0
  55. package/dist/vendors/analytics/promptwatch.js +29 -0
  56. package/dist/vendors/analytics/rybbit-analytics.cjs +100 -0
  57. package/dist/vendors/analytics/rybbit-analytics.js +63 -0
  58. package/dist/vendors/analytics/segment.cjs +93 -0
  59. package/dist/vendors/analytics/segment.js +56 -0
  60. package/dist/vendors/analytics/umami-analytics.cjs +76 -0
  61. package/dist/vendors/analytics/umami-analytics.js +39 -0
  62. package/dist/vendors/analytics/vercel-analytics.cjs +90 -0
  63. package/dist/vendors/analytics/vercel-analytics.js +53 -0
  64. package/dist/vendors/functional/crisp.cjs +139 -0
  65. package/dist/vendors/functional/crisp.js +102 -0
  66. package/dist/vendors/functional/intercom.cjs +85 -0
  67. package/dist/vendors/functional/intercom.js +45 -0
  68. package/dist/{google-tag-manager.cjs → vendors/tag-managers/google-tag-manager.cjs} +6 -27
  69. package/dist/{google-tag-manager.js → vendors/tag-managers/google-tag-manager.js} +6 -27
  70. package/dist-types/__tests__/helpers.d.ts +141 -0
  71. package/dist-types/engine/runtime.d.ts +1 -1
  72. package/dist-types/registry.d.ts +368 -0
  73. package/dist-types/types.d.ts +13 -0
  74. package/dist-types/vendors/_shared/attributes.d.ts +35 -0
  75. package/dist-types/vendors/_shared/google-consent.d.ts +47 -0
  76. package/dist-types/vendors/_shared/install-builders.d.ts +30 -0
  77. package/dist-types/vendors/_shared/script-url.d.ts +75 -0
  78. package/dist-types/{linkedin-insights.d.ts → vendors/ads-and-pixels/linkedin-insights.d.ts} +22 -9
  79. package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +289 -0
  80. package/dist-types/{microsoft-uet.d.ts → vendors/ads-and-pixels/microsoft-uet.d.ts} +21 -10
  81. package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +211 -0
  82. package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +171 -0
  83. package/dist-types/{tiktok-pixel.d.ts → vendors/ads-and-pixels/tiktok-pixel.d.ts} +20 -5
  84. package/dist-types/{x-pixel.d.ts → vendors/ads-and-pixels/x-pixel.d.ts} +21 -4
  85. package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +62 -0
  86. package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +67 -0
  87. package/dist-types/vendors/analytics/fathom-analytics.d.ts +90 -0
  88. package/dist-types/{google-tag.d.ts → vendors/analytics/google-tag.d.ts} +5 -8
  89. package/dist-types/vendors/analytics/hotjar.d.ts +73 -0
  90. package/dist-types/vendors/analytics/matomo-analytics.d.ts +41 -0
  91. package/dist-types/vendors/analytics/microsoft-clarity.d.ts +86 -0
  92. package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +101 -0
  93. package/dist-types/vendors/analytics/plausible-analytics.d.ts +122 -0
  94. package/dist-types/{posthog.d.ts → vendors/analytics/posthog.d.ts} +47 -5
  95. package/dist-types/vendors/analytics/promptwatch.d.ts +36 -0
  96. package/dist-types/vendors/analytics/rybbit-analytics.d.ts +82 -0
  97. package/dist-types/vendors/analytics/segment.d.ts +158 -0
  98. package/dist-types/vendors/analytics/umami-analytics.d.ts +93 -0
  99. package/dist-types/vendors/analytics/vercel-analytics.d.ts +66 -0
  100. package/dist-types/vendors/functional/crisp.d.ts +78 -0
  101. package/dist-types/vendors/functional/intercom.d.ts +135 -0
  102. package/dist-types/{google-tag-manager.d.ts → vendors/tag-managers/google-tag-manager.d.ts} +5 -8
  103. package/package.json +166 -5
  104. package/dist/meta-pixel.cjs +0 -129
  105. package/dist/meta-pixel.js +0 -89
  106. package/dist/posthog.js +0 -100
  107. package/dist-types/engine.test.d.ts +0 -1
  108. package/dist-types/helpers.test.d.ts +0 -1
  109. package/dist-types/meta-pixel.d.ts +0 -185
  110. /package/dist-types/{databuddy.d.ts → vendors/analytics/databuddy.d.ts} +0 -0
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ hotjarManifest: ()=>hotjarManifest,
28
+ hotjar: ()=>hotjar
29
+ });
30
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
31
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
32
+ const script_url_cjs_namespaceObject = require("../_shared/script-url.cjs");
33
+ const hotjarManifest = {
34
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
35
+ vendor: 'hotjar',
36
+ category: 'measurement',
37
+ install: [
38
+ {
39
+ type: 'setGlobal',
40
+ name: '_hjSettings',
41
+ value: {
42
+ hjid: '{{siteId}}',
43
+ hjsv: '{{version}}'
44
+ },
45
+ ifUndefined: true
46
+ },
47
+ {
48
+ type: 'defineStubFunction',
49
+ name: 'hj',
50
+ queue: {
51
+ property: 'q'
52
+ },
53
+ queueFormat: 'array',
54
+ ifUndefined: true
55
+ },
56
+ {
57
+ type: 'loadScript',
58
+ src: "{{scriptUrl}}",
59
+ async: true
60
+ }
61
+ ]
62
+ };
63
+ function hotjar({ siteId, version = 6, scriptUrl }) {
64
+ if (null == siteId) throw new Error('hotjar: missing or invalid siteId');
65
+ const normalizedSiteId = String(siteId).trim();
66
+ if (0 === normalizedSiteId.length || '0' === normalizedSiteId) throw new Error('hotjar: missing or invalid siteId');
67
+ return (0, external_resolve_cjs_namespaceObject.resolveManifest)(hotjarManifest, {
68
+ siteId: normalizedSiteId,
69
+ version,
70
+ scriptUrl: (0, script_url_cjs_namespaceObject.resolveScriptUrl)(scriptUrl, `https://static.hotjar.com/c/hotjar-${normalizedSiteId}.js?sv=${version}`)
71
+ });
72
+ }
73
+ exports.hotjar = __webpack_exports__.hotjar;
74
+ exports.hotjarManifest = __webpack_exports__.hotjarManifest;
75
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
76
+ "hotjar",
77
+ "hotjarManifest"
78
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
79
+ Object.defineProperty(exports, '__esModule', {
80
+ value: true
81
+ });
@@ -0,0 +1,44 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ import { resolveScriptUrl } from "../_shared/script-url.js";
4
+ const hotjarManifest = {
5
+ ...vendorManifestContract,
6
+ vendor: 'hotjar',
7
+ category: 'measurement',
8
+ install: [
9
+ {
10
+ type: 'setGlobal',
11
+ name: '_hjSettings',
12
+ value: {
13
+ hjid: '{{siteId}}',
14
+ hjsv: '{{version}}'
15
+ },
16
+ ifUndefined: true
17
+ },
18
+ {
19
+ type: 'defineStubFunction',
20
+ name: 'hj',
21
+ queue: {
22
+ property: 'q'
23
+ },
24
+ queueFormat: 'array',
25
+ ifUndefined: true
26
+ },
27
+ {
28
+ type: 'loadScript',
29
+ src: "{{scriptUrl}}",
30
+ async: true
31
+ }
32
+ ]
33
+ };
34
+ function hotjar({ siteId, version = 6, scriptUrl }) {
35
+ if (null == siteId) throw new Error('hotjar: missing or invalid siteId');
36
+ const normalizedSiteId = String(siteId).trim();
37
+ if (0 === normalizedSiteId.length || '0' === normalizedSiteId) throw new Error('hotjar: missing or invalid siteId');
38
+ return resolveManifest(hotjarManifest, {
39
+ siteId: normalizedSiteId,
40
+ version,
41
+ scriptUrl: resolveScriptUrl(scriptUrl, `https://static.hotjar.com/c/hotjar-${normalizedSiteId}.js?sv=${version}`)
42
+ });
43
+ }
44
+ export { hotjar, hotjarManifest };
@@ -0,0 +1,228 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ matomoAnalytics: ()=>matomoAnalytics,
28
+ matomoAnalyticsManifest: ()=>matomoAnalyticsManifest
29
+ });
30
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
31
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
32
+ const script_url_cjs_namespaceObject = require("../_shared/script-url.cjs");
33
+ function stripProtocol(value) {
34
+ if (value.startsWith('https://')) return value.slice(8);
35
+ if (value.startsWith('http://')) return value.slice(7);
36
+ return value;
37
+ }
38
+ function resolveMatomoOrigin(options) {
39
+ if (options.matomoUrl) return (0, script_url_cjs_namespaceObject.stripTrailingSlashes)(options.matomoUrl);
40
+ if (options.cloudId) {
41
+ const cleanedCloudId = (0, script_url_cjs_namespaceObject.stripTrailingSlashes)(stripProtocol(options.cloudId));
42
+ if (cleanedCloudId.endsWith('.matomo.cloud')) return `https://${cleanedCloudId}`;
43
+ return `https://cdn.matomo.cloud/${cleanedCloudId}`;
44
+ }
45
+ }
46
+ function buildInstallSteps(options) {
47
+ const install = [
48
+ {
49
+ type: 'setGlobal',
50
+ name: '_paq',
51
+ value: [],
52
+ ifUndefined: true
53
+ },
54
+ {
55
+ type: 'pushToQueue',
56
+ queue: '_paq',
57
+ value: [
58
+ 'setTrackerUrl',
59
+ '{{trackerUrl}}'
60
+ ]
61
+ },
62
+ {
63
+ type: 'pushToQueue',
64
+ queue: '_paq',
65
+ value: [
66
+ 'setSiteId',
67
+ '{{siteId}}'
68
+ ]
69
+ }
70
+ ];
71
+ if (options.enableLinkTracking) install.push({
72
+ type: 'pushToQueue',
73
+ queue: '_paq',
74
+ value: [
75
+ 'enableLinkTracking'
76
+ ]
77
+ });
78
+ if (options.disableCookies) install.push({
79
+ type: 'pushToQueue',
80
+ queue: '_paq',
81
+ value: [
82
+ 'disableCookies'
83
+ ]
84
+ });
85
+ if (options.enableConsentMode && !options.consentInitiallyGiven) install.push({
86
+ type: 'pushToQueue',
87
+ queue: '_paq',
88
+ value: [
89
+ 'requireConsent'
90
+ ]
91
+ });
92
+ if (options.enableConsentMode && options.consentInitiallyGiven) {
93
+ install.push({
94
+ type: 'pushToQueue',
95
+ queue: '_paq',
96
+ value: [
97
+ 'setConsentGiven'
98
+ ]
99
+ });
100
+ if (options.trackPageView) install.push({
101
+ type: 'pushToQueue',
102
+ queue: '_paq',
103
+ value: [
104
+ 'trackPageView'
105
+ ]
106
+ });
107
+ }
108
+ if (options.trackPageView && !options.enableConsentMode) install.push({
109
+ type: 'pushToQueue',
110
+ queue: '_paq',
111
+ value: [
112
+ 'trackPageView'
113
+ ]
114
+ });
115
+ install.push({
116
+ type: 'loadScript',
117
+ src: "{{scriptUrl}}",
118
+ async: true
119
+ });
120
+ return install;
121
+ }
122
+ function buildGrantedHooks(options) {
123
+ const onBeforeLoadGranted = [];
124
+ if (options.enableConsentMode && !options.consentInitiallyGiven) onBeforeLoadGranted.push({
125
+ type: 'pushToQueue',
126
+ queue: '_paq',
127
+ value: [
128
+ 'setConsentGiven'
129
+ ]
130
+ });
131
+ if (options.trackPageView && options.enableConsentMode && !options.consentInitiallyGiven) onBeforeLoadGranted.push({
132
+ type: 'pushToQueue',
133
+ queue: '_paq',
134
+ value: [
135
+ 'trackPageView'
136
+ ]
137
+ });
138
+ const onConsentGranted = [];
139
+ if (options.enableConsentMode) {
140
+ onConsentGranted.push({
141
+ type: 'pushToQueue',
142
+ queue: '_paq',
143
+ value: [
144
+ 'setConsentGiven'
145
+ ]
146
+ });
147
+ if (options.trackPageView) onConsentGranted.push({
148
+ type: 'pushToQueue',
149
+ queue: '_paq',
150
+ value: [
151
+ 'trackPageView'
152
+ ]
153
+ });
154
+ }
155
+ return {
156
+ onBeforeLoadGranted,
157
+ onConsentGranted
158
+ };
159
+ }
160
+ function buildDeniedHooks(options) {
161
+ const onConsentDenied = [];
162
+ if (options.enableConsentMode) onConsentDenied.push({
163
+ type: 'pushToQueue',
164
+ queue: '_paq',
165
+ value: [
166
+ 'forgetConsentGiven'
167
+ ]
168
+ });
169
+ return onConsentDenied;
170
+ }
171
+ function createMatomoAnalyticsManifest(options) {
172
+ const { onBeforeLoadGranted, onConsentGranted } = buildGrantedHooks(options);
173
+ let alwaysLoad;
174
+ let persistAfterConsentRevoked;
175
+ if (options.enableConsentMode) {
176
+ alwaysLoad = true;
177
+ persistAfterConsentRevoked = true;
178
+ }
179
+ return {
180
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
181
+ vendor: 'matomo-analytics',
182
+ category: 'measurement',
183
+ alwaysLoad,
184
+ persistAfterConsentRevoked,
185
+ install: buildInstallSteps(options),
186
+ onBeforeLoadGranted,
187
+ onConsentGranted,
188
+ onConsentDenied: buildDeniedHooks(options)
189
+ };
190
+ }
191
+ const matomoAnalyticsManifest = createMatomoAnalyticsManifest({
192
+ enableConsentMode: false,
193
+ consentInitiallyGiven: false,
194
+ enableLinkTracking: false,
195
+ disableCookies: false,
196
+ trackPageView: true
197
+ });
198
+ function matomoAnalytics(options = {}) {
199
+ const origin = resolveMatomoOrigin(options);
200
+ let trackerUrl = options.trackerUrl;
201
+ if (!trackerUrl && origin) trackerUrl = (0, script_url_cjs_namespaceObject.joinUrlPath)(origin, 'matomo.php');
202
+ let scriptUrl = options.scriptUrl;
203
+ if (!scriptUrl && origin) scriptUrl = (0, script_url_cjs_namespaceObject.joinUrlPath)(origin, 'matomo.js');
204
+ if (!trackerUrl || !scriptUrl) throw new Error("matomoAnalytics requires `matomoUrl`, `cloudId`, or explicit `trackerUrl` and `scriptUrl` values.");
205
+ const enableConsentMode = 'required' === options.defaultConsent || 'given' === options.defaultConsent;
206
+ const consentInitiallyGiven = 'given' === options.defaultConsent;
207
+ const manifest = createMatomoAnalyticsManifest({
208
+ enableConsentMode,
209
+ consentInitiallyGiven,
210
+ enableLinkTracking: options.enableLinkTracking ?? false,
211
+ disableCookies: options.disableCookies ?? false,
212
+ trackPageView: options.trackPageView ?? true
213
+ });
214
+ return (0, external_resolve_cjs_namespaceObject.resolveManifest)(manifest, {
215
+ siteId: String(options.siteId ?? 1),
216
+ trackerUrl,
217
+ scriptUrl
218
+ });
219
+ }
220
+ exports.matomoAnalytics = __webpack_exports__.matomoAnalytics;
221
+ exports.matomoAnalyticsManifest = __webpack_exports__.matomoAnalyticsManifest;
222
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
223
+ "matomoAnalytics",
224
+ "matomoAnalyticsManifest"
225
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
226
+ Object.defineProperty(exports, '__esModule', {
227
+ value: true
228
+ });
@@ -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,110 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ clarityManifest: ()=>clarityManifest,
28
+ clarity: ()=>clarity
29
+ });
30
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
31
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
32
+ const clarityManifest = {
33
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
34
+ vendor: 'microsoft-clarity',
35
+ category: 'measurement',
36
+ persistAfterConsentRevoked: true,
37
+ bootstrap: [
38
+ {
39
+ type: 'defineStubFunction',
40
+ name: 'clarity',
41
+ queue: {
42
+ property: 'q'
43
+ },
44
+ queueFormat: 'array',
45
+ properties: {
46
+ v: '0.7.0'
47
+ },
48
+ ifUndefined: true
49
+ }
50
+ ],
51
+ install: [
52
+ {
53
+ type: 'loadScript',
54
+ src: "{{scriptUrl}}",
55
+ async: true
56
+ }
57
+ ],
58
+ onConsentGranted: [
59
+ {
60
+ type: 'callGlobal',
61
+ global: 'clarity',
62
+ args: [
63
+ 'consent',
64
+ true
65
+ ]
66
+ }
67
+ ],
68
+ onConsentDenied: [
69
+ {
70
+ type: 'callGlobal',
71
+ global: 'clarity',
72
+ args: [
73
+ 'consent',
74
+ false
75
+ ]
76
+ }
77
+ ]
78
+ };
79
+ function clarity({ id, defaultConsent, scriptUrl }) {
80
+ const normalizedId = id.trim();
81
+ 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.`);
82
+ let manifest = clarityManifest;
83
+ if (void 0 !== defaultConsent) manifest = {
84
+ ...clarityManifest,
85
+ install: [
86
+ {
87
+ type: 'callGlobal',
88
+ global: 'clarity',
89
+ args: [
90
+ 'consent',
91
+ '{{defaultConsent}}'
92
+ ]
93
+ },
94
+ ...clarityManifest.install
95
+ ]
96
+ };
97
+ return (0, external_resolve_cjs_namespaceObject.resolveManifest)(manifest, {
98
+ defaultConsent,
99
+ scriptUrl: scriptUrl ?? `https://www.clarity.ms/tag/${normalizedId}`
100
+ });
101
+ }
102
+ exports.clarity = __webpack_exports__.clarity;
103
+ exports.clarityManifest = __webpack_exports__.clarityManifest;
104
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
105
+ "clarity",
106
+ "clarityManifest"
107
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
108
+ Object.defineProperty(exports, '__esModule', {
109
+ value: true
110
+ });