@c15t/scripts 2.1.0 → 2.2.0-canary-20260804162155

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 (140) hide show
  1. package/AGENTS.md +62 -0
  2. package/README.md +32 -20
  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 +103 -17
  7. package/dist/engine/runtime.js +94 -12
  8. package/dist/registry.cjs +97 -12
  9. package/dist/registry.js +80 -0
  10. package/dist/resolve.cjs +9 -5
  11. package/dist/types.cjs +17 -13
  12. package/dist/vendors/_shared/attributes.cjs +13 -9
  13. package/dist/vendors/_shared/google-consent.cjs +14 -9
  14. package/dist/vendors/_shared/install-builders.cjs +12 -8
  15. package/dist/vendors/_shared/script-url.cjs +16 -12
  16. package/dist/vendors/ads-and-pixels/linkedin-insights.cjs +9 -5
  17. package/dist/vendors/ads-and-pixels/meta-pixel.cjs +13 -9
  18. package/dist/vendors/ads-and-pixels/microsoft-uet.cjs +11 -7
  19. package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +9 -5
  20. package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +11 -7
  21. package/dist/vendors/ads-and-pixels/tiktok-pixel.cjs +9 -5
  22. package/dist/vendors/ads-and-pixels/x-pixel.cjs +9 -5
  23. package/dist/vendors/analytics/adobe-analytics.cjs +90 -0
  24. package/dist/vendors/analytics/adobe-analytics.js +49 -0
  25. package/dist/vendors/analytics/ahrefs-analytics.cjs +11 -7
  26. package/dist/vendors/analytics/amplitude.cjs +193 -0
  27. package/dist/vendors/analytics/amplitude.js +134 -0
  28. package/dist/vendors/analytics/clearbit.cjs +69 -0
  29. package/dist/vendors/analytics/clearbit.js +28 -0
  30. package/dist/vendors/analytics/cloudflare-web-analytics.cjs +11 -7
  31. package/dist/vendors/analytics/databuddy.cjs +11 -7
  32. package/dist/vendors/analytics/fathom-analytics.cjs +11 -7
  33. package/dist/vendors/analytics/google-tag.cjs +11 -7
  34. package/dist/vendors/analytics/heap.cjs +181 -0
  35. package/dist/vendors/analytics/heap.js +134 -0
  36. package/dist/vendors/analytics/hightouch.cjs +153 -0
  37. package/dist/vendors/analytics/hightouch.js +109 -0
  38. package/dist/vendors/analytics/hotjar.cjs +11 -7
  39. package/dist/vendors/analytics/logrocket.cjs +99 -0
  40. package/dist/vendors/analytics/logrocket.js +58 -0
  41. package/dist/vendors/analytics/matomo-analytics.cjs +9 -5
  42. package/dist/vendors/analytics/microsoft-clarity.cjs +75 -47
  43. package/dist/vendors/analytics/microsoft-clarity.js +64 -40
  44. package/dist/vendors/analytics/mixpanel-analytics.cjs +31 -16
  45. package/dist/vendors/analytics/mixpanel-analytics.js +22 -11
  46. package/dist/vendors/analytics/pirsch.cjs +108 -0
  47. package/dist/vendors/analytics/pirsch.js +67 -0
  48. package/dist/vendors/analytics/plausible-analytics.cjs +9 -5
  49. package/dist/vendors/analytics/posthog.cjs +63 -27
  50. package/dist/vendors/analytics/posthog.js +52 -20
  51. package/dist/vendors/analytics/promptwatch.cjs +11 -7
  52. package/dist/vendors/analytics/rudderstack.cjs +227 -0
  53. package/dist/vendors/analytics/rudderstack.js +183 -0
  54. package/dist/vendors/analytics/rybbit-analytics.cjs +9 -5
  55. package/dist/vendors/analytics/segment.cjs +9 -5
  56. package/dist/vendors/analytics/umami-analytics.cjs +9 -5
  57. package/dist/vendors/analytics/vercel-analytics.cjs +11 -7
  58. package/dist/vendors/functional/crisp.cjs +9 -5
  59. package/dist/vendors/functional/intercom.cjs +11 -7
  60. package/dist/vendors/tag-managers/google-tag-manager.cjs +11 -7
  61. package/dist-types/registry.d.ts +313 -241
  62. package/dist-types/types.d.ts +46 -4
  63. package/dist-types/vendors/ads-and-pixels/linkedin-insights.d.ts +18 -18
  64. package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +21 -21
  65. package/dist-types/vendors/ads-and-pixels/microsoft-uet.d.ts +32 -32
  66. package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +19 -19
  67. package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +16 -16
  68. package/dist-types/vendors/ads-and-pixels/tiktok-pixel.d.ts +28 -28
  69. package/dist-types/vendors/ads-and-pixels/x-pixel.d.ts +13 -13
  70. package/dist-types/vendors/analytics/adobe-analytics.d.ts +75 -0
  71. package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +7 -7
  72. package/dist-types/vendors/analytics/amplitude.d.ts +234 -0
  73. package/dist-types/vendors/analytics/clearbit.d.ts +60 -0
  74. package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +7 -7
  75. package/dist-types/vendors/analytics/databuddy.d.ts +25 -25
  76. package/dist-types/vendors/analytics/fathom-analytics.d.ts +11 -11
  77. package/dist-types/vendors/analytics/google-tag.d.ts +17 -17
  78. package/dist-types/vendors/analytics/heap.d.ts +316 -0
  79. package/dist-types/vendors/analytics/hightouch.d.ts +285 -0
  80. package/dist-types/vendors/analytics/hotjar.d.ts +14 -14
  81. package/dist-types/vendors/analytics/logrocket.d.ts +101 -0
  82. package/dist-types/vendors/analytics/microsoft-clarity.d.ts +42 -30
  83. package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +40 -28
  84. package/dist-types/vendors/analytics/pirsch.d.ts +96 -0
  85. package/dist-types/vendors/analytics/plausible-analytics.d.ts +13 -13
  86. package/dist-types/vendors/analytics/posthog.d.ts +63 -45
  87. package/dist-types/vendors/analytics/promptwatch.d.ts +7 -7
  88. package/dist-types/vendors/analytics/rudderstack.d.ts +330 -0
  89. package/dist-types/vendors/analytics/rybbit-analytics.d.ts +18 -18
  90. package/dist-types/vendors/analytics/segment.d.ts +13 -13
  91. package/dist-types/vendors/analytics/umami-analytics.d.ts +12 -12
  92. package/dist-types/vendors/analytics/vercel-analytics.d.ts +16 -16
  93. package/dist-types/vendors/functional/crisp.d.ts +11 -11
  94. package/dist-types/vendors/functional/intercom.d.ts +16 -16
  95. package/dist-types/vendors/tag-managers/google-tag-manager.d.ts +18 -18
  96. package/docs/README.md +62 -0
  97. package/docs/frameworks/javascript/script-loader.md +356 -0
  98. package/docs/frameworks/next/script-loader.md +501 -0
  99. package/docs/frameworks/react/script-loader.md +555 -0
  100. package/docs/integrations/adobe-analytics.md +160 -0
  101. package/docs/integrations/ahrefs-analytics.md +157 -0
  102. package/docs/integrations/amplitude.md +230 -0
  103. package/docs/integrations/building-integrations.md +239 -0
  104. package/docs/integrations/clearbit.md +130 -0
  105. package/docs/integrations/cloudflare-web-analytics.md +126 -0
  106. package/docs/integrations/crisp.md +140 -0
  107. package/docs/integrations/databuddy.md +205 -0
  108. package/docs/integrations/fathom-analytics.md +150 -0
  109. package/docs/integrations/google-maps.md +263 -0
  110. package/docs/integrations/google-tag-manager.md +154 -0
  111. package/docs/integrations/google-tag.md +134 -0
  112. package/docs/integrations/heap.md +219 -0
  113. package/docs/integrations/hightouch.md +199 -0
  114. package/docs/integrations/hotjar.md +143 -0
  115. package/docs/integrations/intercom.md +144 -0
  116. package/docs/integrations/linkedin-insights.md +161 -0
  117. package/docs/integrations/logrocket.md +175 -0
  118. package/docs/integrations/matomo-analytics.md +171 -0
  119. package/docs/integrations/meta-pixel.md +412 -0
  120. package/docs/integrations/microsoft-clarity.md +173 -0
  121. package/docs/integrations/microsoft-uet.md +156 -0
  122. package/docs/integrations/mixpanel-analytics.md +130 -0
  123. package/docs/integrations/overview.md +149 -0
  124. package/docs/integrations/pirsch.md +142 -0
  125. package/docs/integrations/plausible-analytics.md +154 -0
  126. package/docs/integrations/posthog.md +258 -0
  127. package/docs/integrations/promptwatch.md +121 -0
  128. package/docs/integrations/reddit-pixel.md +241 -0
  129. package/docs/integrations/rudderstack.md +271 -0
  130. package/docs/integrations/rybbit-analytics.md +143 -0
  131. package/docs/integrations/segment.md +146 -0
  132. package/docs/integrations/snapchat-pixel.md +163 -0
  133. package/docs/integrations/tiktok-pixel.md +123 -0
  134. package/docs/integrations/umami-analytics.md +148 -0
  135. package/docs/integrations/vercel-analytics.md +141 -0
  136. package/docs/integrations/x-pixel.md +157 -0
  137. package/docs/integrations/youtube.md +193 -0
  138. package/docs/shared/react/guides/script-loader.md +311 -0
  139. package/package.json +61 -7
  140. package/readme.json +8 -4
