@c15t/scripts 2.0.1 → 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 (106) hide show
  1. package/README.md +9 -9
  2. package/dist/engine/runtime.cjs +11 -0
  3. package/dist/engine/runtime.js +11 -0
  4. package/dist/registry.cjs +338 -0
  5. package/dist/registry.js +292 -0
  6. package/dist/types.cjs +18 -0
  7. package/dist/types.js +10 -1
  8. package/dist/vendors/_shared/attributes.cjs +51 -0
  9. package/dist/vendors/_shared/attributes.js +14 -0
  10. package/dist/vendors/_shared/google-consent.cjs +64 -0
  11. package/dist/vendors/_shared/google-consent.js +27 -0
  12. package/dist/vendors/_shared/install-builders.cjs +55 -0
  13. package/dist/vendors/_shared/install-builders.js +21 -0
  14. package/dist/vendors/_shared/script-url.cjs +74 -0
  15. package/dist/vendors/_shared/script-url.js +28 -0
  16. package/dist/{linkedin-insights.cjs → vendors/ads-and-pixels/linkedin-insights.cjs} +2 -2
  17. package/dist/{linkedin-insights.js → vendors/ads-and-pixels/linkedin-insights.js} +2 -2
  18. package/dist/vendors/ads-and-pixels/meta-pixel.cjs +202 -0
  19. package/dist/vendors/ads-and-pixels/meta-pixel.js +153 -0
  20. package/dist/{microsoft-uet.cjs → vendors/ads-and-pixels/microsoft-uet.cjs} +31 -14
  21. package/dist/{microsoft-uet.js → vendors/ads-and-pixels/microsoft-uet.js} +31 -14
  22. package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +147 -0
  23. package/dist/vendors/ads-and-pixels/reddit-pixel.js +107 -0
  24. package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +127 -0
  25. package/dist/vendors/ads-and-pixels/snapchat-pixel.js +87 -0
  26. package/dist/{tiktok-pixel.cjs → vendors/ads-and-pixels/tiktok-pixel.cjs} +2 -2
  27. package/dist/{tiktok-pixel.js → vendors/ads-and-pixels/tiktok-pixel.js} +2 -2
  28. package/dist/{x-pixel.cjs → vendors/ads-and-pixels/x-pixel.cjs} +6 -3
  29. package/dist/{x-pixel.js → vendors/ads-and-pixels/x-pixel.js} +6 -3
  30. package/dist/vendors/analytics/ahrefs-analytics.cjs +64 -0
  31. package/dist/vendors/analytics/ahrefs-analytics.js +27 -0
  32. package/dist/vendors/analytics/cloudflare-web-analytics.cjs +69 -0
  33. package/dist/vendors/analytics/cloudflare-web-analytics.js +32 -0
  34. package/dist/{databuddy.cjs → vendors/analytics/databuddy.cjs} +3 -3
  35. package/dist/{databuddy.js → vendors/analytics/databuddy.js} +3 -3
  36. package/dist/vendors/analytics/fathom-analytics.cjs +72 -0
  37. package/dist/vendors/analytics/fathom-analytics.js +35 -0
  38. package/dist/{google-tag.cjs → vendors/analytics/google-tag.cjs} +7 -28
  39. package/dist/{google-tag.js → vendors/analytics/google-tag.js} +7 -28
  40. package/dist/vendors/analytics/hotjar.cjs +81 -0
  41. package/dist/vendors/analytics/hotjar.js +44 -0
  42. package/dist/vendors/analytics/matomo-analytics.cjs +228 -0
  43. package/dist/vendors/analytics/matomo-analytics.js +191 -0
  44. package/dist/vendors/analytics/microsoft-clarity.cjs +110 -0
  45. package/dist/vendors/analytics/microsoft-clarity.js +73 -0
  46. package/dist/vendors/analytics/mixpanel-analytics.cjs +119 -0
  47. package/dist/vendors/analytics/mixpanel-analytics.js +82 -0
  48. package/dist/vendors/analytics/plausible-analytics.cjs +118 -0
  49. package/dist/vendors/analytics/plausible-analytics.js +81 -0
  50. package/dist/{posthog.cjs → vendors/analytics/posthog.cjs} +69 -6
  51. package/dist/vendors/analytics/posthog.js +163 -0
  52. package/dist/vendors/analytics/promptwatch.cjs +66 -0
  53. package/dist/vendors/analytics/promptwatch.js +29 -0
  54. package/dist/vendors/analytics/rybbit-analytics.cjs +100 -0
  55. package/dist/vendors/analytics/rybbit-analytics.js +63 -0
  56. package/dist/vendors/analytics/segment.cjs +93 -0
  57. package/dist/vendors/analytics/segment.js +56 -0
  58. package/dist/vendors/analytics/umami-analytics.cjs +76 -0
  59. package/dist/vendors/analytics/umami-analytics.js +39 -0
  60. package/dist/vendors/analytics/vercel-analytics.cjs +90 -0
  61. package/dist/vendors/analytics/vercel-analytics.js +53 -0
  62. package/dist/vendors/functional/crisp.cjs +139 -0
  63. package/dist/vendors/functional/crisp.js +102 -0
  64. package/dist/vendors/functional/intercom.cjs +85 -0
  65. package/dist/vendors/functional/intercom.js +45 -0
  66. package/dist/{google-tag-manager.cjs → vendors/tag-managers/google-tag-manager.cjs} +6 -27
  67. package/dist/{google-tag-manager.js → vendors/tag-managers/google-tag-manager.js} +6 -27
  68. package/dist-types/__tests__/helpers.d.ts +141 -0
  69. package/dist-types/engine/runtime.d.ts +1 -1
  70. package/dist-types/registry.d.ts +368 -0
  71. package/dist-types/types.d.ts +13 -0
  72. package/dist-types/vendors/_shared/attributes.d.ts +35 -0
  73. package/dist-types/vendors/_shared/google-consent.d.ts +47 -0
  74. package/dist-types/vendors/_shared/install-builders.d.ts +30 -0
  75. package/dist-types/vendors/_shared/script-url.d.ts +75 -0
  76. package/dist-types/{linkedin-insights.d.ts → vendors/ads-and-pixels/linkedin-insights.d.ts} +22 -9
  77. package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +289 -0
  78. package/dist-types/{microsoft-uet.d.ts → vendors/ads-and-pixels/microsoft-uet.d.ts} +21 -10
  79. package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +211 -0
  80. package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +171 -0
  81. package/dist-types/{tiktok-pixel.d.ts → vendors/ads-and-pixels/tiktok-pixel.d.ts} +20 -5
  82. package/dist-types/{x-pixel.d.ts → vendors/ads-and-pixels/x-pixel.d.ts} +21 -4
  83. package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +62 -0
  84. package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +67 -0
  85. package/dist-types/vendors/analytics/fathom-analytics.d.ts +90 -0
  86. package/dist-types/{google-tag.d.ts → vendors/analytics/google-tag.d.ts} +5 -8
  87. package/dist-types/vendors/analytics/hotjar.d.ts +73 -0
  88. package/dist-types/vendors/analytics/matomo-analytics.d.ts +41 -0
  89. package/dist-types/vendors/analytics/microsoft-clarity.d.ts +86 -0
  90. package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +101 -0
  91. package/dist-types/vendors/analytics/plausible-analytics.d.ts +122 -0
  92. package/dist-types/{posthog.d.ts → vendors/analytics/posthog.d.ts} +47 -5
  93. package/dist-types/vendors/analytics/promptwatch.d.ts +36 -0
  94. package/dist-types/vendors/analytics/rybbit-analytics.d.ts +82 -0
  95. package/dist-types/vendors/analytics/segment.d.ts +158 -0
  96. package/dist-types/vendors/analytics/umami-analytics.d.ts +93 -0
  97. package/dist-types/vendors/analytics/vercel-analytics.d.ts +66 -0
  98. package/dist-types/vendors/functional/crisp.d.ts +78 -0
  99. package/dist-types/vendors/functional/intercom.d.ts +135 -0
  100. package/dist-types/{google-tag-manager.d.ts → vendors/tag-managers/google-tag-manager.d.ts} +5 -8
  101. package/package.json +165 -4
  102. package/dist/meta-pixel.cjs +0 -129
  103. package/dist/meta-pixel.js +0 -89
  104. package/dist/posthog.js +0 -100
  105. package/dist-types/meta-pixel.d.ts +0 -185
  106. /package/dist-types/{databuddy.d.ts → vendors/analytics/databuddy.d.ts} +0 -0
