@c15t/scripts 1.0.1 → 1.1.0-rc.1
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/dist/databuddy.cjs +105 -50
- package/dist/databuddy.js +99 -47
- package/dist/engine/compile.cjs +126 -0
- package/dist/engine/compile.js +89 -0
- package/dist/engine/runtime.cjs +379 -0
- package/dist/engine/runtime.js +345 -0
- package/dist/google-tag-manager.cjs +80 -96
- package/dist/google-tag-manager.js +74 -87
- package/dist/google-tag.cjs +88 -39
- package/dist/google-tag.js +82 -36
- package/dist/linkedin-insights.cjs +52 -41
- package/dist/linkedin-insights.js +45 -37
- package/dist/meta-pixel.cjs +92 -26
- package/dist/meta-pixel.js +86 -23
- package/dist/microsoft-uet.cjs +92 -52
- package/dist/microsoft-uet.js +86 -49
- package/dist/posthog.cjs +102 -53
- package/dist/posthog.js +96 -50
- package/dist/resolve.cjs +67 -0
- package/dist/resolve.js +33 -0
- package/dist/tiktok-pixel.cjs +93 -27
- package/dist/tiktok-pixel.js +86 -23
- package/dist/types.cjs +47 -0
- package/dist/types.js +7 -0
- package/dist/x-pixel.cjs +49 -19
- package/dist/x-pixel.js +42 -15
- package/dist-types/databuddy.d.ts +144 -0
- package/dist-types/engine/compile.d.ts +3 -0
- package/dist-types/engine/runtime.d.ts +3 -0
- package/dist-types/engine.test.d.ts +1 -0
- package/dist-types/google-tag-manager.d.ts +97 -0
- package/dist-types/google-tag.d.ts +96 -0
- package/dist-types/helpers.test.d.ts +1 -0
- package/dist-types/linkedin-insights.d.ts +79 -0
- package/{dist → dist-types}/meta-pixel.d.ts +61 -14
- package/dist-types/microsoft-uet.d.ts +94 -0
- package/dist-types/posthog.d.ts +112 -0
- package/dist-types/resolve.d.ts +9 -0
- package/dist-types/tiktok-pixel.d.ts +91 -0
- package/dist-types/types.d.ts +259 -0
- package/{dist → dist-types}/x-pixel.d.ts +38 -12
- package/package.json +46 -45
- package/LICENSE.md +0 -595
- package/dist/databuddy.d.ts +0 -104
- package/dist/databuddy.d.ts.map +0 -1
- package/dist/google-tag-manager.d.ts +0 -63
- package/dist/google-tag-manager.d.ts.map +0 -1
- package/dist/google-tag.d.ts +0 -38
- package/dist/google-tag.d.ts.map +0 -1
- package/dist/linkedin-insights.d.ts +0 -48
- package/dist/linkedin-insights.d.ts.map +0 -1
- package/dist/meta-pixel.d.ts.map +0 -1
- package/dist/microsoft-uet.d.ts +0 -40
- package/dist/microsoft-uet.d.ts.map +0 -1
- package/dist/posthog.d.ts +0 -54
- package/dist/posthog.d.ts.map +0 -1
- package/dist/tiktok-pixel.d.ts +0 -44
- package/dist/tiktok-pixel.d.ts.map +0 -1
- package/dist/x-pixel.d.ts.map +0 -1
|
@@ -83,27 +83,75 @@ declare global {
|
|
|
83
83
|
_fbq: Window['fbq'];
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Meta Pixel vendor manifest.
|
|
88
|
+
*
|
|
89
|
+
* The Meta Pixel uses structured bootstrap steps to define the standard `fbq`
|
|
90
|
+
* stub and provides a consent API via `fbq('consent', 'grant'|'revoke')`.
|
|
91
|
+
*/
|
|
92
|
+
export declare const metaPixelManifest: {
|
|
93
|
+
readonly vendor: "meta-pixel";
|
|
94
|
+
readonly category: "marketing";
|
|
95
|
+
readonly persistAfterConsentRevoked: true;
|
|
96
|
+
readonly bootstrap: [{
|
|
97
|
+
readonly type: "defineStubFunction";
|
|
98
|
+
readonly name: "fbq";
|
|
99
|
+
readonly queue: {
|
|
100
|
+
readonly property: "queue";
|
|
101
|
+
};
|
|
102
|
+
readonly dispatchProperty: "callMethod";
|
|
103
|
+
readonly selfReferences: ["push"];
|
|
104
|
+
readonly aliases: ["_fbq"];
|
|
105
|
+
readonly properties: {
|
|
106
|
+
readonly loaded: true;
|
|
107
|
+
readonly version: "2.0";
|
|
108
|
+
};
|
|
109
|
+
readonly ifUndefined: true;
|
|
110
|
+
}];
|
|
111
|
+
readonly install: [{
|
|
112
|
+
readonly type: "callGlobal";
|
|
113
|
+
readonly global: "fbq";
|
|
114
|
+
readonly args: ["consent", "grant"];
|
|
115
|
+
}, {
|
|
116
|
+
readonly type: "callGlobal";
|
|
117
|
+
readonly global: "fbq";
|
|
118
|
+
readonly args: ["init", "{{pixelId}}"];
|
|
119
|
+
}, {
|
|
120
|
+
readonly type: "callGlobal";
|
|
121
|
+
readonly global: "fbq";
|
|
122
|
+
readonly args: ["track", "PageView"];
|
|
123
|
+
}, {
|
|
124
|
+
readonly type: "loadScript";
|
|
125
|
+
readonly src: "{{scriptSrc}}";
|
|
126
|
+
readonly async: true;
|
|
127
|
+
}];
|
|
128
|
+
readonly onConsentGranted: [{
|
|
129
|
+
readonly type: "callGlobal";
|
|
130
|
+
readonly global: "fbq";
|
|
131
|
+
readonly args: ["consent", "grant"];
|
|
132
|
+
}];
|
|
133
|
+
readonly onConsentDenied: [{
|
|
134
|
+
readonly type: "callGlobal";
|
|
135
|
+
readonly global: "fbq";
|
|
136
|
+
readonly args: ["consent", "revoke"];
|
|
137
|
+
}];
|
|
138
|
+
readonly kind: "c15t.vendor-manifest";
|
|
139
|
+
readonly schemaVersion: 1;
|
|
140
|
+
};
|
|
86
141
|
export interface MetaPixelOptions {
|
|
87
142
|
/**
|
|
88
143
|
* Your Meta Pixel ID
|
|
89
144
|
* @example `123456789012345`
|
|
90
145
|
*/
|
|
91
146
|
pixelId: string;
|
|
92
|
-
/**
|
|
93
|
-
|
|
94
|
-
*
|
|
95
|
-
* Default values:
|
|
96
|
-
* - `id`: 'meta-pixel'
|
|
97
|
-
* - `src`: `https://connect.facebook.net/en_US/fbevents.js`
|
|
98
|
-
* - `category`: 'marketing'
|
|
99
|
-
*/
|
|
100
|
-
script?: Partial<Script>;
|
|
147
|
+
/** Meta Pixel loader URL. */
|
|
148
|
+
scriptSrc?: string;
|
|
101
149
|
}
|
|
102
150
|
/**
|
|
103
|
-
* Creates a Meta Pixel script
|
|
151
|
+
* Creates a Meta Pixel script.
|
|
104
152
|
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
153
|
+
* The manifest defines a structured `fbq` stub plus the external loader URL,
|
|
154
|
+
* avoiding raw inline vendor snippets in the manifest payload.
|
|
107
155
|
*
|
|
108
156
|
* @param options - The options for the Meta Pixel script
|
|
109
157
|
* @returns The Meta Pixel script configuration
|
|
@@ -117,7 +165,7 @@ export interface MetaPixelOptions {
|
|
|
117
165
|
*
|
|
118
166
|
* @see {@link https://developers.facebook.com/docs/meta-pixel/get-started} Meta Pixel documentation
|
|
119
167
|
*/
|
|
120
|
-
export declare function metaPixel({ pixelId,
|
|
168
|
+
export declare function metaPixel({ pixelId, scriptSrc }: MetaPixelOptions): Script;
|
|
121
169
|
/**
|
|
122
170
|
* Meta Pixel Event
|
|
123
171
|
* This is a wrapper around the `fbq` function that the Meta Pixel script uses.
|
|
@@ -135,4 +183,3 @@ export declare function metaPixel({ pixelId, script }: MetaPixelOptions): Script
|
|
|
135
183
|
*/
|
|
136
184
|
export declare const metaPixelEvent: <TEventName extends StandardEventName>(eventName: TEventName, params?: StandardEventParams[TEventName], eventId?: string) => void;
|
|
137
185
|
export {};
|
|
138
|
-
//# sourceMappingURL=meta-pixel.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
uetq: unknown[] | undefined;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Microsoft UET vendor manifest.
|
|
9
|
+
*
|
|
10
|
+
* Uses structured startup steps and manages consent via the UET push API:
|
|
11
|
+
* `window.uetq.push('consent', 'default'|'update', { ad_storage: 'granted'|'denied' })`
|
|
12
|
+
*/
|
|
13
|
+
export declare const microsoftUetManifest: {
|
|
14
|
+
readonly vendor: "microsoft-uet";
|
|
15
|
+
readonly category: "marketing";
|
|
16
|
+
readonly persistAfterConsentRevoked: true;
|
|
17
|
+
readonly bootstrap: [{
|
|
18
|
+
readonly type: "setGlobal";
|
|
19
|
+
readonly name: "uetq";
|
|
20
|
+
readonly value: readonly [];
|
|
21
|
+
readonly ifUndefined: true;
|
|
22
|
+
}];
|
|
23
|
+
readonly install: [{
|
|
24
|
+
readonly type: "loadScript";
|
|
25
|
+
readonly src: "{{scriptSrc}}";
|
|
26
|
+
readonly async: true;
|
|
27
|
+
}];
|
|
28
|
+
readonly afterLoad: [{
|
|
29
|
+
readonly type: "constructGlobal";
|
|
30
|
+
readonly constructor: "UET";
|
|
31
|
+
readonly assignTo: "uetq";
|
|
32
|
+
readonly args: [{
|
|
33
|
+
readonly ti: "{{id}}";
|
|
34
|
+
readonly enableAutoSpaTracking: true;
|
|
35
|
+
}];
|
|
36
|
+
readonly copyAssignedValueToArgProperty: "q";
|
|
37
|
+
}, {
|
|
38
|
+
readonly type: "callGlobal";
|
|
39
|
+
readonly global: "uetq";
|
|
40
|
+
readonly method: "push";
|
|
41
|
+
readonly args: ["pageLoad"];
|
|
42
|
+
}, {
|
|
43
|
+
readonly type: "callGlobal";
|
|
44
|
+
readonly global: "uetq";
|
|
45
|
+
readonly method: "push";
|
|
46
|
+
readonly args: ["consent", "default", {
|
|
47
|
+
readonly ad_storage: "granted";
|
|
48
|
+
}];
|
|
49
|
+
}];
|
|
50
|
+
readonly onConsentGranted: [{
|
|
51
|
+
readonly type: "callGlobal";
|
|
52
|
+
readonly global: "uetq";
|
|
53
|
+
readonly method: "push";
|
|
54
|
+
readonly args: ["consent", "update", {
|
|
55
|
+
readonly ad_storage: "granted";
|
|
56
|
+
}];
|
|
57
|
+
}];
|
|
58
|
+
readonly onConsentDenied: [{
|
|
59
|
+
readonly type: "callGlobal";
|
|
60
|
+
readonly global: "uetq";
|
|
61
|
+
readonly method: "push";
|
|
62
|
+
readonly args: ["consent", "update", {
|
|
63
|
+
readonly ad_storage: "denied";
|
|
64
|
+
}];
|
|
65
|
+
}];
|
|
66
|
+
readonly kind: "c15t.vendor-manifest";
|
|
67
|
+
readonly schemaVersion: 1;
|
|
68
|
+
};
|
|
69
|
+
export interface MicrosoftUetOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Your Microsoft UET ID
|
|
72
|
+
* @example `123456789012345`
|
|
73
|
+
*/
|
|
74
|
+
id: string;
|
|
75
|
+
/** Microsoft UET loader URL. */
|
|
76
|
+
scriptSrc?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Microsoft UET Script
|
|
80
|
+
* This script is persistent after consent is revoked because it has built-in functionality to opt into and out of tracking based on consent, which allows us to not need to load the script again when consent is revoked.
|
|
81
|
+
*
|
|
82
|
+
* @param options - The options for the Microsoft UET script
|
|
83
|
+
* @returns The Microsoft UET script configuration
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const microsoftUetScript = microsoftUet({
|
|
88
|
+
* id: '123456789012345',
|
|
89
|
+
* });
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @see https://learn.microsoft.com/en-us/advertising/guides/universal-event-tracking?view=bingads-13
|
|
93
|
+
*/
|
|
94
|
+
export declare function microsoftUet({ id, scriptSrc }: MicrosoftUetOptions): Script;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
posthog: {
|
|
5
|
+
init: (token: string, options: {
|
|
6
|
+
api_host: string;
|
|
7
|
+
ui_host?: string;
|
|
8
|
+
autocapture?: boolean;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}) => void;
|
|
11
|
+
opt_in_capturing: () => void;
|
|
12
|
+
opt_out_capturing: () => void;
|
|
13
|
+
get_explicit_consent_status: () => string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* PostHog vendor manifest.
|
|
19
|
+
*
|
|
20
|
+
* PostHog manages its own consent internally via opt_in/opt_out capturing.
|
|
21
|
+
* The script always loads, and consent is toggled via the PostHog API.
|
|
22
|
+
*/
|
|
23
|
+
export declare const posthogManifest: {
|
|
24
|
+
readonly vendor: "posthog";
|
|
25
|
+
readonly category: "measurement";
|
|
26
|
+
readonly alwaysLoad: true;
|
|
27
|
+
readonly bootstrap: [{
|
|
28
|
+
readonly type: "setGlobal";
|
|
29
|
+
readonly name: "posthog";
|
|
30
|
+
readonly value: {};
|
|
31
|
+
readonly ifUndefined: true;
|
|
32
|
+
}, {
|
|
33
|
+
readonly type: "defineGlobalMethods";
|
|
34
|
+
readonly target: "posthog";
|
|
35
|
+
readonly methods: [{
|
|
36
|
+
readonly name: "init";
|
|
37
|
+
readonly behavior: "noop";
|
|
38
|
+
}, {
|
|
39
|
+
readonly name: "opt_in_capturing";
|
|
40
|
+
readonly behavior: "noop";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "opt_out_capturing";
|
|
43
|
+
readonly behavior: "noop";
|
|
44
|
+
}, {
|
|
45
|
+
readonly name: "get_explicit_consent_status";
|
|
46
|
+
readonly behavior: "return";
|
|
47
|
+
readonly value: "pending";
|
|
48
|
+
}];
|
|
49
|
+
}];
|
|
50
|
+
readonly install: [{
|
|
51
|
+
readonly type: "loadScript";
|
|
52
|
+
readonly src: "{{scriptUrl}}";
|
|
53
|
+
readonly async: true;
|
|
54
|
+
readonly attributes: {
|
|
55
|
+
readonly crossorigin: "anonymous";
|
|
56
|
+
readonly 'data-api-host': "{{apiHost}}";
|
|
57
|
+
readonly 'data-ui-host': "{{apiHost}}";
|
|
58
|
+
};
|
|
59
|
+
}];
|
|
60
|
+
readonly afterLoad: [{
|
|
61
|
+
readonly type: "callGlobal";
|
|
62
|
+
readonly global: "posthog";
|
|
63
|
+
readonly method: "init";
|
|
64
|
+
readonly args: ["{{id}}", "{{initOptions}}"];
|
|
65
|
+
}];
|
|
66
|
+
readonly onLoadGranted: [{
|
|
67
|
+
readonly type: "callGlobal";
|
|
68
|
+
readonly global: "posthog";
|
|
69
|
+
readonly method: "opt_in_capturing";
|
|
70
|
+
}];
|
|
71
|
+
readonly onLoadDenied: [{
|
|
72
|
+
readonly type: "callGlobal";
|
|
73
|
+
readonly global: "posthog";
|
|
74
|
+
readonly method: "opt_out_capturing";
|
|
75
|
+
}];
|
|
76
|
+
readonly onConsentGranted: [{
|
|
77
|
+
readonly type: "callGlobal";
|
|
78
|
+
readonly global: "posthog";
|
|
79
|
+
readonly method: "opt_in_capturing";
|
|
80
|
+
}];
|
|
81
|
+
readonly onConsentDenied: [{
|
|
82
|
+
readonly type: "callGlobal";
|
|
83
|
+
readonly global: "posthog";
|
|
84
|
+
readonly method: "opt_out_capturing";
|
|
85
|
+
}];
|
|
86
|
+
readonly kind: "c15t.vendor-manifest";
|
|
87
|
+
readonly schemaVersion: 1;
|
|
88
|
+
};
|
|
89
|
+
export interface PosthogConsentOptions {
|
|
90
|
+
/**
|
|
91
|
+
* Your posthog id, begins with 'phc_'.
|
|
92
|
+
*/
|
|
93
|
+
id: string;
|
|
94
|
+
/**
|
|
95
|
+
* Your posthog api host.
|
|
96
|
+
* @default 'https://eu.i.posthog.com'
|
|
97
|
+
*/
|
|
98
|
+
apiHost?: string;
|
|
99
|
+
/** The PostHog array loader URL. */
|
|
100
|
+
scriptUrl?: string;
|
|
101
|
+
/** PostHog init options passed to `posthog.init(...)`. */
|
|
102
|
+
initOptions?: Record<string, unknown>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Loads the PostHog script and initializes it with the given options.
|
|
106
|
+
* This uses posthog.opt_in_capturing() to opt in to capturing. And posthog.opt_out_capturing() to opt out of capturing.
|
|
107
|
+
* @see https://posthog.com/docs/libraries/js#opt-in-capturing
|
|
108
|
+
*
|
|
109
|
+
* @param options - Optional configuration for the PostHog consent script
|
|
110
|
+
* @returns The Posthog script
|
|
111
|
+
*/
|
|
112
|
+
export declare function posthog(options: PosthogConsentOptions): Script;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
import type { VendorManifest } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Compiles a `VendorManifest` + config into a `Script` object.
|
|
5
|
+
*
|
|
6
|
+
* This compatibility wrapper preserves the existing public resolver API while
|
|
7
|
+
* delegating to the new compile and runtime conversion phases internally.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveManifest(manifest: VendorManifest, config?: Record<string, unknown>): Script;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
ttq: {
|
|
5
|
+
grantConsent: () => void;
|
|
6
|
+
revokeConsent: () => void;
|
|
7
|
+
page: () => void;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* TikTok Pixel vendor manifest.
|
|
13
|
+
*
|
|
14
|
+
* Uses structured bootstrap steps and provides a consent API
|
|
15
|
+
* via `ttq.grantConsent()` / `ttq.revokeConsent()`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const tiktokPixelManifest: {
|
|
18
|
+
readonly vendor: "tiktok-pixel";
|
|
19
|
+
readonly category: "marketing";
|
|
20
|
+
readonly persistAfterConsentRevoked: true;
|
|
21
|
+
readonly bootstrap: [{
|
|
22
|
+
readonly type: "setGlobal";
|
|
23
|
+
readonly name: "TiktokAnalyticsObject";
|
|
24
|
+
readonly value: "ttq";
|
|
25
|
+
}, {
|
|
26
|
+
readonly type: "setGlobal";
|
|
27
|
+
readonly name: "ttq";
|
|
28
|
+
readonly value: readonly [];
|
|
29
|
+
readonly ifUndefined: true;
|
|
30
|
+
}, {
|
|
31
|
+
readonly type: "defineQueueMethods";
|
|
32
|
+
readonly target: "ttq";
|
|
33
|
+
readonly methods: ["page", "track", "identify", "instances", "debug", "on", "off", "once", "ready", "alias", "group", "enableCookie", "disableCookie", "holdConsent", "revokeConsent", "grantConsent"];
|
|
34
|
+
}];
|
|
35
|
+
readonly install: [{
|
|
36
|
+
readonly type: "callGlobal";
|
|
37
|
+
readonly global: "ttq";
|
|
38
|
+
readonly method: "grantConsent";
|
|
39
|
+
}, {
|
|
40
|
+
readonly type: "callGlobal";
|
|
41
|
+
readonly global: "ttq";
|
|
42
|
+
readonly method: "page";
|
|
43
|
+
}, {
|
|
44
|
+
readonly type: "loadScript";
|
|
45
|
+
readonly src: "{{scriptSrc}}?sdkid={{pixelId}}&lib=ttq";
|
|
46
|
+
readonly async: true;
|
|
47
|
+
}];
|
|
48
|
+
readonly afterLoad: [{
|
|
49
|
+
readonly type: "callGlobal";
|
|
50
|
+
readonly global: "ttq";
|
|
51
|
+
readonly method: "grantConsent";
|
|
52
|
+
}];
|
|
53
|
+
readonly onConsentGranted: [{
|
|
54
|
+
readonly type: "callGlobal";
|
|
55
|
+
readonly global: "ttq";
|
|
56
|
+
readonly method: "grantConsent";
|
|
57
|
+
}];
|
|
58
|
+
readonly onConsentDenied: [{
|
|
59
|
+
readonly type: "callGlobal";
|
|
60
|
+
readonly global: "ttq";
|
|
61
|
+
readonly method: "revokeConsent";
|
|
62
|
+
}];
|
|
63
|
+
readonly kind: "c15t.vendor-manifest";
|
|
64
|
+
readonly schemaVersion: 1;
|
|
65
|
+
};
|
|
66
|
+
export interface TikTokPixelOptions {
|
|
67
|
+
/**
|
|
68
|
+
* Your TikTok Pixel ID
|
|
69
|
+
* @example `123456789012345`
|
|
70
|
+
*/
|
|
71
|
+
pixelId: string;
|
|
72
|
+
/** TikTok Pixel loader base URL. */
|
|
73
|
+
scriptSrc?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Creates a Tiktok Pixel script.
|
|
77
|
+
* This script is persistent after consent is revoked because it has built-in functionality to opt into and out of tracking based on consent, which allows us to not need to load the script again when consent is revoked.
|
|
78
|
+
*
|
|
79
|
+
* @param options - The options for the TikTok Pixel script
|
|
80
|
+
* @returns The TikTok Pixel script configuration
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const tiktokPixelScript = tiktokPixel({
|
|
85
|
+
* pixelId: '123456789012345',
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @see {@link https://ads.tiktok.com/help/article/tiktok-pixel} TikTok Pixel documentation
|
|
90
|
+
*/
|
|
91
|
+
export declare function tiktokPixel({ pixelId, scriptSrc, }: TikTokPixelOptions): Script;
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import type { AllConsentNames, HasCondition } from 'c15t';
|
|
2
|
+
export declare const VENDOR_MANIFEST_KIND = "c15t.vendor-manifest";
|
|
3
|
+
export declare const VENDOR_MANIFEST_SCHEMA_VERSION = 1;
|
|
4
|
+
export declare const vendorManifestContract: {
|
|
5
|
+
readonly kind: "c15t.vendor-manifest";
|
|
6
|
+
readonly schemaVersion: 1;
|
|
7
|
+
};
|
|
8
|
+
export interface ManifestContract {
|
|
9
|
+
kind: typeof VENDOR_MANIFEST_KIND;
|
|
10
|
+
schemaVersion: typeof VENDOR_MANIFEST_SCHEMA_VERSION;
|
|
11
|
+
}
|
|
12
|
+
type ManifestInterpolationToken = `{{${string}}}`;
|
|
13
|
+
export type ManifestCategoryCondition = HasCondition<AllConsentNames | ManifestInterpolationToken>;
|
|
14
|
+
export interface LoadScriptStep {
|
|
15
|
+
type: 'loadScript';
|
|
16
|
+
src: string;
|
|
17
|
+
async?: boolean;
|
|
18
|
+
defer?: boolean;
|
|
19
|
+
attributes?: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
export interface SetGlobalStep {
|
|
22
|
+
type: 'setGlobal';
|
|
23
|
+
/** Global variable name (e.g. 'dataLayer') */
|
|
24
|
+
name: string;
|
|
25
|
+
/** Value to assign. Arrays and objects are recursively cloned on execution. */
|
|
26
|
+
value: unknown;
|
|
27
|
+
/**
|
|
28
|
+
* Only set the global if it's not already defined.
|
|
29
|
+
* Mirrors the common `window.x = window.x || value` pattern.
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
ifUndefined?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface DefineQueueFunctionStep {
|
|
35
|
+
type: 'defineQueueFunction';
|
|
36
|
+
/** Global function name (e.g. 'gtag') */
|
|
37
|
+
name: string;
|
|
38
|
+
/** Global array name that receives queued calls (e.g. 'dataLayer') */
|
|
39
|
+
queue: string;
|
|
40
|
+
/**
|
|
41
|
+
* Only define the function if it is not already present.
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
ifUndefined?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether queued calls should store the `arguments` object or a copied array.
|
|
47
|
+
* @default 'arguments'
|
|
48
|
+
*/
|
|
49
|
+
pushStyle?: 'arguments' | 'array';
|
|
50
|
+
}
|
|
51
|
+
export interface DefineStubFunctionStep {
|
|
52
|
+
type: 'defineStubFunction';
|
|
53
|
+
/** Global function name (e.g. 'fbq', 'twq', 'lintrk') */
|
|
54
|
+
name: string;
|
|
55
|
+
/**
|
|
56
|
+
* Queue storage location:
|
|
57
|
+
* - `global` pushes into another global array (e.g. `dataLayer`)
|
|
58
|
+
* - `property` pushes into a property on the stub function itself (e.g. `fbq.queue`)
|
|
59
|
+
*/
|
|
60
|
+
queue: {
|
|
61
|
+
global: string;
|
|
62
|
+
property?: never;
|
|
63
|
+
} | {
|
|
64
|
+
global?: never;
|
|
65
|
+
property: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* If present, calls `stub[dispatchProperty](...args)` when available instead of queueing.
|
|
69
|
+
* Mirrors vendor APIs like Meta Pixel's `callMethod`.
|
|
70
|
+
*/
|
|
71
|
+
dispatchProperty?: string;
|
|
72
|
+
/**
|
|
73
|
+
* How queued values should be stored.
|
|
74
|
+
* - `'arguments'` => push the `arguments` object
|
|
75
|
+
* - `'array'` => push a copied array of arguments
|
|
76
|
+
*/
|
|
77
|
+
queueFormat?: 'arguments' | 'array';
|
|
78
|
+
/** Additional globals that should reference the same stub */
|
|
79
|
+
aliases?: string[];
|
|
80
|
+
/** Properties on the stub that should reference the stub itself (e.g. `push`) */
|
|
81
|
+
selfReferences?: string[];
|
|
82
|
+
/** Additional scalar/object properties assigned to the stub */
|
|
83
|
+
properties?: Record<string, unknown>;
|
|
84
|
+
/** Only define the stub if not already present. */
|
|
85
|
+
ifUndefined?: boolean;
|
|
86
|
+
}
|
|
87
|
+
export interface CallGlobalStep {
|
|
88
|
+
type: 'callGlobal';
|
|
89
|
+
/** Global object name (e.g. 'posthog', 'fbq') */
|
|
90
|
+
global: string;
|
|
91
|
+
/** Method to call on the global. If omitted, the global itself is called as a function. */
|
|
92
|
+
method?: string;
|
|
93
|
+
/** Arguments to pass */
|
|
94
|
+
args?: unknown[];
|
|
95
|
+
}
|
|
96
|
+
export interface PushToQueueStep {
|
|
97
|
+
type: 'pushToQueue';
|
|
98
|
+
/** Global array name that receives queued values (e.g. 'dataLayer') */
|
|
99
|
+
queue: string;
|
|
100
|
+
/** Value to push onto the queue */
|
|
101
|
+
value: unknown;
|
|
102
|
+
}
|
|
103
|
+
export interface SetGlobalPathStep {
|
|
104
|
+
type: 'setGlobalPath';
|
|
105
|
+
/** Path segments under window (e.g. ['databuddy', 'options', 'disabled']) */
|
|
106
|
+
path: string[];
|
|
107
|
+
/** Value to assign at the target path */
|
|
108
|
+
value: unknown;
|
|
109
|
+
}
|
|
110
|
+
export interface DefineQueueMethodsStep {
|
|
111
|
+
type: 'defineQueueMethods';
|
|
112
|
+
/** Global array/object name that owns the queue methods */
|
|
113
|
+
target: string;
|
|
114
|
+
/** Method names to attach */
|
|
115
|
+
methods: string[];
|
|
116
|
+
/** Optional queue location. Defaults to the target itself. */
|
|
117
|
+
queue?: {
|
|
118
|
+
global: string;
|
|
119
|
+
property?: never;
|
|
120
|
+
} | {
|
|
121
|
+
global?: never;
|
|
122
|
+
property: string;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export type GlobalMethodBehavior = {
|
|
126
|
+
name: string;
|
|
127
|
+
behavior: 'noop';
|
|
128
|
+
} | {
|
|
129
|
+
name: string;
|
|
130
|
+
behavior: 'return';
|
|
131
|
+
value: unknown;
|
|
132
|
+
};
|
|
133
|
+
export interface DefineGlobalMethodsStep {
|
|
134
|
+
type: 'defineGlobalMethods';
|
|
135
|
+
/** Global object name to receive the methods */
|
|
136
|
+
target: string;
|
|
137
|
+
methods: Array<GlobalMethodBehavior>;
|
|
138
|
+
}
|
|
139
|
+
export interface ConstructGlobalStep {
|
|
140
|
+
type: 'constructGlobal';
|
|
141
|
+
/** Global constructor name (e.g. `UET`) */
|
|
142
|
+
constructor: string;
|
|
143
|
+
/** Global name to assign the constructed instance to */
|
|
144
|
+
assignTo: string;
|
|
145
|
+
/** Constructor args */
|
|
146
|
+
args?: unknown[];
|
|
147
|
+
/**
|
|
148
|
+
* Copies the current `window[assignTo]` value into the first constructor arg object
|
|
149
|
+
* under this property before constructing.
|
|
150
|
+
*/
|
|
151
|
+
copyAssignedValueToArgProperty?: string;
|
|
152
|
+
}
|
|
153
|
+
export type ManifestStep = LoadScriptStep | SetGlobalStep | DefineQueueFunctionStep | DefineStubFunctionStep | CallGlobalStep | PushToQueueStep | SetGlobalPathStep | DefineQueueMethodsStep | DefineGlobalMethodsStep | ConstructGlobalStep;
|
|
154
|
+
/**
|
|
155
|
+
* Consent signal type determines how consent state is communicated to the vendor.
|
|
156
|
+
*
|
|
157
|
+
* - `'gtag'` — Google Consent Mode pattern: calls `gtag('consent', 'default'|'update', state)`
|
|
158
|
+
*/
|
|
159
|
+
export type ConsentSignalType = 'gtag';
|
|
160
|
+
/**
|
|
161
|
+
* A declarative definition of a vendor integration.
|
|
162
|
+
*
|
|
163
|
+
* Manifests are the source definition that the scripts engine compiles into a
|
|
164
|
+
* serializable resolved manifest and then converts into a runtime `Script`.
|
|
165
|
+
*/
|
|
166
|
+
export interface VendorManifest extends ManifestContract {
|
|
167
|
+
/** Manifest contract identifier. */
|
|
168
|
+
kind: typeof VENDOR_MANIFEST_KIND;
|
|
169
|
+
/** Manifest schema version. */
|
|
170
|
+
schemaVersion: typeof VENDOR_MANIFEST_SCHEMA_VERSION;
|
|
171
|
+
/** Unique vendor identifier (used as Script.id) */
|
|
172
|
+
vendor: string;
|
|
173
|
+
/** Consent category or condition required to load this vendor */
|
|
174
|
+
category: ManifestCategoryCondition;
|
|
175
|
+
/** Load regardless of consent state (vendor manages its own consent internally) */
|
|
176
|
+
alwaysLoad?: boolean | string;
|
|
177
|
+
/** Keep script in DOM after consent revocation (vendor has a consent API) */
|
|
178
|
+
persistAfterConsentRevoked?: boolean | string;
|
|
179
|
+
/**
|
|
180
|
+
* Steps that must execute before default consent signaling.
|
|
181
|
+
*
|
|
182
|
+
* This is primarily used for integrations such as Google tags where a stub
|
|
183
|
+
* global must exist before calling the vendor's consent API.
|
|
184
|
+
*/
|
|
185
|
+
bootstrap?: ManifestStep[];
|
|
186
|
+
/**
|
|
187
|
+
* Steps to execute when installing the vendor.
|
|
188
|
+
*
|
|
189
|
+
* The resolver extracts the script source from these steps:
|
|
190
|
+
* - If a `loadScript` step exists, its `src` becomes `Script.src`
|
|
191
|
+
* - All non-`loadScript` steps run as part of `onBeforeLoad`
|
|
192
|
+
*/
|
|
193
|
+
install: ManifestStep[];
|
|
194
|
+
/** Steps to execute after the main script loads */
|
|
195
|
+
afterLoad?: ManifestStep[];
|
|
196
|
+
/** Steps to execute before load when the vendor has consent */
|
|
197
|
+
onBeforeLoadGranted?: ManifestStep[];
|
|
198
|
+
/** Steps to execute before load when the vendor does not have consent */
|
|
199
|
+
onBeforeLoadDenied?: ManifestStep[];
|
|
200
|
+
/** Steps to execute after load when the vendor has consent */
|
|
201
|
+
onLoadGranted?: ManifestStep[];
|
|
202
|
+
/** Steps to execute after load when the vendor does not have consent */
|
|
203
|
+
onLoadDenied?: ManifestStep[];
|
|
204
|
+
/** Steps to run on any consent state change */
|
|
205
|
+
onConsentChange?: ManifestStep[];
|
|
206
|
+
/** Steps to run when this vendor's category consent is granted */
|
|
207
|
+
onConsentGranted?: ManifestStep[];
|
|
208
|
+
/** Steps to run when this vendor's category consent is denied */
|
|
209
|
+
onConsentDenied?: ManifestStep[];
|
|
210
|
+
/**
|
|
211
|
+
* Maps c15t consent categories to vendor-specific consent type names.
|
|
212
|
+
*
|
|
213
|
+
* Used with `consentSignal` to translate c15t consent state into
|
|
214
|
+
* the vendor's consent API format.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* // Google Consent Mode v2 mapping
|
|
219
|
+
* consentMapping: {
|
|
220
|
+
* marketing: ['ad_storage', 'ad_user_data', 'ad_personalization'],
|
|
221
|
+
* measurement: ['analytics_storage'],
|
|
222
|
+
* functionality: ['functionality_storage'],
|
|
223
|
+
* necessary: ['security_storage'],
|
|
224
|
+
* experience: ['personalization_storage'],
|
|
225
|
+
* }
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
consentMapping?: Record<string, string[]>;
|
|
229
|
+
/** How to signal consent state to the vendor */
|
|
230
|
+
consentSignal?: ConsentSignalType;
|
|
231
|
+
/** Target global for consent signaling (defaults based on signal type) */
|
|
232
|
+
consentSignalTarget?: string;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Internal transport-ready manifest shape produced by the compile phase.
|
|
236
|
+
*
|
|
237
|
+
* Contains only serializable data and no runtime callbacks.
|
|
238
|
+
*/
|
|
239
|
+
export interface ResolvedManifest extends ManifestContract {
|
|
240
|
+
vendor: string;
|
|
241
|
+
category: HasCondition<AllConsentNames>;
|
|
242
|
+
alwaysLoad?: boolean;
|
|
243
|
+
persistAfterConsentRevoked?: boolean;
|
|
244
|
+
bootstrapSteps: ManifestStep[];
|
|
245
|
+
setupSteps: ManifestStep[];
|
|
246
|
+
loadScript?: LoadScriptStep;
|
|
247
|
+
afterLoadSteps: ManifestStep[];
|
|
248
|
+
onBeforeLoadGrantedSteps: ManifestStep[];
|
|
249
|
+
onBeforeLoadDeniedSteps: ManifestStep[];
|
|
250
|
+
onLoadGrantedSteps: ManifestStep[];
|
|
251
|
+
onLoadDeniedSteps: ManifestStep[];
|
|
252
|
+
onConsentChangeSteps: ManifestStep[];
|
|
253
|
+
onConsentGrantedSteps: ManifestStep[];
|
|
254
|
+
onConsentDeniedSteps: ManifestStep[];
|
|
255
|
+
consentMapping?: Record<string, string[]>;
|
|
256
|
+
consentSignal?: ConsentSignalType;
|
|
257
|
+
consentSignalTarget?: string;
|
|
258
|
+
}
|
|
259
|
+
export {};
|