@@ -0,0 +1,153 @@
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
+ HIGHTOUCH_QUEUE_METHODS: ()=>HIGHTOUCH_QUEUE_METHODS,
32
+ hightouch: ()=>hightouch,
33
+ hightouchManifest: ()=>hightouchManifest
34
+ });
35
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
36
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
37
+ const script_url_cjs_namespaceObject = require("../_shared/script-url.cjs");
38
+ const DEFAULT_HIGHTOUCH_SCRIPT_URL = 'https://cdn.hightouch-events.com/browser/release/v1-latest/events.min.js';
39
+ const HIGHTOUCH_QUEUE_METHODS = [
40
+ 'trackSubmit',
41
+ 'trackClick',
42
+ 'trackLink',
43
+ 'trackForm',
44
+ 'pageview',
45
+ 'identify',
46
+ 'reset',
47
+ 'group',
48
+ 'track',
49
+ 'ready',
50
+ 'alias',
51
+ 'debug',
52
+ 'page',
53
+ 'once',
54
+ 'off',
55
+ 'on',
56
+ 'addSourceMiddleware',
57
+ 'addIntegrationMiddleware',
58
+ 'setAnonymousId',
59
+ 'addDestinationMiddleware',
60
+ 'load'
61
+ ];
62
+ const hightouchManifest = {
63
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
64
+ vendor: 'hightouch',
65
+ category: 'measurement',
66
+ bootstrap: [
67
+ {
68
+ type: 'setGlobal',
69
+ name: 'htevents',
70
+ value: [],
71
+ ifUndefined: true
72
+ },
73
+ {
74
+ type: 'defineQueueMethods',
75
+ target: 'htevents',
76
+ methods: [
77
+ ...HIGHTOUCH_QUEUE_METHODS
78
+ ]
79
+ },
80
+ {
81
+ type: 'setGlobalPath',
82
+ path: [
83
+ 'htevents',
84
+ '_writeKey'
85
+ ],
86
+ value: '{{writeKey}}'
87
+ },
88
+ {
89
+ type: 'setGlobalPath',
90
+ path: [
91
+ 'htevents',
92
+ '_loadOptions'
93
+ ],
94
+ value: '{{loadOptions}}'
95
+ }
96
+ ],
97
+ install: [
98
+ {
99
+ type: 'callGlobal',
100
+ global: 'htevents',
101
+ method: 'load',
102
+ args: [
103
+ '{{writeKey}}',
104
+ '{{loadOptions}}'
105
+ ]
106
+ },
107
+ {
108
+ type: 'callGlobal',
109
+ global: 'htevents',
110
+ method: 'page'
111
+ },
112
+ {
113
+ type: 'loadScript',
114
+ src: "{{scriptUrl}}",
115
+ async: true
116
+ }
117
+ ]
118
+ };
119
+ function validateWriteKey(writeKey) {
120
+ const normalized = 'string' == typeof writeKey ? writeKey.trim() : '';
121
+ if (0 === normalized.length) throw new Error('hightouch: missing or invalid writeKey');
122
+ return normalized;
123
+ }
124
+ function normalizeApiHost(apiHost) {
125
+ return (0, script_url_cjs_namespaceObject.trimToUndefined)(apiHost);
126
+ }
127
+ function hightouch({ writeKey, apiHost, trackPageView = true, scriptUrl }) {
128
+ const normalizedWriteKey = validateWriteKey(writeKey);
129
+ const loadOptions = {
130
+ apiHost: normalizeApiHost(apiHost)
131
+ };
132
+ let manifest = hightouchManifest;
133
+ if (!trackPageView) manifest = {
134
+ ...hightouchManifest,
135
+ install: hightouchManifest.install.filter((step)=>!('callGlobal' === step.type && 'htevents' === step.global && 'page' === step.method))
136
+ };
137
+ return (0, external_resolve_cjs_namespaceObject.resolveManifest)(manifest, {
138
+ loadOptions,
139
+ writeKey: normalizedWriteKey,
140
+ scriptUrl: (0, script_url_cjs_namespaceObject.resolveScriptUrl)((0, script_url_cjs_namespaceObject.trimToUndefined)(scriptUrl), DEFAULT_HIGHTOUCH_SCRIPT_URL)
141
+ });
142
+ }
143
+ exports.HIGHTOUCH_QUEUE_METHODS = __webpack_exports__.HIGHTOUCH_QUEUE_METHODS;
144
+ exports.hightouch = __webpack_exports__.hightouch;
145
+ exports.hightouchManifest = __webpack_exports__.hightouchManifest;
146
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
147
+ "HIGHTOUCH_QUEUE_METHODS",
148
+ "hightouch",
149
+ "hightouchManifest"
150
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
151
+ Object.defineProperty(exports, '__esModule', {
152
+ value: true
153
+ });
@@ -0,0 +1,109 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ import { resolveScriptUrl, trimToUndefined } from "../_shared/script-url.js";
4
+ const DEFAULT_HIGHTOUCH_SCRIPT_URL = 'https://cdn.hightouch-events.com/browser/release/v1-latest/events.min.js';
5
+ const HIGHTOUCH_QUEUE_METHODS = [
6
+ 'trackSubmit',
7
+ 'trackClick',
8
+ 'trackLink',
9
+ 'trackForm',
10
+ 'pageview',
11
+ 'identify',
12
+ 'reset',
13
+ 'group',
14
+ 'track',
15
+ 'ready',
16
+ 'alias',
17
+ 'debug',
18
+ 'page',
19
+ 'once',
20
+ 'off',
21
+ 'on',
22
+ 'addSourceMiddleware',
23
+ 'addIntegrationMiddleware',
24
+ 'setAnonymousId',
25
+ 'addDestinationMiddleware',
26
+ 'load'
27
+ ];
28
+ const hightouchManifest = {
29
+ ...vendorManifestContract,
30
+ vendor: 'hightouch',
31
+ category: 'measurement',
32
+ bootstrap: [
33
+ {
34
+ type: 'setGlobal',
35
+ name: 'htevents',
36
+ value: [],
37
+ ifUndefined: true
38
+ },
39
+ {
40
+ type: 'defineQueueMethods',
41
+ target: 'htevents',
42
+ methods: [
43
+ ...HIGHTOUCH_QUEUE_METHODS
44
+ ]
45
+ },
46
+ {
47
+ type: 'setGlobalPath',
48
+ path: [
49
+ 'htevents',
50
+ '_writeKey'
51
+ ],
52
+ value: '{{writeKey}}'
53
+ },
54
+ {
55
+ type: 'setGlobalPath',
56
+ path: [
57
+ 'htevents',
58
+ '_loadOptions'
59
+ ],
60
+ value: '{{loadOptions}}'
61
+ }
62
+ ],
63
+ install: [
64
+ {
65
+ type: 'callGlobal',
66
+ global: 'htevents',
67
+ method: 'load',
68
+ args: [
69
+ '{{writeKey}}',
70
+ '{{loadOptions}}'
71
+ ]
72
+ },
73
+ {
74
+ type: 'callGlobal',
75
+ global: 'htevents',
76
+ method: 'page'
77
+ },
78
+ {
79
+ type: 'loadScript',
80
+ src: "{{scriptUrl}}",
81
+ async: true
82
+ }
83
+ ]
84
+ };
85
+ function validateWriteKey(writeKey) {
86
+ const normalized = 'string' == typeof writeKey ? writeKey.trim() : '';
87
+ if (0 === normalized.length) throw new Error('hightouch: missing or invalid writeKey');
88
+ return normalized;
89
+ }
90
+ function normalizeApiHost(apiHost) {
91
+ return trimToUndefined(apiHost);
92
+ }
93
+ function hightouch({ writeKey, apiHost, trackPageView = true, scriptUrl }) {
94
+ const normalizedWriteKey = validateWriteKey(writeKey);
95
+ const loadOptions = {
96
+ apiHost: normalizeApiHost(apiHost)
97
+ };
98
+ let manifest = hightouchManifest;
99
+ if (!trackPageView) manifest = {
100
+ ...hightouchManifest,
101
+ install: hightouchManifest.install.filter((step)=>!('callGlobal' === step.type && 'htevents' === step.global && 'page' === step.method))
102
+ };
103
+ return resolveManifest(manifest, {
104
+ loadOptions,
105
+ writeKey: normalizedWriteKey,
106
+ scriptUrl: resolveScriptUrl(trimToUndefined(scriptUrl), DEFAULT_HIGHTOUCH_SCRIPT_URL)
107
+ });
108
+ }
109
+ export { HIGHTOUCH_QUEUE_METHODS, hightouch, hightouchManifest };
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
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
- });
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");
9
13
  };
