@c15t/scripts 2.0.1 → 2.2.0-canary-20260727202135
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 +62 -0
- package/README.md +41 -29
- package/dist/e2e-test-utils.cjs +51 -10
- package/dist/e2e-test-utils.js +37 -3
- package/dist/engine/compile.cjs +9 -5
- package/dist/engine/runtime.cjs +111 -17
- package/dist/engine/runtime.js +102 -12
- package/dist/registry.cjs +423 -0
- package/dist/registry.js +372 -0
- package/dist/resolve.cjs +9 -5
- package/dist/types.cjs +32 -10
- package/dist/types.js +10 -1
- package/dist/vendors/_shared/attributes.cjs +55 -0
- package/dist/vendors/_shared/attributes.js +14 -0
- package/dist/vendors/_shared/google-consent.cjs +69 -0
- package/dist/vendors/_shared/google-consent.js +27 -0
- package/dist/vendors/_shared/install-builders.cjs +59 -0
- package/dist/vendors/_shared/install-builders.js +21 -0
- package/dist/vendors/_shared/script-url.cjs +78 -0
- package/dist/vendors/_shared/script-url.js +28 -0
- package/dist/{linkedin-insights.cjs → vendors/ads-and-pixels/linkedin-insights.cjs} +11 -7
- package/dist/{linkedin-insights.js → vendors/ads-and-pixels/linkedin-insights.js} +2 -2
- package/dist/vendors/ads-and-pixels/meta-pixel.cjs +206 -0
- package/dist/vendors/ads-and-pixels/meta-pixel.js +153 -0
- package/dist/{microsoft-uet.cjs → vendors/ads-and-pixels/microsoft-uet.cjs} +42 -21
- package/dist/{microsoft-uet.js → vendors/ads-and-pixels/microsoft-uet.js} +31 -14
- package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +151 -0
- package/dist/vendors/ads-and-pixels/reddit-pixel.js +107 -0
- package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +131 -0
- package/dist/vendors/ads-and-pixels/snapchat-pixel.js +87 -0
- package/dist/{tiktok-pixel.cjs → vendors/ads-and-pixels/tiktok-pixel.cjs} +11 -7
- 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} +15 -8
- package/dist/{x-pixel.js → vendors/ads-and-pixels/x-pixel.js} +6 -3
- package/dist/vendors/analytics/adobe-analytics.cjs +90 -0
- package/dist/vendors/analytics/adobe-analytics.js +49 -0
- package/dist/vendors/analytics/ahrefs-analytics.cjs +68 -0
- package/dist/vendors/analytics/ahrefs-analytics.js +27 -0
- package/dist/vendors/analytics/amplitude.cjs +193 -0
- package/dist/vendors/analytics/amplitude.js +134 -0
- package/dist/vendors/analytics/clearbit.cjs +69 -0
- package/dist/vendors/analytics/clearbit.js +28 -0
- package/dist/vendors/analytics/cloudflare-web-analytics.cjs +73 -0
- package/dist/vendors/analytics/cloudflare-web-analytics.js +32 -0
- package/dist/{databuddy.cjs → vendors/analytics/databuddy.cjs} +14 -10
- package/dist/{databuddy.js → vendors/analytics/databuddy.js} +3 -3
- package/dist/vendors/analytics/fathom-analytics.cjs +76 -0
- package/dist/vendors/analytics/fathom-analytics.js +35 -0
- package/dist/{google-tag.cjs → vendors/analytics/google-tag.cjs} +18 -35
- package/dist/{google-tag.js → vendors/analytics/google-tag.js} +7 -28
- package/dist/vendors/analytics/heap.cjs +181 -0
- package/dist/vendors/analytics/heap.js +134 -0
- package/dist/vendors/analytics/hightouch.cjs +153 -0
- package/dist/vendors/analytics/hightouch.js +109 -0
- package/dist/vendors/analytics/hotjar.cjs +85 -0
- package/dist/vendors/analytics/hotjar.js +44 -0
- package/dist/vendors/analytics/logrocket.cjs +99 -0
- package/dist/vendors/analytics/logrocket.js +58 -0
- package/dist/vendors/analytics/matomo-analytics.cjs +232 -0
- package/dist/vendors/analytics/matomo-analytics.js +191 -0
- package/dist/vendors/analytics/microsoft-clarity.cjs +138 -0
- package/dist/vendors/analytics/microsoft-clarity.js +97 -0
- package/dist/vendors/analytics/mixpanel-analytics.cjs +134 -0
- package/dist/vendors/analytics/mixpanel-analytics.js +93 -0
- package/dist/vendors/analytics/pirsch.cjs +108 -0
- package/dist/vendors/analytics/pirsch.js +67 -0
- package/dist/vendors/analytics/plausible-analytics.cjs +122 -0
- package/dist/vendors/analytics/plausible-analytics.js +81 -0
- package/dist/vendors/analytics/posthog.cjs +204 -0
- package/dist/vendors/analytics/posthog.js +163 -0
- package/dist/vendors/analytics/promptwatch.cjs +70 -0
- package/dist/vendors/analytics/promptwatch.js +29 -0
- package/dist/vendors/analytics/rudderstack.cjs +227 -0
- package/dist/vendors/analytics/rudderstack.js +183 -0
- package/dist/vendors/analytics/rybbit-analytics.cjs +104 -0
- package/dist/vendors/analytics/rybbit-analytics.js +63 -0
- package/dist/vendors/analytics/segment.cjs +97 -0
- package/dist/vendors/analytics/segment.js +56 -0
- package/dist/vendors/analytics/umami-analytics.cjs +80 -0
- package/dist/vendors/analytics/umami-analytics.js +39 -0
- package/dist/vendors/analytics/vercel-analytics.cjs +94 -0
- package/dist/vendors/analytics/vercel-analytics.js +53 -0
- package/dist/vendors/functional/crisp.cjs +143 -0
- package/dist/vendors/functional/crisp.js +102 -0
- package/dist/vendors/functional/intercom.cjs +89 -0
- package/dist/vendors/functional/intercom.js +45 -0
- package/dist/{google-tag-manager.cjs → vendors/tag-managers/google-tag-manager.cjs} +17 -34
- 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 +440 -0
- package/dist-types/types.d.ts +53 -2
- 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/vendors/ads-and-pixels/linkedin-insights.d.ts +92 -0
- 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} +45 -34
- 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} +48 -33
- package/dist-types/{x-pixel.d.ts → vendors/ads-and-pixels/x-pixel.d.ts} +34 -17
- package/dist-types/vendors/analytics/adobe-analytics.d.ts +75 -0
- package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +62 -0
- package/dist-types/vendors/analytics/amplitude.d.ts +234 -0
- package/dist-types/vendors/analytics/clearbit.d.ts +60 -0
- package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +67 -0
- package/dist-types/{databuddy.d.ts → vendors/analytics/databuddy.d.ts} +25 -25
- package/dist-types/vendors/analytics/fathom-analytics.d.ts +90 -0
- package/dist-types/{google-tag.d.ts → vendors/analytics/google-tag.d.ts} +21 -24
- package/dist-types/vendors/analytics/heap.d.ts +316 -0
- package/dist-types/vendors/analytics/hightouch.d.ts +285 -0
- package/dist-types/vendors/analytics/hotjar.d.ts +73 -0
- package/dist-types/vendors/analytics/logrocket.d.ts +101 -0
- package/dist-types/vendors/analytics/matomo-analytics.d.ts +41 -0
- package/dist-types/vendors/analytics/microsoft-clarity.d.ts +98 -0
- package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +113 -0
- package/dist-types/vendors/analytics/pirsch.d.ts +96 -0
- package/dist-types/vendors/analytics/plausible-analytics.d.ts +122 -0
- package/dist-types/vendors/analytics/posthog.d.ts +154 -0
- package/dist-types/vendors/analytics/promptwatch.d.ts +36 -0
- package/dist-types/vendors/analytics/rudderstack.d.ts +330 -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} +22 -25
- package/docs/README.md +62 -0
- package/docs/frameworks/javascript/script-loader.md +354 -0
- package/docs/frameworks/next/script-loader.md +499 -0
- package/docs/frameworks/react/script-loader.md +553 -0
- package/docs/integrations/adobe-analytics.md +160 -0
- package/docs/integrations/ahrefs-analytics.md +157 -0
- package/docs/integrations/amplitude.md +230 -0
- package/docs/integrations/building-integrations.md +239 -0
- package/docs/integrations/clearbit.md +130 -0
- package/docs/integrations/cloudflare-web-analytics.md +126 -0
- package/docs/integrations/crisp.md +140 -0
- package/docs/integrations/databuddy.md +205 -0
- package/docs/integrations/fathom-analytics.md +150 -0
- package/docs/integrations/google-maps.md +263 -0
- package/docs/integrations/google-tag-manager.md +154 -0
- package/docs/integrations/google-tag.md +134 -0
- package/docs/integrations/heap.md +219 -0
- package/docs/integrations/hightouch.md +199 -0
- package/docs/integrations/hotjar.md +143 -0
- package/docs/integrations/intercom.md +144 -0
- package/docs/integrations/linkedin-insights.md +161 -0
- package/docs/integrations/logrocket.md +175 -0
- package/docs/integrations/matomo-analytics.md +171 -0
- package/docs/integrations/meta-pixel.md +412 -0
- package/docs/integrations/microsoft-clarity.md +173 -0
- package/docs/integrations/microsoft-uet.md +156 -0
- package/docs/integrations/mixpanel-analytics.md +130 -0
- package/docs/integrations/overview.md +149 -0
- package/docs/integrations/pirsch.md +142 -0
- package/docs/integrations/plausible-analytics.md +154 -0
- package/docs/integrations/posthog.md +258 -0
- package/docs/integrations/promptwatch.md +121 -0
- package/docs/integrations/reddit-pixel.md +241 -0
- package/docs/integrations/rudderstack.md +271 -0
- package/docs/integrations/rybbit-analytics.md +143 -0
- package/docs/integrations/segment.md +146 -0
- package/docs/integrations/snapchat-pixel.md +163 -0
- package/docs/integrations/tiktok-pixel.md +123 -0
- package/docs/integrations/umami-analytics.md +148 -0
- package/docs/integrations/vercel-analytics.md +141 -0
- package/docs/integrations/x-pixel.md +157 -0
- package/docs/integrations/youtube.md +193 -0
- package/docs/shared/react/guides/script-loader.md +309 -0
- package/package.json +223 -8
- package/readme.json +8 -4
- package/dist/meta-pixel.cjs +0 -129
- package/dist/meta-pixel.js +0 -89
- package/dist/posthog.cjs +0 -137
- package/dist/posthog.js +0 -100
- package/dist-types/linkedin-insights.d.ts +0 -79
- package/dist-types/meta-pixel.d.ts +0 -185
- package/dist-types/posthog.d.ts +0 -112
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
/** Snippet version marker consumed by `init_from_snippet`. */
|
|
13
|
+
__SV?: number;
|
|
14
|
+
/** Pending `[token, config, instanceName]` init tuples consumed at SDK load. */
|
|
15
|
+
_i?: unknown[][];
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Mixpanel vendor manifest.
|
|
21
|
+
*
|
|
22
|
+
* Implements the official snippet contract: the stub array carries the
|
|
23
|
+
* snippet version marker (`__SV`) and the pending `[token, config, 'mixpanel']`
|
|
24
|
+
* init tuple in `_i`, which `mixpanel-2-latest.min.js` consumes at load time via
|
|
25
|
+
* `init_from_snippet`. Without `__SV` the SDK logs "Mixpanel error: Version
|
|
26
|
+
* mismatch" and never initializes, silently dropping queued calls.
|
|
27
|
+
*
|
|
28
|
+
* Mixpanel can stay loaded across consent changes and toggle tracking with its
|
|
29
|
+
* own opt-in and opt-out APIs.
|
|
30
|
+
*/
|
|
31
|
+
export declare const mixpanelAnalyticsManifest: {
|
|
32
|
+
readonly kind: "c15t.vendor-manifest";
|
|
33
|
+
readonly schemaVersion: 1;
|
|
34
|
+
readonly vendor: 'mixpanel-analytics';
|
|
35
|
+
readonly category: 'measurement';
|
|
36
|
+
readonly alwaysLoad: true;
|
|
37
|
+
readonly install: [{
|
|
38
|
+
readonly type: 'setGlobal';
|
|
39
|
+
readonly name: 'mixpanel';
|
|
40
|
+
readonly value: readonly [];
|
|
41
|
+
readonly ifUndefined: true;
|
|
42
|
+
}, {
|
|
43
|
+
readonly type: 'setGlobalPath';
|
|
44
|
+
readonly path: ["mixpanel", "__SV"];
|
|
45
|
+
readonly value: 1.2;
|
|
46
|
+
}, {
|
|
47
|
+
readonly type: 'setGlobalPath';
|
|
48
|
+
readonly path: ["mixpanel", "_i"];
|
|
49
|
+
readonly value: readonly [readonly ["{{token}}", "{{initOptions}}", "mixpanel"]];
|
|
50
|
+
}, {
|
|
51
|
+
readonly type: 'defineQueueMethods';
|
|
52
|
+
readonly target: 'mixpanel';
|
|
53
|
+
readonly methods: ["track", "identify", "reset", "register", "opt_in_tracking", "opt_out_tracking"];
|
|
54
|
+
}, {
|
|
55
|
+
readonly type: 'loadScript';
|
|
56
|
+
readonly src: '{{scriptUrl}}';
|
|
57
|
+
readonly async: true;
|
|
58
|
+
}];
|
|
59
|
+
readonly onLoadGranted: [{
|
|
60
|
+
readonly type: 'callGlobal';
|
|
61
|
+
readonly global: 'mixpanel';
|
|
62
|
+
readonly method: 'opt_in_tracking';
|
|
63
|
+
}];
|
|
64
|
+
readonly onLoadDenied: [{
|
|
65
|
+
readonly type: 'callGlobal';
|
|
66
|
+
readonly global: 'mixpanel';
|
|
67
|
+
readonly method: 'opt_out_tracking';
|
|
68
|
+
}];
|
|
69
|
+
readonly onConsentGranted: [{
|
|
70
|
+
readonly type: 'callGlobal';
|
|
71
|
+
readonly global: 'mixpanel';
|
|
72
|
+
readonly method: 'opt_in_tracking';
|
|
73
|
+
}];
|
|
74
|
+
readonly onConsentDenied: [{
|
|
75
|
+
readonly type: 'callGlobal';
|
|
76
|
+
readonly global: 'mixpanel';
|
|
77
|
+
readonly method: 'opt_out_tracking';
|
|
78
|
+
}];
|
|
79
|
+
};
|
|
80
|
+
export interface MixpanelAnalyticsOptions {
|
|
81
|
+
/** Your Mixpanel project token. */
|
|
82
|
+
token: string;
|
|
83
|
+
/**
|
|
84
|
+
* Mixpanel init options passed after the library loads.
|
|
85
|
+
*
|
|
86
|
+
* The manifest engine serializes this object as a template variable, so use
|
|
87
|
+
* JSON-serializable values only (no functions, class instances, prototypes,
|
|
88
|
+
* `Map`, `Set`, or other non-JSON types). Named instances and nested
|
|
89
|
+
* `people.*` queue helpers are intentionally out of scope for this helper.
|
|
90
|
+
*/
|
|
91
|
+
initOptions?: Record<string, unknown>;
|
|
92
|
+
/** Mixpanel loader URL. */
|
|
93
|
+
scriptUrl?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Creates a Mixpanel Analytics script.
|
|
97
|
+
*
|
|
98
|
+
* @param options - The options for the Mixpanel Analytics script.
|
|
99
|
+
* @returns The Mixpanel Analytics script configuration.
|
|
100
|
+
* @throws {Error} Throws when `token` is not a non-empty 32-character
|
|
101
|
+
* hexadecimal Mixpanel project token.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* import { mixpanelAnalytics } from '@c15t/scripts/mixpanel-analytics';
|
|
106
|
+
*
|
|
107
|
+
* const script = mixpanelAnalytics({
|
|
108
|
+
* token: '1234567890abcdef1234567890abcdef',
|
|
109
|
+
* initOptions: { debug: true },
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare function mixpanelAnalytics({ token, initOptions, scriptUrl, }: MixpanelAnalyticsOptions): Script;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Script } from 'c15t';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
pirsch?: (eventName: string, options?: {
|
|
5
|
+
duration?: number;
|
|
6
|
+
meta?: Record<string, unknown>;
|
|
7
|
+
non_interactive?: boolean;
|
|
8
|
+
}) => Promise<null | undefined>;
|
|
9
|
+
pirschClearSession?: () => void;
|
|
10
|
+
pirschInit?: () => void;
|
|
11
|
+
pirschNotFound?: () => void;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Pirsch vendor manifest.
|
|
16
|
+
*
|
|
17
|
+
* Configures Pirsch through script attributes. Pirsch finds the script element
|
|
18
|
+
* by a fixed element id, so the `id` attribute is part of the loader contract.
|
|
19
|
+
*/
|
|
20
|
+
export declare const pirschManifest: {
|
|
21
|
+
readonly kind: "c15t.vendor-manifest";
|
|
22
|
+
readonly schemaVersion: 1;
|
|
23
|
+
readonly vendor: 'pirsch';
|
|
24
|
+
readonly category: 'measurement';
|
|
25
|
+
readonly install: [{
|
|
26
|
+
readonly type: 'loadScript';
|
|
27
|
+
readonly src: '{{scriptUrl}}';
|
|
28
|
+
readonly defer: true;
|
|
29
|
+
readonly attributes: {
|
|
30
|
+
readonly id: '{{scriptElementId}}';
|
|
31
|
+
readonly 'data-code': '{{identificationCode}}';
|
|
32
|
+
readonly 'data-domain': '{{domain}}';
|
|
33
|
+
readonly 'data-dev': '{{dev}}';
|
|
34
|
+
readonly 'data-hit-endpoint': '{{hitEndpoint}}';
|
|
35
|
+
readonly 'data-event-endpoint': '{{eventEndpoint}}';
|
|
36
|
+
readonly 'data-disable-page-views': '{{disablePageViews}}';
|
|
37
|
+
};
|
|
38
|
+
}];
|
|
39
|
+
};
|
|
40
|
+
export interface PirschOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Your Pirsch identification code.
|
|
43
|
+
*/
|
|
44
|
+
identificationCode: string;
|
|
45
|
+
/**
|
|
46
|
+
* Additional dashboard domains, optionally including per-domain codes.
|
|
47
|
+
*
|
|
48
|
+
* Arrays are serialized as Pirsch's comma-separated `data-domain` value.
|
|
49
|
+
*/
|
|
50
|
+
domain?: string | string[];
|
|
51
|
+
/**
|
|
52
|
+
* Enable localhost testing by rewriting the tracked hostname.
|
|
53
|
+
*/
|
|
54
|
+
dev?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Custom pageview endpoint.
|
|
57
|
+
*/
|
|
58
|
+
hitEndpoint?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Custom event endpoint.
|
|
61
|
+
*/
|
|
62
|
+
eventEndpoint?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Disable automatic pageview tracking.
|
|
65
|
+
*/
|
|
66
|
+
disablePageViews?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Load Pirsch's extended script variant.
|
|
69
|
+
*/
|
|
70
|
+
extended?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Custom loader URL.
|
|
73
|
+
*/
|
|
74
|
+
scriptUrl?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Creates a Pirsch Analytics script.
|
|
78
|
+
*
|
|
79
|
+
* @see https://docs.pirsch.io/get-started/frontend-integration
|
|
80
|
+
*
|
|
81
|
+
* @param options - The options for the Pirsch script.
|
|
82
|
+
* @returns The Pirsch script.
|
|
83
|
+
* @throws {Error} When `identificationCode` is missing, empty, or invalid.
|
|
84
|
+
* Provide a valid non-empty `identificationCode` string to prevent this error.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* import { pirsch } from '@c15t/scripts/pirsch';
|
|
89
|
+
*
|
|
90
|
+
* pirsch({
|
|
91
|
+
* identificationCode: 'YOUR_IDENTIFICATION_CODE',
|
|
92
|
+
* domain: 'rollup.example.com:ROLLUP_CODE',
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare function pirsch(options: PirschOptions): 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 kind: "c15t.vendor-manifest";
|
|
31
|
+
readonly schemaVersion: 1;
|
|
32
|
+
readonly vendor: 'plausible-analytics';
|
|
33
|
+
readonly category: 'measurement';
|
|
34
|
+
readonly bootstrap: [{
|
|
35
|
+
readonly type: 'defineStubFunction';
|
|
36
|
+
readonly name: 'plausible';
|
|
37
|
+
readonly queue: {
|
|
38
|
+
readonly property: 'q';
|
|
39
|
+
};
|
|
40
|
+
readonly queueFormat: 'array';
|
|
41
|
+
readonly properties: {
|
|
42
|
+
readonly o: '{{initOptions}}';
|
|
43
|
+
};
|
|
44
|
+
readonly ifUndefined: true;
|
|
45
|
+
}];
|
|
46
|
+
readonly install: [{
|
|
47
|
+
readonly type: 'loadScript';
|
|
48
|
+
readonly src: '{{scriptUrl}}';
|
|
49
|
+
readonly defer: true;
|
|
50
|
+
readonly attributes: {
|
|
51
|
+
readonly 'data-domain': '{{domain}}';
|
|
52
|
+
readonly 'data-api': '{{apiAttribute}}';
|
|
53
|
+
};
|
|
54
|
+
}];
|
|
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;
|
|
@@ -0,0 +1,154 @@
|
|
|
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
|
+
capture: (event: string, properties?: Record<string, unknown>) => void;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export type PosthogRegion = 'eu' | 'us';
|
|
19
|
+
export type PosthogLoadMode = 'always' | 'after-consent' | 'disabled';
|
|
20
|
+
/**
|
|
21
|
+
* PostHog vendor manifest.
|
|
22
|
+
*
|
|
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.
|
|
26
|
+
*/
|
|
27
|
+
export declare const posthogManifest: {
|
|
28
|
+
readonly kind: "c15t.vendor-manifest";
|
|
29
|
+
readonly schemaVersion: 1;
|
|
30
|
+
readonly vendor: 'posthog';
|
|
31
|
+
readonly category: 'measurement';
|
|
32
|
+
readonly alwaysLoad: true;
|
|
33
|
+
readonly bootstrap: [{
|
|
34
|
+
readonly type: 'setGlobal';
|
|
35
|
+
readonly name: 'posthog';
|
|
36
|
+
readonly value: {};
|
|
37
|
+
readonly ifUndefined: true;
|
|
38
|
+
}, {
|
|
39
|
+
readonly type: 'defineGlobalMethods';
|
|
40
|
+
readonly target: 'posthog';
|
|
41
|
+
readonly methods: [{
|
|
42
|
+
readonly name: 'init';
|
|
43
|
+
readonly behavior: 'noop';
|
|
44
|
+
}, {
|
|
45
|
+
readonly name: 'capture';
|
|
46
|
+
readonly behavior: 'noop';
|
|
47
|
+
}, {
|
|
48
|
+
readonly name: 'opt_in_capturing';
|
|
49
|
+
readonly behavior: 'noop';
|
|
50
|
+
}, {
|
|
51
|
+
readonly name: 'opt_out_capturing';
|
|
52
|
+
readonly behavior: 'noop';
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: 'get_explicit_consent_status';
|
|
55
|
+
readonly behavior: 'return';
|
|
56
|
+
readonly value: 'pending';
|
|
57
|
+
}];
|
|
58
|
+
}];
|
|
59
|
+
readonly install: [{
|
|
60
|
+
readonly type: 'loadScript';
|
|
61
|
+
readonly src: '{{scriptUrl}}';
|
|
62
|
+
readonly async: true;
|
|
63
|
+
readonly attributes: {
|
|
64
|
+
readonly crossorigin: 'anonymous';
|
|
65
|
+
readonly 'data-api-host': '{{apiHost}}';
|
|
66
|
+
readonly 'data-ui-host': '{{uiHost}}';
|
|
67
|
+
};
|
|
68
|
+
}];
|
|
69
|
+
readonly afterLoad: [{
|
|
70
|
+
readonly type: 'callGlobal';
|
|
71
|
+
readonly global: 'posthog';
|
|
72
|
+
readonly method: 'init';
|
|
73
|
+
readonly args: ["{{id}}", "{{initOptions}}"];
|
|
74
|
+
}];
|
|
75
|
+
readonly onLoadGranted: [{
|
|
76
|
+
readonly type: 'callGlobal';
|
|
77
|
+
readonly global: 'posthog';
|
|
78
|
+
readonly method: 'opt_in_capturing';
|
|
79
|
+
}];
|
|
80
|
+
readonly onLoadDenied: [{
|
|
81
|
+
readonly type: 'callGlobal';
|
|
82
|
+
readonly global: 'posthog';
|
|
83
|
+
readonly method: 'opt_out_capturing';
|
|
84
|
+
}];
|
|
85
|
+
readonly onConsentGranted: [{
|
|
86
|
+
readonly type: 'callGlobal';
|
|
87
|
+
readonly global: 'posthog';
|
|
88
|
+
readonly method: 'opt_in_capturing';
|
|
89
|
+
}];
|
|
90
|
+
readonly onConsentDenied: [{
|
|
91
|
+
readonly type: 'callGlobal';
|
|
92
|
+
readonly global: 'posthog';
|
|
93
|
+
readonly method: 'opt_out_capturing';
|
|
94
|
+
}];
|
|
95
|
+
};
|
|
96
|
+
export interface PosthogConsentOptions {
|
|
97
|
+
/**
|
|
98
|
+
* Your posthog id, begins with 'phc_'.
|
|
99
|
+
*/
|
|
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;
|
|
107
|
+
/**
|
|
108
|
+
* Your posthog api host.
|
|
109
|
+
* @default 'https://eu.i.posthog.com'
|
|
110
|
+
*/
|
|
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;
|
|
117
|
+
/** The PostHog array loader URL. */
|
|
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;
|
|
129
|
+
/** PostHog init options passed to `posthog.init(...)`. */
|
|
130
|
+
initOptions?: Record<string, unknown>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
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
|
+
*
|
|
149
|
+
* @see https://posthog.com/docs/libraries/js#opt-in-capturing
|
|
150
|
+
*
|
|
151
|
+
* @param options - Optional configuration for the PostHog consent script
|
|
152
|
+
* @returns The Posthog script
|
|
153
|
+
*/
|
|
154
|
+
export declare function posthog(options: PosthogConsentOptions): 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 kind: "c15t.vendor-manifest";
|
|
9
|
+
readonly schemaVersion: 1;
|
|
10
|
+
readonly vendor: 'promptwatch';
|
|
11
|
+
readonly category: 'measurement';
|
|
12
|
+
readonly install: [{
|
|
13
|
+
readonly type: 'loadScript';
|
|
14
|
+
readonly src: '{{scriptUrl}}';
|
|
15
|
+
readonly async: true;
|
|
16
|
+
readonly attributes: {
|
|
17
|
+
readonly 'data-project-id': '{{projectId}}';
|
|
18
|
+
};
|
|
19
|
+
}];
|
|
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;
|