@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
@@ -1,5 +1,55 @@
1
1
  import { resolveManifest } from "../../resolve.js";
2
2
  import { vendorManifestContract } from "../../types.js";
3
+ function toClarityConsentState(value) {
4
+ if (true === value) return 'granted';
5
+ if (false === value) return 'denied';
6
+ if ('string' != typeof value) return;
7
+ const normalized = value.toLowerCase();
8
+ if ('granted' === normalized || 'true' === normalized) return 'granted';
9
+ if ('denied' === normalized || 'false' === normalized) return 'denied';
10
+ }
11
+ function getConsentValue(value, keys) {
12
+ for (const key of keys){
13
+ const consent = toClarityConsentState(value[key]);
14
+ if (consent) return consent;
15
+ }
16
+ }
17
+ function getConsentPayloadFromState(consents) {
18
+ let adStorage;
19
+ adStorage = consents.marketing ? 'granted' : 'denied';
20
+ let analyticsStorage;
21
+ analyticsStorage = consents.measurement ? 'granted' : 'denied';
22
+ return {
23
+ ad_Storage: adStorage,
24
+ analytics_Storage: analyticsStorage
25
+ };
26
+ }
27
+ function getClarityConsentPayload(consents, defaultConsent) {
28
+ const fallback = getConsentPayloadFromState(consents);
29
+ if (void 0 === defaultConsent) return fallback;
30
+ const booleanConsent = toClarityConsentState(defaultConsent);
31
+ if (booleanConsent) return {
32
+ ad_Storage: booleanConsent,
33
+ analytics_Storage: booleanConsent
34
+ };
35
+ if (null !== defaultConsent && 'object' == typeof defaultConsent) return {
36
+ ad_Storage: getConsentValue(defaultConsent, [
37
+ 'ad_Storage',
38
+ 'ad_storage',
39
+ 'marketing'
40
+ ]) ?? fallback.ad_Storage,
41
+ analytics_Storage: getConsentValue(defaultConsent, [
42
+ 'analytics_Storage',
43
+ 'analytics_storage',
44
+ 'measurement',
45
+ 'analytics'
46
+ ]) ?? fallback.analytics_Storage
47
+ };
48
+ return fallback;
49
+ }
50
+ function syncClarityConsent(info, defaultConsent) {
51
+ window.clarity?.('consentv2', getClarityConsentPayload(info.consents, defaultConsent));
52
+ }
3
53
  const clarityManifest = {
4
54
  ...vendorManifestContract,
5
55
  vendor: 'microsoft-clarity',
@@ -13,9 +63,6 @@ const clarityManifest = {
13
63
  property: 'q'
14
64
  },
15
65
  queueFormat: 'array',
16
- properties: {
17
- v: '0.7.0'
18
- },
19
66
  ifUndefined: true
20
67
  }
21
68
  ],
@@ -25,49 +72,26 @@ const clarityManifest = {
25
72
  src: "{{scriptUrl}}",
26
73
  async: true
27
74
  }
28
- ],
29
- onConsentGranted: [
30
- {
31
- type: 'callGlobal',
32
- global: 'clarity',
33
- args: [
34
- 'consent',
35
- true
36
- ]
37
- }
38
- ],
39
- onConsentDenied: [
40
- {
41
- type: 'callGlobal',
42
- global: 'clarity',
43
- args: [
44
- 'consent',
45
- false
46
- ]
47
- }
48
75
  ]
49
76
  };