10
14
  })();
11
15
  (()=>{
@@ -24,8 +28,8 @@ var __webpack_require__ = {};
24
28
  var __webpack_exports__ = {};
25
29
  __webpack_require__.r(__webpack_exports__);
26
30
  __webpack_require__.d(__webpack_exports__, {
27
- hotjarManifest: ()=>hotjarManifest,
28
- hotjar: ()=>hotjar
31
+ hotjar: ()=>hotjar,
32
+ hotjarManifest: ()=>hotjarManifest
29
33
  });
30
34
  const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
31
35
  const external_types_cjs_namespaceObject = require("../../types.cjs");
@@ -0,0 +1,99 @@
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
+ logRocket: ()=>logRocket,
32
+ logRocketManifest: ()=>logRocketManifest
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
+ const DEFAULT_LOGROCKET_SCRIPT_URL = 'https://cdn.logrocket.io/LogRocket.min.js';
38
+ function validateLogRocketAppId(appId) {
39
+ const normalized = 'string' == typeof appId ? appId.trim() : '';
40
+ const segments = normalized.split('/');
41
+ if (2 !== segments.length || segments.some((segment)=>0 === segment.length)) throw new Error("logRocket: invalid appId - must be a non-empty string in 'org/app' format");
42
+ return normalized;
43
+ }
44
+ const logRocketManifest = {
45
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
46
+ vendor: 'logrocket',
47
+ category: 'measurement',
48
+ install: [
49
+ {
50
+ type: 'loadScript',
51
+ src: "{{scriptUrl}}",
52
+ attributes: {
53
+ crossorigin: 'anonymous'
54
+ }
55
+ }
56
+ ],
57
+ afterLoad: [
58
+ {
59
+ type: 'callGlobal',
60
+ global: 'LogRocket',
61
+ method: 'init',
62
+ args: [
63
+ '{{appId}}',
64
+ '{{initOptions}}'
65
+ ]
66
+ }
67
+ ]
68
+ };
69
+ function logRocket(options) {
70
+ const appId = validateLogRocketAppId(options?.appId);
71
+ const asyncScriptUrl = (0, script_url_cjs_namespaceObject.trimToUndefined)(options.asyncScriptUrl);
72
+ let manifest = logRocketManifest;
73
+ if (asyncScriptUrl) manifest = {
74
+ ...logRocketManifest,
75
+ bootstrap: [
76
+ {
77
+ type: 'setGlobal',
78
+ name: '_lrAsyncScript',
79
+ value: '{{asyncScriptUrl}}',
80
+ ifUndefined: false
81
+ }
82
+ ]
83
+ };
84
+ return (0, external_resolve_cjs_namespaceObject.resolveManifest)(manifest, {
85
+ appId,
86
+ asyncScriptUrl,
87
+ initOptions: options.initOptions ?? {},
88
+ scriptUrl: (0, script_url_cjs_namespaceObject.resolveScriptUrl)((0, script_url_cjs_namespaceObject.trimToUndefined)(options.scriptUrl), DEFAULT_LOGROCKET_SCRIPT_URL)
89
+ });
90
+ }
91
+ exports.logRocket = __webpack_exports__.logRocket;
92
+ exports.logRocketManifest = __webpack_exports__.logRocketManifest;
93
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
94
+ "logRocket",
95
+ "logRocketManifest"
96
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
97
+ Object.defineProperty(exports, '__esModule', {
98
+ value: true
99
+ });
@@ -0,0 +1,58 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ import { resolveScriptUrl, trimToUndefined } from "../_shared/script-url.js";
4
+ const DEFAULT_LOGROCKET_SCRIPT_URL = 'https://cdn.logrocket.io/LogRocket.min.js';
5
+ function validateLogRocketAppId(appId) {
6
+ const normalized = 'string' == typeof appId ? appId.trim() : '';
7
+ const segments = normalized.split('/');
8
+ if (2 !== segments.length || segments.some((segment)=>0 === segment.length)) throw new Error("logRocket: invalid appId - must be a non-empty string in 'org/app' format");
9
+ return normalized;
10
+ }
11
+ const logRocketManifest = {
12
+ ...vendorManifestContract,
13
+ vendor: 'logrocket',
14
+ category: 'measurement',
15
+ install: [
16
+ {
17
+ type: 'loadScript',
18
+ src: "{{scriptUrl}}",
19
+ attributes: {
20
+ crossorigin: 'anonymous'
21
+ }
22
+ }
23
+ ],
24
+ afterLoad: [
25
+ {
26
+ type: 'callGlobal',
27
+ global: 'LogRocket',
28
+ method: 'init',
29
+ args: [
30
+ '{{appId}}',
31
+ '{{initOptions}}'
32
+ ]
33
+ }
34
+ ]
35
+ };
36
+ function logRocket(options) {
37
+ const appId = validateLogRocketAppId(options?.appId);
38
+ const asyncScriptUrl = trimToUndefined(options.asyncScriptUrl);
39
+ let manifest = logRocketManifest;
40
+ if (asyncScriptUrl) manifest = {
41
+ ...logRocketManifest,
42
+ bootstrap: [
43
+ {
44
+ type: 'setGlobal',
45
+ name: '_lrAsyncScript',
46
+ value: '{{asyncScriptUrl}}',
47
+ ifUndefined: false
48
+ }
49
+ ]
50
+ };
51
+ return resolveManifest(manifest, {
52
+ appId,
53
+ asyncScriptUrl,
54
+ initOptions: options.initOptions ?? {},
55
+ scriptUrl: resolveScriptUrl(trimToUndefined(options.scriptUrl), DEFAULT_LOGROCKET_SCRIPT_URL)
56
+ });
57
+ }
58
+ export { logRocket, logRocketManifest };
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
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
- });
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");
9
13
  };
