@c15t/scripts 2.0.0 → 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.
Files changed (110) hide show
  1. package/README.md +9 -9
  2. package/dist/e2e-test-utils.cjs +125 -0
  3. package/dist/e2e-test-utils.js +67 -0
  4. package/dist/engine/runtime.cjs +19 -9
  5. package/dist/engine/runtime.js +19 -9
  6. package/dist/registry.cjs +338 -0
  7. package/dist/registry.js +292 -0
  8. package/dist/types.cjs +18 -0
  9. package/dist/types.js +10 -1
  10. package/dist/vendors/_shared/attributes.cjs +51 -0
  11. package/dist/vendors/_shared/attributes.js +14 -0
  12. package/dist/vendors/_shared/google-consent.cjs +64 -0
  13. package/dist/vendors/_shared/google-consent.js +27 -0
  14. package/dist/vendors/_shared/install-builders.cjs +55 -0
  15. package/dist/vendors/_shared/install-builders.js +21 -0
  16. package/dist/vendors/_shared/script-url.cjs +74 -0
  17. package/dist/vendors/_shared/script-url.js +28 -0
  18. package/dist/{linkedin-insights.cjs → vendors/ads-and-pixels/linkedin-insights.cjs} +2 -2
  19. package/dist/{linkedin-insights.js → vendors/ads-and-pixels/linkedin-insights.js} +2 -2
  20. package/dist/vendors/ads-and-pixels/meta-pixel.cjs +202 -0
  21. package/dist/vendors/ads-and-pixels/meta-pixel.js +153 -0
  22. package/dist/{microsoft-uet.cjs → vendors/ads-and-pixels/microsoft-uet.cjs} +31 -14
  23. package/dist/{microsoft-uet.js → vendors/ads-and-pixels/microsoft-uet.js} +31 -14
  24. package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +147 -0
  25. package/dist/vendors/ads-and-pixels/reddit-pixel.js +107 -0
  26. package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +127 -0
  27. package/dist/vendors/ads-and-pixels/snapchat-pixel.js +87 -0
  28. package/dist/{tiktok-pixel.cjs → vendors/ads-and-pixels/tiktok-pixel.cjs} +2 -2
  29. package/dist/{tiktok-pixel.js → vendors/ads-and-pixels/tiktok-pixel.js} +2 -2
  30. package/dist/{x-pixel.cjs → vendors/ads-and-pixels/x-pixel.cjs} +6 -3
  31. package/dist/{x-pixel.js → vendors/ads-and-pixels/x-pixel.js} +6 -3
  32. package/dist/vendors/analytics/ahrefs-analytics.cjs +64 -0
  33. package/dist/vendors/analytics/ahrefs-analytics.js +27 -0
  34. package/dist/vendors/analytics/cloudflare-web-analytics.cjs +69 -0
  35. package/dist/vendors/analytics/cloudflare-web-analytics.js +32 -0
  36. package/dist/{databuddy.cjs → vendors/analytics/databuddy.cjs} +3 -3
  37. package/dist/{databuddy.js → vendors/analytics/databuddy.js} +3 -3
  38. package/dist/vendors/analytics/fathom-analytics.cjs +72 -0
  39. package/dist/vendors/analytics/fathom-analytics.js +35 -0
  40. package/dist/{google-tag.cjs → vendors/analytics/google-tag.cjs} +7 -28
  41. package/dist/{google-tag.js → vendors/analytics/google-tag.js} +7 -28
  42. package/dist/vendors/analytics/hotjar.cjs +81 -0
  43. package/dist/vendors/analytics/hotjar.js +44 -0
  44. package/dist/vendors/analytics/matomo-analytics.cjs +228 -0
  45. package/dist/vendors/analytics/matomo-analytics.js +191 -0
  46. package/dist/vendors/analytics/microsoft-clarity.cjs +110 -0
  47. package/dist/vendors/analytics/microsoft-clarity.js +73 -0
  48. package/dist/vendors/analytics/mixpanel-analytics.cjs +119 -0
  49. package/dist/vendors/analytics/mixpanel-analytics.js +82 -0
  50. package/dist/vendors/analytics/plausible-analytics.cjs +118 -0
  51. package/dist/vendors/analytics/plausible-analytics.js +81 -0
  52. package/dist/{posthog.cjs → vendors/analytics/posthog.cjs} +69 -6
  53. package/dist/vendors/analytics/posthog.js +163 -0
  54. package/dist/vendors/analytics/promptwatch.cjs +66 -0
  55. package/dist/vendors/analytics/promptwatch.js +29 -0
  56. package/dist/vendors/analytics/rybbit-analytics.cjs +100 -0
  57. package/dist/vendors/analytics/rybbit-analytics.js +63 -0
  58. package/dist/vendors/analytics/segment.cjs +93 -0
  59. package/dist/vendors/analytics/segment.js +56 -0
  60. package/dist/vendors/analytics/umami-analytics.cjs +76 -0
  61. package/dist/vendors/analytics/umami-analytics.js +39 -0
  62. package/dist/vendors/analytics/vercel-analytics.cjs +90 -0
  63. package/dist/vendors/analytics/vercel-analytics.js +53 -0
  64. package/dist/vendors/functional/crisp.cjs +139 -0
  65. package/dist/vendors/functional/crisp.js +102 -0
  66. package/dist/vendors/functional/intercom.cjs +85 -0
  67. package/dist/vendors/functional/intercom.js +45 -0
  68. package/dist/{google-tag-manager.cjs → vendors/tag-managers/google-tag-manager.cjs} +6 -27
  69. package/dist/{google-tag-manager.js → vendors/tag-managers/google-tag-manager.js} +6 -27
  70. package/dist-types/__tests__/helpers.d.ts +141 -0
  71. package/dist-types/engine/runtime.d.ts +1 -1
  72. package/dist-types/registry.d.ts +368 -0
  73. package/dist-types/types.d.ts +13 -0
  74. package/dist-types/vendors/_shared/attributes.d.ts +35 -0
  75. package/dist-types/vendors/_shared/google-consent.d.ts +47 -0
  76. package/dist-types/vendors/_shared/install-builders.d.ts +30 -0
  77. package/dist-types/vendors/_shared/script-url.d.ts +75 -0
  78. package/dist-types/{linkedin-insights.d.ts → vendors/ads-and-pixels/linkedin-insights.d.ts} +22 -9
  79. package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +289 -0
  80. package/dist-types/{microsoft-uet.d.ts → vendors/ads-and-pixels/microsoft-uet.d.ts} +21 -10
  81. package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +211 -0
  82. package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +171 -0
  83. package/dist-types/{tiktok-pixel.d.ts → vendors/ads-and-pixels/tiktok-pixel.d.ts} +20 -5
  84. package/dist-types/{x-pixel.d.ts → vendors/ads-and-pixels/x-pixel.d.ts} +21 -4
  85. package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +62 -0
  86. package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +67 -0
  87. package/dist-types/vendors/analytics/fathom-analytics.d.ts +90 -0
  88. package/dist-types/{google-tag.d.ts → vendors/analytics/google-tag.d.ts} +5 -8
  89. package/dist-types/vendors/analytics/hotjar.d.ts +73 -0
  90. package/dist-types/vendors/analytics/matomo-analytics.d.ts +41 -0
  91. package/dist-types/vendors/analytics/microsoft-clarity.d.ts +86 -0
  92. package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +101 -0
  93. package/dist-types/vendors/analytics/plausible-analytics.d.ts +122 -0
  94. package/dist-types/{posthog.d.ts → vendors/analytics/posthog.d.ts} +47 -5
  95. package/dist-types/vendors/analytics/promptwatch.d.ts +36 -0
  96. package/dist-types/vendors/analytics/rybbit-analytics.d.ts +82 -0
  97. package/dist-types/vendors/analytics/segment.d.ts +158 -0
  98. package/dist-types/vendors/analytics/umami-analytics.d.ts +93 -0
  99. package/dist-types/vendors/analytics/vercel-analytics.d.ts +66 -0
  100. package/dist-types/vendors/functional/crisp.d.ts +78 -0
  101. package/dist-types/vendors/functional/intercom.d.ts +135 -0
  102. package/dist-types/{google-tag-manager.d.ts → vendors/tag-managers/google-tag-manager.d.ts} +5 -8
  103. package/package.json +166 -5
  104. package/dist/meta-pixel.cjs +0 -129
  105. package/dist/meta-pixel.js +0 -89
  106. package/dist/posthog.js +0 -100
  107. package/dist-types/engine.test.d.ts +0 -1
  108. package/dist-types/helpers.test.d.ts +0 -1
  109. package/dist-types/meta-pixel.d.ts +0 -185
  110. /package/dist-types/{databuddy.d.ts → vendors/analytics/databuddy.d.ts} +0 -0
