@c15t/scripts 2.1.0 → 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 (139) 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 +100 -17
  7. package/dist/engine/runtime.js +91 -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 +11 -7
  50. package/dist/vendors/analytics/promptwatch.cjs +11 -7
  51. package/dist/vendors/analytics/rudderstack.cjs +227 -0
  52. package/dist/vendors/analytics/rudderstack.js +183 -0
  53. package/dist/vendors/analytics/rybbit-analytics.cjs +9 -5
  54. package/dist/vendors/analytics/segment.cjs +9 -5
  55. package/dist/vendors/analytics/umami-analytics.cjs +9 -5
  56. package/dist/vendors/analytics/vercel-analytics.cjs +11 -7
  57. package/dist/vendors/functional/crisp.cjs +9 -5
  58. package/dist/vendors/functional/intercom.cjs +11 -7
  59. package/dist/vendors/tag-managers/google-tag-manager.cjs +11 -7
  60. package/dist-types/registry.d.ts +313 -241
  61. package/dist-types/types.d.ts +42 -4
  62. package/dist-types/vendors/ads-and-pixels/linkedin-insights.d.ts +18 -18
  63. package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +21 -21
  64. package/dist-types/vendors/ads-and-pixels/microsoft-uet.d.ts +32 -32
  65. package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +19 -19
  66. package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +16 -16
  67. package/dist-types/vendors/ads-and-pixels/tiktok-pixel.d.ts +28 -28
  68. package/dist-types/vendors/ads-and-pixels/x-pixel.d.ts +13 -13
  69. package/dist-types/vendors/analytics/adobe-analytics.d.ts +75 -0
  70. package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +7 -7
  71. package/dist-types/vendors/analytics/amplitude.d.ts +234 -0
  72. package/dist-types/vendors/analytics/clearbit.d.ts +60 -0
  73. package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +7 -7
  74. package/dist-types/vendors/analytics/databuddy.d.ts +25 -25
  75. package/dist-types/vendors/analytics/fathom-analytics.d.ts +11 -11
  76. package/dist-types/vendors/analytics/google-tag.d.ts +17 -17
  77. package/dist-types/vendors/analytics/heap.d.ts +316 -0
  78. package/dist-types/vendors/analytics/hightouch.d.ts +285 -0
  79. package/dist-types/vendors/analytics/hotjar.d.ts +14 -14
  80. package/dist-types/vendors/analytics/logrocket.d.ts +101 -0
  81. package/dist-types/vendors/analytics/microsoft-clarity.d.ts +42 -30
  82. package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +40 -28
  83. package/dist-types/vendors/analytics/pirsch.d.ts +96 -0
  84. package/dist-types/vendors/analytics/plausible-analytics.d.ts +13 -13
  85. package/dist-types/vendors/analytics/posthog.d.ts +39 -39
  86. package/dist-types/vendors/analytics/promptwatch.d.ts +7 -7
  87. package/dist-types/vendors/analytics/rudderstack.d.ts +330 -0
  88. package/dist-types/vendors/analytics/rybbit-analytics.d.ts +18 -18
  89. package/dist-types/vendors/analytics/segment.d.ts +13 -13
  90. package/dist-types/vendors/analytics/umami-analytics.d.ts +12 -12
  91. package/dist-types/vendors/analytics/vercel-analytics.d.ts +16 -16
  92. package/dist-types/vendors/functional/crisp.d.ts +11 -11
  93. package/dist-types/vendors/functional/intercom.d.ts +16 -16
  94. package/dist-types/vendors/tag-managers/google-tag-manager.d.ts +18 -18
  95. package/docs/README.md +62 -0
  96. package/docs/frameworks/javascript/script-loader.md +354 -0
  97. package/docs/frameworks/next/script-loader.md +499 -0
  98. package/docs/frameworks/react/script-loader.md +553 -0
  99. package/docs/integrations/adobe-analytics.md +160 -0
  100. package/docs/integrations/ahrefs-analytics.md +157 -0
  101. package/docs/integrations/amplitude.md +230 -0
  102. package/docs/integrations/building-integrations.md +239 -0
  103. package/docs/integrations/clearbit.md +130 -0
  104. package/docs/integrations/cloudflare-web-analytics.md +126 -0
  105. package/docs/integrations/crisp.md +140 -0
  106. package/docs/integrations/databuddy.md +205 -0
  107. package/docs/integrations/fathom-analytics.md +150 -0
  108. package/docs/integrations/google-maps.md +263 -0
  109. package/docs/integrations/google-tag-manager.md +154 -0
  110. package/docs/integrations/google-tag.md +134 -0
  111. package/docs/integrations/heap.md +219 -0
  112. package/docs/integrations/hightouch.md +199 -0
  113. package/docs/integrations/hotjar.md +143 -0
  114. package/docs/integrations/intercom.md +144 -0
  115. package/docs/integrations/linkedin-insights.md +161 -0
  116. package/docs/integrations/logrocket.md +175 -0
  117. package/docs/integrations/matomo-analytics.md +171 -0
  118. package/docs/integrations/meta-pixel.md +412 -0
  119. package/docs/integrations/microsoft-clarity.md +173 -0
  120. package/docs/integrations/microsoft-uet.md +156 -0
  121. package/docs/integrations/mixpanel-analytics.md +130 -0
  122. package/docs/integrations/overview.md +149 -0
  123. package/docs/integrations/pirsch.md +142 -0
  124. package/docs/integrations/plausible-analytics.md +154 -0
  125. package/docs/integrations/posthog.md +258 -0
  126. package/docs/integrations/promptwatch.md +121 -0
  127. package/docs/integrations/reddit-pixel.md +241 -0
  128. package/docs/integrations/rudderstack.md +271 -0
  129. package/docs/integrations/rybbit-analytics.md +143 -0
  130. package/docs/integrations/segment.md +146 -0
  131. package/docs/integrations/snapchat-pixel.md +163 -0
  132. package/docs/integrations/tiktok-pixel.md +123 -0
  133. package/docs/integrations/umami-analytics.md +148 -0
  134. package/docs/integrations/vercel-analytics.md +141 -0
  135. package/docs/integrations/x-pixel.md +157 -0
  136. package/docs/integrations/youtube.md +193 -0
  137. package/docs/shared/react/guides/script-loader.md +309 -0
  138. package/package.json +61 -7
  139. package/readme.json +8 -4
