@c15t/scripts 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/dist/e2e-test-utils.cjs +125 -0
- package/dist/e2e-test-utils.js +67 -0
- package/dist/engine/runtime.cjs +19 -9
- package/dist/engine/runtime.js +19 -9
- package/dist/registry.cjs +338 -0
- package/dist/registry.js +292 -0
- package/dist/types.cjs +18 -0
- package/dist/types.js +10 -1
- package/dist/vendors/_shared/attributes.cjs +51 -0
- package/dist/vendors/_shared/attributes.js +14 -0
- package/dist/vendors/_shared/google-consent.cjs +64 -0
- package/dist/vendors/_shared/google-consent.js +27 -0
- package/dist/vendors/_shared/install-builders.cjs +55 -0
- package/dist/vendors/_shared/install-builders.js +21 -0
- package/dist/vendors/_shared/script-url.cjs +74 -0
- package/dist/vendors/_shared/script-url.js +28 -0
- package/dist/{linkedin-insights.cjs → vendors/ads-and-pixels/linkedin-insights.cjs} +2 -2
- package/dist/{linkedin-insights.js → vendors/ads-and-pixels/linkedin-insights.js} +2 -2
- package/dist/vendors/ads-and-pixels/meta-pixel.cjs +202 -0
- package/dist/vendors/ads-and-pixels/meta-pixel.js +153 -0
- package/dist/{microsoft-uet.cjs → vendors/ads-and-pixels/microsoft-uet.cjs} +31 -14
- package/dist/{microsoft-uet.js → vendors/ads-and-pixels/microsoft-uet.js} +31 -14
- package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +147 -0
- package/dist/vendors/ads-and-pixels/reddit-pixel.js +107 -0
- package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +127 -0
- package/dist/vendors/ads-and-pixels/snapchat-pixel.js +87 -0
- package/dist/{tiktok-pixel.cjs → vendors/ads-and-pixels/tiktok-pixel.cjs} +2 -2
- package/dist/{tiktok-pixel.js → vendors/ads-and-pixels/tiktok-pixel.js} +2 -2
- package/dist/{x-pixel.cjs → vendors/ads-and-pixels/x-pixel.cjs} +6 -3
- package/dist/{x-pixel.js → vendors/ads-and-pixels/x-pixel.js} +6 -3
- package/dist/vendors/analytics/ahrefs-analytics.cjs +64 -0
- package/dist/vendors/analytics/ahrefs-analytics.js +27 -0
- package/dist/vendors/analytics/cloudflare-web-analytics.cjs +69 -0
- package/dist/vendors/analytics/cloudflare-web-analytics.js +32 -0
- package/dist/{databuddy.cjs → vendors/analytics/databuddy.cjs} +3 -3
- package/dist/{databuddy.js → vendors/analytics/databuddy.js} +3 -3
- package/dist/vendors/analytics/fathom-analytics.cjs +72 -0
- package/dist/vendors/analytics/fathom-analytics.js +35 -0
- package/dist/{google-tag.cjs → vendors/analytics/google-tag.cjs} +7 -28
- package/dist/{google-tag.js → vendors/analytics/google-tag.js} +7 -28
- package/dist/vendors/analytics/hotjar.cjs +81 -0
- package/dist/vendors/analytics/hotjar.js +44 -0
- package/dist/vendors/analytics/matomo-analytics.cjs +228 -0
- package/dist/vendors/analytics/matomo-analytics.js +191 -0
- package/dist/vendors/analytics/microsoft-clarity.cjs +110 -0
- package/dist/vendors/analytics/microsoft-clarity.js +73 -0
- package/dist/vendors/analytics/mixpanel-analytics.cjs +119 -0
- package/dist/vendors/analytics/mixpanel-analytics.js +82 -0
- package/dist/vendors/analytics/plausible-analytics.cjs +118 -0
- package/dist/vendors/analytics/plausible-analytics.js +81 -0
- package/dist/{posthog.cjs → vendors/analytics/posthog.cjs} +69 -6
- package/dist/vendors/analytics/posthog.js +163 -0
- package/dist/vendors/analytics/promptwatch.cjs +66 -0
- package/dist/vendors/analytics/promptwatch.js +29 -0
- package/dist/vendors/analytics/rybbit-analytics.cjs +100 -0
- package/dist/vendors/analytics/rybbit-analytics.js +63 -0
- package/dist/vendors/analytics/segment.cjs +93 -0
- package/dist/vendors/analytics/segment.js +56 -0
- package/dist/vendors/analytics/umami-analytics.cjs +76 -0
- package/dist/vendors/analytics/umami-analytics.js +39 -0
- package/dist/vendors/analytics/vercel-analytics.cjs +90 -0
- package/dist/vendors/analytics/vercel-analytics.js +53 -0
- package/dist/vendors/functional/crisp.cjs +139 -0
- package/dist/vendors/functional/crisp.js +102 -0
- package/dist/vendors/functional/intercom.cjs +85 -0
- package/dist/vendors/functional/intercom.js +45 -0
- package/dist/{google-tag-manager.cjs → vendors/tag-managers/google-tag-manager.cjs} +6 -27
- package/dist/{google-tag-manager.js → vendors/tag-managers/google-tag-manager.js} +6 -27
- package/dist-types/__tests__/helpers.d.ts +141 -0
- package/dist-types/engine/runtime.d.ts +1 -1
- package/dist-types/registry.d.ts +368 -0
- package/dist-types/types.d.ts +13 -0
- package/dist-types/vendors/_shared/attributes.d.ts +35 -0
- package/dist-types/vendors/_shared/google-consent.d.ts +47 -0
- package/dist-types/vendors/_shared/install-builders.d.ts +30 -0
- package/dist-types/vendors/_shared/script-url.d.ts +75 -0
- package/dist-types/{linkedin-insights.d.ts → vendors/ads-and-pixels/linkedin-insights.d.ts} +22 -9
- package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +289 -0
- package/dist-types/{microsoft-uet.d.ts → vendors/ads-and-pixels/microsoft-uet.d.ts} +21 -10
- package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +211 -0
- package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +171 -0
- package/dist-types/{tiktok-pixel.d.ts → vendors/ads-and-pixels/tiktok-pixel.d.ts} +20 -5
- package/dist-types/{x-pixel.d.ts → vendors/ads-and-pixels/x-pixel.d.ts} +21 -4
- package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +62 -0
- package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +67 -0
- package/dist-types/vendors/analytics/fathom-analytics.d.ts +90 -0
- package/dist-types/{google-tag.d.ts → vendors/analytics/google-tag.d.ts} +5 -8
- package/dist-types/vendors/analytics/hotjar.d.ts +73 -0
- package/dist-types/vendors/analytics/matomo-analytics.d.ts +41 -0
- package/dist-types/vendors/analytics/microsoft-clarity.d.ts +86 -0
- package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +101 -0
- package/dist-types/vendors/analytics/plausible-analytics.d.ts +122 -0
- package/dist-types/{posthog.d.ts → vendors/analytics/posthog.d.ts} +47 -5
- package/dist-types/vendors/analytics/promptwatch.d.ts +36 -0
- package/dist-types/vendors/analytics/rybbit-analytics.d.ts +82 -0
- package/dist-types/vendors/analytics/segment.d.ts +158 -0
- package/dist-types/vendors/analytics/umami-analytics.d.ts +93 -0
- package/dist-types/vendors/analytics/vercel-analytics.d.ts +66 -0
- package/dist-types/vendors/functional/crisp.d.ts +78 -0
- package/dist-types/vendors/functional/intercom.d.ts +135 -0
- package/dist-types/{google-tag-manager.d.ts → vendors/tag-managers/google-tag-manager.d.ts} +5 -8
- package/package.json +166 -5
- package/dist/meta-pixel.cjs +0 -129
- package/dist/meta-pixel.js +0 -89
- package/dist/posthog.js +0 -100
- package/dist-types/engine.test.d.ts +0 -1
- package/dist-types/helpers.test.d.ts +0 -1
- package/dist-types/meta-pixel.d.ts +0 -185
- /package/dist-types/{databuddy.d.ts → vendors/analytics/databuddy.d.ts} +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { resolveManifest } from "../../resolve.js";
|
|
2
|
+
import { vendorManifestContract } from "../../types.js";
|
|
3
|
+
const clarityManifest = {
|
|
4
|
+
...vendorManifestContract,
|
|
5
|
+
vendor: 'microsoft-clarity',
|
|
6
|
+
category: 'measurement',
|
|
7
|
+
persistAfterConsentRevoked: true,
|
|
8
|
+
bootstrap: [
|
|
9
|
+
{
|
|
10
|
+
type: 'defineStubFunction',
|
|
11
|
+
name: 'clarity',
|
|
12
|
+
queue: {
|
|
13
|
+
property: 'q'
|
|
14
|
+
},
|
|
15
|
+
queueFormat: 'array',
|
|
16
|
+
properties: {
|
|
17
|
+
v: '0.7.0'
|
|
18
|
+
},
|
|
19
|
+
ifUndefined: true
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
install: [
|
|
23
|
+
{
|
|
24
|
+
type: 'loadScript',
|
|
25
|
+
src: "{{scriptUrl}}",
|
|
26
|
+
async: true
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
onConsentGranted: [
|
|
30
|
+
{
|
|
31
|
+
type: 'callGlobal',
|
|
32
|
+
global: 'clarity',
|
|
33
|
+
args: [
|
|
34
|
+
'consent',
|
|
35
|
+
true
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
onConsentDenied: [
|
|
40
|
+
{
|
|
41
|
+
type: 'callGlobal',
|
|
42
|
+
global: 'clarity',
|
|
43
|
+
args: [
|
|
44
|
+
'consent',
|
|
45
|
+
false
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
};
|
|
50
|
+
function clarity({ id, defaultConsent, scriptUrl }) {
|
|
51
|
+
const normalizedId = id.trim();
|
|
52
|
+
if (void 0 === scriptUrl && 0 === normalizedId.length) throw new Error(`Invalid Clarity id value "${id}". A non-empty id is required to construct the Clarity loader URL when scriptUrl is not provided.`);
|
|
53
|
+
let manifest = clarityManifest;
|
|
54
|
+
if (void 0 !== defaultConsent) manifest = {
|
|
55
|
+
...clarityManifest,
|
|
56
|
+
install: [
|
|
57
|
+
{
|
|
58
|
+
type: 'callGlobal',
|
|
59
|
+
global: 'clarity',
|
|
60
|
+
args: [
|
|
61
|
+
'consent',
|
|
62
|
+
'{{defaultConsent}}'
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
...clarityManifest.install
|
|
66
|
+
]
|
|
67
|
+
};
|
|
68
|
+
return resolveManifest(manifest, {
|
|
69
|
+
defaultConsent,
|
|
70
|
+
scriptUrl: scriptUrl ?? `https://www.clarity.ms/tag/${normalizedId}`
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export { clarity, clarityManifest };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
mixpanelAnalytics: ()=>mixpanelAnalytics,
|
|
28
|
+
mixpanelAnalyticsManifest: ()=>mixpanelAnalyticsManifest
|
|
29
|
+
});
|
|
30
|
+
const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
|
|
31
|
+
const external_types_cjs_namespaceObject = require("../../types.cjs");
|
|
32
|
+
const mixpanelAnalyticsManifest = {
|
|
33
|
+
...external_types_cjs_namespaceObject.vendorManifestContract,
|
|
34
|
+
vendor: 'mixpanel-analytics',
|
|
35
|
+
category: 'measurement',
|
|
36
|
+
alwaysLoad: true,
|
|
37
|
+
install: [
|
|
38
|
+
{
|
|
39
|
+
type: 'setGlobal',
|
|
40
|
+
name: 'mixpanel',
|
|
41
|
+
value: [],
|
|
42
|
+
ifUndefined: true
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'defineQueueMethods',
|
|
46
|
+
target: 'mixpanel',
|
|
47
|
+
methods: [
|
|
48
|
+
'track',
|
|
49
|
+
'identify',
|
|
50
|
+
'reset',
|
|
51
|
+
'register',
|
|
52
|
+
'opt_in_tracking',
|
|
53
|
+
'opt_out_tracking'
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: 'loadScript',
|
|
58
|
+
src: "{{scriptUrl}}",
|
|
59
|
+
async: true
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
afterLoad: [
|
|
63
|
+
{
|
|
64
|
+
type: 'callGlobal',
|
|
65
|
+
global: 'mixpanel',
|
|
66
|
+
method: 'init',
|
|
67
|
+
args: [
|
|
68
|
+
'{{token}}',
|
|
69
|
+
'{{initOptions}}'
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
onLoadGranted: [
|
|
74
|
+
{
|
|
75
|
+
type: 'callGlobal',
|
|
76
|
+
global: 'mixpanel',
|
|
77
|
+
method: 'opt_in_tracking'
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
onLoadDenied: [
|
|
81
|
+
{
|
|
82
|
+
type: 'callGlobal',
|
|
83
|
+
global: 'mixpanel',
|
|
84
|
+
method: 'opt_out_tracking'
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
onConsentGranted: [
|
|
88
|
+
{
|
|
89
|
+
type: 'callGlobal',
|
|
90
|
+
global: 'mixpanel',
|
|
91
|
+
method: 'opt_in_tracking'
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
onConsentDenied: [
|
|
95
|
+
{
|
|
96
|
+
type: 'callGlobal',
|
|
97
|
+
global: 'mixpanel',
|
|
98
|
+
method: 'opt_out_tracking'
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
function mixpanelAnalytics({ token, initOptions, scriptUrl }) {
|
|
103
|
+
const normalizedToken = token.trim();
|
|
104
|
+
if (!/^[a-f0-9]{32}$/i.test(normalizedToken)) throw new Error("mixpanelAnalytics: token must be a non-empty 32-character hexadecimal string");
|
|
105
|
+
return (0, external_resolve_cjs_namespaceObject.resolveManifest)(mixpanelAnalyticsManifest, {
|
|
106
|
+
token: normalizedToken,
|
|
107
|
+
initOptions: initOptions ?? {},
|
|
108
|
+
scriptUrl: scriptUrl ?? 'https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
exports.mixpanelAnalytics = __webpack_exports__.mixpanelAnalytics;
|
|
112
|
+
exports.mixpanelAnalyticsManifest = __webpack_exports__.mixpanelAnalyticsManifest;
|
|
113
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
114
|
+
"mixpanelAnalytics",
|
|
115
|
+
"mixpanelAnalyticsManifest"
|
|
116
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
117
|
+
Object.defineProperty(exports, '__esModule', {
|
|
118
|
+
value: true
|
|
119
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { resolveManifest } from "../../resolve.js";
|
|
2
|
+
import { vendorManifestContract } from "../../types.js";
|
|
3
|
+
const mixpanelAnalyticsManifest = {
|
|
4
|
+
...vendorManifestContract,
|
|
5
|
+
vendor: 'mixpanel-analytics',
|
|
6
|
+
category: 'measurement',
|
|
7
|
+
alwaysLoad: true,
|
|
8
|
+
install: [
|
|
9
|
+
{
|
|
10
|
+
type: 'setGlobal',
|
|
11
|
+
name: 'mixpanel',
|
|
12
|
+
value: [],
|
|
13
|
+
ifUndefined: true
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
type: 'defineQueueMethods',
|
|
17
|
+
target: 'mixpanel',
|
|
18
|
+
methods: [
|
|
19
|
+
'track',
|
|
20
|
+
'identify',
|
|
21
|
+
'reset',
|
|
22
|
+
'register',
|
|
23
|
+
'opt_in_tracking',
|
|
24
|
+
'opt_out_tracking'
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: 'loadScript',
|
|
29
|
+
src: "{{scriptUrl}}",
|
|
30
|
+
async: true
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
afterLoad: [
|
|
34
|
+
{
|
|
35
|
+
type: 'callGlobal',
|
|
36
|
+
global: 'mixpanel',
|
|
37
|
+
method: 'init',
|
|
38
|
+
args: [
|
|
39
|
+
'{{token}}',
|
|
40
|
+
'{{initOptions}}'
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
onLoadGranted: [
|
|
45
|
+
{
|
|
46
|
+
type: 'callGlobal',
|
|
47
|
+
global: 'mixpanel',
|
|
48
|
+
method: 'opt_in_tracking'
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
onLoadDenied: [
|
|
52
|
+
{
|
|
53
|
+
type: 'callGlobal',
|
|
54
|
+
global: 'mixpanel',
|
|
55
|
+
method: 'opt_out_tracking'
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
onConsentGranted: [
|
|
59
|
+
{
|
|
60
|
+
type: 'callGlobal',
|
|
61
|
+
global: 'mixpanel',
|
|
62
|
+
method: 'opt_in_tracking'
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
onConsentDenied: [
|
|
66
|
+
{
|
|
67
|
+
type: 'callGlobal',
|
|
68
|
+
global: 'mixpanel',
|
|
69
|
+
method: 'opt_out_tracking'
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
};
|
|
73
|
+
function mixpanelAnalytics({ token, initOptions, scriptUrl }) {
|
|
74
|
+
const normalizedToken = token.trim();
|
|
75
|
+
if (!/^[a-f0-9]{32}$/i.test(normalizedToken)) throw new Error("mixpanelAnalytics: token must be a non-empty 32-character hexadecimal string");
|
|
76
|
+
return resolveManifest(mixpanelAnalyticsManifest, {
|
|
77
|
+
token: normalizedToken,
|
|
78
|
+
initOptions: initOptions ?? {},
|
|
79
|
+
scriptUrl: scriptUrl ?? 'https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export { mixpanelAnalytics, mixpanelAnalyticsManifest };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
plausibleAnalytics: ()=>plausibleAnalytics,
|
|
28
|
+
plausibleAnalyticsManifest: ()=>plausibleAnalyticsManifest
|
|
29
|
+
});
|
|
30
|
+
const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
|
|
31
|
+
const external_types_cjs_namespaceObject = require("../../types.cjs");
|
|
32
|
+
function buildPlausibleScriptUrl(options) {
|
|
33
|
+
if (options.scriptId) return `https://plausible.io/js/pa-${options.scriptId}.js`;
|
|
34
|
+
if (options.extension) {
|
|
35
|
+
let extensions;
|
|
36
|
+
extensions = Array.isArray(options.extension) ? options.extension.join('.') : options.extension;
|
|
37
|
+
return `https://plausible.io/js/script.${extensions}.js`;
|
|
38
|
+
}
|
|
39
|
+
return "https://plausible.io/js/script.js";
|
|
40
|
+
}
|
|
41
|
+
function buildPlausibleInitOptions(options) {
|
|
42
|
+
const initOptions = {};
|
|
43
|
+
if (options.customProperties) initOptions.customProperties = options.customProperties;
|
|
44
|
+
if (options.endpoint) initOptions.endpoint = options.endpoint;
|
|
45
|
+
if (options.fileDownloads) initOptions.fileDownloads = options.fileDownloads;
|
|
46
|
+
if (void 0 !== options.hashBasedRouting) initOptions.hashBasedRouting = options.hashBasedRouting;
|
|
47
|
+
if (void 0 !== options.autoCapturePageviews) initOptions.autoCapturePageviews = options.autoCapturePageviews;
|
|
48
|
+
if (void 0 !== options.captureOnLocalhost) initOptions.captureOnLocalhost = options.captureOnLocalhost;
|
|
49
|
+
return initOptions;
|
|
50
|
+
}
|
|
51
|
+
const plausibleAnalyticsManifest = {
|
|
52
|
+
...external_types_cjs_namespaceObject.vendorManifestContract,
|
|
53
|
+
vendor: 'plausible-analytics',
|
|
54
|
+
category: 'measurement',
|
|
55
|
+
bootstrap: [
|
|
56
|
+
{
|
|
57
|
+
type: 'defineStubFunction',
|
|
58
|
+
name: 'plausible',
|
|
59
|
+
queue: {
|
|
60
|
+
property: 'q'
|
|
61
|
+
},
|
|
62
|
+
queueFormat: 'array',
|
|
63
|
+
properties: {
|
|
64
|
+
o: '{{initOptions}}'
|
|
65
|
+
},
|
|
66
|
+
ifUndefined: true
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
install: [
|
|
70
|
+
{
|
|
71
|
+
type: 'loadScript',
|
|
72
|
+
src: "{{scriptUrl}}",
|
|
73
|
+
defer: true,
|
|
74
|
+
attributes: {
|
|
75
|
+
'data-domain': '{{domain}}',
|
|
76
|
+
'data-api': '{{apiAttribute}}'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
};
|
|
81
|
+
function plausibleAnalytics(options) {
|
|
82
|
+
let scriptId;
|
|
83
|
+
if (options.scriptId) scriptId = options.scriptId.trim();
|
|
84
|
+
let domain;
|
|
85
|
+
if (options.domain) domain = options.domain.trim();
|
|
86
|
+
if (!scriptId && !domain) throw new Error("plausibleAnalytics: missing scriptId or domain");
|
|
87
|
+
const normalizedOptions = {
|
|
88
|
+
...options
|
|
89
|
+
};
|
|
90
|
+
if (scriptId) normalizedOptions.scriptId = scriptId;
|
|
91
|
+
else delete normalizedOptions.scriptId;
|
|
92
|
+
if (domain) normalizedOptions.domain = domain;
|
|
93
|
+
else delete normalizedOptions.domain;
|
|
94
|
+
const manifestOptions = {
|
|
95
|
+
scriptUrl: normalizedOptions.scriptUrl ?? buildPlausibleScriptUrl(normalizedOptions),
|
|
96
|
+
domain: void 0,
|
|
97
|
+
apiAttribute: void 0,
|
|
98
|
+
initOptions: buildPlausibleInitOptions(normalizedOptions)
|
|
99
|
+
};
|
|
100
|
+
if (scriptId) {
|
|
101
|
+
manifestOptions.domain = void 0;
|
|
102
|
+
manifestOptions.apiAttribute = void 0;
|
|
103
|
+
} else {
|
|
104
|
+
manifestOptions.domain = domain;
|
|
105
|
+
manifestOptions.apiAttribute = normalizedOptions.endpoint;
|
|
106
|
+
}
|
|
107
|
+
const resolved = (0, external_resolve_cjs_namespaceObject.resolveManifest)(plausibleAnalyticsManifest, manifestOptions);
|
|
108
|
+
return resolved;
|
|
109
|
+
}
|
|
110
|
+
exports.plausibleAnalytics = __webpack_exports__.plausibleAnalytics;
|
|
111
|
+
exports.plausibleAnalyticsManifest = __webpack_exports__.plausibleAnalyticsManifest;
|
|
112
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
113
|
+
"plausibleAnalytics",
|
|
114
|
+
"plausibleAnalyticsManifest"
|
|
115
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
116
|
+
Object.defineProperty(exports, '__esModule', {
|
|
117
|
+
value: true
|
|
118
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { resolveManifest } from "../../resolve.js";
|
|
2
|
+
import { vendorManifestContract } from "../../types.js";
|
|
3
|
+
function buildPlausibleScriptUrl(options) {
|
|
4
|
+
if (options.scriptId) return `https://plausible.io/js/pa-${options.scriptId}.js`;
|
|
5
|
+
if (options.extension) {
|
|
6
|
+
let extensions;
|
|
7
|
+
extensions = Array.isArray(options.extension) ? options.extension.join('.') : options.extension;
|
|
8
|
+
return `https://plausible.io/js/script.${extensions}.js`;
|
|
9
|
+
}
|
|
10
|
+
return "https://plausible.io/js/script.js";
|
|
11
|
+
}
|
|
12
|
+
function buildPlausibleInitOptions(options) {
|
|
13
|
+
const initOptions = {};
|
|
14
|
+
if (options.customProperties) initOptions.customProperties = options.customProperties;
|
|
15
|
+
if (options.endpoint) initOptions.endpoint = options.endpoint;
|
|
16
|
+
if (options.fileDownloads) initOptions.fileDownloads = options.fileDownloads;
|
|
17
|
+
if (void 0 !== options.hashBasedRouting) initOptions.hashBasedRouting = options.hashBasedRouting;
|
|
18
|
+
if (void 0 !== options.autoCapturePageviews) initOptions.autoCapturePageviews = options.autoCapturePageviews;
|
|
19
|
+
if (void 0 !== options.captureOnLocalhost) initOptions.captureOnLocalhost = options.captureOnLocalhost;
|
|
20
|
+
return initOptions;
|
|
21
|
+
}
|
|
22
|
+
const plausibleAnalyticsManifest = {
|
|
23
|
+
...vendorManifestContract,
|
|
24
|
+
vendor: 'plausible-analytics',
|
|
25
|
+
category: 'measurement',
|
|
26
|
+
bootstrap: [
|
|
27
|
+
{
|
|
28
|
+
type: 'defineStubFunction',
|
|
29
|
+
name: 'plausible',
|
|
30
|
+
queue: {
|
|
31
|
+
property: 'q'
|
|
32
|
+
},
|
|
33
|
+
queueFormat: 'array',
|
|
34
|
+
properties: {
|
|
35
|
+
o: '{{initOptions}}'
|
|
36
|
+
},
|
|
37
|
+
ifUndefined: true
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
install: [
|
|
41
|
+
{
|
|
42
|
+
type: 'loadScript',
|
|
43
|
+
src: "{{scriptUrl}}",
|
|
44
|
+
defer: true,
|
|
45
|
+
attributes: {
|
|
46
|
+
'data-domain': '{{domain}}',
|
|
47
|
+
'data-api': '{{apiAttribute}}'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
};
|
|
52
|
+
function plausibleAnalytics(options) {
|
|
53
|
+
let scriptId;
|
|
54
|
+
if (options.scriptId) scriptId = options.scriptId.trim();
|
|
55
|
+
let domain;
|
|
56
|
+
if (options.domain) domain = options.domain.trim();
|
|
57
|
+
if (!scriptId && !domain) throw new Error("plausibleAnalytics: missing scriptId or domain");
|
|
58
|
+
const normalizedOptions = {
|
|
59
|
+
...options
|
|
60
|
+
};
|
|
61
|
+
if (scriptId) normalizedOptions.scriptId = scriptId;
|
|
62
|
+
else delete normalizedOptions.scriptId;
|
|
63
|
+
if (domain) normalizedOptions.domain = domain;
|
|
64
|
+
else delete normalizedOptions.domain;
|
|
65
|
+
const manifestOptions = {
|
|
66
|
+
scriptUrl: normalizedOptions.scriptUrl ?? buildPlausibleScriptUrl(normalizedOptions),
|
|
67
|
+
domain: void 0,
|
|
68
|
+
apiAttribute: void 0,
|
|
69
|
+
initOptions: buildPlausibleInitOptions(normalizedOptions)
|
|
70
|
+
};
|
|
71
|
+
if (scriptId) {
|
|
72
|
+
manifestOptions.domain = void 0;
|
|
73
|
+
manifestOptions.apiAttribute = void 0;
|
|
74
|
+
} else {
|
|
75
|
+
manifestOptions.domain = domain;
|
|
76
|
+
manifestOptions.apiAttribute = normalizedOptions.endpoint;
|
|
77
|
+
}
|
|
78
|
+
const resolved = resolveManifest(plausibleAnalyticsManifest, manifestOptions);
|
|
79
|
+
return resolved;
|
|
80
|
+
}
|
|
81
|
+
export { plausibleAnalytics, plausibleAnalyticsManifest };
|
|
@@ -27,8 +27,53 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
27
|
posthogManifest: ()=>posthogManifest,
|
|
28
28
|
posthog: ()=>posthog
|
|
29
29
|
});
|
|
30
|
-
const external_resolve_cjs_namespaceObject = require("
|
|
31
|
-
const external_types_cjs_namespaceObject = require("
|
|
30
|
+
const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
|
|
31
|
+
const external_types_cjs_namespaceObject = require("../../types.cjs");
|
|
32
|
+
const script_url_cjs_namespaceObject = require("../_shared/script-url.cjs");
|
|
33
|
+
const DEFAULT_API_HOST = 'https://eu.i.posthog.com';
|
|
34
|
+
const DEFAULT_SCRIPT_URL = 'https://eu-assets.i.posthog.com/static/array.js';
|
|
35
|
+
const DEFAULT_UI_HOST = 'https://eu.posthog.com';
|
|
36
|
+
const DEFAULTS_DATE = '2026-01-30';
|
|
37
|
+
const REGION_HOSTS = {
|
|
38
|
+
eu: {
|
|
39
|
+
apiHost: DEFAULT_API_HOST,
|
|
40
|
+
uiHost: DEFAULT_UI_HOST,
|
|
41
|
+
scriptUrl: DEFAULT_SCRIPT_URL
|
|
42
|
+
},
|
|
43
|
+
us: {
|
|
44
|
+
apiHost: 'https://us.i.posthog.com',
|
|
45
|
+
uiHost: 'https://us.posthog.com',
|
|
46
|
+
scriptUrl: 'https://us-assets.i.posthog.com/static/array.js'
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function normalizeHost(host) {
|
|
50
|
+
return (0, script_url_cjs_namespaceObject.stripTrailingSlashes)(host);
|
|
51
|
+
}
|
|
52
|
+
function regionFromHost(host) {
|
|
53
|
+
const normalized = normalizeHost(host);
|
|
54
|
+
if (/^https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com$/i.test(normalized)) return 'us';
|
|
55
|
+
if (/^https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com$/i.test(normalized)) return 'eu';
|
|
56
|
+
}
|
|
57
|
+
function deriveScriptUrlFromApiHost(apiHost) {
|
|
58
|
+
const normalized = normalizeHost(apiHost);
|
|
59
|
+
const region = regionFromHost(normalized);
|
|
60
|
+
if (region) return REGION_HOSTS[region].scriptUrl;
|
|
61
|
+
return `${normalized}/static/array.js`;
|
|
62
|
+
}
|
|
63
|
+
function resolvePosthogHosts(options) {
|
|
64
|
+
const regionDefaults = REGION_HOSTS[options.region ?? 'eu'];
|
|
65
|
+
const apiHost = normalizeHost(options.apiHost ?? regionDefaults.apiHost);
|
|
66
|
+
const inferredRegion = regionFromHost(apiHost);
|
|
67
|
+
let uiHost;
|
|
68
|
+
uiHost = void 0 !== options.uiHost ? options.uiHost : inferredRegion ? REGION_HOSTS[inferredRegion].uiHost : void 0 !== options.region ? REGION_HOSTS[options.region].uiHost : apiHost;
|
|
69
|
+
let scriptUrl;
|
|
70
|
+
scriptUrl = void 0 !== options.scriptUrl ? options.scriptUrl : void 0 !== options.apiHost ? deriveScriptUrlFromApiHost(apiHost) : regionDefaults.scriptUrl;
|
|
71
|
+
return {
|
|
72
|
+
apiHost,
|
|
73
|
+
uiHost: normalizeHost(uiHost),
|
|
74
|
+
scriptUrl
|
|
75
|
+
};
|
|
76
|
+
}
|
|
32
77
|
const posthogManifest = {
|
|
33
78
|
...external_types_cjs_namespaceObject.vendorManifestContract,
|
|
34
79
|
vendor: 'posthog',
|
|
@@ -49,6 +94,10 @@ const posthogManifest = {
|
|
|
49
94
|
name: 'init',
|
|
50
95
|
behavior: 'noop'
|
|
51
96
|
},
|
|
97
|
+
{
|
|
98
|
+
name: 'capture',
|
|
99
|
+
behavior: 'noop'
|
|
100
|
+
},
|
|
52
101
|
{
|
|
53
102
|
name: 'opt_in_capturing',
|
|
54
103
|
behavior: 'noop'
|
|
@@ -73,7 +122,7 @@ const posthogManifest = {
|
|
|
73
122
|
attributes: {
|
|
74
123
|
crossorigin: 'anonymous',
|
|
75
124
|
'data-api-host': '{{apiHost}}',
|
|
76
|
-
'data-ui-host': '{{
|
|
125
|
+
'data-ui-host': '{{uiHost}}'
|
|
77
126
|
}
|
|
78
127
|
}
|
|
79
128
|
],
|
|
@@ -118,12 +167,26 @@ const posthogManifest = {
|
|
|
118
167
|
]
|
|
119
168
|
};
|
|
120
169
|
function posthog(options) {
|
|
170
|
+
if ('disabled' === options.loadMode) return {
|
|
171
|
+
id: 'posthog',
|
|
172
|
+
category: 'measurement',
|
|
173
|
+
callbackOnly: true
|
|
174
|
+
};
|
|
175
|
+
const { apiHost, uiHost, scriptUrl } = resolvePosthogHosts(options);
|
|
121
176
|
const resolved = (0, external_resolve_cjs_namespaceObject.resolveManifest)(posthogManifest, {
|
|
122
177
|
id: options.id,
|
|
123
|
-
apiHost
|
|
124
|
-
|
|
125
|
-
|
|
178
|
+
apiHost,
|
|
179
|
+
uiHost,
|
|
180
|
+
scriptUrl,
|
|
181
|
+
initOptions: {
|
|
182
|
+
defaults: DEFAULTS_DATE,
|
|
183
|
+
cookieless_mode: 'on_reject',
|
|
184
|
+
...options.initOptions,
|
|
185
|
+
api_host: apiHost,
|
|
186
|
+
ui_host: uiHost
|
|
187
|
+
}
|
|
126
188
|
});
|
|
189
|
+
if ('after-consent' === options.loadMode) resolved.alwaysLoad = void 0;
|
|
127
190
|
return resolved;
|
|
128
191
|
}
|
|
129
192
|
exports.posthog = __webpack_exports__.posthog;
|