@c15t/scripts 2.2.0 → 3.0.0-alpha.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/AGENTS.md +74 -48
- package/README.md +3 -3
- package/dist/e2e-test-utils.js +60 -24
- package/dist/engine/compile.js +45 -45
- package/dist/engine/runtime.js +119 -119
- package/dist/registry.js +186 -176
- package/dist/resolve.js +12 -12
- package/dist/vendors/_shared/attributes.js +5 -5
- package/dist/vendors/_shared/google-consent.js +10 -10
- package/dist/vendors/_shared/install-builders.js +9 -9
- package/dist/vendors/_shared/script-url.js +12 -12
- package/dist/vendors/ads-and-pixels/linkedin-insights.js +16 -16
- package/dist/vendors/ads-and-pixels/meta-pixel.js +82 -82
- package/dist/vendors/ads-and-pixels/microsoft-uet.js +57 -57
- package/dist/vendors/ads-and-pixels/openai-pixel.js +88 -0
- package/dist/vendors/ads-and-pixels/reddit-pixel.js +39 -39
- package/dist/vendors/ads-and-pixels/snapchat-pixel.js +25 -25
- package/dist/vendors/ads-and-pixels/tiktok-pixel.js +31 -31
- package/dist/vendors/ads-and-pixels/x-pixel.js +17 -17
- package/dist/vendors/analytics/adobe-analytics.js +17 -17
- package/dist/vendors/analytics/ahrefs-analytics.js +8 -8
- package/dist/vendors/analytics/amplitude.js +39 -39
- package/dist/vendors/analytics/clearbit.js +11 -11
- package/dist/vendors/analytics/cloudflare-web-analytics.js +13 -13
- package/dist/vendors/analytics/databuddy.js +45 -45
- package/dist/vendors/analytics/fathom-analytics.js +15 -15
- package/dist/vendors/analytics/google-tag.js +23 -23
- package/dist/vendors/analytics/heap.js +37 -37
- package/dist/vendors/analytics/hightouch.js +30 -30
- package/dist/vendors/analytics/hotjar.js +14 -14
- package/dist/vendors/analytics/logrocket.js +24 -24
- package/dist/vendors/analytics/matomo-analytics.js +51 -51
- package/dist/vendors/analytics/microsoft-clarity.js +31 -31
- package/dist/vendors/analytics/mixpanel-analytics.js +31 -31
- package/dist/vendors/analytics/pirsch.js +27 -27
- package/dist/vendors/analytics/plausible-analytics.js +24 -24
- package/dist/vendors/analytics/posthog.js +84 -79
- package/dist/vendors/analytics/promptwatch.js +8 -8
- package/dist/vendors/analytics/rudderstack.js +50 -50
- package/dist/vendors/analytics/rybbit-analytics.js +30 -30
- package/dist/vendors/analytics/segment.js +16 -16
- package/dist/vendors/analytics/umami-analytics.js +16 -16
- package/dist/vendors/analytics/vercel-analytics.js +22 -22
- package/dist/vendors/functional/crisp.js +49 -51
- package/dist/vendors/functional/intercom.js +18 -18
- package/dist/vendors/tag-managers/google-tag-manager.js +20 -20
- package/dist-types/__tests__/helpers.d.ts +10 -10
- package/dist-types/engine/compile.d.ts +2 -2
- package/dist-types/engine/runtime.d.ts +3 -3
- package/dist-types/registry.d.ts +182 -173
- package/dist-types/resolve.d.ts +2 -2
- package/dist-types/types.d.ts +2 -2
- package/dist-types/vendors/_shared/attributes.d.ts +2 -2
- package/dist-types/vendors/_shared/google-consent.d.ts +2 -2
- package/dist-types/vendors/_shared/install-builders.d.ts +1 -1
- package/dist-types/vendors/_shared/script-url.d.ts +6 -6
- package/dist-types/vendors/ads-and-pixels/linkedin-insights.d.ts +14 -14
- package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +27 -27
- package/dist-types/vendors/ads-and-pixels/microsoft-uet.d.ts +40 -40
- package/dist-types/vendors/ads-and-pixels/openai-pixel.d.ts +211 -0
- package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +28 -29
- package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +23 -23
- package/dist-types/vendors/ads-and-pixels/tiktok-pixel.d.ts +22 -22
- package/dist-types/vendors/ads-and-pixels/x-pixel.d.ts +15 -15
- package/dist-types/vendors/analytics/adobe-analytics.d.ts +3 -3
- package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +5 -5
- package/dist-types/vendors/analytics/amplitude.d.ts +24 -24
- package/dist-types/vendors/analytics/clearbit.d.ts +5 -5
- package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +6 -6
- package/dist-types/vendors/analytics/databuddy.d.ts +34 -31
- package/dist-types/vendors/analytics/fathom-analytics.d.ts +8 -8
- package/dist-types/vendors/analytics/google-tag.d.ts +17 -17
- package/dist-types/vendors/analytics/heap.d.ts +17 -17
- package/dist-types/vendors/analytics/hightouch.d.ts +15 -15
- package/dist-types/vendors/analytics/hotjar.d.ts +9 -9
- package/dist-types/vendors/analytics/logrocket.d.ts +11 -11
- package/dist-types/vendors/analytics/matomo-analytics.d.ts +3 -3
- package/dist-types/vendors/analytics/microsoft-clarity.d.ts +12 -13
- package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +20 -20
- package/dist-types/vendors/analytics/pirsch.d.ts +10 -10
- package/dist-types/vendors/analytics/plausible-analytics.d.ts +13 -13
- package/dist-types/vendors/analytics/posthog.d.ts +35 -32
- package/dist-types/vendors/analytics/promptwatch.d.ts +5 -5
- package/dist-types/vendors/analytics/rudderstack.d.ts +16 -16
- package/dist-types/vendors/analytics/rybbit-analytics.d.ts +15 -15
- package/dist-types/vendors/analytics/segment.d.ts +11 -11
- package/dist-types/vendors/analytics/umami-analytics.d.ts +9 -9
- package/dist-types/vendors/analytics/vercel-analytics.d.ts +13 -13
- package/dist-types/vendors/functional/crisp.d.ts +9 -9
- package/dist-types/vendors/functional/intercom.d.ts +12 -12
- package/dist-types/vendors/tag-managers/google-tag-manager.d.ts +16 -16
- package/docs/README.md +74 -48
- package/docs/assets/v3/brand-bar.png +0 -0
- package/docs/assets/v3/brand-card.png +0 -0
- package/docs/assets/v3/choice-wall.png +0 -0
- package/docs/assets/v3/mobile-card.png +0 -0
- package/docs/assets/v3/preferences.png +0 -0
- package/docs/customization/overview.md +45 -0
- package/docs/customization/recipes.md +79 -0
- package/docs/customization/slots.md +55 -0
- package/docs/customization/tokens.md +76 -0
- package/docs/customization/translations.md +49 -0
- package/docs/frameworks/javascript/script-loader.md +30 -339
- package/docs/frameworks/next/script-loader.md +134 -467
- package/docs/frameworks/react/script-loader.md +35 -535
- package/docs/guides/consent-state.md +60 -0
- package/docs/guides/data-fetching.md +163 -0
- package/docs/guides/deployment-modes.md +63 -0
- package/docs/guides/troubleshooting.md +68 -0
- package/docs/guides/verify-consent.md +62 -0
- package/docs/integrations/adobe-analytics.md +239 -105
- package/docs/integrations/ahrefs-analytics.md +238 -104
- package/docs/integrations/amplitude.md +219 -157
- package/docs/integrations/building-integrations.md +32 -224
- package/docs/integrations/clearbit.md +247 -86
- package/docs/integrations/cloudflare-web-analytics.md +250 -84
- package/docs/integrations/crisp.md +251 -97
- package/docs/integrations/databuddy.md +259 -153
- package/docs/integrations/fathom-analytics.md +239 -96
- package/docs/integrations/google-maps.md +328 -207
- package/docs/integrations/google-tag-manager.md +248 -96
- package/docs/integrations/google-tag.md +261 -90
- package/docs/integrations/heap.md +222 -149
- package/docs/integrations/hightouch.md +225 -131
- package/docs/integrations/hotjar.md +239 -90
- package/docs/integrations/intercom.md +239 -98
- package/docs/integrations/linkedin-insights.md +243 -113
- package/docs/integrations/logrocket.md +241 -123
- package/docs/integrations/matomo-analytics.md +256 -111
- package/docs/integrations/meta-pixel.md +197 -324
- package/docs/integrations/microsoft-clarity.md +233 -114
- package/docs/integrations/microsoft-uet.md +245 -110
- package/docs/integrations/mixpanel-analytics.md +252 -87
- package/docs/integrations/openai-pixel.md +441 -0
- package/docs/integrations/overview.md +95 -133
- package/docs/integrations/pirsch.md +249 -96
- package/docs/integrations/plausible-analytics.md +241 -100
- package/docs/integrations/posthog.md +353 -214
- package/docs/integrations/promptwatch.md +251 -81
- package/docs/integrations/reddit-pixel.md +226 -173
- package/docs/integrations/rudderstack.md +244 -187
- package/docs/integrations/rybbit-analytics.md +244 -91
- package/docs/integrations/segment.md +238 -92
- package/docs/integrations/snapchat-pixel.md +240 -110
- package/docs/integrations/tiktok-pixel.md +249 -81
- package/docs/integrations/umami-analytics.md +242 -95
- package/docs/integrations/vercel-analytics.md +242 -90
- package/docs/integrations/x-pixel.md +238 -104
- package/docs/integrations/youtube.md +354 -142
- package/docs/upgrade-v3.md +334 -0
- package/package.json +85 -78
- package/readme.json +2 -2
- package/dist/e2e-test-utils.cjs +0 -166
- package/dist/engine/compile.cjs +0 -130
- package/dist/engine/runtime.cjs +0 -475
- package/dist/registry.cjs +0 -423
- package/dist/resolve.cjs +0 -71
- package/dist/types.cjs +0 -69
- package/dist/vendors/_shared/attributes.cjs +0 -55
- package/dist/vendors/_shared/google-consent.cjs +0 -69
- package/dist/vendors/_shared/install-builders.cjs +0 -59
- package/dist/vendors/_shared/script-url.cjs +0 -78
- package/dist/vendors/ads-and-pixels/linkedin-insights.cjs +0 -89
- package/dist/vendors/ads-and-pixels/meta-pixel.cjs +0 -206
- package/dist/vendors/ads-and-pixels/microsoft-uet.cjs +0 -151
- package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +0 -151
- package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +0 -131
- package/dist/vendors/ads-and-pixels/tiktok-pixel.cjs +0 -130
- package/dist/vendors/ads-and-pixels/x-pixel.cjs +0 -92
- package/dist/vendors/analytics/adobe-analytics.cjs +0 -90
- package/dist/vendors/analytics/ahrefs-analytics.cjs +0 -68
- package/dist/vendors/analytics/amplitude.cjs +0 -193
- package/dist/vendors/analytics/clearbit.cjs +0 -69
- package/dist/vendors/analytics/cloudflare-web-analytics.cjs +0 -73
- package/dist/vendors/analytics/databuddy.cjs +0 -144
- package/dist/vendors/analytics/fathom-analytics.cjs +0 -76
- package/dist/vendors/analytics/google-tag.cjs +0 -107
- package/dist/vendors/analytics/heap.cjs +0 -181
- package/dist/vendors/analytics/hightouch.cjs +0 -153
- package/dist/vendors/analytics/hotjar.cjs +0 -85
- package/dist/vendors/analytics/logrocket.cjs +0 -99
- package/dist/vendors/analytics/matomo-analytics.cjs +0 -232
- package/dist/vendors/analytics/microsoft-clarity.cjs +0 -138
- package/dist/vendors/analytics/mixpanel-analytics.cjs +0 -134
- package/dist/vendors/analytics/pirsch.cjs +0 -108
- package/dist/vendors/analytics/plausible-analytics.cjs +0 -122
- package/dist/vendors/analytics/posthog.cjs +0 -236
- package/dist/vendors/analytics/promptwatch.cjs +0 -70
- package/dist/vendors/analytics/rudderstack.cjs +0 -227
- package/dist/vendors/analytics/rybbit-analytics.cjs +0 -104
- package/dist/vendors/analytics/segment.cjs +0 -97
- package/dist/vendors/analytics/umami-analytics.cjs +0 -80
- package/dist/vendors/analytics/vercel-analytics.cjs +0 -94
- package/dist/vendors/functional/crisp.cjs +0 -143
- package/dist/vendors/functional/intercom.cjs +0 -89
- package/dist/vendors/tag-managers/google-tag-manager.cjs +0 -100
- package/docs/shared/react/guides/script-loader.md +0 -311
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveManifest } from "../../resolve.js";
|
|
2
2
|
import { vendorManifestContract } from "../../types.js";
|
|
3
|
-
function
|
|
3
|
+
const plausible_analytics_buildPlausibleScriptUrl = function(options) {
|
|
4
4
|
if (options.scriptId) return `https://plausible.io/js/pa-${options.scriptId}.js`;
|
|
5
5
|
if (options.extension) {
|
|
6
6
|
let extensions;
|
|
@@ -8,8 +8,8 @@ function buildPlausibleScriptUrl(options) {
|
|
|
8
8
|
return `https://plausible.io/js/script.${extensions}.js`;
|
|
9
9
|
}
|
|
10
10
|
return "https://plausible.io/js/script.js";
|
|
11
|
-
}
|
|
12
|
-
function
|
|
11
|
+
};
|
|
12
|
+
const plausible_analytics_buildPlausibleInitOptions = function(options) {
|
|
13
13
|
const initOptions = {};
|
|
14
14
|
if (options.customProperties) initOptions.customProperties = options.customProperties;
|
|
15
15
|
if (options.endpoint) initOptions.endpoint = options.endpoint;
|
|
@@ -18,38 +18,38 @@ function buildPlausibleInitOptions(options) {
|
|
|
18
18
|
if (void 0 !== options.autoCapturePageviews) initOptions.autoCapturePageviews = options.autoCapturePageviews;
|
|
19
19
|
if (void 0 !== options.captureOnLocalhost) initOptions.captureOnLocalhost = options.captureOnLocalhost;
|
|
20
20
|
return initOptions;
|
|
21
|
-
}
|
|
21
|
+
};
|
|
22
22
|
const plausibleAnalyticsManifest = {
|
|
23
23
|
...vendorManifestContract,
|
|
24
|
-
vendor: 'plausible-analytics',
|
|
25
|
-
category: 'measurement',
|
|
26
24
|
bootstrap: [
|
|
27
25
|
{
|
|
28
|
-
|
|
26
|
+
ifUndefined: true,
|
|
29
27
|
name: 'plausible',
|
|
28
|
+
properties: {
|
|
29
|
+
o: '{{initOptions}}'
|
|
30
|
+
},
|
|
30
31
|
queue: {
|
|
31
32
|
property: 'q'
|
|
32
33
|
},
|
|
33
34
|
queueFormat: 'array',
|
|
34
|
-
|
|
35
|
-
o: '{{initOptions}}'
|
|
36
|
-
},
|
|
37
|
-
ifUndefined: true
|
|
35
|
+
type: 'defineStubFunction'
|
|
38
36
|
}
|
|
39
37
|
],
|
|
38
|
+
category: 'measurement',
|
|
40
39
|
install: [
|
|
41
40
|
{
|
|
42
|
-
type: 'loadScript',
|
|
43
|
-
src: "{{scriptUrl}}",
|
|
44
|
-
defer: true,
|
|
45
41
|
attributes: {
|
|
46
|
-
'data-
|
|
47
|
-
'data-
|
|
48
|
-
}
|
|
42
|
+
'data-api': '{{apiAttribute}}',
|
|
43
|
+
'data-domain': '{{domain}}'
|
|
44
|
+
},
|
|
45
|
+
defer: true,
|
|
46
|
+
src: "{{scriptUrl}}",
|
|
47
|
+
type: 'loadScript'
|
|
49
48
|
}
|
|
50
|
-
]
|
|
49
|
+
],
|
|
50
|
+
vendor: 'plausible-analytics'
|
|
51
51
|
};
|
|
52
|
-
function
|
|
52
|
+
const plausible_analytics_plausibleAnalytics = function(options) {
|
|
53
53
|
let scriptId;
|
|
54
54
|
if (options.scriptId) scriptId = options.scriptId.trim();
|
|
55
55
|
let domain;
|
|
@@ -63,10 +63,10 @@ function plausibleAnalytics(options) {
|
|
|
63
63
|
if (domain) normalizedOptions.domain = domain;
|
|
64
64
|
else delete normalizedOptions.domain;
|
|
65
65
|
const manifestOptions = {
|
|
66
|
-
scriptUrl: normalizedOptions.scriptUrl ?? buildPlausibleScriptUrl(normalizedOptions),
|
|
67
|
-
domain: void 0,
|
|
68
66
|
apiAttribute: void 0,
|
|
69
|
-
|
|
67
|
+
domain: void 0,
|
|
68
|
+
initOptions: plausible_analytics_buildPlausibleInitOptions(normalizedOptions),
|
|
69
|
+
scriptUrl: normalizedOptions.scriptUrl ?? plausible_analytics_buildPlausibleScriptUrl(normalizedOptions)
|
|
70
70
|
};
|
|
71
71
|
if (scriptId) {
|
|
72
72
|
manifestOptions.domain = void 0;
|
|
@@ -77,5 +77,5 @@ function plausibleAnalytics(options) {
|
|
|
77
77
|
}
|
|
78
78
|
const resolved = resolveManifest(plausibleAnalyticsManifest, manifestOptions);
|
|
79
79
|
return resolved;
|
|
80
|
-
}
|
|
81
|
-
export {
|
|
80
|
+
};
|
|
81
|
+
export { plausibleAnalyticsManifest, plausible_analytics_plausibleAnalytics as plausibleAnalytics };
|
|
@@ -8,188 +8,193 @@ const DEFAULTS_DATE = '2026-01-30';
|
|
|
8
8
|
const REGION_HOSTS = {
|
|
9
9
|
eu: {
|
|
10
10
|
apiHost: DEFAULT_API_HOST,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
scriptUrl: DEFAULT_SCRIPT_URL,
|
|
12
|
+
uiHost: DEFAULT_UI_HOST
|
|
13
13
|
},
|
|
14
14
|
us: {
|
|
15
15
|
apiHost: 'https://us.i.posthog.com',
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
scriptUrl: 'https://us-assets.i.posthog.com/static/array.js',
|
|
17
|
+
uiHost: 'https://us.posthog.com'
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
-
function
|
|
20
|
+
const posthog_normalizeHost = function(host) {
|
|
21
21
|
return stripTrailingSlashes(host);
|
|
22
|
-
}
|
|
23
|
-
function
|
|
24
|
-
const normalized =
|
|
25
|
-
if (/^https:\/\/(app|us|us-assets)(
|
|
26
|
-
if (/^https:\/\/(eu|eu-assets)(
|
|
27
|
-
}
|
|
28
|
-
function
|
|
29
|
-
const normalized =
|
|
30
|
-
const region =
|
|
22
|
+
};
|
|
23
|
+
const posthog_regionFromHost = function(host) {
|
|
24
|
+
const normalized = posthog_normalizeHost(host);
|
|
25
|
+
if (/^https:\/\/(?<capture1>app|us|us-assets)(?<capture2>\.i)?\.posthog\.com$/iu.test(normalized)) return 'us';
|
|
26
|
+
if (/^https:\/\/(?<capture1>eu|eu-assets)(?<capture2>\.i)?\.posthog\.com$/iu.test(normalized)) return 'eu';
|
|
27
|
+
};
|
|
28
|
+
const posthog_deriveScriptUrlFromApiHost = function(apiHost) {
|
|
29
|
+
const normalized = posthog_normalizeHost(apiHost);
|
|
30
|
+
const region = posthog_regionFromHost(normalized);
|
|
31
31
|
if (region) return REGION_HOSTS[region].scriptUrl;
|
|
32
32
|
return `${normalized}/static/array.js`;
|
|
33
|
-
}
|
|
34
|
-
function
|
|
33
|
+
};
|
|
34
|
+
const posthog_resolvePosthogHosts = function(options) {
|
|
35
35
|
const regionDefaults = REGION_HOSTS[options.region ?? 'eu'];
|
|
36
|
-
const apiHost =
|
|
37
|
-
const inferredRegion =
|
|
36
|
+
const apiHost = posthog_normalizeHost(options.apiHost ?? regionDefaults.apiHost);
|
|
37
|
+
const inferredRegion = posthog_regionFromHost(apiHost);
|
|
38
38
|
let uiHost;
|
|
39
|
-
uiHost = void 0 !== options.uiHost ? options.uiHost : inferredRegion ? REGION_HOSTS[inferredRegion].uiHost : void 0
|
|
39
|
+
uiHost = void 0 !== options.uiHost ? options.uiHost : inferredRegion ? REGION_HOSTS[inferredRegion].uiHost : void 0 === options.region ? apiHost : REGION_HOSTS[options.region].uiHost;
|
|
40
40
|
let scriptUrl;
|
|
41
|
-
scriptUrl = void 0 !== options.scriptUrl ? options.scriptUrl : void 0
|
|
41
|
+
scriptUrl = void 0 !== options.scriptUrl ? options.scriptUrl : void 0 === options.apiHost ? regionDefaults.scriptUrl : posthog_deriveScriptUrlFromApiHost(apiHost);
|
|
42
42
|
return {
|
|
43
43
|
apiHost,
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
scriptUrl,
|
|
45
|
+
uiHost: posthog_normalizeHost(uiHost)
|
|
46
46
|
};
|
|
47
|
-
}
|
|
47
|
+
};
|
|
48
48
|
const posthogManifest = {
|
|
49
49
|
...vendorManifestContract,
|
|
50
|
-
vendor: 'posthog',
|
|
51
|
-
category: 'measurement',
|
|
52
50
|
alwaysLoad: true,
|
|
53
51
|
bootstrap: [
|
|
54
52
|
{
|
|
55
|
-
|
|
53
|
+
ifUndefined: true,
|
|
56
54
|
name: 'posthog',
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
type: 'setGlobal',
|
|
56
|
+
value: []
|
|
59
57
|
},
|
|
60
58
|
{
|
|
61
|
-
|
|
59
|
+
ifGlobalIsQueue: true,
|
|
62
60
|
path: [
|
|
63
61
|
'posthog',
|
|
64
62
|
'_i'
|
|
65
63
|
],
|
|
64
|
+
type: 'setGlobalPath',
|
|
66
65
|
value: [
|
|
67
66
|
[
|
|
68
67
|
'{{id}}',
|
|
69
68
|
'{{initOptions}}',
|
|
70
69
|
'posthog'
|
|
71
70
|
]
|
|
72
|
-
]
|
|
73
|
-
ifGlobalIsQueue: true
|
|
71
|
+
]
|
|
74
72
|
},
|
|
75
73
|
{
|
|
76
|
-
|
|
74
|
+
ifGlobalIsQueue: true,
|
|
77
75
|
path: [
|
|
78
76
|
'posthog',
|
|
79
77
|
'people'
|
|
80
78
|
],
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
type: 'setGlobalPath',
|
|
80
|
+
value: []
|
|
83
81
|
},
|
|
84
82
|
{
|
|
85
|
-
type: 'defineQueueMethods',
|
|
86
|
-
target: 'posthog',
|
|
87
83
|
methods: [
|
|
88
84
|
'capture',
|
|
89
85
|
'opt_in_capturing',
|
|
90
86
|
'opt_out_capturing'
|
|
91
|
-
]
|
|
87
|
+
],
|
|
88
|
+
target: 'posthog',
|
|
89
|
+
type: 'defineQueueMethods'
|
|
92
90
|
},
|
|
93
91
|
{
|
|
94
|
-
type: 'defineGlobalMethods',
|
|
95
|
-
target: 'posthog',
|
|
96
92
|
ifGlobalIsQueue: true,
|
|
97
93
|
methods: [
|
|
98
94
|
{
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
behavior: 'noop',
|
|
96
|
+
name: 'init'
|
|
101
97
|
},
|
|
102
98
|
{
|
|
103
|
-
name: 'get_explicit_consent_status',
|
|
104
99
|
behavior: 'return',
|
|
100
|
+
name: 'get_explicit_consent_status',
|
|
105
101
|
value: 'pending'
|
|
106
102
|
}
|
|
107
|
-
]
|
|
103
|
+
],
|
|
104
|
+
target: 'posthog',
|
|
105
|
+
type: 'defineGlobalMethods'
|
|
108
106
|
}
|
|
109
107
|
],
|
|
108
|
+
category: 'measurement',
|
|
110
109
|
install: [
|
|
111
110
|
{
|
|
112
|
-
type: 'loadScript',
|
|
113
|
-
src: "{{scriptUrl}}",
|
|
114
111
|
async: true,
|
|
115
112
|
attributes: {
|
|
116
113
|
crossorigin: 'anonymous',
|
|
117
114
|
'data-api-host': '{{apiHost}}',
|
|
118
115
|
'data-ui-host': '{{uiHost}}'
|
|
119
|
-
}
|
|
116
|
+
},
|
|
117
|
+
src: "{{scriptUrl}}",
|
|
118
|
+
type: 'loadScript'
|
|
120
119
|
}
|
|
121
120
|
],
|
|
122
|
-
|
|
121
|
+
onBeforeLoadDenied: [
|
|
123
122
|
{
|
|
124
|
-
type: 'pushToQueue',
|
|
125
123
|
queue: 'posthog',
|
|
124
|
+
type: 'pushToQueue',
|
|
126
125
|
value: [
|
|
127
|
-
'
|
|
128
|
-
{
|
|
129
|
-
captureEventName: null
|
|
130
|
-
}
|
|
126
|
+
'opt_out_capturing'
|
|
131
127
|
]
|
|
132
128
|
}
|
|
133
129
|
],
|
|
134
|
-
|
|
130
|
+
onBeforeLoadGranted: [
|
|
135
131
|
{
|
|
136
|
-
type: 'pushToQueue',
|
|
137
132
|
queue: 'posthog',
|
|
133
|
+
type: 'pushToQueue',
|
|
138
134
|
value: [
|
|
139
|
-
'
|
|
135
|
+
'opt_in_capturing',
|
|
136
|
+
{
|
|
137
|
+
captureEventName: null
|
|
138
|
+
}
|
|
140
139
|
]
|
|
141
140
|
}
|
|
142
141
|
],
|
|
143
|
-
|
|
142
|
+
onConsentDenied: [
|
|
144
143
|
{
|
|
145
|
-
type: 'callGlobal',
|
|
146
144
|
global: 'posthog',
|
|
147
|
-
method: '
|
|
145
|
+
method: 'opt_out_capturing',
|
|
146
|
+
type: 'callGlobal'
|
|
148
147
|
}
|
|
149
148
|
],
|
|
150
|
-
|
|
149
|
+
onConsentGranted: [
|
|
151
150
|
{
|
|
152
|
-
type: 'callGlobal',
|
|
153
151
|
global: 'posthog',
|
|
154
|
-
method: '
|
|
152
|
+
method: 'opt_in_capturing',
|
|
153
|
+
type: 'callGlobal'
|
|
155
154
|
}
|
|
156
155
|
],
|
|
157
|
-
|
|
156
|
+
onLoadDenied: [
|
|
158
157
|
{
|
|
159
|
-
type: 'callGlobal',
|
|
160
158
|
global: 'posthog',
|
|
161
|
-
method: '
|
|
159
|
+
method: 'opt_out_capturing',
|
|
160
|
+
type: 'callGlobal'
|
|
162
161
|
}
|
|
163
162
|
],
|
|
164
|
-
|
|
163
|
+
onLoadGranted: [
|
|
165
164
|
{
|
|
166
|
-
|
|
165
|
+
args: [
|
|
166
|
+
{
|
|
167
|
+
captureEventName: null
|
|
168
|
+
}
|
|
169
|
+
],
|
|
167
170
|
global: 'posthog',
|
|
168
|
-
method: '
|
|
171
|
+
method: 'opt_in_capturing',
|
|
172
|
+
type: 'callGlobal'
|
|
169
173
|
}
|
|
170
|
-
]
|
|
174
|
+
],
|
|
175
|
+
vendor: 'posthog'
|
|
171
176
|
};
|
|
172
|
-
function
|
|
177
|
+
const posthog_posthog = function(options) {
|
|
173
178
|
if ('disabled' === options.loadMode) return {
|
|
174
|
-
|
|
179
|
+
callbackOnly: true,
|
|
175
180
|
category: 'measurement',
|
|
176
|
-
|
|
181
|
+
id: 'posthog'
|
|
177
182
|
};
|
|
178
|
-
const { apiHost, uiHost, scriptUrl } =
|
|
183
|
+
const { apiHost, uiHost, scriptUrl } = posthog_resolvePosthogHosts(options);
|
|
179
184
|
const resolved = resolveManifest(posthogManifest, {
|
|
180
|
-
id: options.id,
|
|
181
185
|
apiHost,
|
|
182
|
-
|
|
183
|
-
scriptUrl,
|
|
186
|
+
id: options.id,
|
|
184
187
|
initOptions: {
|
|
185
|
-
defaults: DEFAULTS_DATE,
|
|
186
188
|
cookieless_mode: 'on_reject',
|
|
189
|
+
defaults: DEFAULTS_DATE,
|
|
187
190
|
...options.initOptions,
|
|
188
191
|
api_host: apiHost,
|
|
189
192
|
ui_host: uiHost
|
|
190
|
-
}
|
|
193
|
+
},
|
|
194
|
+
scriptUrl,
|
|
195
|
+
uiHost
|
|
191
196
|
});
|
|
192
197
|
if ('after-consent' === options.loadMode) resolved.alwaysLoad = void 0;
|
|
193
198
|
return resolved;
|
|
194
|
-
}
|
|
195
|
-
export {
|
|
199
|
+
};
|
|
200
|
+
export { posthogManifest, posthog_posthog as posthog };
|
|
@@ -3,20 +3,20 @@ import { vendorManifestContract } from "../../types.js";
|
|
|
3
3
|
import { resolveScriptUrl, trimToUndefined } from "../_shared/script-url.js";
|
|
4
4
|
const promptwatchManifest = {
|
|
5
5
|
...vendorManifestContract,
|
|
6
|
-
vendor: 'promptwatch',
|
|
7
6
|
category: 'measurement',
|
|
8
7
|
install: [
|
|
9
8
|
{
|
|
10
|
-
type: 'loadScript',
|
|
11
|
-
src: "{{scriptUrl}}",
|
|
12
9
|
async: true,
|
|
13
10
|
attributes: {
|
|
14
11
|
'data-project-id': '{{projectId}}'
|
|
15
|
-
}
|
|
12
|
+
},
|
|
13
|
+
src: "{{scriptUrl}}",
|
|
14
|
+
type: 'loadScript'
|
|
16
15
|
}
|
|
17
|
-
]
|
|
16
|
+
],
|
|
17
|
+
vendor: 'promptwatch'
|
|
18
18
|
};
|
|
19
|
-
function
|
|
19
|
+
const promptwatch_promptwatch = function({ projectId, scriptUrl }) {
|
|
20
20
|
const normalizedProjectId = projectId.trim();
|
|
21
21
|
if (0 === normalizedProjectId.length) throw new Error('promptwatch: invalid projectId - must be a non-empty string');
|
|
22
22
|
const defaultScriptUrl = 'https://ingest.promptwatch.com/js/client.min.js';
|
|
@@ -25,5 +25,5 @@ function promptwatch({ projectId, scriptUrl }) {
|
|
|
25
25
|
projectId: normalizedProjectId,
|
|
26
26
|
scriptUrl: normalizedScriptUrl
|
|
27
27
|
});
|
|
28
|
-
}
|
|
29
|
-
export {
|
|
28
|
+
};
|
|
29
|
+
export { promptwatchManifest, promptwatch_promptwatch as promptwatch };
|
|
@@ -20,74 +20,74 @@ const RUDDERSTACK_QUEUE_METHODS = [
|
|
|
20
20
|
];
|
|
21
21
|
const rudderstackManifest = {
|
|
22
22
|
...vendorManifestContract,
|
|
23
|
-
vendor: 'rudderstack',
|
|
24
|
-
category: 'measurement',
|
|
25
23
|
bootstrap: [
|
|
26
24
|
{
|
|
27
|
-
|
|
25
|
+
ifUndefined: true,
|
|
28
26
|
name: 'rudderanalytics',
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
type: 'setGlobal',
|
|
28
|
+
value: []
|
|
31
29
|
},
|
|
32
30
|
{
|
|
33
|
-
type: 'setGlobal',
|
|
34
31
|
name: 'RudderSnippetVersion',
|
|
32
|
+
type: 'setGlobal',
|
|
35
33
|
value: '3.0.32'
|
|
36
34
|
},
|
|
37
35
|
{
|
|
38
|
-
type: 'setGlobal',
|
|
39
36
|
name: 'rudderAnalyticsBuildType',
|
|
37
|
+
type: 'setGlobal',
|
|
40
38
|
value: 'modern'
|
|
41
39
|
},
|
|
42
40
|
{
|
|
43
|
-
type: 'setGlobalPath',
|
|
44
41
|
path: [
|
|
45
42
|
'rudderanalytics',
|
|
46
43
|
'snippetExecuted'
|
|
47
44
|
],
|
|
45
|
+
type: 'setGlobalPath',
|
|
48
46
|
value: true
|
|
49
47
|
},
|
|
50
48
|
{
|
|
51
|
-
type: 'defineQueueMethods',
|
|
52
|
-
target: 'rudderanalytics',
|
|
53
49
|
methods: [
|
|
54
50
|
...RUDDERSTACK_QUEUE_METHODS
|
|
55
|
-
]
|
|
51
|
+
],
|
|
52
|
+
target: 'rudderanalytics',
|
|
53
|
+
type: 'defineQueueMethods'
|
|
56
54
|
}
|
|
57
55
|
],
|
|
56
|
+
category: 'measurement',
|
|
58
57
|
install: [
|
|
59
58
|
{
|
|
60
|
-
type: 'callGlobal',
|
|
61
|
-
global: 'rudderanalytics',
|
|
62
|
-
method: 'load',
|
|
63
59
|
args: [
|
|
64
60
|
'{{writeKey}}',
|
|
65
61
|
'{{dataPlaneUrl}}',
|
|
66
62
|
'{{loadOptions}}'
|
|
67
|
-
]
|
|
63
|
+
],
|
|
64
|
+
global: 'rudderanalytics',
|
|
65
|
+
method: 'load',
|
|
66
|
+
type: 'callGlobal'
|
|
68
67
|
},
|
|
69
68
|
{
|
|
70
|
-
type: 'callGlobal',
|
|
71
69
|
global: 'rudderanalytics',
|
|
72
|
-
method: 'page'
|
|
70
|
+
method: 'page',
|
|
71
|
+
type: 'callGlobal'
|
|
73
72
|
},
|
|
74
73
|
{
|
|
75
|
-
type: 'loadScript',
|
|
76
|
-
src: "{{scriptUrl}}",
|
|
77
74
|
async: true,
|
|
78
75
|
attributes: {
|
|
79
76
|
'data-loader': 'RS_JS_SDK',
|
|
80
77
|
'data-rsa-write-key': '{{writeKey}}'
|
|
81
|
-
}
|
|
78
|
+
},
|
|
79
|
+
src: "{{scriptUrl}}",
|
|
80
|
+
type: 'loadScript'
|
|
82
81
|
}
|
|
83
|
-
]
|
|
82
|
+
],
|
|
83
|
+
vendor: 'rudderstack'
|
|
84
84
|
};
|
|
85
|
-
function
|
|
85
|
+
const rudderstack_validateRequiredString = function(value, label) {
|
|
86
86
|
const normalized = 'string' == typeof value ? value.trim() : '';
|
|
87
87
|
if (0 === normalized.length) throw new Error(`rudderstack: missing or invalid ${label}`);
|
|
88
88
|
return normalized;
|
|
89
|
-
}
|
|
90
|
-
function
|
|
89
|
+
};
|
|
90
|
+
const rudderstack_validateOptionalHttpsScriptUrl = function(scriptUrl) {
|
|
91
91
|
if (void 0 === scriptUrl) return;
|
|
92
92
|
let parsed;
|
|
93
93
|
try {
|
|
@@ -97,11 +97,11 @@ function validateOptionalHttpsScriptUrl(scriptUrl) {
|
|
|
97
97
|
}
|
|
98
98
|
if ('https:' !== parsed.protocol) throw new Error("rudderstack: scriptUrl must be a valid https URL");
|
|
99
99
|
return scriptUrl;
|
|
100
|
-
}
|
|
101
|
-
function
|
|
100
|
+
};
|
|
101
|
+
const rudderstack_isJsonObjectValue = function(value) {
|
|
102
102
|
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
103
|
-
}
|
|
104
|
-
function
|
|
103
|
+
};
|
|
104
|
+
const rudderstack_validateConsentMapping = function(consentManagement) {
|
|
105
105
|
const normalized = {};
|
|
106
106
|
for (const [category, ids] of Object.entries(consentManagement.mapping)){
|
|
107
107
|
if (!Array.isArray(ids)) throw new Error(`rudderstack: consentManagement.mapping.${category} must be an array of consent IDs`);
|
|
@@ -114,25 +114,25 @@ function validateConsentMapping(consentManagement) {
|
|
|
114
114
|
}
|
|
115
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
116
|
return normalized;
|
|
117
|
-
}
|
|
118
|
-
function
|
|
117
|
+
};
|
|
118
|
+
const rudderstack_buildPreConsentLoadOptions = function(loadOptions) {
|
|
119
119
|
let userConsentManagement = {};
|
|
120
|
-
if (
|
|
120
|
+
if (rudderstack_isJsonObjectValue(loadOptions.consentManagement)) userConsentManagement = loadOptions.consentManagement;
|
|
121
121
|
let userPreConsent = {};
|
|
122
|
-
if (
|
|
122
|
+
if (rudderstack_isJsonObjectValue(loadOptions.preConsent)) userPreConsent = loadOptions.preConsent;
|
|
123
123
|
let storage = {
|
|
124
124
|
strategy: 'none'
|
|
125
125
|
};
|
|
126
|
-
if (
|
|
126
|
+
if (rudderstack_isJsonObjectValue(userPreConsent.storage)) storage = userPreConsent.storage;
|
|
127
127
|
return {
|
|
128
128
|
...loadOptions,
|
|
129
129
|
preConsent: {
|
|
130
130
|
...userPreConsent,
|
|
131
131
|
enabled: true,
|
|
132
|
-
storage,
|
|
133
132
|
events: {
|
|
134
133
|
delivery: 'buffer'
|
|
135
|
-
}
|
|
134
|
+
},
|
|
135
|
+
storage
|
|
136
136
|
},
|
|
137
137
|
consentManagement: {
|
|
138
138
|
...userConsentManagement,
|
|
@@ -140,9 +140,9 @@ function buildPreConsentLoadOptions(loadOptions) {
|
|
|
140
140
|
provider: 'custom'
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
}
|
|
144
|
-
function
|
|
145
|
-
const normalized =
|
|
143
|
+
};
|
|
144
|
+
const rudderstack_validateDataPlaneUrl = function(dataPlaneUrl) {
|
|
145
|
+
const normalized = rudderstack_validateRequiredString(dataPlaneUrl, 'dataPlaneUrl');
|
|
146
146
|
let parsed;
|
|
147
147
|
try {
|
|
148
148
|
parsed = new URL(normalized);
|
|
@@ -151,23 +151,23 @@ function validateDataPlaneUrl(dataPlaneUrl) {
|
|
|
151
151
|
}
|
|
152
152
|
if ('https:' !== parsed.protocol) throw new Error('rudderstack: dataPlaneUrl must be a valid https URL');
|
|
153
153
|
return normalized;
|
|
154
|
-
}
|
|
155
|
-
function
|
|
156
|
-
const normalizedWriteKey =
|
|
157
|
-
const normalizedDataPlaneUrl =
|
|
154
|
+
};
|
|
155
|
+
const rudderstack_rudderstack = function({ writeKey, dataPlaneUrl, consentManagement, loadOptions = {}, trackPageView = true, scriptUrl }) {
|
|
156
|
+
const normalizedWriteKey = rudderstack_validateRequiredString(writeKey, 'writeKey');
|
|
157
|
+
const normalizedDataPlaneUrl = rudderstack_validateDataPlaneUrl(dataPlaneUrl);
|
|
158
158
|
let manifest = rudderstackManifest;
|
|
159
159
|
let resolvedLoadOptions = loadOptions;
|
|
160
160
|
if (consentManagement) {
|
|
161
|
-
const consentMapping =
|
|
161
|
+
const consentMapping = rudderstack_validateConsentMapping(consentManagement);
|
|
162
162
|
manifest = {
|
|
163
163
|
...manifest,
|
|
164
164
|
alwaysLoad: true,
|
|
165
|
-
persistAfterConsentRevoked: true,
|
|
166
165
|
consentMapping,
|
|
167
166
|
consentSignal: 'rudderstack',
|
|
168
|
-
consentSignalTarget: 'rudderanalytics'
|
|
167
|
+
consentSignalTarget: 'rudderanalytics',
|
|
168
|
+
persistAfterConsentRevoked: true
|
|
169
169
|
};
|
|
170
|
-
resolvedLoadOptions =
|
|
170
|
+
resolvedLoadOptions = rudderstack_buildPreConsentLoadOptions(loadOptions);
|
|
171
171
|
}
|
|
172
172
|
if (!trackPageView) manifest = {
|
|
173
173
|
...manifest,
|
|
@@ -176,8 +176,8 @@ function rudderstack({ writeKey, dataPlaneUrl, consentManagement, loadOptions =
|
|
|
176
176
|
return resolveManifest(manifest, {
|
|
177
177
|
dataPlaneUrl: normalizedDataPlaneUrl,
|
|
178
178
|
loadOptions: resolvedLoadOptions,
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
scriptUrl: resolveScriptUrl(rudderstack_validateOptionalHttpsScriptUrl(trimToUndefined(scriptUrl)), DEFAULT_RUDDERSTACK_SCRIPT_URL),
|
|
180
|
+
writeKey: normalizedWriteKey
|
|
181
181
|
});
|
|
182
|
-
}
|
|
183
|
-
export { RUDDERSTACK_QUEUE_METHODS,
|
|
182
|
+
};
|
|
183
|
+
export { RUDDERSTACK_QUEUE_METHODS, rudderstackManifest, rudderstack_rudderstack as rudderstack };
|