@@ -0,0 +1,108 @@
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
+ pirsch: ()=>pirsch,
32
+ pirschManifest: ()=>pirschManifest
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_PIRSCH_SCRIPT_URL = 'https://api.pirsch.io/pa.js';
38
+ const DEFAULT_PIRSCH_EXTENDED_SCRIPT_URL = 'https://api.pirsch.io/pirsch-extended.js';
39
+ const pirschManifest = {
40
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
41
+ vendor: 'pirsch',
42
+ category: 'measurement',
43
+ install: [
44
+ {
45
+ type: 'loadScript',
46
+ src: "{{scriptUrl}}",
47
+ defer: true,
48
+ attributes: {
49
+ id: "{{scriptElementId}}",
50
+ 'data-code': '{{identificationCode}}',
51
+ 'data-domain': '{{domain}}',
52
+ 'data-dev': '{{dev}}',
53
+ 'data-hit-endpoint': '{{hitEndpoint}}',
54
+ 'data-event-endpoint': '{{eventEndpoint}}',
55
+ 'data-disable-page-views': '{{disablePageViews}}'
56
+ }
57
+ }
58
+ ]
59
+ };
60
+ function commaListDataAttribute(value) {
61
+ if (void 0 === value) return;
62
+ if (Array.isArray(value)) {
63
+ const items = value.map((item)=>item.trim()).filter((item)=>item.length > 0);
64
+ if (0 === items.length) return;
65
+ return items.join(',');
66
+ }
67
+ return (0, script_url_cjs_namespaceObject.trimToUndefined)(value);
68
+ }
69
+ function presenceDataAttribute(value) {
70
+ if (true === value) return '';
71
+ }
72
+ function getPirschScriptElementId(options) {
73
+ if (true === options.extended) return 'pirschextendedjs';
74
+ return 'pianjs';
75
+ }
76
+ function getPirschScriptUrl(options) {
77
+ const defaultScriptUrl = true === options.extended ? DEFAULT_PIRSCH_EXTENDED_SCRIPT_URL : DEFAULT_PIRSCH_SCRIPT_URL;
78
+ return (0, script_url_cjs_namespaceObject.resolveScriptUrl)((0, script_url_cjs_namespaceObject.trimToUndefined)(options.scriptUrl), defaultScriptUrl);
79
+ }
80
+ function pirsch(options) {
81
+ const identificationCode = options.identificationCode.trim();
82
+ if (0 === identificationCode.length) throw new Error('pirsch: invalid identificationCode - must be a non-empty string');
83
+ const resolved = (0, external_resolve_cjs_namespaceObject.resolveManifest)(pirschManifest, {
84
+ identificationCode,
85
+ domain: commaListDataAttribute(options.domain),
86
+ dev: (0, script_url_cjs_namespaceObject.trimToUndefined)(options.dev),
87
+ hitEndpoint: (0, script_url_cjs_namespaceObject.trimToUndefined)(options.hitEndpoint),
88
+ eventEndpoint: (0, script_url_cjs_namespaceObject.trimToUndefined)(options.eventEndpoint),
89
+ disablePageViews: presenceDataAttribute(options.disablePageViews),
90
+ scriptElementId: getPirschScriptElementId(options),
91
+ scriptUrl: getPirschScriptUrl(options)
92
+ });
93
+ const manifestOnLoad = resolved.onLoad;
94
+ resolved.onLoad = (info)=>{
95
+ manifestOnLoad?.(info);
96
+ if ('loading' !== document.readyState) window.pirschInit?.();
97
+ };
98
+ return resolved;
99
+ }
100
+ exports.pirsch = __webpack_exports__.pirsch;
101
+ exports.pirschManifest = __webpack_exports__.pirschManifest;
102
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
103
+ "pirsch",
104
+ "pirschManifest"
105
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
106
+ Object.defineProperty(exports, '__esModule', {
107
+ value: true
108
+ });
@@ -0,0 +1,67 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ import { resolveScriptUrl, trimToUndefined } from "../_shared/script-url.js";
4
+ const DEFAULT_PIRSCH_SCRIPT_URL = 'https://api.pirsch.io/pa.js';
5
+ const DEFAULT_PIRSCH_EXTENDED_SCRIPT_URL = 'https://api.pirsch.io/pirsch-extended.js';
6
+ const pirschManifest = {
7
+ ...vendorManifestContract,
8
+ vendor: 'pirsch',
9
+ category: 'measurement',
10
+ install: [
11
+ {
12
+ type: 'loadScript',
13
+ src: "{{scriptUrl}}",
14
+ defer: true,
15
+ attributes: {
16
+ id: "{{scriptElementId}}",
17
+ 'data-code': '{{identificationCode}}',
18
+ 'data-domain': '{{domain}}',
19
+ 'data-dev': '{{dev}}',
20
+ 'data-hit-endpoint': '{{hitEndpoint}}',
21
+ 'data-event-endpoint': '{{eventEndpoint}}',
22
+ 'data-disable-page-views': '{{disablePageViews}}'
23
+ }
24
+ }
25
+ ]
26
+ };
27
+ function commaListDataAttribute(value) {
28
+ if (void 0 === value) return;
29
+ if (Array.isArray(value)) {
30
+ const items = value.map((item)=>item.trim()).filter((item)=>item.length > 0);
31
+ if (0 === items.length) return;
32
+ return items.join(',');
33
+ }
34
+ return trimToUndefined(value);
35
+ }
36
+ function presenceDataAttribute(value) {
37
+ if (true === value) return '';
38
+ }
39
+ function getPirschScriptElementId(options) {
40
+ if (true === options.extended) return 'pirschextendedjs';
41
+ return 'pianjs';
42
+ }
43
+ function getPirschScriptUrl(options) {
44
+ const defaultScriptUrl = true === options.extended ? DEFAULT_PIRSCH_EXTENDED_SCRIPT_URL : DEFAULT_PIRSCH_SCRIPT_URL;
45
+ return resolveScriptUrl(trimToUndefined(options.scriptUrl), defaultScriptUrl);
46
+ }
47
+ function pirsch(options) {
48
+ const identificationCode = options.identificationCode.trim();
49
+ if (0 === identificationCode.length) throw new Error('pirsch: invalid identificationCode - must be a non-empty string');
50
+ const resolved = resolveManifest(pirschManifest, {
51
+ identificationCode,
52
+ domain: commaListDataAttribute(options.domain),
53
+ dev: trimToUndefined(options.dev),
54
+ hitEndpoint: trimToUndefined(options.hitEndpoint),
55
+ eventEndpoint: trimToUndefined(options.eventEndpoint),
56
+ disablePageViews: presenceDataAttribute(options.disablePageViews),
57
+ scriptElementId: getPirschScriptElementId(options),
58
+ scriptUrl: getPirschScriptUrl(options)
59
+ });
60
+ const manifestOnLoad = resolved.onLoad;
61
+ resolved.onLoad = (info)=>{
62
+ manifestOnLoad?.(info);
63
+ if ('loading' !== document.readyState) window.pirschInit?.();
64
+ };
65
+ return resolved;
66
+ }
67
+ export { pirsch, pirschManifest };
@@ -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,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
- posthogManifest: ()=>posthogManifest,
28
- posthog: ()=>posthog
31
+ posthog: ()=>posthog,
32
+ posthogManifest: ()=>posthogManifest
29
33
  });
