@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,86 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
export type ClarityConsentValue = boolean | Record<string, string>;
|
|
3
|
+
type ClarityFunction = {
|
|
4
|
+
(command: 'consent', value?: ClarityConsentValue): void;
|
|
5
|
+
(command: 'event', value: string): void;
|
|
6
|
+
(command: 'identify', id: string, session?: string, page?: string): unknown;
|
|
7
|
+
(command: 'set', key: string, value: string | string[]): void;
|
|
8
|
+
(command: 'start', options?: Record<string, unknown>): void;
|
|
9
|
+
(command: 'upgrade', reason: string): void;
|
|
10
|
+
(command: string, ...args: unknown[]): unknown;
|
|
11
|
+
};
|
|
12
|
+
declare global {
|
|
13
|
+
interface Window {
|
|
14
|
+
clarity?: ClarityFunction & {
|
|
15
|
+
q?: unknown[][];
|
|
16
|
+
v?: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Microsoft Clarity vendor manifest.
|
|
22
|
+
*
|
|
23
|
+
* Seeds the global queue stub before loading the vendor bundle and uses
|
|
24
|
+
* Clarity's consent API for simple granted and denied transitions.
|
|
25
|
+
*/
|
|
26
|
+
export declare const clarityManifest: {
|
|
27
|
+
readonly vendor: "microsoft-clarity";
|
|
28
|
+
readonly category: "measurement";
|
|
29
|
+
readonly persistAfterConsentRevoked: true;
|
|
30
|
+
readonly bootstrap: [{
|
|
31
|
+
readonly type: "defineStubFunction";
|
|
32
|
+
readonly name: "clarity";
|
|
33
|
+
readonly queue: {
|
|
34
|
+
readonly property: "q";
|
|
35
|
+
};
|
|
36
|
+
readonly queueFormat: "array";
|
|
37
|
+
readonly properties: {
|
|
38
|
+
readonly v: "0.7.0";
|
|
39
|
+
};
|
|
40
|
+
readonly ifUndefined: true;
|
|
41
|
+
}];
|
|
42
|
+
readonly install: [{
|
|
43
|
+
readonly type: "loadScript";
|
|
44
|
+
readonly src: "{{scriptUrl}}";
|
|
45
|
+
readonly async: true;
|
|
46
|
+
}];
|
|
47
|
+
readonly onConsentGranted: [{
|
|
48
|
+
readonly type: "callGlobal";
|
|
49
|
+
readonly global: "clarity";
|
|
50
|
+
readonly args: ["consent", true];
|
|
51
|
+
}];
|
|
52
|
+
readonly onConsentDenied: [{
|
|
53
|
+
readonly type: "callGlobal";
|
|
54
|
+
readonly global: "clarity";
|
|
55
|
+
readonly args: ["consent", false];
|
|
56
|
+
}];
|
|
57
|
+
readonly kind: "c15t.vendor-manifest";
|
|
58
|
+
readonly schemaVersion: 1;
|
|
59
|
+
};
|
|
60
|
+
export interface ClarityOptions {
|
|
61
|
+
/**
|
|
62
|
+
* Your Microsoft Clarity project ID.
|
|
63
|
+
* @example `abcdef1234`
|
|
64
|
+
*/
|
|
65
|
+
id: string;
|
|
66
|
+
/**
|
|
67
|
+
* Optional initial consent value queued before the script loads.
|
|
68
|
+
*
|
|
69
|
+
* Object-shaped advanced consent vectors are supported only for this initial
|
|
70
|
+
* boot-time value. Later c15t consent changes are mapped to simple booleans.
|
|
71
|
+
*/
|
|
72
|
+
defaultConsent?: ClarityConsentValue;
|
|
73
|
+
/** Clarity loader URL. */
|
|
74
|
+
scriptUrl?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Creates a Microsoft Clarity script.
|
|
78
|
+
*
|
|
79
|
+
* @param options - The options for the Clarity script.
|
|
80
|
+
* @returns The Clarity script configuration.
|
|
81
|
+
* @throws {Error} When `options.id` is missing or invalid and no `scriptUrl`
|
|
82
|
+
* override is provided. Provide a valid Clarity project id string to prevent
|
|
83
|
+
* this error.
|
|
84
|
+
*/
|
|
85
|
+
export declare function clarity({ id, defaultConsent, scriptUrl, }: ClarityOptions): Script;
|
|
86
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
mixpanel?: {
|
|
5
|
+
init: (token: string, config?: Record<string, unknown>) => void;
|
|
6
|
+
track: (event: string, properties?: Record<string, unknown>) => void;
|
|
7
|
+
identify: (distinctId: string) => void;
|
|
8
|
+
reset: () => void;
|
|
9
|
+
register: (properties: Record<string, unknown>) => void;
|
|
10
|
+
opt_in_tracking: () => void;
|
|
11
|
+
opt_out_tracking: () => void;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Mixpanel vendor manifest.
|
|
17
|
+
*
|
|
18
|
+
* Mixpanel can stay loaded across consent changes and toggle tracking with its
|
|
19
|
+
* own opt-in and opt-out APIs.
|
|
20
|
+
*/
|
|
21
|
+
export declare const mixpanelAnalyticsManifest: {
|
|
22
|
+
readonly vendor: "mixpanel-analytics";
|
|
23
|
+
readonly category: "measurement";
|
|
24
|
+
readonly alwaysLoad: true;
|
|
25
|
+
readonly install: [{
|
|
26
|
+
readonly type: "setGlobal";
|
|
27
|
+
readonly name: "mixpanel";
|
|
28
|
+
readonly value: readonly [];
|
|
29
|
+
readonly ifUndefined: true;
|
|
30
|
+
}, {
|
|
31
|
+
readonly type: "defineQueueMethods";
|
|
32
|
+
readonly target: "mixpanel";
|
|
33
|
+
readonly methods: ["track", "identify", "reset", "register", "opt_in_tracking", "opt_out_tracking"];
|
|
34
|
+
}, {
|
|
35
|
+
readonly type: "loadScript";
|
|
36
|
+
readonly src: "{{scriptUrl}}";
|
|
37
|
+
readonly async: true;
|
|
38
|
+
}];
|
|
39
|
+
readonly afterLoad: [{
|
|
40
|
+
readonly type: "callGlobal";
|
|
41
|
+
readonly global: "mixpanel";
|
|
42
|
+
readonly method: "init";
|
|
43
|
+
readonly args: ["{{token}}", "{{initOptions}}"];
|
|
44
|
+
}];
|
|
45
|
+
readonly onLoadGranted: [{
|
|
46
|
+
readonly type: "callGlobal";
|
|
47
|
+
readonly global: "mixpanel";
|
|
48
|
+
readonly method: "opt_in_tracking";
|
|
49
|
+
}];
|
|
50
|
+
readonly onLoadDenied: [{
|
|
51
|
+
readonly type: "callGlobal";
|
|
52
|
+
readonly global: "mixpanel";
|
|
53
|
+
readonly method: "opt_out_tracking";
|
|
54
|
+
}];
|
|
55
|
+
readonly onConsentGranted: [{
|
|
56
|
+
readonly type: "callGlobal";
|
|
57
|
+
readonly global: "mixpanel";
|
|
58
|
+
readonly method: "opt_in_tracking";
|
|
59
|
+
}];
|
|
60
|
+
readonly onConsentDenied: [{
|
|
61
|
+
readonly type: "callGlobal";
|
|
62
|
+
readonly global: "mixpanel";
|
|
63
|
+
readonly method: "opt_out_tracking";
|
|
64
|
+
}];
|
|
65
|
+
readonly kind: "c15t.vendor-manifest";
|
|
66
|
+
readonly schemaVersion: 1;
|
|
67
|
+
};
|
|
68
|
+
export interface MixpanelAnalyticsOptions {
|
|
69
|
+
/** Your Mixpanel project token. */
|
|
70
|
+
token: string;
|
|
71
|
+
/**
|
|
72
|
+
* Mixpanel init options passed after the library loads.
|
|
73
|
+
*
|
|
74
|
+
* The manifest engine serializes this object as a template variable, so use
|
|
75
|
+
* JSON-serializable values only (no functions, class instances, prototypes,
|
|
76
|
+
* `Map`, `Set`, or other non-JSON types). Named instances and nested
|
|
77
|
+
* `people.*` queue helpers are intentionally out of scope for this helper.
|
|
78
|
+
*/
|
|
79
|
+
initOptions?: Record<string, unknown>;
|
|
80
|
+
/** Mixpanel loader URL. */
|
|
81
|
+
scriptUrl?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates a Mixpanel Analytics script.
|
|
85
|
+
*
|
|
86
|
+
* @param options - The options for the Mixpanel Analytics script.
|
|
87
|
+
* @returns The Mixpanel Analytics script configuration.
|
|
88
|
+
* @throws {Error} Throws when `token` is not a non-empty 32-character
|
|
89
|
+
* hexadecimal Mixpanel project token.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* import { mixpanelAnalytics } from '@c15t/scripts/mixpanel-analytics';
|
|
94
|
+
*
|
|
95
|
+
* const script = mixpanelAnalytics({
|
|
96
|
+
* token: '1234567890abcdef1234567890abcdef',
|
|
97
|
+
* initOptions: { debug: true },
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare function mixpanelAnalytics({ token, initOptions, scriptUrl, }: MixpanelAnalyticsOptions): Script;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
export type PlausibleExtension = 'hash' | 'outbound-links' | 'file-downloads' | 'tagged-events' | 'revenue' | 'pageview-props' | 'compat' | 'local' | 'manual';
|
|
3
|
+
export interface PlausibleInitOptions {
|
|
4
|
+
customProperties?: Record<string, unknown>;
|
|
5
|
+
endpoint?: string;
|
|
6
|
+
fileDownloads?: {
|
|
7
|
+
fileExtensions?: string[];
|
|
8
|
+
};
|
|
9
|
+
hashBasedRouting?: boolean;
|
|
10
|
+
autoCapturePageviews?: boolean;
|
|
11
|
+
captureOnLocalhost?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare global {
|
|
14
|
+
interface Window {
|
|
15
|
+
plausible?: ((...args: unknown[]) => void) & {
|
|
16
|
+
o?: PlausibleInitOptions;
|
|
17
|
+
q?: unknown[][];
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Plausible Analytics vendor manifest.
|
|
23
|
+
*
|
|
24
|
+
* Seeds a small queue stub so early `window.plausible(...)` calls can be
|
|
25
|
+
* buffered before the real tracker loads. Plausible is cookieless and only
|
|
26
|
+
* tracks page views, so the script is gated on `measurement` consent and is
|
|
27
|
+
* unloaded when consent is revoked.
|
|
28
|
+
*/
|
|
29
|
+
export declare const plausibleAnalyticsManifest: {
|
|
30
|
+
readonly vendor: "plausible-analytics";
|
|
31
|
+
readonly category: "measurement";
|
|
32
|
+
readonly bootstrap: [{
|
|
33
|
+
readonly type: "defineStubFunction";
|
|
34
|
+
readonly name: "plausible";
|
|
35
|
+
readonly queue: {
|
|
36
|
+
readonly property: "q";
|
|
37
|
+
};
|
|
38
|
+
readonly queueFormat: "array";
|
|
39
|
+
readonly properties: {
|
|
40
|
+
readonly o: "{{initOptions}}";
|
|
41
|
+
};
|
|
42
|
+
readonly ifUndefined: true;
|
|
43
|
+
}];
|
|
44
|
+
readonly install: [{
|
|
45
|
+
readonly type: "loadScript";
|
|
46
|
+
readonly src: "{{scriptUrl}}";
|
|
47
|
+
readonly defer: true;
|
|
48
|
+
readonly attributes: {
|
|
49
|
+
readonly 'data-domain': "{{domain}}";
|
|
50
|
+
readonly 'data-api': "{{apiAttribute}}";
|
|
51
|
+
};
|
|
52
|
+
}];
|
|
53
|
+
readonly kind: "c15t.vendor-manifest";
|
|
54
|
+
readonly schemaVersion: 1;
|
|
55
|
+
};
|
|
56
|
+
export interface PlausibleAnalyticsOptions {
|
|
57
|
+
/**
|
|
58
|
+
* Unique Plausible script ID for the new script format.
|
|
59
|
+
*/
|
|
60
|
+
scriptId?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Legacy domain-based site identifier.
|
|
63
|
+
*/
|
|
64
|
+
domain?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Legacy script extensions.
|
|
67
|
+
*/
|
|
68
|
+
extension?: PlausibleExtension | PlausibleExtension[];
|
|
69
|
+
/**
|
|
70
|
+
* Properties tracked with each pageview.
|
|
71
|
+
*/
|
|
72
|
+
customProperties?: Record<string, unknown>;
|
|
73
|
+
/**
|
|
74
|
+
* Custom tracking endpoint.
|
|
75
|
+
*/
|
|
76
|
+
endpoint?: string;
|
|
77
|
+
/**
|
|
78
|
+
* File download tracking configuration.
|
|
79
|
+
*/
|
|
80
|
+
fileDownloads?: {
|
|
81
|
+
fileExtensions?: string[];
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Enable hash-based routing support.
|
|
85
|
+
*/
|
|
86
|
+
hashBasedRouting?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Disable automatic pageview capture when set to `false`.
|
|
89
|
+
*/
|
|
90
|
+
autoCapturePageviews?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Enable tracking on localhost.
|
|
93
|
+
*/
|
|
94
|
+
captureOnLocalhost?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Custom loader URL.
|
|
97
|
+
*/
|
|
98
|
+
scriptUrl?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Creates a Plausible Analytics script.
|
|
102
|
+
*
|
|
103
|
+
* Models Plausible's queue bootstrap and loader attributes as a c15t-managed
|
|
104
|
+
* script. Supports both the new `scriptId`-based loader and the legacy
|
|
105
|
+
* `domain` + extension-based loader.
|
|
106
|
+
*
|
|
107
|
+
* @see https://plausible.io/docs/script-extensions
|
|
108
|
+
*
|
|
109
|
+
* @param options - The options for the Plausible Analytics script.
|
|
110
|
+
* @returns The Plausible Analytics script.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* import { plausibleAnalytics } from '@c15t/scripts/plausible-analytics';
|
|
115
|
+
*
|
|
116
|
+
* plausibleAnalytics({
|
|
117
|
+
* domain: 'example.com',
|
|
118
|
+
* extension: ['file-downloads', 'outbound-links'],
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export declare function plausibleAnalytics(options: PlausibleAnalyticsOptions): Script;
|
|
@@ -11,14 +11,18 @@ declare global {
|
|
|
11
11
|
opt_in_capturing: () => void;
|
|
12
12
|
opt_out_capturing: () => void;
|
|
13
13
|
get_explicit_consent_status: () => string;
|
|
14
|
+
capture: (event: string, properties?: Record<string, unknown>) => void;
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
17
|
}
|
|
18
|
+
export type PosthogRegion = 'eu' | 'us';
|
|
19
|
+
export type PosthogLoadMode = 'always' | 'after-consent' | 'disabled';
|
|
17
20
|
/**
|
|
18
21
|
* PostHog vendor manifest.
|
|
19
22
|
*
|
|
20
|
-
* PostHog manages its own consent internally via
|
|
21
|
-
*
|
|
23
|
+
* By default, PostHog manages its own consent internally via
|
|
24
|
+
* opt_in/opt_out capturing. The helper can also gate loading until
|
|
25
|
+
* measurement consent is granted.
|
|
22
26
|
*/
|
|
23
27
|
export declare const posthogManifest: {
|
|
24
28
|
readonly vendor: "posthog";
|
|
@@ -35,6 +39,9 @@ export declare const posthogManifest: {
|
|
|
35
39
|
readonly methods: [{
|
|
36
40
|
readonly name: "init";
|
|
37
41
|
readonly behavior: "noop";
|
|
42
|
+
}, {
|
|
43
|
+
readonly name: "capture";
|
|
44
|
+
readonly behavior: "noop";
|
|
38
45
|
}, {
|
|
39
46
|
readonly name: "opt_in_capturing";
|
|
40
47
|
readonly behavior: "noop";
|
|
@@ -54,7 +61,7 @@ export declare const posthogManifest: {
|
|
|
54
61
|
readonly attributes: {
|
|
55
62
|
readonly crossorigin: "anonymous";
|
|
56
63
|
readonly 'data-api-host': "{{apiHost}}";
|
|
57
|
-
readonly 'data-ui-host': "{{
|
|
64
|
+
readonly 'data-ui-host': "{{uiHost}}";
|
|
58
65
|
};
|
|
59
66
|
}];
|
|
60
67
|
readonly afterLoad: [{
|
|
@@ -91,19 +98,54 @@ export interface PosthogConsentOptions {
|
|
|
91
98
|
* Your posthog id, begins with 'phc_'.
|
|
92
99
|
*/
|
|
93
100
|
id: string;
|
|
101
|
+
/**
|
|
102
|
+
* PostHog Cloud region used to derive hosts when explicit host options are not
|
|
103
|
+
* provided.
|
|
104
|
+
* @default 'eu'
|
|
105
|
+
*/
|
|
106
|
+
region?: PosthogRegion;
|
|
94
107
|
/**
|
|
95
108
|
* Your posthog api host.
|
|
96
109
|
* @default 'https://eu.i.posthog.com'
|
|
97
110
|
*/
|
|
98
111
|
apiHost?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Your PostHog UI host. Defaults to the UI host for the selected region or
|
|
114
|
+
* inferred API host region.
|
|
115
|
+
*/
|
|
116
|
+
uiHost?: string;
|
|
99
117
|
/** The PostHog array loader URL. */
|
|
100
118
|
scriptUrl?: string;
|
|
119
|
+
/**
|
|
120
|
+
* How c15t should load the PostHog script.
|
|
121
|
+
*
|
|
122
|
+
* - `always`: load immediately and synchronize consent through PostHog APIs.
|
|
123
|
+
* - `after-consent`: wait for measurement consent before loading PostHog.
|
|
124
|
+
* - `disabled`: return an inert callback-only script with no network request.
|
|
125
|
+
*
|
|
126
|
+
* @default 'always'
|
|
127
|
+
*/
|
|
128
|
+
loadMode?: PosthogLoadMode;
|
|
101
129
|
/** PostHog init options passed to `posthog.init(...)`. */
|
|
102
130
|
initOptions?: Record<string, unknown>;
|
|
103
131
|
}
|
|
104
132
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
133
|
+
* Creates a c15t PostHog script helper.
|
|
134
|
+
*
|
|
135
|
+
* The `posthog()` helper uses `region` to resolve the PostHog API, UI, and
|
|
136
|
+
* bootstrap script hosts. By default, `loadMode: 'always'` loads PostHog
|
|
137
|
+
* immediately and syncs consent with `posthog.opt_in_capturing()` or
|
|
138
|
+
* `posthog.opt_out_capturing()`.
|
|
139
|
+
*
|
|
140
|
+
* With `loadMode: 'after-consent'`, the script is consent-gated and c15t calls
|
|
141
|
+
* `posthog.opt_in_capturing()` or `posthog.opt_out_capturing()` after load
|
|
142
|
+
* based on the user's measurement consent. With `loadMode: 'disabled'`, no
|
|
143
|
+
* PostHog script is loaded and no `posthog.opt_in_capturing()` or
|
|
144
|
+
* `posthog.opt_out_capturing()` calls are made.
|
|
145
|
+
*
|
|
146
|
+
* Edge case: `loadMode: 'disabled'` skips consent-related flows entirely; use it
|
|
147
|
+
* only when consumers manage PostHog loading and consent externally.
|
|
148
|
+
*
|
|
107
149
|
* @see https://posthog.com/docs/libraries/js#opt-in-capturing
|
|
108
150
|
*
|
|
109
151
|
* @param options - Optional configuration for the PostHog consent script
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
/**
|
|
3
|
+
* Promptwatch vendor manifest.
|
|
4
|
+
*
|
|
5
|
+
* Loads the Promptwatch client with your project id on the script element.
|
|
6
|
+
*/
|
|
7
|
+
export declare const promptwatchManifest: {
|
|
8
|
+
readonly vendor: "promptwatch";
|
|
9
|
+
readonly category: "measurement";
|
|
10
|
+
readonly install: [{
|
|
11
|
+
readonly type: "loadScript";
|
|
12
|
+
readonly src: "{{scriptUrl}}";
|
|
13
|
+
readonly async: true;
|
|
14
|
+
readonly attributes: {
|
|
15
|
+
readonly 'data-project-id': "{{projectId}}";
|
|
16
|
+
};
|
|
17
|
+
}];
|
|
18
|
+
readonly kind: "c15t.vendor-manifest";
|
|
19
|
+
readonly schemaVersion: 1;
|
|
20
|
+
};
|
|
21
|
+
export interface PromptwatchOptions {
|
|
22
|
+
/** Your Promptwatch project id (UUID from the Promptwatch dashboard). */
|
|
23
|
+
projectId: string;
|
|
24
|
+
/** Promptwatch client script URL. */
|
|
25
|
+
scriptUrl?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Promptwatch analytics script for AI traffic and usage insights.
|
|
29
|
+
*
|
|
30
|
+
* @param options - Promptwatch integration options.
|
|
31
|
+
* @param options.projectId - Promptwatch project id from your dashboard.
|
|
32
|
+
* @param options.scriptUrl - Optional custom script URL override.
|
|
33
|
+
* @throws {Error} When `projectId` is empty or only whitespace.
|
|
34
|
+
* @returns The Promptwatch script configuration.
|
|
35
|
+
*/
|
|
36
|
+
export declare function promptwatch({ projectId, scriptUrl, }: PromptwatchOptions): Script;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
rybbit?: {
|
|
5
|
+
clearUserId: () => void;
|
|
6
|
+
event: (name: string, properties?: Record<string, unknown>) => void;
|
|
7
|
+
getUserId: () => string | null;
|
|
8
|
+
identify: (userId: string) => void;
|
|
9
|
+
pageview: () => void;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Rybbit Analytics vendor manifest.
|
|
15
|
+
*
|
|
16
|
+
* Rybbit reads its configuration from script data attributes at load time.
|
|
17
|
+
*/
|
|
18
|
+
export declare const rybbitAnalyticsManifest: {
|
|
19
|
+
readonly vendor: "rybbit-analytics";
|
|
20
|
+
readonly category: "measurement";
|
|
21
|
+
readonly install: [{
|
|
22
|
+
readonly type: "loadScript";
|
|
23
|
+
readonly src: "{{scriptUrl}}";
|
|
24
|
+
readonly defer: true;
|
|
25
|
+
readonly attributes: {
|
|
26
|
+
readonly 'data-site-id': "{{siteId}}";
|
|
27
|
+
readonly 'data-auto-track-pageview': "{{autoTrackPageview}}";
|
|
28
|
+
readonly 'data-track-spa': "{{trackSpa}}";
|
|
29
|
+
readonly 'data-track-query': "{{trackQuery}}";
|
|
30
|
+
readonly 'data-track-outbound': "{{trackOutbound}}";
|
|
31
|
+
readonly 'data-track-errors': "{{trackErrors}}";
|
|
32
|
+
readonly 'data-session-replay': "{{sessionReplay}}";
|
|
33
|
+
readonly 'data-web-vitals': "{{webVitals}}";
|
|
34
|
+
readonly 'data-skip-patterns': "{{skipPatterns}}";
|
|
35
|
+
readonly 'data-mask-patterns': "{{maskPatterns}}";
|
|
36
|
+
readonly 'data-debounce': "{{debounce}}";
|
|
37
|
+
readonly 'data-api-key': "{{apiKey}}";
|
|
38
|
+
};
|
|
39
|
+
}];
|
|
40
|
+
readonly kind: "c15t.vendor-manifest";
|
|
41
|
+
readonly schemaVersion: 1;
|
|
42
|
+
};
|
|
43
|
+
export interface RybbitAnalyticsOptions {
|
|
44
|
+
/** Your Rybbit site ID. */
|
|
45
|
+
siteId: string | number;
|
|
46
|
+
/** Automatically track pageviews. */
|
|
47
|
+
autoTrackPageview?: boolean;
|
|
48
|
+
/** Enable SPA route tracking. */
|
|
49
|
+
trackSpa?: boolean;
|
|
50
|
+
/** Include query parameters in tracked URLs. */
|
|
51
|
+
trackQuery?: boolean;
|
|
52
|
+
/** Track outbound link clicks. */
|
|
53
|
+
trackOutbound?: boolean;
|
|
54
|
+
/** Track JavaScript errors. */
|
|
55
|
+
trackErrors?: boolean;
|
|
56
|
+
/** Enable session replay. */
|
|
57
|
+
sessionReplay?: boolean;
|
|
58
|
+
/** Enable Web Vitals tracking. */
|
|
59
|
+
webVitals?: boolean;
|
|
60
|
+
/** URL patterns to skip from tracking. */
|
|
61
|
+
skipPatterns?: string[];
|
|
62
|
+
/** URL patterns to mask in tracked data. */
|
|
63
|
+
maskPatterns?: string[];
|
|
64
|
+
/** Debounce interval for pageview tracking. */
|
|
65
|
+
debounce?: number;
|
|
66
|
+
/** API key for authenticated tracking. */
|
|
67
|
+
apiKey?: string;
|
|
68
|
+
/** Override the analytics host URL. */
|
|
69
|
+
analyticsHost?: string;
|
|
70
|
+
/** Custom loader URL. */
|
|
71
|
+
scriptUrl?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Creates a Rybbit Analytics script.
|
|
75
|
+
*
|
|
76
|
+
* @param options - The options for the Rybbit Analytics script.
|
|
77
|
+
* @returns The Rybbit Analytics script.
|
|
78
|
+
* @throws {Error} Throws `rybbitAnalytics: missing siteId` when
|
|
79
|
+
* `options.siteId` is undefined, null, or trims to an empty string. Provide a
|
|
80
|
+
* valid non-empty site ID string to prevent this error.
|
|
81
|
+
*/
|
|
82
|
+
export declare function rybbitAnalytics(options: RybbitAnalyticsOptions): Script;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
/**
|
|
3
|
+
* Public Segment Analytics.js API exposed on `window.analytics`.
|
|
4
|
+
*
|
|
5
|
+
* Use this interface when interacting with Segment calls queued before or after
|
|
6
|
+
* the client library is fully initialized.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* window.analytics.track('Signup', { plan: 'pro' });
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export interface SegmentApi {
|
|
14
|
+
/**
|
|
15
|
+
* Queues an event tracking call.
|
|
16
|
+
*
|
|
17
|
+
* @param event - Event name to record.
|
|
18
|
+
* @param properties - Optional event properties payload.
|
|
19
|
+
* @returns `void`.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Calls are queued until Analytics.js initializes.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* window.analytics.track('Signup', { plan: 'pro' });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
track: (event: string, properties?: Record<string, unknown>) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Queues a page tracking call.
|
|
32
|
+
*
|
|
33
|
+
* @param name - Optional page name override.
|
|
34
|
+
* @param properties - Optional page metadata payload.
|
|
35
|
+
* @returns `void`.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* If no name is passed, Segment infers the current page context.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* window.analytics.page('Pricing');
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
page: (name?: string, properties?: Record<string, unknown>) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Queues a user identification call.
|
|
48
|
+
*
|
|
49
|
+
* @param userId - Stable user identifier.
|
|
50
|
+
* @param traits - Optional trait map associated with the user.
|
|
51
|
+
* @param options - Optional Segment call options.
|
|
52
|
+
* @returns `void`.
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* Ensure the client is initialized and use a stable `userId` to avoid
|
|
56
|
+
* fragmented user profiles.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* window.analytics.identify('user_123', { email: 'dev@example.com' });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
identify: (userId: string, traits?: Record<string, unknown>, options?: Record<string, unknown>) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Queues a group association call for account-level analytics.
|
|
66
|
+
*
|
|
67
|
+
* @param groupId - Group or account identifier.
|
|
68
|
+
* @param traits - Optional group trait map.
|
|
69
|
+
* @param options - Optional Segment call options.
|
|
70
|
+
* @returns `void`.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* window.analytics.group('acme-inc', { plan: 'enterprise' });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
group: (groupId: string, traits?: Record<string, unknown>, options?: Record<string, unknown>) => void;
|
|
78
|
+
/**
|
|
79
|
+
* Queues a user alias call to merge identities.
|
|
80
|
+
*
|
|
81
|
+
* @param userId - New canonical user identifier.
|
|
82
|
+
* @param previousId - Optional previous anonymous or legacy identifier.
|
|
83
|
+
* @param options - Optional Segment call options.
|
|
84
|
+
* @returns `void`.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* Use `previousId` only when linking an existing anonymous identity to the
|
|
88
|
+
* new `userId`.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* window.analytics.alias('user_123', 'anon_456');
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
alias: (userId: string, previousId?: string, options?: Record<string, unknown>) => void;
|
|
96
|
+
/**
|
|
97
|
+
* Queues a reset call that clears current user identity state.
|
|
98
|
+
*
|
|
99
|
+
* @returns `void`.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* window.analytics.reset();
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
reset: () => void;
|
|
107
|
+
}
|
|
108
|
+
declare global {
|
|
109
|
+
interface Window {
|
|
110
|
+
analytics?: SegmentApi;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Segment vendor manifest.
|
|
115
|
+
*
|
|
116
|
+
* Uses Segment's standard `window.analytics` queue shape and optionally queues
|
|
117
|
+
* the initial `page()` call before the bundle loads.
|
|
118
|
+
*/
|
|
119
|
+
export declare const segmentManifest: {
|
|
120
|
+
readonly vendor: "segment";
|
|
121
|
+
readonly category: "measurement";
|
|
122
|
+
readonly bootstrap: [{
|
|
123
|
+
readonly type: "setGlobal";
|
|
124
|
+
readonly name: "analytics";
|
|
125
|
+
readonly value: readonly [];
|
|
126
|
+
readonly ifUndefined: true;
|
|
127
|
+
}, {
|
|
128
|
+
readonly type: "defineQueueMethods";
|
|
129
|
+
readonly target: "analytics";
|
|
130
|
+
readonly methods: ["track", "page", "identify", "group", "alias", "reset"];
|
|
131
|
+
}];
|
|
132
|
+
readonly install: [{
|
|
133
|
+
readonly type: "callGlobal";
|
|
134
|
+
readonly global: "analytics";
|
|
135
|
+
readonly method: "page";
|
|
136
|
+
}, {
|
|
137
|
+
readonly type: "loadScript";
|
|
138
|
+
readonly src: "{{scriptUrl}}";
|
|
139
|
+
readonly async: true;
|
|
140
|
+
}];
|
|
141
|
+
readonly kind: "c15t.vendor-manifest";
|
|
142
|
+
readonly schemaVersion: 1;
|
|
143
|
+
};
|
|
144
|
+
export interface SegmentOptions {
|
|
145
|
+
/** Your Segment write key. */
|
|
146
|
+
writeKey: string;
|
|
147
|
+
/** Queue the initial `analytics.page()` call during setup. */
|
|
148
|
+
trackPageView?: boolean;
|
|
149
|
+
/** Optional full loader URL override. */
|
|
150
|
+
scriptUrl?: string;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Creates a Segment Analytics.js script.
|
|
154
|
+
*
|
|
155
|
+
* @param options - The options for the Segment script.
|
|
156
|
+
* @returns The Segment script configuration.
|
|
157
|
+
*/
|
|
158
|
+
export declare function segment({ writeKey, trackPageView, scriptUrl, }: SegmentOptions): Script;
|