@c15t/scripts 2.0.1 → 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/engine/runtime.cjs +11 -0
- package/dist/engine/runtime.js +11 -0
- 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 +165 -4
- package/dist/meta-pixel.cjs +0 -129
- package/dist/meta-pixel.js +0 -89
- package/dist/posthog.js +0 -100
- 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,85 @@
|
|
|
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
|
+
intercom: ()=>intercom,
|
|
28
|
+
intercomManifest: ()=>intercomManifest,
|
|
29
|
+
INTERCOM_API_BASES: ()=>INTERCOM_API_BASES
|
|
30
|
+
});
|
|
31
|
+
const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
|
|
32
|
+
const external_types_cjs_namespaceObject = require("../../types.cjs");
|
|
33
|
+
const INTERCOM_API_BASES = {
|
|
34
|
+
us: 'https://api-iam.intercom.io',
|
|
35
|
+
eu: 'https://api-iam.eu.intercom.io',
|
|
36
|
+
au: 'https://api-iam.au.intercom.io'
|
|
37
|
+
};
|
|
38
|
+
const intercomManifest = {
|
|
39
|
+
...external_types_cjs_namespaceObject.vendorManifestContract,
|
|
40
|
+
vendor: 'intercom',
|
|
41
|
+
category: 'functionality',
|
|
42
|
+
install: [
|
|
43
|
+
{
|
|
44
|
+
type: 'defineStubFunction',
|
|
45
|
+
name: 'Intercom',
|
|
46
|
+
queue: {
|
|
47
|
+
property: 'q'
|
|
48
|
+
},
|
|
49
|
+
queueFormat: 'array',
|
|
50
|
+
ifUndefined: true
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: 'setGlobal',
|
|
54
|
+
name: 'intercomSettings',
|
|
55
|
+
value: '{{settings}}',
|
|
56
|
+
ifUndefined: false
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: 'loadScript',
|
|
60
|
+
src: "{{scriptSrc}}",
|
|
61
|
+
async: true
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
};
|
|
65
|
+
function intercom({ appId, apiBase = INTERCOM_API_BASES.us, settings, scriptSrc }) {
|
|
66
|
+
return (0, external_resolve_cjs_namespaceObject.resolveManifest)(intercomManifest, {
|
|
67
|
+
settings: {
|
|
68
|
+
...settings ?? {},
|
|
69
|
+
app_id: appId,
|
|
70
|
+
api_base: apiBase
|
|
71
|
+
},
|
|
72
|
+
scriptSrc: scriptSrc ?? `https://widget.intercom.io/widget/${appId}`
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
exports.INTERCOM_API_BASES = __webpack_exports__.INTERCOM_API_BASES;
|
|
76
|
+
exports.intercom = __webpack_exports__.intercom;
|
|
77
|
+
exports.intercomManifest = __webpack_exports__.intercomManifest;
|
|
78
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
79
|
+
"INTERCOM_API_BASES",
|
|
80
|
+
"intercom",
|
|
81
|
+
"intercomManifest"
|
|
82
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
83
|
+
Object.defineProperty(exports, '__esModule', {
|
|
84
|
+
value: true
|
|
85
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { resolveManifest } from "../../resolve.js";
|
|
2
|
+
import { vendorManifestContract } from "../../types.js";
|
|
3
|
+
const INTERCOM_API_BASES = {
|
|
4
|
+
us: 'https://api-iam.intercom.io',
|
|
5
|
+
eu: 'https://api-iam.eu.intercom.io',
|
|
6
|
+
au: 'https://api-iam.au.intercom.io'
|
|
7
|
+
};
|
|
8
|
+
const intercomManifest = {
|
|
9
|
+
...vendorManifestContract,
|
|
10
|
+
vendor: 'intercom',
|
|
11
|
+
category: 'functionality',
|
|
12
|
+
install: [
|
|
13
|
+
{
|
|
14
|
+
type: 'defineStubFunction',
|
|
15
|
+
name: 'Intercom',
|
|
16
|
+
queue: {
|
|
17
|
+
property: 'q'
|
|
18
|
+
},
|
|
19
|
+
queueFormat: 'array',
|
|
20
|
+
ifUndefined: true
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: 'setGlobal',
|
|
24
|
+
name: 'intercomSettings',
|
|
25
|
+
value: '{{settings}}',
|
|
26
|
+
ifUndefined: false
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: 'loadScript',
|
|
30
|
+
src: "{{scriptSrc}}",
|
|
31
|
+
async: true
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
function intercom({ appId, apiBase = INTERCOM_API_BASES.us, settings, scriptSrc }) {
|
|
36
|
+
return resolveManifest(intercomManifest, {
|
|
37
|
+
settings: {
|
|
38
|
+
...settings ?? {},
|
|
39
|
+
app_id: appId,
|
|
40
|
+
api_base: apiBase
|
|
41
|
+
},
|
|
42
|
+
scriptSrc: scriptSrc ?? `https://widget.intercom.io/widget/${appId}`
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export { INTERCOM_API_BASES, intercom, intercomManifest };
|
|
@@ -27,8 +27,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
27
|
googleTagManagerManifest: ()=>googleTagManagerManifest,
|
|
28
28
|
googleTagManager: ()=>googleTagManager
|
|
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 google_consent_cjs_namespaceObject = require("../_shared/google-consent.cjs");
|
|
32
33
|
const googleTagManagerManifest = {
|
|
33
34
|
...external_types_cjs_namespaceObject.vendorManifestContract,
|
|
34
35
|
vendor: 'google-tag-manager',
|
|
@@ -53,7 +54,7 @@ const googleTagManagerManifest = {
|
|
|
53
54
|
type: 'pushToQueue',
|
|
54
55
|
queue: 'dataLayer',
|
|
55
56
|
value: {
|
|
56
|
-
'gtm.start':
|
|
57
|
+
'gtm.start': external_types_cjs_namespaceObject.runtimeTimestampValue,
|
|
57
58
|
event: 'gtm.js'
|
|
58
59
|
}
|
|
59
60
|
},
|
|
@@ -73,35 +74,13 @@ const googleTagManagerManifest = {
|
|
|
73
74
|
]
|
|
74
75
|
}
|
|
75
76
|
],
|
|
76
|
-
consentMapping:
|
|
77
|
-
necessary: [
|
|
78
|
-
'security_storage'
|
|
79
|
-
],
|
|
80
|
-
functionality: [
|
|
81
|
-
'functionality_storage'
|
|
82
|
-
],
|
|
83
|
-
measurement: [
|
|
84
|
-
'analytics_storage'
|
|
85
|
-
],
|
|
86
|
-
marketing: [
|
|
87
|
-
'ad_storage',
|
|
88
|
-
'ad_user_data',
|
|
89
|
-
'ad_personalization'
|
|
90
|
-
],
|
|
91
|
-
experience: [
|
|
92
|
-
'personalization_storage'
|
|
93
|
-
]
|
|
94
|
-
},
|
|
77
|
+
consentMapping: google_consent_cjs_namespaceObject.GOOGLE_CONSENT_MODE_V2_DEFAULT_MAPPING,
|
|
95
78
|
consentSignal: 'gtag'
|
|
96
79
|
};
|
|
97
80
|
function googleTagManager({ id, updateEventName, consentMapping }) {
|
|
98
|
-
const manifest =
|
|
99
|
-
...googleTagManagerManifest,
|
|
100
|
-
consentMapping
|
|
101
|
-
} : googleTagManagerManifest;
|
|
81
|
+
const manifest = (0, google_consent_cjs_namespaceObject.withOptionalConsentMapping)(googleTagManagerManifest, consentMapping);
|
|
102
82
|
const resolved = (0, external_resolve_cjs_namespaceObject.resolveManifest)(manifest, {
|
|
103
83
|
id,
|
|
104
|
-
loadTime: Date.now(),
|
|
105
84
|
updateEventName: updateEventName ?? 'consent-update'
|
|
106
85
|
});
|
|
107
86
|
return resolved;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { resolveManifest } from "
|
|
2
|
-
import { vendorManifestContract } from "
|
|
1
|
+
import { resolveManifest } from "../../resolve.js";
|
|
2
|
+
import { runtimeTimestampValue, vendorManifestContract } from "../../types.js";
|
|
3
|
+
import { GOOGLE_CONSENT_MODE_V2_DEFAULT_MAPPING, withOptionalConsentMapping } from "../_shared/google-consent.js";
|
|
3
4
|
const googleTagManagerManifest = {
|
|
4
5
|
...vendorManifestContract,
|
|
5
6
|
vendor: 'google-tag-manager',
|
|
@@ -24,7 +25,7 @@ const googleTagManagerManifest = {
|
|
|
24
25
|
type: 'pushToQueue',
|
|
25
26
|
queue: 'dataLayer',
|
|
26
27
|
value: {
|
|
27
|
-
'gtm.start':
|
|
28
|
+
'gtm.start': runtimeTimestampValue,
|
|
28
29
|
event: 'gtm.js'
|
|
29
30
|
}
|
|
30
31
|
},
|
|
@@ -44,35 +45,13 @@ const googleTagManagerManifest = {
|
|
|
44
45
|
]
|
|
45
46
|
}
|
|
46
47
|
],
|
|
47
|
-
consentMapping:
|
|
48
|
-
necessary: [
|
|
49
|
-
'security_storage'
|
|
50
|
-
],
|
|
51
|
-
functionality: [
|
|
52
|
-
'functionality_storage'
|
|
53
|
-
],
|
|
54
|
-
measurement: [
|
|
55
|
-
'analytics_storage'
|
|
56
|
-
],
|
|
57
|
-
marketing: [
|
|
58
|
-
'ad_storage',
|
|
59
|
-
'ad_user_data',
|
|
60
|
-
'ad_personalization'
|
|
61
|
-
],
|
|
62
|
-
experience: [
|
|
63
|
-
'personalization_storage'
|
|
64
|
-
]
|
|
65
|
-
},
|
|
48
|
+
consentMapping: GOOGLE_CONSENT_MODE_V2_DEFAULT_MAPPING,
|
|
66
49
|
consentSignal: 'gtag'
|
|
67
50
|
};
|
|
68
51
|
function googleTagManager({ id, updateEventName, consentMapping }) {
|
|
69
|
-
const manifest = consentMapping
|
|
70
|
-
...googleTagManagerManifest,
|
|
71
|
-
consentMapping
|
|
72
|
-
} : googleTagManagerManifest;
|
|
52
|
+
const manifest = withOptionalConsentMapping(googleTagManagerManifest, consentMapping);
|
|
73
53
|
const resolved = resolveManifest(manifest, {
|
|
74
54
|
id,
|
|
75
|
-
loadTime: Date.now(),
|
|
76
55
|
updateEventName: updateEventName ?? 'consent-update'
|
|
77
56
|
});
|
|
78
57
|
return resolved;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { ConsentState, Script, ScriptCallbackInfo } from 'c15t';
|
|
2
|
+
import { type BuiltInScriptIntegrationKey } from '../registry';
|
|
3
|
+
/**
|
|
4
|
+
* Typed view of `globalThis` used by script helper tests.
|
|
5
|
+
*
|
|
6
|
+
* Additional string-keyed properties model browser and vendor globals created
|
|
7
|
+
* during setup and individual test cases.
|
|
8
|
+
*/
|
|
9
|
+
export type TestGlobal = typeof globalThis & Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Snapshot of the script fields asserted by helper tests.
|
|
12
|
+
*/
|
|
13
|
+
export interface HelperScriptSnapshot {
|
|
14
|
+
/** Unique script identifier generated by the helper under test. */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Consent category associated with the script integration. */
|
|
17
|
+
category: unknown;
|
|
18
|
+
/** Whether the script should load even before optional consent is granted. */
|
|
19
|
+
alwaysLoad?: boolean;
|
|
20
|
+
/** Whether the script stays loaded after consent for its category is revoked. */
|
|
21
|
+
persistAfterConsentRevoked?: boolean;
|
|
22
|
+
/** Remote script URL emitted by the helper, when applicable. */
|
|
23
|
+
src?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Expected integration metadata and script attributes for a helper assertion.
|
|
27
|
+
*/
|
|
28
|
+
export interface ExpectedScriptSnapshot {
|
|
29
|
+
/** Expected `alwaysLoad` flag from the generated helper script. */
|
|
30
|
+
alwaysLoad: boolean | undefined;
|
|
31
|
+
/** Expected consent-revocation persistence flag from the generated script. */
|
|
32
|
+
persistAfterConsentRevoked: boolean | undefined;
|
|
33
|
+
/** Expected remote script URL from the generated helper script. */
|
|
34
|
+
src: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Consent state with only required storage enabled.
|
|
38
|
+
*
|
|
39
|
+
* `necessary` keeps essential storage on, `functionality` covers site
|
|
40
|
+
* preferences, `measurement` controls analytics, `marketing` controls
|
|
41
|
+
* advertising-related storage, and `experience` controls personalization.
|
|
42
|
+
*/
|
|
43
|
+
export declare const deniedConsentState: ConsentState;
|
|
44
|
+
/**
|
|
45
|
+
* Consent state with required and measurement storage enabled.
|
|
46
|
+
*
|
|
47
|
+
* `necessary` keeps essential storage on, `functionality` covers site
|
|
48
|
+
* preferences, `measurement` controls analytics, `marketing` controls
|
|
49
|
+
* advertising-related storage, and `experience` controls personalization.
|
|
50
|
+
*/
|
|
51
|
+
export declare const grantedMeasurementConsentState: ConsentState;
|
|
52
|
+
/**
|
|
53
|
+
* Required callback fields for creating a script lifecycle payload in tests.
|
|
54
|
+
*/
|
|
55
|
+
export type CallbackInfoOverrides = Partial<ScriptCallbackInfo> & Pick<ScriptCallbackInfo, 'id'>;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a fully typed callback payload for script lifecycle tests.
|
|
58
|
+
*
|
|
59
|
+
* Defaults model a denied-consent callback for the same DOM element ID as the
|
|
60
|
+
* script ID, while allowing individual tests to override the relevant fields.
|
|
61
|
+
*/
|
|
62
|
+
export declare function createCallbackInfo(overrides: CallbackInfoOverrides): ScriptCallbackInfo;
|
|
63
|
+
export type LifecycleCallbackOverrides = Partial<Omit<ScriptCallbackInfo, 'id'>>;
|
|
64
|
+
export declare function runOnBeforeLoad(script: Pick<Script, 'id' | 'onBeforeLoad'>, overrides?: LifecycleCallbackOverrides): void;
|
|
65
|
+
/**
|
|
66
|
+
* Returns a mutable test-friendly reference to the global object.
|
|
67
|
+
*
|
|
68
|
+
* @returns The current global object cast to `TestGlobal`.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const globalRef = getTestGlobal();
|
|
73
|
+
* globalRef.dataLayer = [];
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function getTestGlobal(): TestGlobal;
|
|
77
|
+
/**
|
|
78
|
+
* Registers browser-like setup and teardown hooks for script helper tests.
|
|
79
|
+
*
|
|
80
|
+
* Before each test, this installs mocked `window` and `document` globals.
|
|
81
|
+
* After each test, it unstubs globals and removes vendor-specific globals left
|
|
82
|
+
* behind by script execution.
|
|
83
|
+
*
|
|
84
|
+
* @returns Nothing.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* describe('googleTagManager', () => {
|
|
89
|
+
* setupScriptHelperTest();
|
|
90
|
+
* });
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function setupScriptHelperTest(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Asserts that a helper-generated script matches registry metadata and
|
|
96
|
+
* expected script fields.
|
|
97
|
+
*
|
|
98
|
+
* @param key - Built-in integration key used to find the registry entry.
|
|
99
|
+
* @param script - Snapshot of the helper-generated script under test.
|
|
100
|
+
* @param expected - Expected script metadata and output for the assertion.
|
|
101
|
+
* @returns Nothing.
|
|
102
|
+
*
|
|
103
|
+
* @remarks
|
|
104
|
+
* If `key` does not match any built-in integration, the assertion fails before
|
|
105
|
+
* the non-null access is used.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* expectScriptMatchesIntegration(
|
|
110
|
+
* 'googleTagManager',
|
|
111
|
+
* googleTagManager({ id: 'GTM-123' }),
|
|
112
|
+
* {
|
|
113
|
+
* alwaysLoad: true,
|
|
114
|
+
* persistAfterConsentRevoked: undefined,
|
|
115
|
+
* src: 'https://www.googletagmanager.com/gtm.js?id=GTM-123',
|
|
116
|
+
* }
|
|
117
|
+
* );
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare function expectScriptMatchesIntegration(key: BuiltInScriptIntegrationKey, script: HelperScriptSnapshot, expected: ExpectedScriptSnapshot): void;
|
|
121
|
+
/**
|
|
122
|
+
* Converts an array-like value into a plain array.
|
|
123
|
+
*
|
|
124
|
+
* @param value - Array-like input such as `arguments`, a `NodeList`, or a
|
|
125
|
+
* vendor queue entry.
|
|
126
|
+
* @returns A new array containing the indexed values from `value`.
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* Passing `null` or `undefined` throws because `slice` requires an object-like
|
|
130
|
+
* value.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* function collectArgs(...args: unknown[]) {
|
|
135
|
+
* return toArgumentsArray(args);
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare function toArgumentsArray(value: unknown): unknown[];
|
|
140
|
+
export declare function expectGoogleConsentDefault(entry: unknown): void;
|
|
141
|
+
export declare function expectStubCommandQueue(stub: unknown, queueKey: string, commands: unknown[][]): void;
|