50
77
  function clarity({ id, defaultConsent, scriptUrl }) {
51
78
  const normalizedId = id.trim();
52
79
  if (void 0 === scriptUrl && 0 === normalizedId.length) throw new Error(`Invalid Clarity id value "${id}". A non-empty id is required to construct the Clarity loader URL when scriptUrl is not provided.`);
53
- let manifest = clarityManifest;
54
- if (void 0 !== defaultConsent) manifest = {
55
- ...clarityManifest,
56
- install: [
57
- {
58
- type: 'callGlobal',
59
- global: 'clarity',
60
- args: [
61
- 'consent',
62
- '{{defaultConsent}}'
63
- ]
64
- },
65
- ...clarityManifest.install
66
- ]
67
- };
68
- return resolveManifest(manifest, {
69
- defaultConsent,
80
+ const resolved = resolveManifest(clarityManifest, {
70
81
  scriptUrl: scriptUrl ?? `https://www.clarity.ms/tag/${normalizedId}`
71
82
  });
83
+ const onBeforeLoad = resolved.onBeforeLoad;
84
+ const onConsentChange = resolved.onConsentChange;
85
+ return {
86
+ ...resolved,
87
+ onBeforeLoad: (info)=>{
88
+ onBeforeLoad?.(info);
89
+ syncClarityConsent(info, defaultConsent);
90
+ },
91
+ onConsentChange: (info)=>{
92
+ onConsentChange?.(info);
93
+ syncClarityConsent(info);
94
+ }
95
+ };
72
96
  }
73
97
  export { clarity, clarityManifest };
@@ -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
  (()=>{
@@ -41,6 +45,28 @@ const mixpanelAnalyticsManifest = {
41
45
  value: [],
42
46
  ifUndefined: true
43
47
  },
48
+ {
49
+ type: 'setGlobalPath',
50
+ path: [
51
+ 'mixpanel',
52
+ '__SV'
53
+ ],
54
+ value: 1.2
55
+ },
56
+ {
57
+ type: 'setGlobalPath',
58
+ path: [
59
+ 'mixpanel',
60
+ '_i'
61
+ ],
62
+ value: [
63
+ [
64
+ '{{token}}',
65
+ '{{initOptions}}',
66
+ 'mixpanel'
67
+ ]
68
+ ]
69
+ },
44
70
  {
45
71
  type: 'defineQueueMethods',
46
72
  target: 'mixpanel',
@@ -59,17 +85,6 @@ const mixpanelAnalyticsManifest = {
59
85
  async: true
60
86
  }
61
87
  ],
62
- afterLoad: [
63
- {
64
- type: 'callGlobal',
65
- global: 'mixpanel',
66
- method: 'init',
67
- args: [
68
- '{{token}}',
69
- '{{initOptions}}'
70
- ]
71
- }
72
- ],
73
88
  onLoadGranted: [
74
89
  {
75
90
  type: 'callGlobal',
@@ -12,6 +12,28 @@ const mixpanelAnalyticsManifest = {
12
12
  value: [],
13
13
  ifUndefined: true
14
14
  },
15
+ {
16
+ type: 'setGlobalPath',
17
+ path: [
18
+ 'mixpanel',
19
+ '__SV'
20
+ ],
21
+ value: 1.2
22
+ },
23
+ {
24
+ type: 'setGlobalPath',
25
+ path: [
26
+ 'mixpanel',
27
+ '_i'
28
+ ],
29
+ value: [
30
+ [
31
+ '{{token}}',
32
+ '{{initOptions}}',
33
+ 'mixpanel'
34
+ ]
35
+ ]
36
+ },
15
37
  {
16
38
  type: 'defineQueueMethods',
17
39
  target: 'mixpanel',
@@ -30,17 +52,6 @@ const mixpanelAnalyticsManifest = {
30
52
  async: true
31
53
  }
32
54
  ],
33
- afterLoad: [
34
- {
35
- type: 'callGlobal',
36
- global: 'mixpanel',
37
- method: 'init',
38
- args: [
39
- '{{token}}',
40
- '{{initOptions}}'
41
- ]
42
- }
43
- ],
44
55
  onLoadGranted: [
45
56
  {
46
57
  type: 'callGlobal',
@@ -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");
@@ -83,29 +87,51 @@ const posthogManifest = {
83
87
  {
84
88
  type: 'setGlobal',
85
89
  name: 'posthog',
86
- value: {},
90
+ value: [],
87
91
  ifUndefined: true
88
92
  },
93
+ {
94
+ type: 'setGlobalPath',
95
+ path: [
96
+ 'posthog',
97
+ '_i'
98
+ ],
99
+ value: [
100
+ [
101
+ '{{id}}',
102
+ '{{initOptions}}',
103
+ 'posthog'
104
+ ]
105
+ ],
106
+ ifGlobalIsQueue: true
107
+ },
108
+ {
109
+ type: 'setGlobalPath',
110
+ path: [
111
+ 'posthog',
112
+ 'people'
113
+ ],
114
+ value: [],
115
+ ifGlobalIsQueue: true
116
+ },
117
+ {
118
+ type: 'defineQueueMethods',
119
+ target: 'posthog',
120
+ methods: [
121
+ 'capture',
122
+ 'opt_in_capturing',
123
+ 'opt_out_capturing'
124
+ ]
125
+ },
89
126
  {
90
127
  type: 'defineGlobalMethods',
91
128
  target: 'posthog',
129
+ ifGlobalIsQueue: true,
92
130
  methods: [
93
131
  {
94
132
  name: 'init',
95
133
  behavior: 'noop'
96
134
  },
97
- {
98
- name: 'capture',
99
- behavior: 'noop'
100
- },
101
- {
102
- name: 'opt_in_capturing',
103
- behavior: 'noop'
104
- },
105
- {
106
- name: 'opt_out_capturing',
107
- behavior: 'noop'
108
- },
109
135
  {
110
136
  name: 'get_explicit_consent_status',
111
137
  behavior: 'return',
@@ -126,14 +152,24 @@ const posthogManifest = {
126
152
  }
127
153
  }
128
154
  ],
129
- afterLoad: [
155
+ onBeforeLoadGranted: [
130
156
  {
131
- type: 'callGlobal',
132
- global: 'posthog',
133
- method: 'init',
134
- args: [
135
- '{{id}}',
136
- '{{initOptions}}'
157
+ type: 'pushToQueue',
158
+ queue: 'posthog',
159
+ value: [
160
+ 'opt_in_capturing',
161
+ {
162
+ captureEventName: null
163
+ }
164
+ ]
165
+ }
166
+ ],
167
+ onBeforeLoadDenied: [
168
+ {
169
+ type: 'pushToQueue',
170
+ queue: 'posthog',
171
+ value: [
172
+ 'opt_out_capturing'
137
173
  ]
138
174
  }
139
175
  ],
@@ -54,29 +54,51 @@ const posthogManifest = {
54
54
  {
55
55
  type: 'setGlobal',
56
56
  name: 'posthog',
57
- value: {},
57
+ value: [],
58
58
  ifUndefined: true
59
59
  },
60
+ {
61
+ type: 'setGlobalPath',
62
+ path: [
63
+ 'posthog',
64
+ '_i'
65
+ ],
66
+ value: [
67
+ [
68
+ '{{id}}',
69
+ '{{initOptions}}',
70
+ 'posthog'
71
+ ]
72
+ ],
73
+ ifGlobalIsQueue: true
74
+ },
75
+ {
76
+ type: 'setGlobalPath',
77
+ path: [
78
+ 'posthog',
79
+ 'people'
80
+ ],
81
+ value: [],
82
+ ifGlobalIsQueue: true
83
+ },
84
+ {
85
+ type: 'defineQueueMethods',
86
+ target: 'posthog',
87
+ methods: [
88
+ 'capture',
89
+ 'opt_in_capturing',
90
+ 'opt_out_capturing'
91
+ ]
92
+ },
60
93
  {
61
94
  type: 'defineGlobalMethods',
62
95
  target: 'posthog',
96
+ ifGlobalIsQueue: true,
63
97
  methods: [
64
98
  {
65
99
  name: 'init',
66
100
  behavior: 'noop'
67
101
  },
68
- {
69
- name: 'capture',
70
- behavior: 'noop'
71
- },
72
- {
73
- name: 'opt_in_capturing',
74
- behavior: 'noop'
75
- },
76
- {
77
- name: 'opt_out_capturing',
78
- behavior: 'noop'
79
- },
80
102
  {
81
103
  name: 'get_explicit_consent_status',
82
104
  behavior: 'return',
@@ -97,14 +119,24 @@ const posthogManifest = {
97
119
  }
98
120
  }
99
121
  ],
100
- afterLoad: [
122
+ onBeforeLoadGranted: [
101
123
  {
102
- type: 'callGlobal',
103
- global: 'posthog',
104
- method: 'init',
105
- args: [
106
- '{{id}}',
107
- '{{initOptions}}'
124
+ type: 'pushToQueue',
125
+ queue: 'posthog',
126
+ value: [
127
+ 'opt_in_capturing',
128
+ {
129
+ captureEventName: null
130
+ }
131
+ ]
132
+ }
133
+ ],
134
+ onBeforeLoadDenied: [
135
+ {
136
+ type: 'pushToQueue',
137
+ queue: 'posthog',
138
+ value: [
139
+ 'opt_out_capturing'
108
140
  ]
109
141
  }
110
142
  ],