30
34
  const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
31
35
  const external_types_cjs_namespaceObject = require("../../types.cjs");
@@ -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
- promptwatchManifest: ()=>promptwatchManifest,
28
- promptwatch: ()=>promptwatch
31
+ promptwatch: ()=>promptwatch,
32
+ promptwatchManifest: ()=>promptwatchManifest
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,227 @@
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
+ RUDDERSTACK_QUEUE_METHODS: ()=>RUDDERSTACK_QUEUE_METHODS,
32
+ rudderstack: ()=>rudderstack,
33
+ rudderstackManifest: ()=>rudderstackManifest
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_RUDDERSTACK_SCRIPT_URL = 'https://cdn.rudderlabs.com/v3/modern/rsa.min.js';
39
+ const RUDDERSTACK_QUEUE_METHODS = [
40
+ 'setDefaultInstanceKey',
41
+ 'load',
42
+ 'ready',
43
+ 'page',
44
+ 'track',
45
+ 'identify',
46
+ 'alias',
47
+ 'group',
48
+ 'reset',
49
+ 'setAnonymousId',
50
+ 'startSession',
51
+ 'endSession',
52
+ 'consent',
53
+ 'addCustomIntegration'
54
+ ];
55
+ const rudderstackManifest = {
56
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
57
+ vendor: 'rudderstack',
58
+ category: 'measurement',
59
+ bootstrap: [
60
+ {
61
+ type: 'setGlobal',
62
+ name: 'rudderanalytics',
63
+ value: [],
64
+ ifUndefined: true
65
+ },
66
+ {
67
+ type: 'setGlobal',
68
+ name: 'RudderSnippetVersion',
69
+ value: '3.0.32'
70
+ },
71
+ {
72
+ type: 'setGlobal',
73
+ name: 'rudderAnalyticsBuildType',
74
+ value: 'modern'
75
+ },
76
+ {
77
+ type: 'setGlobalPath',
78
+ path: [
79
+ 'rudderanalytics',
80
+ 'snippetExecuted'
81
+ ],
82
+ value: true
83
+ },
84
+ {
85
+ type: 'defineQueueMethods',
86
+ target: 'rudderanalytics',
87
+ methods: [
88
+ ...RUDDERSTACK_QUEUE_METHODS
89
+ ]
90
+ }
91
+ ],
92
+ install: [
93
+ {
94
+ type: 'callGlobal',
95
+ global: 'rudderanalytics',
96
+ method: 'load',
97
+ args: [
98
+ '{{writeKey}}',
99
+ '{{dataPlaneUrl}}',
100
+ '{{loadOptions}}'
101
+ ]
102
+ },
103
+ {
104
+ type: 'callGlobal',
105
+ global: 'rudderanalytics',
106
+ method: 'page'
107
+ },
108
+ {
109
+ type: 'loadScript',
110
+ src: "{{scriptUrl}}",
111
+ async: true,
112
+ attributes: {
113
+ 'data-loader': 'RS_JS_SDK',
114
+ 'data-rsa-write-key': '{{writeKey}}'
115
+ }
116
+ }
117
+ ]
118
+ };
119
+ function validateRequiredString(value, label) {
120
+ const normalized = 'string' == typeof value ? value.trim() : '';
121
+ if (0 === normalized.length) throw new Error(`rudderstack: missing or invalid ${label}`);
122
+ return normalized;
123
+ }
124
+ function validateOptionalHttpsScriptUrl(scriptUrl) {
125
+ if (void 0 === scriptUrl) return;
126
+ let parsed;
127
+ try {
128
+ parsed = new URL(scriptUrl);
129
+ } catch {
130
+ throw new Error("rudderstack: scriptUrl must be a valid https URL");
131
+ }
132
+ if ('https:' !== parsed.protocol) throw new Error("rudderstack: scriptUrl must be a valid https URL");
133
+ return scriptUrl;
134
+ }
135
+ function isJsonObjectValue(value) {
136
+ return 'object' == typeof value && null !== value && !Array.isArray(value);
137
+ }
138
+ function validateConsentMapping(consentManagement) {
139
+ const normalized = {};
140
+ for (const [category, ids] of Object.entries(consentManagement.mapping)){
141
+ if (!Array.isArray(ids)) throw new Error(`rudderstack: consentManagement.mapping.${category} must be an array of consent IDs`);
142
+ const trimmed = ids.map((id)=>{
143
+ if ('string' == typeof id) return id.trim();
144
+ return '';
145
+ }).filter((id)=>id.length > 0);
146
+ if (0 === trimmed.length) throw new Error(`rudderstack: consentManagement.mapping.${category} is declared but contains no valid consent IDs`);
147
+ normalized[category] = trimmed;
148
+ }
149
+ if (0 === Object.keys(normalized).length) throw new Error('rudderstack: consentManagement.mapping must map at least one c15t category to a non-empty list of RudderStack consent IDs');
150
+ return normalized;
151
+ }
152
+ function buildPreConsentLoadOptions(loadOptions) {
153
+ let userConsentManagement = {};
154
+ if (isJsonObjectValue(loadOptions.consentManagement)) userConsentManagement = loadOptions.consentManagement;
155
+ let userPreConsent = {};
156
+ if (isJsonObjectValue(loadOptions.preConsent)) userPreConsent = loadOptions.preConsent;
157
+ let storage = {
158
+ strategy: 'none'
159
+ };
160
+ if (isJsonObjectValue(userPreConsent.storage)) storage = userPreConsent.storage;
161
+ return {
162
+ ...loadOptions,
163
+ preConsent: {
164
+ ...userPreConsent,
165
+ enabled: true,
166
+ storage,
167
+ events: {
168
+ delivery: 'buffer'
169
+ }
170
+ },
171
+ consentManagement: {
172
+ ...userConsentManagement,
173
+ enabled: true,
174
+ provider: 'custom'
175
+ }
176
+ };
177
+ }
178
+ function validateDataPlaneUrl(dataPlaneUrl) {
179
+ const normalized = validateRequiredString(dataPlaneUrl, 'dataPlaneUrl');
180
+ let parsed;
181
+ try {
182
+ parsed = new URL(normalized);
183
+ } catch {
184
+ throw new Error('rudderstack: dataPlaneUrl must be a valid https URL');
185
+ }
186
+ if ('https:' !== parsed.protocol) throw new Error('rudderstack: dataPlaneUrl must be a valid https URL');
187
+ return normalized;
188
+ }
189
+ function rudderstack({ writeKey, dataPlaneUrl, consentManagement, loadOptions = {}, trackPageView = true, scriptUrl }) {
190
+ const normalizedWriteKey = validateRequiredString(writeKey, 'writeKey');
191
+ const normalizedDataPlaneUrl = validateDataPlaneUrl(dataPlaneUrl);
192
+ let manifest = rudderstackManifest;
193
+ let resolvedLoadOptions = loadOptions;
194
+ if (consentManagement) {
195
+ const consentMapping = validateConsentMapping(consentManagement);
196
+ manifest = {
197
+ ...manifest,
198
+ alwaysLoad: true,
199
+ persistAfterConsentRevoked: true,
200
+ consentMapping,
201
+ consentSignal: 'rudderstack',
202
+ consentSignalTarget: 'rudderanalytics'
203
+ };
204
+ resolvedLoadOptions = buildPreConsentLoadOptions(loadOptions);
205
+ }
206
+ if (!trackPageView) manifest = {
207
+ ...manifest,
208
+ install: manifest.install.filter((step)=>!('callGlobal' === step.type && 'rudderanalytics' === step.global && 'page' === step.method))
209
+ };
210
+ return (0, external_resolve_cjs_namespaceObject.resolveManifest)(manifest, {
211
+ dataPlaneUrl: normalizedDataPlaneUrl,
212
+ loadOptions: resolvedLoadOptions,
213
+ writeKey: normalizedWriteKey,
214
+ scriptUrl: (0, script_url_cjs_namespaceObject.resolveScriptUrl)(validateOptionalHttpsScriptUrl((0, script_url_cjs_namespaceObject.trimToUndefined)(scriptUrl)), DEFAULT_RUDDERSTACK_SCRIPT_URL)
215
+ });
216
+ }
217
+ exports.RUDDERSTACK_QUEUE_METHODS = __webpack_exports__.RUDDERSTACK_QUEUE_METHODS;
218
+ exports.rudderstack = __webpack_exports__.rudderstack;
219
+ exports.rudderstackManifest = __webpack_exports__.rudderstackManifest;
220
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
221
+ "RUDDERSTACK_QUEUE_METHODS",
222
+ "rudderstack",
223
+ "rudderstackManifest"
224
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
225
+ Object.defineProperty(exports, '__esModule', {
226
+ value: true
227
+ });
@@ -0,0 +1,183 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ import { resolveScriptUrl, trimToUndefined } from "../_shared/script-url.js";
4
+ const DEFAULT_RUDDERSTACK_SCRIPT_URL = 'https://cdn.rudderlabs.com/v3/modern/rsa.min.js';
5
+ const RUDDERSTACK_QUEUE_METHODS = [
6
+ 'setDefaultInstanceKey',
7
+ 'load',
8
+ 'ready',
9
+ 'page',
10
+ 'track',
11
+ 'identify',
12
+ 'alias',
13
+ 'group',
14
+ 'reset',
15
+ 'setAnonymousId',
16
+ 'startSession',
17
+ 'endSession',
18
+ 'consent',
19
+ 'addCustomIntegration'
20
+ ];
21
+ const rudderstackManifest = {
22
+ ...vendorManifestContract,
23
+ vendor: 'rudderstack',
24
+ category: 'measurement',
25
+ bootstrap: [
26
+ {
27
+ type: 'setGlobal',
28
+ name: 'rudderanalytics',
29
+ value: [],
30
+ ifUndefined: true
31
+ },
32
+ {
33
+ type: 'setGlobal',
34
+ name: 'RudderSnippetVersion',
35
+ value: '3.0.32'
36
+ },
37
+ {
38
+ type: 'setGlobal',
39
+ name: 'rudderAnalyticsBuildType',
40
+ value: 'modern'
41
+ },
42
+ {
43
+ type: 'setGlobalPath',
44
+ path: [
45
+ 'rudderanalytics',
46
+ 'snippetExecuted'
47
+ ],
48
+ value: true
49
+ },
50
+ {
51
+ type: 'defineQueueMethods',
52
+ target: 'rudderanalytics',
53
+ methods: [
54
+ ...RUDDERSTACK_QUEUE_METHODS
55
+ ]
56
+ }
57
+ ],
58
+ install: [
59
+ {
60
+ type: 'callGlobal',
61
+ global: 'rudderanalytics',
62
+ method: 'load',
63
+ args: [
64
+ '{{writeKey}}',
65
+ '{{dataPlaneUrl}}',
66
+ '{{loadOptions}}'
67
+ ]
68
+ },
69
+ {
70
+ type: 'callGlobal',
71
+ global: 'rudderanalytics',
72
+ method: 'page'
73
+ },
74
+ {
75
+ type: 'loadScript',
76
+ src: "{{scriptUrl}}",
77
+ async: true,
78
+ attributes: {
79
+ 'data-loader': 'RS_JS_SDK',
80
+ 'data-rsa-write-key': '{{writeKey}}'
81
+ }
82
+ }
83
+ ]
84
+ };
85
+ function validateRequiredString(value, label) {
86
+ const normalized = 'string' == typeof value ? value.trim() : '';
87
+ if (0 === normalized.length) throw new Error(`rudderstack: missing or invalid ${label}`);
88
+ return normalized;
89
+ }
90
+ function validateOptionalHttpsScriptUrl(scriptUrl) {
91
+ if (void 0 === scriptUrl) return;
92
+ let parsed;
93
+ try {
94
+ parsed = new URL(scriptUrl);
95
+ } catch {
96
+ throw new Error("rudderstack: scriptUrl must be a valid https URL");
97
+ }
98
+ if ('https:' !== parsed.protocol) throw new Error("rudderstack: scriptUrl must be a valid https URL");
99
+ return scriptUrl;
100
+ }
101
+ function isJsonObjectValue(value) {
102
+ return 'object' == typeof value && null !== value && !Array.isArray(value);
103
+ }
104
+ function validateConsentMapping(consentManagement) {
105
+ const normalized = {};
106
+ for (const [category, ids] of Object.entries(consentManagement.mapping)){
107
+ if (!Array.isArray(ids)) throw new Error(`rudderstack: consentManagement.mapping.${category} must be an array of consent IDs`);
108
+ const trimmed = ids.map((id)=>{
109
+ if ('string' == typeof id) return id.trim();
110
+ return '';
111
+ }).filter((id)=>id.length > 0);
112
+ if (0 === trimmed.length) throw new Error(`rudderstack: consentManagement.mapping.${category} is declared but contains no valid consent IDs`);
113
+ normalized[category] = trimmed;
114
+ }
115
+ if (0 === Object.keys(normalized).length) throw new Error('rudderstack: consentManagement.mapping must map at least one c15t category to a non-empty list of RudderStack consent IDs');
116
+ return normalized;
117
+ }
118
+ function buildPreConsentLoadOptions(loadOptions) {
119
+ let userConsentManagement = {};
120
+ if (isJsonObjectValue(loadOptions.consentManagement)) userConsentManagement = loadOptions.consentManagement;
121
+ let userPreConsent = {};
122
+ if (isJsonObjectValue(loadOptions.preConsent)) userPreConsent = loadOptions.preConsent;
123
+ let storage = {
124
+ strategy: 'none'
125
+ };
126
+ if (isJsonObjectValue(userPreConsent.storage)) storage = userPreConsent.storage;
127
+ return {
128
+ ...loadOptions,
129
+ preConsent: {
130
+ ...userPreConsent,
131
+ enabled: true,
132
+ storage,
133
+ events: {
134
+ delivery: 'buffer'
135
+ }
136
+ },
137
+ consentManagement: {
138
+ ...userConsentManagement,
139
+ enabled: true,
140
+ provider: 'custom'
141
+ }
142
+ };
143
+ }
144
+ function validateDataPlaneUrl(dataPlaneUrl) {
145
+ const normalized = validateRequiredString(dataPlaneUrl, 'dataPlaneUrl');
146
+ let parsed;
147
+ try {
148
+ parsed = new URL(normalized);
149
+ } catch {
150
+ throw new Error('rudderstack: dataPlaneUrl must be a valid https URL');
151
+ }
152
+ if ('https:' !== parsed.protocol) throw new Error('rudderstack: dataPlaneUrl must be a valid https URL');
153
+ return normalized;
154
+ }
155
+ function rudderstack({ writeKey, dataPlaneUrl, consentManagement, loadOptions = {}, trackPageView = true, scriptUrl }) {
156
+ const normalizedWriteKey = validateRequiredString(writeKey, 'writeKey');
157
+ const normalizedDataPlaneUrl = validateDataPlaneUrl(dataPlaneUrl);
158
+ let manifest = rudderstackManifest;
159
+ let resolvedLoadOptions = loadOptions;
160
+ if (consentManagement) {
161
+ const consentMapping = validateConsentMapping(consentManagement);
162
+ manifest = {
163
+ ...manifest,
164
+ alwaysLoad: true,
165
+ persistAfterConsentRevoked: true,
166
+ consentMapping,
167
+ consentSignal: 'rudderstack',
168
+ consentSignalTarget: 'rudderanalytics'
169
+ };
170
+ resolvedLoadOptions = buildPreConsentLoadOptions(loadOptions);
171
+ }
172
+ if (!trackPageView) manifest = {
173
+ ...manifest,
174
+ install: manifest.install.filter((step)=>!('callGlobal' === step.type && 'rudderanalytics' === step.global && 'page' === step.method))
175
+ };
176
+ return resolveManifest(manifest, {
177
+ dataPlaneUrl: normalizedDataPlaneUrl,
178
+ loadOptions: resolvedLoadOptions,
179
+ writeKey: normalizedWriteKey,
180
+ scriptUrl: resolveScriptUrl(validateOptionalHttpsScriptUrl(trimToUndefined(scriptUrl)), DEFAULT_RUDDERSTACK_SCRIPT_URL)
181
+ });
182
+ }
183
+ export { RUDDERSTACK_QUEUE_METHODS, rudderstack, rudderstackManifest };