@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,134 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ import { resolveScriptUrl, trimToUndefined } from "../_shared/script-url.js";
4
+ const DEFAULT_AMPLITUDE_BROWSER_SDK_VERSION = '2.44.4';
5
+ const DEFAULT_AMPLITUDE_SCRIPT_URL = `https://cdn.amplitude.com/libs/analytics-browser-${DEFAULT_AMPLITUDE_BROWSER_SDK_VERSION}-min.js.gz`;
6
+ const AMPLITUDE_PROMISE_QUEUE_METHODS = [
7
+ 'init',
8
+ 'track',
9
+ 'identify',
10
+ 'flush'
11
+ ];
12
+ const AMPLITUDE_SYNC_QUEUE_METHODS = [
13
+ 'setUserId',
14
+ 'setOptOut'
15
+ ];
16
+ const AMPLITUDE_QUEUE_METHODS = [
17
+ ...AMPLITUDE_PROMISE_QUEUE_METHODS,
18
+ ...AMPLITUDE_SYNC_QUEUE_METHODS
19
+ ];
20
+ const AMPLITUDE_IDENTIFY_METHODS = [
21
+ 'set',
22
+ 'setOnce',
23
+ 'add',
24
+ 'append',
25
+ 'prepend',
26
+ 'preInsert',
27
+ 'postInsert',
28
+ 'remove',
29
+ 'unset',
30
+ 'clearAll',
31
+ 'getUserProperties'
32
+ ];
33
+ const amplitudeManifest = {
34
+ ...vendorManifestContract,
35
+ vendor: 'amplitude',
36
+ category: 'measurement',
37
+ install: [
38
+ {
39
+ type: 'setGlobal',
40
+ name: 'amplitude',
41
+ value: {
42
+ _q: [],
43
+ _iq: {},
44
+ invoked: true
45
+ },
46
+ ifUndefined: true
47
+ },
48
+ {
49
+ type: 'defineQueueClass',
50
+ target: 'amplitude',
51
+ name: 'Identify',
52
+ queueProperty: '_q',
53
+ methods: [
54
+ ...AMPLITUDE_IDENTIFY_METHODS
55
+ ]
56
+ },
57
+ {
58
+ type: 'defineQueueMethods',
59
+ target: 'amplitude',
60
+ queue: {
61
+ property: '_q'
62
+ },
63
+ queueFormat: 'wrappedMethodCall',
64
+ methods: [
65
+ ...AMPLITUDE_PROMISE_QUEUE_METHODS
66
+ ]
67
+ },
68
+ {
69
+ type: 'defineQueueMethods',
70
+ target: 'amplitude',
71
+ queue: {
72
+ property: '_q'
73
+ },
74
+ queueFormat: 'voidMethodCall',
75
+ methods: [
76
+ ...AMPLITUDE_SYNC_QUEUE_METHODS
77
+ ]
78
+ },
79
+ {
80
+ type: 'callGlobal',
81
+ global: 'amplitude',
82
+ method: 'init',
83
+ args: [
84
+ '{{apiKey}}',
85
+ '{{initOptions}}'
86
+ ]
87
+ },
88
+ {
89
+ type: 'loadScript',
90
+ src: "{{scriptUrl}}",
91
+ async: true
92
+ }
93
+ ],
94
+ onLoadDenied: [
95
+ {
96
+ type: 'callGlobal',
97
+ global: 'amplitude',
98
+ method: 'setOptOut',
99
+ args: [
100
+ true
101
+ ]
102
+ }
103
+ ],
104
+ onConsentGranted: [
105
+ {
106
+ type: 'callGlobal',
107
+ global: 'amplitude',
108
+ method: 'setOptOut',
109
+ args: [
110
+ false
111
+ ]
112
+ }
113
+ ],
114
+ onConsentDenied: [
115
+ {
116
+ type: 'callGlobal',
117
+ global: 'amplitude',
118
+ method: 'setOptOut',
119
+ args: [
120
+ true
121
+ ]
122
+ }
123
+ ]
124
+ };
125
+ function amplitude({ apiKey, initOptions = {}, scriptUrl }) {
126
+ const normalizedApiKey = 'string' == typeof apiKey ? apiKey.trim() : '';
127
+ if (0 === normalizedApiKey.length) throw new Error('amplitude: missing or invalid apiKey');
128
+ return resolveManifest(amplitudeManifest, {
129
+ apiKey: normalizedApiKey,
130
+ initOptions,
131
+ scriptUrl: resolveScriptUrl(trimToUndefined(scriptUrl), DEFAULT_AMPLITUDE_SCRIPT_URL)
132
+ });
133
+ }
134
+ export { AMPLITUDE_IDENTIFY_METHODS, AMPLITUDE_PROMISE_QUEUE_METHODS, AMPLITUDE_QUEUE_METHODS, AMPLITUDE_SYNC_QUEUE_METHODS, DEFAULT_AMPLITUDE_BROWSER_SDK_VERSION, DEFAULT_AMPLITUDE_SCRIPT_URL, amplitude, amplitudeManifest };
@@ -0,0 +1,69 @@
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
+ clearbit: ()=>clearbit,
32
+ clearbitManifest: ()=>clearbitManifest
33
+ });
34
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
35
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
36
+ const script_url_cjs_namespaceObject = require("../_shared/script-url.cjs");
37
+ function getDefaultClearbitScriptUrl(publishableKey) {
38
+ return `https://tag.clearbitscripts.com/v1/${encodeURIComponent(publishableKey)}/tags.js`;
39
+ }
40
+ const clearbitManifest = {
41
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
42
+ vendor: 'clearbit',
43
+ category: 'marketing',
44
+ install: [
45
+ {
46
+ type: 'loadScript',
47
+ src: "{{scriptUrl}}",
48
+ attributes: {
49
+ referrerpolicy: 'strict-origin-when-cross-origin'
50
+ }
51
+ }
52
+ ]
53
+ };
54
+ function clearbit(options) {
55
+ const publishableKey = 'string' == typeof options.publishableKey ? options.publishableKey.trim() : '';
56
+ if (0 === publishableKey.length) throw new Error('clearbit: invalid publishableKey - must be a non-empty string');
57
+ return (0, external_resolve_cjs_namespaceObject.resolveManifest)(clearbitManifest, {
58
+ scriptUrl: (0, script_url_cjs_namespaceObject.resolveScriptUrl)((0, script_url_cjs_namespaceObject.trimToUndefined)(options.scriptUrl), getDefaultClearbitScriptUrl(publishableKey))
59
+ });
60
+ }
61
+ exports.clearbit = __webpack_exports__.clearbit;
62
+ exports.clearbitManifest = __webpack_exports__.clearbitManifest;
63
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
64
+ "clearbit",
65
+ "clearbitManifest"
66
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
67
+ Object.defineProperty(exports, '__esModule', {
68
+ value: true
69
+ });
@@ -0,0 +1,28 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ import { resolveScriptUrl, trimToUndefined } from "../_shared/script-url.js";
4
+ function getDefaultClearbitScriptUrl(publishableKey) {
5
+ return `https://tag.clearbitscripts.com/v1/${encodeURIComponent(publishableKey)}/tags.js`;
6
+ }
7
+ const clearbitManifest = {
8
+ ...vendorManifestContract,
9
+ vendor: 'clearbit',
10
+ category: 'marketing',
11
+ install: [
12
+ {
13
+ type: 'loadScript',
14
+ src: "{{scriptUrl}}",
15
+ attributes: {
16
+ referrerpolicy: 'strict-origin-when-cross-origin'
17
+ }
18
+ }
19
+ ]
20
+ };
21
+ function clearbit(options) {
22
+ const publishableKey = 'string' == typeof options.publishableKey ? options.publishableKey.trim() : '';
23
+ if (0 === publishableKey.length) throw new Error('clearbit: invalid publishableKey - must be a non-empty string');
24
+ return resolveManifest(clearbitManifest, {
25
+ scriptUrl: resolveScriptUrl(trimToUndefined(options.scriptUrl), getDefaultClearbitScriptUrl(publishableKey))
26
+ });
27
+ }
28
+ export { clearbit, clearbitManifest };
@@ -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
- cloudflareWebAnalyticsManifest: ()=>cloudflareWebAnalyticsManifest,
28
- cloudflareWebAnalytics: ()=>cloudflareWebAnalytics
31
+ cloudflareWebAnalytics: ()=>cloudflareWebAnalytics,
32
+ cloudflareWebAnalyticsManifest: ()=>cloudflareWebAnalyticsManifest
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
- databuddyManifest: ()=>databuddyManifest,
28
- databuddy: ()=>databuddy
31
+ databuddy: ()=>databuddy,
32
+ databuddyManifest: ()=>databuddyManifest
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
- fathomAnalyticsManifest: ()=>fathomAnalyticsManifest,
28
- fathomAnalytics: ()=>fathomAnalytics
31
+ fathomAnalytics: ()=>fathomAnalytics,
32
+ fathomAnalyticsManifest: ()=>fathomAnalyticsManifest
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
- gtagManifest: ()=>gtagManifest,
28
- gtag: ()=>gtag
31
+ gtag: ()=>gtag,
32
+ gtagManifest: ()=>gtagManifest
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,181 @@
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
+ DEFAULT_HEAP_CONFIG_BASE_URL: ()=>DEFAULT_HEAP_CONFIG_BASE_URL,
32
+ HEAP_QUEUE_METHODS: ()=>HEAP_QUEUE_METHODS,
33
+ heap: ()=>heap,
34
+ heapManifest: ()=>heapManifest
35
+ });
36
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
37
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
38
+ const script_url_cjs_namespaceObject = require("../_shared/script-url.cjs");
39
+ const DEFAULT_HEAP_CONFIG_BASE_URL = 'https://cdn.us.heap-api.com/config';
40
+ const HEAP_QUEUE_METHODS = [
41
+ 'init',
42
+ 'startTracking',
43
+ 'stopTracking',
44
+ 'track',
45
+ 'resetIdentity',
46
+ 'identify',
47
+ 'identifyHashed',
48
+ 'getSessionId',
49
+ 'getUserId',
50
+ 'getIdentity',
51
+ 'addUserProperties',
52
+ 'addEventProperties',
53
+ 'removeEventProperty',
54
+ 'clearEventProperties',
55
+ 'addAccountProperties',
56
+ 'addAdapter',
57
+ 'addTransformer',
58
+ 'addTransformerFn',
59
+ 'onReady',
60
+ 'addPageviewProperties',
61
+ 'removePageviewProperty',
62
+ 'clearPageviewProperties',
63
+ 'trackPageview'
64
+ ];
65
+ const heapManifest = {
66
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
67
+ vendor: 'heap',
68
+ category: 'measurement',
69
+ install: [
70
+ {
71
+ type: 'setGlobal',
72
+ name: 'heapReadyCb',
73
+ value: [],
74
+ ifUndefined: true
75
+ },
76
+ {
77
+ type: 'setGlobal',
78
+ name: 'heap',
79
+ value: [],
80
+ ifUndefined: true
81
+ },
82
+ {
83
+ type: 'setGlobalPath',
84
+ path: [
85
+ 'heap',
86
+ 'envId'
87
+ ],
88
+ value: '{{envId}}'
89
+ },
90
+ {
91
+ type: 'setGlobalPath',
92
+ path: [
93
+ 'heap',
94
+ 'appid'
95
+ ],
96
+ value: '{{envId}}'
97
+ },
98
+ {
99
+ type: 'setGlobalPath',
100
+ path: [
101
+ 'heap',
102
+ 'clientConfig'
103
+ ],
104
+ value: '{{clientConfig}}'
105
+ },
106
+ {
107
+ type: 'defineQueueMethods',
108
+ target: 'heap',
109
+ queue: {
110
+ global: 'heapReadyCb'
111
+ },
112
+ queueFormat: 'callback',
113
+ methods: [
114
+ ...HEAP_QUEUE_METHODS
115
+ ]
116
+ },
117
+ {
118
+ type: 'loadScript',
119
+ src: "{{scriptUrl}}",
120
+ async: true
121
+ }
122
+ ]
123
+ };
124
+ function validateEnvId(envId) {
125
+ const normalized = 'string' == typeof envId ? envId.trim() : '';
126
+ if (0 === normalized.length) throw new Error('heap: missing or invalid envId');
127
+ return normalized;
128
+ }
129
+ function isPlainRecord(value) {
130
+ if (null === value || 'object' != typeof value || Array.isArray(value)) return false;
131
+ const prototype = Object.getPrototypeOf(value);
132
+ return prototype === Object.prototype || null === prototype;
133
+ }
134
+ function toJsonValue(value, path) {
135
+ if (null === value) return null;
136
+ if ('string' == typeof value || 'boolean' == typeof value) return value;
137
+ if ('number' == typeof value) {
138
+ if (Number.isFinite(value)) return value;
139
+ throw new TypeError(`heap: clientConfig${path ? `.${path}` : ''} must be a finite number`);
140
+ }
141
+ if (Array.isArray(value)) return value.map((item, index)=>toJsonValue(item, `${path}[${index}]`));
142
+ if (isPlainRecord(value)) {
143
+ const result = {};
144
+ for (const [key, nestedValue] of Object.entries(value))result[key] = toJsonValue(nestedValue, path ? `${path}.${key}` : key);
145
+ return result;
146
+ }
147
+ throw new TypeError(`heap: clientConfig${path ? `.${path}` : ''} must be JSON-serializable`);
148
+ }
149
+ function normalizeClientConfig(clientConfig) {
150
+ const config = clientConfig ?? {};
151
+ const normalized = toJsonValue(config, '');
152
+ if (!isPlainRecord(normalized)) throw new TypeError('heap: clientConfig must be a plain object');
153
+ return {
154
+ ...normalized,
155
+ shouldFetchServerConfig: false
156
+ };
157
+ }
158
+ function resolveHeapScriptUrl(envId, scriptUrl) {
159
+ return (0, script_url_cjs_namespaceObject.resolveScriptUrl)((0, script_url_cjs_namespaceObject.trimToUndefined)(scriptUrl), (0, script_url_cjs_namespaceObject.joinUrlPath)(DEFAULT_HEAP_CONFIG_BASE_URL, `${envId}/heap_config.js`));
160
+ }
161
+ function heap({ envId, clientConfig, scriptUrl }) {
162
+ const normalizedEnvId = validateEnvId(envId);
163
+ return (0, external_resolve_cjs_namespaceObject.resolveManifest)(heapManifest, {
164
+ envId: normalizedEnvId,
165
+ clientConfig: normalizeClientConfig(clientConfig),
166
+ scriptUrl: resolveHeapScriptUrl(normalizedEnvId, scriptUrl)
167
+ });
168
+ }
169
+ exports.DEFAULT_HEAP_CONFIG_BASE_URL = __webpack_exports__.DEFAULT_HEAP_CONFIG_BASE_URL;
170
+ exports.HEAP_QUEUE_METHODS = __webpack_exports__.HEAP_QUEUE_METHODS;
171
+ exports.heap = __webpack_exports__.heap;
172
+ exports.heapManifest = __webpack_exports__.heapManifest;
173
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
174
+ "DEFAULT_HEAP_CONFIG_BASE_URL",
175
+ "HEAP_QUEUE_METHODS",
176
+ "heap",
177
+ "heapManifest"
178
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
179
+ Object.defineProperty(exports, '__esModule', {
180
+ value: true
181
+ });
@@ -0,0 +1,134 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ import { joinUrlPath, resolveScriptUrl, trimToUndefined } from "../_shared/script-url.js";
4
+ const DEFAULT_HEAP_CONFIG_BASE_URL = 'https://cdn.us.heap-api.com/config';
5
+ const HEAP_QUEUE_METHODS = [
6
+ 'init',
7
+ 'startTracking',
8
+ 'stopTracking',
9
+ 'track',
10
+ 'resetIdentity',
11
+ 'identify',
12
+ 'identifyHashed',
13
+ 'getSessionId',
14
+ 'getUserId',
15
+ 'getIdentity',
16
+ 'addUserProperties',
17
+ 'addEventProperties',
18
+ 'removeEventProperty',
19
+ 'clearEventProperties',
20
+ 'addAccountProperties',
21
+ 'addAdapter',
22
+ 'addTransformer',
23
+ 'addTransformerFn',
24
+ 'onReady',
25
+ 'addPageviewProperties',
26
+ 'removePageviewProperty',
27
+ 'clearPageviewProperties',
28
+ 'trackPageview'
29
+ ];
30
+ const heapManifest = {
31
+ ...vendorManifestContract,
32
+ vendor: 'heap',
33
+ category: 'measurement',
34
+ install: [
35
+ {
36
+ type: 'setGlobal',
37
+ name: 'heapReadyCb',
38
+ value: [],
39
+ ifUndefined: true
40
+ },
41
+ {
42
+ type: 'setGlobal',
43
+ name: 'heap',
44
+ value: [],
45
+ ifUndefined: true
46
+ },
47
+ {
48
+ type: 'setGlobalPath',
49
+ path: [
50
+ 'heap',
51
+ 'envId'
52
+ ],
53
+ value: '{{envId}}'
54
+ },
55
+ {
56
+ type: 'setGlobalPath',
57
+ path: [
58
+ 'heap',
59
+ 'appid'
60
+ ],
61
+ value: '{{envId}}'
62
+ },
63
+ {
64
+ type: 'setGlobalPath',
65
+ path: [
66
+ 'heap',
67
+ 'clientConfig'
68
+ ],
69
+ value: '{{clientConfig}}'
70
+ },
71
+ {
72
+ type: 'defineQueueMethods',
73
+ target: 'heap',
74
+ queue: {
75
+ global: 'heapReadyCb'
76
+ },
77
+ queueFormat: 'callback',
78
+ methods: [
79
+ ...HEAP_QUEUE_METHODS
80
+ ]
81
+ },
82
+ {
83
+ type: 'loadScript',
84
+ src: "{{scriptUrl}}",
85
+ async: true
86
+ }
87
+ ]
88
+ };
89
+ function validateEnvId(envId) {
90
+ const normalized = 'string' == typeof envId ? envId.trim() : '';
91
+ if (0 === normalized.length) throw new Error('heap: missing or invalid envId');
92
+ return normalized;
93
+ }
94
+ function isPlainRecord(value) {
95
+ if (null === value || 'object' != typeof value || Array.isArray(value)) return false;
96
+ const prototype = Object.getPrototypeOf(value);
97
+ return prototype === Object.prototype || null === prototype;
98
+ }
99
+ function toJsonValue(value, path) {
100
+ if (null === value) return null;
101
+ if ('string' == typeof value || 'boolean' == typeof value) return value;
102
+ if ('number' == typeof value) {
103
+ if (Number.isFinite(value)) return value;
104
+ throw new TypeError(`heap: clientConfig${path ? `.${path}` : ''} must be a finite number`);
105
+ }
106
+ if (Array.isArray(value)) return value.map((item, index)=>toJsonValue(item, `${path}[${index}]`));
107
+ if (isPlainRecord(value)) {
108
+ const result = {};
109
+ for (const [key, nestedValue] of Object.entries(value))result[key] = toJsonValue(nestedValue, path ? `${path}.${key}` : key);
110
+ return result;
111
+ }
112
+ throw new TypeError(`heap: clientConfig${path ? `.${path}` : ''} must be JSON-serializable`);
113
+ }
114
+ function normalizeClientConfig(clientConfig) {
115
+ const config = clientConfig ?? {};
116
+ const normalized = toJsonValue(config, '');
117
+ if (!isPlainRecord(normalized)) throw new TypeError('heap: clientConfig must be a plain object');
118
+ return {
119
+ ...normalized,
120
+ shouldFetchServerConfig: false
121
+ };
122
+ }
123
+ function resolveHeapScriptUrl(envId, scriptUrl) {
124
+ return resolveScriptUrl(trimToUndefined(scriptUrl), joinUrlPath(DEFAULT_HEAP_CONFIG_BASE_URL, `${envId}/heap_config.js`));
125
+ }
126
+ function heap({ envId, clientConfig, scriptUrl }) {
127
+ const normalizedEnvId = validateEnvId(envId);
128
+ return resolveManifest(heapManifest, {
129
+ envId: normalizedEnvId,
130
+ clientConfig: normalizeClientConfig(clientConfig),
131
+ scriptUrl: resolveHeapScriptUrl(normalizedEnvId, scriptUrl)
132
+ });
133
+ }
134
+ export { DEFAULT_HEAP_CONFIG_BASE_URL, HEAP_QUEUE_METHODS, heap, heapManifest };