@@ -30,7 +30,10 @@ export declare const gtagManifest: {
30
30
  readonly install: [{
31
31
  readonly type: "callGlobal";
32
32
  readonly global: "gtag";
33
- readonly args: ["js", "{{loadTime}}"];
33
+ readonly args: ["js", {
34
+ readonly kind: "c15t.runtime-value";
35
+ readonly value: "date";
36
+ }];
34
37
  }, {
35
38
  readonly type: "callGlobal";
36
39
  readonly global: "gtag";
@@ -40,13 +43,7 @@ export declare const gtagManifest: {
40
43
  readonly src: "https://www.googletagmanager.com/gtag/js?id={{id}}";
41
44
  readonly async: true;
42
45
  }];
43
- readonly consentMapping: {
44
- readonly necessary: ["security_storage"];
45
- readonly functionality: ["functionality_storage"];
46
- readonly measurement: ["analytics_storage"];
47
- readonly marketing: ["ad_storage", "ad_user_data", "ad_personalization"];
48
- readonly experience: ["personalization_storage"];
49
- };
46
+ readonly consentMapping: Record<string, string[]>;
50
47
  readonly consentSignal: "gtag";
51
48
  readonly kind: "c15t.vendor-manifest";
52
49
  readonly schemaVersion: 1;
@@ -0,0 +1,73 @@
1
+ import type { Script } from 'c15t';
2
+ declare global {
3
+ interface Window {
4
+ hj?: ((...args: unknown[]) => void) & {
5
+ q?: unknown[][];
6
+ };
7
+ _hjSettings?: {
8
+ hjid: number | string;
9
+ hjsv: number;
10
+ };
11
+ }
12
+ }
13
+ /**
14
+ * Hotjar vendor manifest.
15
+ *
16
+ * Seeds the global Hotjar settings object and queue stub before loading
17
+ * the vendor bundle.
18
+ */
19
+ export declare const hotjarManifest: {
20
+ readonly vendor: "hotjar";
21
+ readonly category: "measurement";
22
+ readonly install: [{
23
+ readonly type: "setGlobal";
24
+ readonly name: "_hjSettings";
25
+ readonly value: {
26
+ readonly hjid: "{{siteId}}";
27
+ readonly hjsv: "{{version}}";
28
+ };
29
+ readonly ifUndefined: true;
30
+ }, {
31
+ readonly type: "defineStubFunction";
32
+ readonly name: "hj";
33
+ readonly queue: {
34
+ readonly property: "q";
35
+ };
36
+ readonly queueFormat: "array";
37
+ readonly ifUndefined: true;
38
+ }, {
39
+ readonly type: "loadScript";
40
+ readonly src: "{{scriptUrl}}";
41
+ readonly async: true;
42
+ }];
43
+ readonly kind: "c15t.vendor-manifest";
44
+ readonly schemaVersion: 1;
45
+ };
46
+ export interface HotjarOptions {
47
+ /**
48
+ * Your Hotjar site ID.
49
+ * @example `1234567`
50
+ */
51
+ siteId: number | string;
52
+ /**
53
+ * Hotjar script version.
54
+ * @default 6
55
+ */
56
+ version?: number;
57
+ /** Hotjar loader URL. */
58
+ scriptUrl?: string;
59
+ }
60
+ /**
61
+ * Creates a Hotjar script.
62
+ *
63
+ * @param options - The options for the Hotjar script.
64
+ * @returns The Hotjar script configuration.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * import { hotjar } from '@c15t/scripts/hotjar';
69
+ *
70
+ * hotjar({ siteId: 1234567 });
71
+ * ```
72
+ */
73
+ export declare function hotjar({ siteId, version, scriptUrl, }: HotjarOptions): Script;
@@ -0,0 +1,41 @@
1
+ import type { Script } from 'c15t';
2
+ import { type VendorManifest } from '../../types';
3
+ declare global {
4
+ interface Window {
5
+ _paq?: unknown[];
6
+ }
7
+ }
8
+ export declare const matomoAnalyticsManifest: VendorManifest;
9
+ export interface MatomoAnalyticsOptions {
10
+ /** Your Matomo site ID. */
11
+ siteId?: string | number;
12
+ /** Your Matomo base URL, for example `https://analytics.example.com`. */
13
+ matomoUrl?: string;
14
+ /** Your Matomo Cloud identifier, for example `my-site.matomo.cloud`. */
15
+ cloudId?: string;
16
+ /** Optional explicit tracker endpoint override. */
17
+ trackerUrl?: string;
18
+ /** Optional explicit script URL override. */
19
+ scriptUrl?: string;
20
+ /** Queue `enableLinkTracking`. */
21
+ enableLinkTracking?: boolean;
22
+ /** Queue `disableCookies`. */
23
+ disableCookies?: boolean;
24
+ /** Queue an initial `trackPageView`. */
25
+ trackPageView?: boolean;
26
+ /** Default Matomo consent state (`required` blocks, `given` starts enabled). */
27
+ defaultConsent?: 'required' | 'given';
28
+ }
29
+ /**
30
+ * Creates a Matomo Analytics script.
31
+ *
32
+ * @param options - The options for the Matomo Analytics script.
33
+ * @returns The Matomo Analytics script configuration.
34
+ * @throws {Error} Throws
35
+ * `'matomoAnalytics requires \`matomoUrl\`, \`cloudId\`, or explicit \`trackerUrl\` and \`scriptUrl\` values.'`
36
+ * when either resolved `trackerUrl` or `scriptUrl` is missing (for example,
37
+ * when neither `matomoUrl` nor `cloudId` is provided and explicit
38
+ * `trackerUrl`/`scriptUrl` values are not supplied). Provide `matomoUrl`, or
39
+ * provide both explicit `trackerUrl` and `scriptUrl`.
40
+ */
41
+ export declare function matomoAnalytics(options?: MatomoAnalyticsOptions): Script;
@@ -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 opt_in/opt_out capturing.
21
- * The script always loads, and consent is toggled via the PostHog API.
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': "{{apiHost}}";
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
- * 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.
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;