10
14
  })();
11
15
  (()=>{
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
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
- });
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");
9
13
  };
10
14
  })();
11
15
  (()=>{
@@ -24,11 +28,61 @@ var __webpack_require__ = {};
24
28
  var __webpack_exports__ = {};
25
29
  __webpack_require__.r(__webpack_exports__);
26
30
  __webpack_require__.d(__webpack_exports__, {
27
- clarityManifest: ()=>clarityManifest,
28
- clarity: ()=>clarity
31
+ clarity: ()=>clarity,
32
+ clarityManifest: ()=>clarityManifest
29
33
  });
30
34
  const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
31
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
+ }
32
86
  const clarityManifest = {
33
87
  ...external_types_cjs_namespaceObject.vendorManifestContract,
34
88
  vendor: 'microsoft-clarity',
@@ -42,9 +96,6 @@ const clarityManifest = {
42
96
  property: 'q'
43
97
  },
44
98
  queueFormat: 'array',
45
- properties: {
46
- v: '0.7.0'
47
- },
48
99
  ifUndefined: true
49
100
  }
50
101
  ],
@@ -54,50 +105,27 @@ const clarityManifest = {
54
105
  src: "{{scriptUrl}}",
55
106
  async: true
56
107
  }
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
108
  ]
78
109
  };
79
110
  function clarity({ id, defaultConsent, scriptUrl }) {
80
111
  const normalizedId = id.trim();
81
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.`);
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,
113
+ const resolved = (0, external_resolve_cjs_namespaceObject.resolveManifest)(clarityManifest, {
99
114
  scriptUrl: scriptUrl ?? `https://www.clarity.ms/tag/${normalizedId}`
100
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
+ };
101
129
  }
102
130
  exports.clarity = __webpack_exports__.clarity;
103
131
  exports.clarityManifest = __webpack_exports__.clarityManifest;