@@ -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
+ });
@@ -0,0 +1,73 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ const clarityManifest = {
4
+ ...vendorManifestContract,
5
+ vendor: 'microsoft-clarity',
6
+ category: 'measurement',
7
+ persistAfterConsentRevoked: true,
8
+ bootstrap: [
9
+ {
10
+ type: 'defineStubFunction',
11
+ name: 'clarity',
12
+ queue: {
13
+ property: 'q'
14
+ },
15
+ queueFormat: 'array',
16
+ properties: {
17
+ v: '0.7.0'
18
+ },
19
+ ifUndefined: true
20
+ }
21
+ ],
22
+ install: [
23
+ {
24
+ type: 'loadScript',
25
+ src: "{{scriptUrl}}",
26
+ async: true
27
+ }
28
+ ],
29
+ onConsentGranted: [
30
+ {
31
+ type: 'callGlobal',
32
+ global: 'clarity',
33
+ args: [
34
+ 'consent',
35
+ true
36
+ ]
37
+ }
38
+ ],
39
+ onConsentDenied: [
40
+ {
41
+ type: 'callGlobal',
42
+ global: 'clarity',
43
+ args: [
44
+ 'consent',
45
+ false
46
+ ]
47
+ }
48
+ ]
49
+ };
50
+ function clarity({ id, defaultConsent, scriptUrl }) {
51
+ const normalizedId = id.trim();
52
+ 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.`);
53
+ let manifest = clarityManifest;
54
+ if (void 0 !== defaultConsent) manifest = {
55
+ ...clarityManifest,
56
+ install: [
57
+ {
58
+ type: 'callGlobal',
59
+ global: 'clarity',
60
+ args: [
61
+ 'consent',
62
+ '{{defaultConsent}}'
63
+ ]
64
+ },
65
+ ...clarityManifest.install
66
+ ]
67
+ };
68
+ return resolveManifest(manifest, {
69
+ defaultConsent,
70
+ scriptUrl: scriptUrl ?? `https://www.clarity.ms/tag/${normalizedId}`
71
+ });
72
+ }
73
+ export { clarity, clarityManifest };
@@ -0,0 +1,119 @@
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
+ mixpanelAnalytics: ()=>mixpanelAnalytics,
28
+ mixpanelAnalyticsManifest: ()=>mixpanelAnalyticsManifest
29
+ });
30
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
31
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
32
+ const mixpanelAnalyticsManifest = {
33
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
34
+ vendor: 'mixpanel-analytics',
35
+ category: 'measurement',
36
+ alwaysLoad: true,
37
+ install: [
38
+ {
39
+ type: 'setGlobal',
40
+ name: 'mixpanel',
41
+ value: [],
42
+ ifUndefined: true
43
+ },
44
+ {
45
+ type: 'defineQueueMethods',
46
+ target: 'mixpanel',
47
+ methods: [
48
+ 'track',
49
+ 'identify',
50
+ 'reset',
51
+ 'register',
52
+ 'opt_in_tracking',
53
+ 'opt_out_tracking'
54
+ ]
55
+ },
56
+ {
57
+ type: 'loadScript',
58
+ src: "{{scriptUrl}}",
59
+ async: true
60
+ }
61
+ ],
62
+ afterLoad: [
63
+ {
64
+ type: 'callGlobal',
65
+ global: 'mixpanel',
66
+ method: 'init',
67
+ args: [
68
+ '{{token}}',
69
+ '{{initOptions}}'
70
+ ]
71
+ }
72
+ ],
73
+ onLoadGranted: [
74
+ {
75
+ type: 'callGlobal',
76
+ global: 'mixpanel',
77
+ method: 'opt_in_tracking'
78
+ }
79
+ ],
80
+ onLoadDenied: [
81
+ {
82
+ type: 'callGlobal',
83
+ global: 'mixpanel',
84
+ method: 'opt_out_tracking'
85
+ }
86
+ ],
87
+ onConsentGranted: [
88
+ {
89
+ type: 'callGlobal',
90
+ global: 'mixpanel',
91
+ method: 'opt_in_tracking'
92
+ }
93
+ ],
94
+ onConsentDenied: [
95
+ {
96
+ type: 'callGlobal',
97
+ global: 'mixpanel',
98
+ method: 'opt_out_tracking'
99
+ }
100
+ ]
101
+ };
102
+ function mixpanelAnalytics({ token, initOptions, scriptUrl }) {
103
+ const normalizedToken = token.trim();
104
+ if (!/^[a-f0-9]{32}$/i.test(normalizedToken)) throw new Error("mixpanelAnalytics: token must be a non-empty 32-character hexadecimal string");
105
+ return (0, external_resolve_cjs_namespaceObject.resolveManifest)(mixpanelAnalyticsManifest, {
106
+ token: normalizedToken,
107
+ initOptions: initOptions ?? {},
108
+ scriptUrl: scriptUrl ?? 'https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'
109
+ });
110
+ }
111
+ exports.mixpanelAnalytics = __webpack_exports__.mixpanelAnalytics;
112
+ exports.mixpanelAnalyticsManifest = __webpack_exports__.mixpanelAnalyticsManifest;
113
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
114
+ "mixpanelAnalytics",
115
+ "mixpanelAnalyticsManifest"
116
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
117
+ Object.defineProperty(exports, '__esModule', {
118
+ value: true
119
+ });
@@ -0,0 +1,82 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ const mixpanelAnalyticsManifest = {
4
+ ...vendorManifestContract,
5
+ vendor: 'mixpanel-analytics',
6
+ category: 'measurement',
7
+ alwaysLoad: true,
8
+ install: [
9
+ {
10
+ type: 'setGlobal',
11
+ name: 'mixpanel',
12
+ value: [],
13
+ ifUndefined: true
14
+ },
15
+ {
16
+ type: 'defineQueueMethods',
17
+ target: 'mixpanel',
18
+ methods: [
19
+ 'track',
20
+ 'identify',
21
+ 'reset',
22
+ 'register',
23
+ 'opt_in_tracking',
24
+ 'opt_out_tracking'
25
+ ]
26
+ },
27
+ {
28
+ type: 'loadScript',
29
+ src: "{{scriptUrl}}",
30
+ async: true
31
+ }
32
+ ],
33
+ afterLoad: [
34
+ {
35
+ type: 'callGlobal',
36
+ global: 'mixpanel',
37
+ method: 'init',
38
+ args: [
39
+ '{{token}}',
40
+ '{{initOptions}}'
41
+ ]
42
+ }
43
+ ],
44
+ onLoadGranted: [
45
+ {
46
+ type: 'callGlobal',
47
+ global: 'mixpanel',
48
+ method: 'opt_in_tracking'
49
+ }
50
+ ],
51
+ onLoadDenied: [
52
+ {
53
+ type: 'callGlobal',
54
+ global: 'mixpanel',
55
+ method: 'opt_out_tracking'
56
+ }
57
+ ],
58
+ onConsentGranted: [
59
+ {
60
+ type: 'callGlobal',
61
+ global: 'mixpanel',
62
+ method: 'opt_in_tracking'
63
+ }
64
+ ],
65
+ onConsentDenied: [
66
+ {
67
+ type: 'callGlobal',
68
+ global: 'mixpanel',
69
+ method: 'opt_out_tracking'
70
+ }
71
+ ]
72
+ };
73
+ function mixpanelAnalytics({ token, initOptions, scriptUrl }) {
74
+ const normalizedToken = token.trim();
75
+ if (!/^[a-f0-9]{32}$/i.test(normalizedToken)) throw new Error("mixpanelAnalytics: token must be a non-empty 32-character hexadecimal string");
76
+ return resolveManifest(mixpanelAnalyticsManifest, {
77
+ token: normalizedToken,
78
+ initOptions: initOptions ?? {},
79
+ scriptUrl: scriptUrl ?? 'https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'
80
+ });
81
+ }
82
+ export { mixpanelAnalytics, mixpanelAnalyticsManifest };
@@ -0,0 +1,118 @@
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
+ plausibleAnalytics: ()=>plausibleAnalytics,
28
+ plausibleAnalyticsManifest: ()=>plausibleAnalyticsManifest
29
+ });
30
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
31
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
32
+ function buildPlausibleScriptUrl(options) {
33
+ if (options.scriptId) return `https://plausible.io/js/pa-${options.scriptId}.js`;
34
+ if (options.extension) {
35
+ let extensions;
36
+ extensions = Array.isArray(options.extension) ? options.extension.join('.') : options.extension;
37
+ return `https://plausible.io/js/script.${extensions}.js`;
38
+ }
39
+ return "https://plausible.io/js/script.js";
40
+ }
41
+ function buildPlausibleInitOptions(options) {
42
+ const initOptions = {};
43
+ if (options.customProperties) initOptions.customProperties = options.customProperties;
44
+ if (options.endpoint) initOptions.endpoint = options.endpoint;
45
+ if (options.fileDownloads) initOptions.fileDownloads = options.fileDownloads;
46
+ if (void 0 !== options.hashBasedRouting) initOptions.hashBasedRouting = options.hashBasedRouting;
47
+ if (void 0 !== options.autoCapturePageviews) initOptions.autoCapturePageviews = options.autoCapturePageviews;
48
+ if (void 0 !== options.captureOnLocalhost) initOptions.captureOnLocalhost = options.captureOnLocalhost;
49
+ return initOptions;
50
+ }
51
+ const plausibleAnalyticsManifest = {
52
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
53
+ vendor: 'plausible-analytics',
54
+ category: 'measurement',
55
+ bootstrap: [
56
+ {
57
+ type: 'defineStubFunction',
58
+ name: 'plausible',
59
+ queue: {
60
+ property: 'q'
61
+ },
62
+ queueFormat: 'array',
63
+ properties: {
64
+ o: '{{initOptions}}'
65
+ },
66
+ ifUndefined: true
67
+ }
68
+ ],
69
+ install: [
70
+ {
71
+ type: 'loadScript',
72
+ src: "{{scriptUrl}}",
73
+ defer: true,
74
+ attributes: {
75
+ 'data-domain': '{{domain}}',
76
+ 'data-api': '{{apiAttribute}}'
77
+ }
78
+ }
79
+ ]
80
+ };
81
+ function plausibleAnalytics(options) {
82
+ let scriptId;
83
+ if (options.scriptId) scriptId = options.scriptId.trim();
84
+ let domain;
85
+ if (options.domain) domain = options.domain.trim();
86
+ if (!scriptId && !domain) throw new Error("plausibleAnalytics: missing scriptId or domain");
87
+ const normalizedOptions = {
88
+ ...options
89
+ };
90
+ if (scriptId) normalizedOptions.scriptId = scriptId;
91
+ else delete normalizedOptions.scriptId;
92
+ if (domain) normalizedOptions.domain = domain;
93
+ else delete normalizedOptions.domain;
94
+ const manifestOptions = {
95
+ scriptUrl: normalizedOptions.scriptUrl ?? buildPlausibleScriptUrl(normalizedOptions),
96
+ domain: void 0,
97
+ apiAttribute: void 0,
98
+ initOptions: buildPlausibleInitOptions(normalizedOptions)
99
+ };
100
+ if (scriptId) {
101
+ manifestOptions.domain = void 0;
102
+ manifestOptions.apiAttribute = void 0;
103
+ } else {
104
+ manifestOptions.domain = domain;
105
+ manifestOptions.apiAttribute = normalizedOptions.endpoint;
106
+ }
107
+ const resolved = (0, external_resolve_cjs_namespaceObject.resolveManifest)(plausibleAnalyticsManifest, manifestOptions);
108
+ return resolved;
109
+ }
110
+ exports.plausibleAnalytics = __webpack_exports__.plausibleAnalytics;
111
+ exports.plausibleAnalyticsManifest = __webpack_exports__.plausibleAnalyticsManifest;
112
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
113
+ "plausibleAnalytics",
114
+ "plausibleAnalyticsManifest"
115
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
116
+ Object.defineProperty(exports, '__esModule', {
117
+ value: true
118
+ });