@c15t/scripts 2.1.0 → 2.2.0-canary-20260804162155
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 +32 -20
- 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 +103 -17
- package/dist/engine/runtime.js +94 -12
- package/dist/registry.cjs +97 -12
- package/dist/registry.js +80 -0
- package/dist/resolve.cjs +9 -5
- package/dist/types.cjs +17 -13
- package/dist/vendors/_shared/attributes.cjs +13 -9
- package/dist/vendors/_shared/google-consent.cjs +14 -9
- package/dist/vendors/_shared/install-builders.cjs +12 -8
- package/dist/vendors/_shared/script-url.cjs +16 -12
- package/dist/vendors/ads-and-pixels/linkedin-insights.cjs +9 -5
- package/dist/vendors/ads-and-pixels/meta-pixel.cjs +13 -9
- package/dist/vendors/ads-and-pixels/microsoft-uet.cjs +11 -7
- package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +9 -5
- package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +11 -7
- package/dist/vendors/ads-and-pixels/tiktok-pixel.cjs +9 -5
- package/dist/vendors/ads-and-pixels/x-pixel.cjs +9 -5
- 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 +11 -7
- 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 +11 -7
- package/dist/vendors/analytics/databuddy.cjs +11 -7
- package/dist/vendors/analytics/fathom-analytics.cjs +11 -7
- package/dist/vendors/analytics/google-tag.cjs +11 -7
- 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 +11 -7
- package/dist/vendors/analytics/logrocket.cjs +99 -0
- package/dist/vendors/analytics/logrocket.js +58 -0
- package/dist/vendors/analytics/matomo-analytics.cjs +9 -5
- package/dist/vendors/analytics/microsoft-clarity.cjs +75 -47
- package/dist/vendors/analytics/microsoft-clarity.js +64 -40
- package/dist/vendors/analytics/mixpanel-analytics.cjs +31 -16
- package/dist/vendors/analytics/mixpanel-analytics.js +22 -11
- package/dist/vendors/analytics/pirsch.cjs +108 -0
- package/dist/vendors/analytics/pirsch.js +67 -0
- package/dist/vendors/analytics/plausible-analytics.cjs +9 -5
- package/dist/vendors/analytics/posthog.cjs +63 -27
- package/dist/vendors/analytics/posthog.js +52 -20
- package/dist/vendors/analytics/promptwatch.cjs +11 -7
- package/dist/vendors/analytics/rudderstack.cjs +227 -0
- package/dist/vendors/analytics/rudderstack.js +183 -0
- package/dist/vendors/analytics/rybbit-analytics.cjs +9 -5
- package/dist/vendors/analytics/segment.cjs +9 -5
- package/dist/vendors/analytics/umami-analytics.cjs +9 -5
- package/dist/vendors/analytics/vercel-analytics.cjs +11 -7
- package/dist/vendors/functional/crisp.cjs +9 -5
- package/dist/vendors/functional/intercom.cjs +11 -7
- package/dist/vendors/tag-managers/google-tag-manager.cjs +11 -7
- package/dist-types/registry.d.ts +313 -241
- package/dist-types/types.d.ts +46 -4
- package/dist-types/vendors/ads-and-pixels/linkedin-insights.d.ts +18 -18
- package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +21 -21
- package/dist-types/vendors/ads-and-pixels/microsoft-uet.d.ts +32 -32
- package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +19 -19
- package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +16 -16
- package/dist-types/vendors/ads-and-pixels/tiktok-pixel.d.ts +28 -28
- package/dist-types/vendors/ads-and-pixels/x-pixel.d.ts +13 -13
- package/dist-types/vendors/analytics/adobe-analytics.d.ts +75 -0
- package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +7 -7
- 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 +7 -7
- package/dist-types/vendors/analytics/databuddy.d.ts +25 -25
- package/dist-types/vendors/analytics/fathom-analytics.d.ts +11 -11
- package/dist-types/vendors/analytics/google-tag.d.ts +17 -17
- 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 +14 -14
- package/dist-types/vendors/analytics/logrocket.d.ts +101 -0
- package/dist-types/vendors/analytics/microsoft-clarity.d.ts +42 -30
- package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +40 -28
- package/dist-types/vendors/analytics/pirsch.d.ts +96 -0
- package/dist-types/vendors/analytics/plausible-analytics.d.ts +13 -13
- package/dist-types/vendors/analytics/posthog.d.ts +63 -45
- package/dist-types/vendors/analytics/promptwatch.d.ts +7 -7
- package/dist-types/vendors/analytics/rudderstack.d.ts +330 -0
- package/dist-types/vendors/analytics/rybbit-analytics.d.ts +18 -18
- package/dist-types/vendors/analytics/segment.d.ts +13 -13
- package/dist-types/vendors/analytics/umami-analytics.d.ts +12 -12
- package/dist-types/vendors/analytics/vercel-analytics.d.ts +16 -16
- package/dist-types/vendors/functional/crisp.d.ts +11 -11
- package/dist-types/vendors/functional/intercom.d.ts +16 -16
- package/dist-types/vendors/tag-managers/google-tag-manager.d.ts +18 -18
- package/docs/README.md +62 -0
- package/docs/frameworks/javascript/script-loader.md +356 -0
- package/docs/frameworks/next/script-loader.md +501 -0
- package/docs/frameworks/react/script-loader.md +555 -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 +311 -0
- package/package.json +61 -7
- package/readme.json +8 -4
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Build a Custom Script Integration
|
|
3
|
+
description: Learn when to use a raw Script, when to build a reusable
|
|
4
|
+
manifest-backed integration, and how to debug and test custom consent-aware
|
|
5
|
+
scripts in c15t.
|
|
6
|
+
group: integrations
|
|
7
|
+
---
|
|
8
|
+
If you cannot find a prebuilt integration in [`@c15t/scripts`](/docs/integrations), you have two good options:
|
|
9
|
+
|
|
10
|
+
1. Build a one-off `Script` object directly in your app.
|
|
11
|
+
2. Build a reusable manifest-backed integration helper.
|
|
12
|
+
|
|
13
|
+
Use the first option for app-specific scripts. Use the second option when you want something reusable, testable, and aligned with c15t's manifest system.
|
|
14
|
+
|
|
15
|
+
## Choose the Right Level
|
|
16
|
+
|
|
17
|
+
### One-off app script
|
|
18
|
+
|
|
19
|
+
Use a raw `Script` when:
|
|
20
|
+
|
|
21
|
+
* the integration is only used in one app
|
|
22
|
+
* the vendor setup is small
|
|
23
|
+
* you do not need to publish or share the helper
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import type { Script } from 'c15t';
|
|
27
|
+
|
|
28
|
+
export function acmeAnalytics(siteId: string): Script {
|
|
29
|
+
return {
|
|
30
|
+
id: 'acme-analytics',
|
|
31
|
+
src: `https://cdn.acme.com/analytics.js?site=${siteId}`,
|
|
32
|
+
category: 'measurement',
|
|
33
|
+
onBeforeLoad: () => {
|
|
34
|
+
window.acmeQueue = window.acmeQueue || [];
|
|
35
|
+
},
|
|
36
|
+
onConsentChange: ({ hasConsent }) => {
|
|
37
|
+
window.acme?.setConsent(hasConsent);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Reusable manifest-backed integration
|
|
44
|
+
|
|
45
|
+
Use a manifest-backed helper when:
|
|
46
|
+
|
|
47
|
+
* you want to contribute to `@c15t/scripts`
|
|
48
|
+
* you want the integration to be reusable across apps
|
|
49
|
+
* you need structured startup/setup phases
|
|
50
|
+
* you want compatibility with c15t's server-side support for script loading
|
|
51
|
+
|
|
52
|
+
Manifest integrations should be declarative, serializable, and built from structured steps rather than raw inline JavaScript strings.
|
|
53
|
+
|
|
54
|
+
## Manifest Contract
|
|
55
|
+
|
|
56
|
+
Every reusable manifest carries two contract fields:
|
|
57
|
+
|
|
58
|
+
* `kind`: identifies the payload as a c15t vendor manifest
|
|
59
|
+
* `schemaVersion`: identifies which manifest schema the runtime should compile
|
|
60
|
+
|
|
61
|
+
Use `vendorManifestContract` so helpers stay aligned with the runtime's current contract:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
const acmeManifest = {
|
|
65
|
+
...vendorManifestContract,
|
|
66
|
+
vendor: 'acme-analytics',
|
|
67
|
+
// ...
|
|
68
|
+
} as const satisfies VendorManifest;
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
If manifests are sent from a server later, these fields are how the client can validate that it knows how to interpret the payload before executing anything.
|
|
72
|
+
|
|
73
|
+
## Manifest Mental Model
|
|
74
|
+
|
|
75
|
+
The manifest runtime executes a script in ordered phases:
|
|
76
|
+
|
|
77
|
+
* `bootstrap`: globals or stubs that must exist before anything else
|
|
78
|
+
* `install`: startup steps plus a single `loadScript`
|
|
79
|
+
* `afterLoad`: work that should run after the external script loads
|
|
80
|
+
* `onBeforeLoadGranted` / `onBeforeLoadDenied`: initial consent-specific setup
|
|
81
|
+
* `onLoadGranted` / `onLoadDenied`: post-load consent-specific setup
|
|
82
|
+
* `onConsentChange`: runs on every consent update
|
|
83
|
+
* `onConsentGranted` / `onConsentDenied`: branch-specific consent updates
|
|
84
|
+
|
|
85
|
+
For vendors with explicit consent APIs, you can also use:
|
|
86
|
+
|
|
87
|
+
* `consentMapping`
|
|
88
|
+
* `consentSignal`
|
|
89
|
+
* `consentSignalTarget`
|
|
90
|
+
|
|
91
|
+
That is how the Google integrations map c15t consent categories to Consent Mode v2 and inject `default` and `update` signals in the correct phase order.
|
|
92
|
+
|
|
93
|
+
`category` supports the same consent condition model as a plain `Script`, so manifests can represent simple or nested rules such as:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
category: { and: ['measurement', { not: 'marketing' }] }
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Structured Steps
|
|
100
|
+
|
|
101
|
+
Prefer structured steps over raw script text. The current manifest DSL supports patterns like:
|
|
102
|
+
|
|
103
|
+
* `setGlobal`
|
|
104
|
+
* `setGlobalPath`
|
|
105
|
+
* `defineQueueFunction`
|
|
106
|
+
* `defineStubFunction`
|
|
107
|
+
* `pushToQueue`
|
|
108
|
+
* `callGlobal`
|
|
109
|
+
* `defineQueueMethods`
|
|
110
|
+
* `defineGlobalMethods`
|
|
111
|
+
* `constructGlobal`
|
|
112
|
+
* `loadScript`
|
|
113
|
+
|
|
114
|
+
These steps are easier to validate, test, debug, and eventually transport from the server.
|
|
115
|
+
|
|
116
|
+
## Example Manifest Integration
|
|
117
|
+
|
|
118
|
+
If you are building a reusable helper, the pattern looks like this:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
import type { Script } from 'c15t';
|
|
122
|
+
import { resolveManifest } from '@c15t/scripts/resolve';
|
|
123
|
+
import {
|
|
124
|
+
vendorManifestContract,
|
|
125
|
+
type VendorManifest,
|
|
126
|
+
} from '@c15t/scripts/types';
|
|
127
|
+
|
|
128
|
+
const acmeManifest = {
|
|
129
|
+
...vendorManifestContract,
|
|
130
|
+
vendor: 'acme-analytics',
|
|
131
|
+
category: 'measurement',
|
|
132
|
+
bootstrap: [
|
|
133
|
+
{
|
|
134
|
+
type: 'setGlobal',
|
|
135
|
+
name: 'acmeQueue',
|
|
136
|
+
value: [],
|
|
137
|
+
ifUndefined: true,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
type: 'defineQueueFunction',
|
|
141
|
+
name: 'acme',
|
|
142
|
+
queue: 'acmeQueue',
|
|
143
|
+
ifUndefined: true,
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
install: [
|
|
147
|
+
{
|
|
148
|
+
type: 'callGlobal',
|
|
149
|
+
global: 'acme',
|
|
150
|
+
args: ['init', '{{siteId}}'],
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
type: 'loadScript',
|
|
154
|
+
src: 'https://cdn.acme.com/analytics.js?site={{siteId}}',
|
|
155
|
+
async: true,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
onConsentGranted: [
|
|
159
|
+
{
|
|
160
|
+
type: 'callGlobal',
|
|
161
|
+
global: 'acme',
|
|
162
|
+
args: ['consent', true],
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
onConsentDenied: [
|
|
166
|
+
{
|
|
167
|
+
type: 'callGlobal',
|
|
168
|
+
global: 'acme',
|
|
169
|
+
args: ['consent', false],
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
} as const satisfies VendorManifest;
|
|
173
|
+
|
|
174
|
+
export function acmeAnalytics(siteId: string): Script {
|
|
175
|
+
return resolveManifest(acmeManifest, { siteId });
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Design Guidelines
|
|
180
|
+
|
|
181
|
+
When building an integration, prefer these rules:
|
|
182
|
+
|
|
183
|
+
* Keep helper logic thin. Put behavior in the manifest, not in post-resolution callback mutation.
|
|
184
|
+
* Keep manifests serializable. Avoid helper-only runtime branches where possible.
|
|
185
|
+
* Use explicit config inputs. Avoid generic override bags when a named option is clearer.
|
|
186
|
+
* Use `alwaysLoad` only when the vendor truly manages its own consent correctly.
|
|
187
|
+
* Use `persistAfterConsentRevoked` only when the vendor exposes a real consent toggle and does not need a full reload.
|
|
188
|
+
* Keep vendor-specific naming out of the core DSL when a generic step can express it.
|
|
189
|
+
|
|
190
|
+
## Testing Checklist
|
|
191
|
+
|
|
192
|
+
At minimum, test these flows:
|
|
193
|
+
|
|
194
|
+
1. Initial page load with consent denied.
|
|
195
|
+
2. Initial page load with consent granted.
|
|
196
|
+
3. Consent granted after the script was previously denied.
|
|
197
|
+
4. Consent revoked after the script was previously active.
|
|
198
|
+
5. Existing script element reuse if the script persists after revocation.
|
|
199
|
+
6. Error handling if the vendor global or loader is missing.
|
|
200
|
+
|
|
201
|
+
If you are contributing to `@c15t/scripts`, add focused engine/helper tests similar to the existing tests in `packages/scripts/src/engine.test.ts` and `packages/scripts/src/helpers.test.ts`.
|
|
202
|
+
|
|
203
|
+
## Debugging
|
|
204
|
+
|
|
205
|
+
Use `@c15t/dev-tools` while implementing and testing integrations.
|
|
206
|
+
|
|
207
|
+
The scripts panel now shows:
|
|
208
|
+
|
|
209
|
+
* whether a script is loaded, pending, or blocked
|
|
210
|
+
* grouped activity for `onBeforeLoad`, `onLoad`, and `onConsentChange`
|
|
211
|
+
* manifest phase activity such as `bootstrap`, `consent-default`, `setup`, and `afterLoad`
|
|
212
|
+
|
|
213
|
+
The events panel also records script lifecycle and manifest step events, which is useful when a vendor reads consent too early or a startup step runs in the wrong order.
|
|
214
|
+
|
|
215
|
+
## When to Stop and Use a Plain Script
|
|
216
|
+
|
|
217
|
+
Not every integration needs a reusable manifest helper.
|
|
218
|
+
|
|
219
|
+
If the vendor snippet is tiny, unique to one app, or mostly static, a plain `Script` object in your runtime options is usually the simpler choice. Reach for the manifest system when you need reuse, consistency, structured startup behavior, or a path to server-driven manifests.
|
|
220
|
+
|
|
221
|
+
## Reference Types
|
|
222
|
+
|
|
223
|
+
### Script
|
|
224
|
+
|
|
225
|
+
|Property|Value|
|
|
226
|
+
|:--|:--|
|
|
227
|
+
|Type Name|\`Script\`|
|
|
228
|
+
|Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
|
|
229
|
+
|
|
230
|
+
\*ExtractedTypeTable: Could not extract "Script" from "./packages/core/src/libs/script-loader/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
231
|
+
|
|
232
|
+
### VendorManifest
|
|
233
|
+
|
|
234
|
+
|Property|Value|
|
|
235
|
+
|:--|:--|
|
|
236
|
+
|Type Name|\`VendorManifest\`|
|
|
237
|
+
|Source Path|\`./packages/scripts/src/types.ts\`|
|
|
238
|
+
|
|
239
|
+
\*ExtractedTypeTable: Could not extract "VendorManifest" from "./packages/scripts/src/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Clearbit
|
|
3
|
+
description: Visitor and company enrichment loaded with Clearbit's account-keyed
|
|
4
|
+
tags.js snippet.
|
|
5
|
+
group: integrations
|
|
6
|
+
icon: clearbit
|
|
7
|
+
---
|
|
8
|
+
[Clearbit](https://clearbit.com) provides visitor and company enrichment for go-to-market workflows. The official embed loads `https://tag.clearbitscripts.com/v1/{publishableKey}/tags.js` with a `referrerpolicy` of `strict-origin-when-cross-origin`.
|
|
9
|
+
|
|
10
|
+
## Integrate with c15t
|
|
11
|
+
|
|
12
|
+
**React**
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { type ReactNode } from 'react';
|
|
16
|
+
import { ConsentManagerProvider } from '@c15t/react';
|
|
17
|
+
import { clearbit } from '@c15t/scripts/clearbit';
|
|
18
|
+
|
|
19
|
+
const scripts = [
|
|
20
|
+
clearbit({
|
|
21
|
+
publishableKey: 'YOUR_PUBLISHABLE_KEY',
|
|
22
|
+
}),
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
26
|
+
return (
|
|
27
|
+
<ConsentManagerProvider
|
|
28
|
+
options={{
|
|
29
|
+
mode: 'hosted',
|
|
30
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
31
|
+
scripts,
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
</ConsentManagerProvider>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Next.js**
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
'use client';
|
|
44
|
+
|
|
45
|
+
import { type ReactNode } from 'react';
|
|
46
|
+
import { ConsentManagerProvider } from '@c15t/nextjs';
|
|
47
|
+
import { clearbit } from '@c15t/scripts/clearbit';
|
|
48
|
+
|
|
49
|
+
const scripts = [
|
|
50
|
+
clearbit({
|
|
51
|
+
publishableKey: 'YOUR_PUBLISHABLE_KEY',
|
|
52
|
+
}),
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
56
|
+
return (
|
|
57
|
+
<ConsentManagerProvider
|
|
58
|
+
options={{
|
|
59
|
+
mode: 'hosted',
|
|
60
|
+
backendURL: '/api/c15t',
|
|
61
|
+
scripts,
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
{children}
|
|
65
|
+
</ConsentManagerProvider>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**JavaScript**
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { getOrCreateConsentRuntime } from 'c15t';
|
|
74
|
+
import { clearbit } from '@c15t/scripts/clearbit';
|
|
75
|
+
|
|
76
|
+
getOrCreateConsentRuntime({
|
|
77
|
+
mode: 'hosted',
|
|
78
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
79
|
+
scripts: [
|
|
80
|
+
clearbit({
|
|
81
|
+
publishableKey: 'YOUR_PUBLISHABLE_KEY',
|
|
82
|
+
}),
|
|
83
|
+
],
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## How c15t loads it
|
|
88
|
+
|
|
89
|
+
* **Category:** `marketing` (Analytics discovery, marketing-sensitive consent)
|
|
90
|
+
* **Loads when:** marketing consent is granted
|
|
91
|
+
* **On revocation:** unloaded — c15t removes the script element from the DOM.
|
|
92
|
+
|
|
93
|
+
Clearbit enrichment tools are privacy-sensitive because they can identify visitors and companies for profiling, enrichment, and intent use cases. The GitHub issue left the category open between measurement and marketing; c15t defaults this integration to `marketing` because enrichment is not just aggregate measurement. The script stays blocked until marketing consent is granted. On revocation c15t removes the script element it created; tags that Clearbit's loader has already appended can keep running until the next page load (c15t reloads the page on revocation by default), so treat the load gate as the consent boundary.
|
|
94
|
+
|
|
95
|
+
The helper maps Clearbit's official snippet:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
clearbit({
|
|
99
|
+
publishableKey: 'YOUR_PUBLISHABLE_KEY',
|
|
100
|
+
})
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
To proxy or self-host the loader, pass a custom URL:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
clearbit({
|
|
107
|
+
publishableKey: 'YOUR_PUBLISHABLE_KEY',
|
|
108
|
+
scriptUrl: 'https://analytics.example.com/clearbit-tags.js',
|
|
109
|
+
})
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Types
|
|
113
|
+
|
|
114
|
+
### ClearbitOptions
|
|
115
|
+
|
|
116
|
+
|Property|Value|
|
|
117
|
+
|:--|:--|
|
|
118
|
+
|Type Name|\`ClearbitOptions\`|
|
|
119
|
+
|Source Path|\`./packages/scripts/src/vendors/analytics/clearbit.ts\`|
|
|
120
|
+
|
|
121
|
+
\*ExtractedTypeTable: Could not extract "ClearbitOptions" from "./packages/scripts/src/vendors/analytics/clearbit.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
122
|
+
|
|
123
|
+
### Script
|
|
124
|
+
|
|
125
|
+
|Property|Value|
|
|
126
|
+
|:--|:--|
|
|
127
|
+
|Type Name|\`Script\`|
|
|
128
|
+
|Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
|
|
129
|
+
|
|
130
|
+
\*ExtractedTypeTable: Could not extract "Script" from "./packages/core/src/libs/script-loader/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Cloudflare Web Analytics
|
|
3
|
+
description: Cookieless analytics from Cloudflare with a prebuilt helper that
|
|
4
|
+
serializes the beacon config into the `data-cf-beacon` attribute.
|
|
5
|
+
group: integrations
|
|
6
|
+
icon: cloudflare-web-analytics
|
|
7
|
+
---
|
|
8
|
+
Cloudflare Web Analytics is a cookieless analytics product configured through a single `data-cf-beacon` attribute on its loader. The `cloudflareWebAnalytics()` helper serializes your token and single-page application (SPA) preference into that attribute and hands the result to c15t's script loader.
|
|
9
|
+
|
|
10
|
+
## Integrate with c15t
|
|
11
|
+
|
|
12
|
+
**React**
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { type ReactNode } from 'react';
|
|
16
|
+
import { ConsentManagerProvider } from '@c15t/react';
|
|
17
|
+
import { cloudflareWebAnalytics } from '@c15t/scripts/cloudflare-web-analytics';
|
|
18
|
+
|
|
19
|
+
const scripts = [
|
|
20
|
+
cloudflareWebAnalytics({
|
|
21
|
+
token: 'your-cloudflare-token',
|
|
22
|
+
}),
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
26
|
+
return (
|
|
27
|
+
<ConsentManagerProvider
|
|
28
|
+
options={{
|
|
29
|
+
mode: 'hosted',
|
|
30
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
31
|
+
scripts,
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
</ConsentManagerProvider>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Next.js**
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
'use client';
|
|
44
|
+
|
|
45
|
+
import { type ReactNode } from 'react';
|
|
46
|
+
import { ConsentManagerProvider } from '@c15t/nextjs';
|
|
47
|
+
import { cloudflareWebAnalytics } from '@c15t/scripts/cloudflare-web-analytics';
|
|
48
|
+
|
|
49
|
+
const scripts = [
|
|
50
|
+
cloudflareWebAnalytics({
|
|
51
|
+
token: 'your-cloudflare-token',
|
|
52
|
+
}),
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
56
|
+
return (
|
|
57
|
+
<ConsentManagerProvider
|
|
58
|
+
options={{
|
|
59
|
+
mode: 'hosted',
|
|
60
|
+
backendURL: '/api/c15t',
|
|
61
|
+
scripts,
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
{children}
|
|
65
|
+
</ConsentManagerProvider>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**JavaScript**
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { getOrCreateConsentRuntime } from 'c15t';
|
|
74
|
+
import { cloudflareWebAnalytics } from '@c15t/scripts/cloudflare-web-analytics';
|
|
75
|
+
|
|
76
|
+
getOrCreateConsentRuntime({
|
|
77
|
+
mode: 'hosted',
|
|
78
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
79
|
+
scripts: [
|
|
80
|
+
cloudflareWebAnalytics({
|
|
81
|
+
token: 'your-cloudflare-token',
|
|
82
|
+
}),
|
|
83
|
+
],
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## How c15t loads it
|
|
88
|
+
|
|
89
|
+
* **Category:** `measurement` (Analytics)
|
|
90
|
+
* **Loads when:** measurement consent is granted
|
|
91
|
+
* **On revocation:** unloaded — c15t removes the script element from the DOM. Cloudflare Web Analytics is cookieless, so no client-side state needs clearing.
|
|
92
|
+
|
|
93
|
+
SPA route tracking is enabled by default. Disable it for traditional multi-page apps:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
cloudflareWebAnalytics({
|
|
97
|
+
token: 'your-cloudflare-token',
|
|
98
|
+
spa: false,
|
|
99
|
+
})
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The helper JSON-encodes `{ token, spa }` into the `data-cf-beacon` attribute that Cloudflare's loader reads at startup, matching Cloudflare's recommended embed.
|
|
103
|
+
|
|
104
|
+
## Tracking events in your app
|
|
105
|
+
|
|
106
|
+
Cloudflare Web Analytics has no app-facing event API — the beacon tracks pageviews automatically once the script is loaded. There are no event calls in your application code to guard, so c15t's consent gating fully controls when and whether tracking happens.
|
|
107
|
+
|
|
108
|
+
## Types
|
|
109
|
+
|
|
110
|
+
### CloudflareWebAnalyticsOptions
|
|
111
|
+
|
|
112
|
+
|Property|Value|
|
|
113
|
+
|:--|:--|
|
|
114
|
+
|Type Name|\`CloudflareWebAnalyticsOptions\`|
|
|
115
|
+
|Source Path|\`./packages/scripts/src/vendors/analytics/cloudflare-web-analytics.ts\`|
|
|
116
|
+
|
|
117
|
+
\*ExtractedTypeTable: Could not extract "CloudflareWebAnalyticsOptions" from "./packages/scripts/src/vendors/analytics/cloudflare-web-analytics.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
118
|
+
|
|
119
|
+
### Script
|
|
120
|
+
|
|
121
|
+
|Property|Value|
|
|
122
|
+
|:--|:--|
|
|
123
|
+
|Type Name|\`Script\`|
|
|
124
|
+
|Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
|
|
125
|
+
|
|
126
|
+
\*ExtractedTypeTable: Could not extract "Script" from "./packages/core/src/libs/script-loader/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Crisp
|
|
3
|
+
description: Load Crisp live chat with website ID, runtime, cookie, and session options.
|
|
4
|
+
group: integrations
|
|
5
|
+
icon: crisp
|
|
6
|
+
---
|
|
7
|
+
Crisp adds the Crisp live chat widget and exposes the `$crisp` queue for
|
|
8
|
+
chatbox actions such as opening the chat, setting user details, and resetting
|
|
9
|
+
sessions.
|
|
10
|
+
|
|
11
|
+
## Official Crisp documentation
|
|
12
|
+
|
|
13
|
+
* [Web Chat SDK](https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/)
|
|
14
|
+
* [$crisp methods](https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/dollar-crisp/)
|
|
15
|
+
* [Identity verification](https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/identity-verification/)
|
|
16
|
+
* [Cookie policies](https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/cookie-policies/)
|
|
17
|
+
* [Session continuity](https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/session-continuity/)
|
|
18
|
+
* [Language customization](https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/language-customization/)
|
|
19
|
+
|
|
20
|
+
## Integrate with c15t
|
|
21
|
+
|
|
22
|
+
**React**
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { type ReactNode } from 'react';
|
|
26
|
+
import { ConsentManagerProvider } from '@c15t/react';
|
|
27
|
+
import { crisp } from '@c15t/scripts/crisp';
|
|
28
|
+
|
|
29
|
+
const scripts = [crisp({ websiteId: 'crisp-123' })];
|
|
30
|
+
|
|
31
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
32
|
+
return (
|
|
33
|
+
<ConsentManagerProvider
|
|
34
|
+
options={{
|
|
35
|
+
mode: 'hosted',
|
|
36
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
37
|
+
scripts,
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
{children}
|
|
41
|
+
</ConsentManagerProvider>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Next.js**
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
'use client';
|
|
50
|
+
|
|
51
|
+
import { type ReactNode } from 'react';
|
|
52
|
+
import { ConsentManagerProvider } from '@c15t/nextjs';
|
|
53
|
+
import { crisp } from '@c15t/scripts/crisp';
|
|
54
|
+
|
|
55
|
+
const scripts = [crisp({ websiteId: 'crisp-123' })];
|
|
56
|
+
|
|
57
|
+
export function ConsentProvider({ children }: { children: ReactNode }) {
|
|
58
|
+
return (
|
|
59
|
+
<ConsentManagerProvider
|
|
60
|
+
options={{
|
|
61
|
+
mode: 'hosted',
|
|
62
|
+
backendURL: '/api/c15t',
|
|
63
|
+
scripts,
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
{children}
|
|
67
|
+
</ConsentManagerProvider>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**JavaScript**
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { getOrCreateConsentRuntime } from 'c15t';
|
|
76
|
+
import { crisp } from '@c15t/scripts/crisp';
|
|
77
|
+
|
|
78
|
+
getOrCreateConsentRuntime({
|
|
79
|
+
mode: 'hosted',
|
|
80
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
81
|
+
scripts: [crisp({ websiteId: 'crisp-123' })],
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## How c15t loads it
|
|
86
|
+
|
|
87
|
+
* **Category:** `functionality` (Functional)
|
|
88
|
+
* **Loads when:** functionality consent is granted
|
|
89
|
+
* **Before load:** c15t seeds `window.$crisp`, `CRISP_WEBSITE_ID`, and any
|
|
90
|
+
optional Crisp runtime globals
|
|
91
|
+
* **On revocation:** c15t follows the default script loader behavior for
|
|
92
|
+
non-persistent scripts
|
|
93
|
+
|
|
94
|
+
## Configure the integration
|
|
95
|
+
|
|
96
|
+
The helper seeds Crisp's documented globals before loading
|
|
97
|
+
`https://client.crisp.chat/l.js`.
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
crisp({
|
|
101
|
+
websiteId: 'crisp-123',
|
|
102
|
+
locale: 'fr',
|
|
103
|
+
cookieDomain: 'app.example.com',
|
|
104
|
+
cookieExpiry: 3600,
|
|
105
|
+
tokenId: 'secure-user-token',
|
|
106
|
+
sessionMerge: true,
|
|
107
|
+
safeMode: true,
|
|
108
|
+
})
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`locale` and `sessionMerge` are written to `CRISP_RUNTIME_CONFIG`.
|
|
112
|
+
`cookieDomain` maps to `CRISP_COOKIE_DOMAIN`, `cookieExpiry` maps to
|
|
113
|
+
`CRISP_COOKIE_EXPIRE`, and `tokenId` maps to `CRISP_TOKEN_ID`. `safeMode`
|
|
114
|
+
queues `['safe', true]` on `window.$crisp` before the loader runs so Crisp
|
|
115
|
+
starts in safe mode.
|
|
116
|
+
|
|
117
|
+
For session continuity, generate `tokenId` on your backend with a secure random
|
|
118
|
+
value. Do not use emails, hashes of emails, timestamps, or incrementing IDs as
|
|
119
|
+
Crisp session tokens. If you verify user emails, generate the HMAC signature on
|
|
120
|
+
your backend and set it with Crisp's `$crisp` API after the helper loads.
|
|
121
|
+
|
|
122
|
+
## Types
|
|
123
|
+
|
|
124
|
+
### CrispOptions
|
|
125
|
+
|
|
126
|
+
|Property|Value|
|
|
127
|
+
|:--|:--|
|
|
128
|
+
|Type Name|\`CrispOptions\`|
|
|
129
|
+
|Source Path|\`./packages/scripts/src/vendors/functional/crisp.ts\`|
|
|
130
|
+
|
|
131
|
+
\*ExtractedTypeTable: Could not extract "CrispOptions" from "./packages/scripts/src/vendors/functional/crisp.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
132
|
+
|
|
133
|
+
### Script
|
|
134
|
+
|
|
135
|
+
|Property|Value|
|
|
136
|
+
|:--|:--|
|
|
137
|
+
|Type Name|\`Script\`|
|
|
138
|
+
|Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
|
|
139
|
+
|
|
140
|
+
\*ExtractedTypeTable: Could not extract "Script" from "./packages/core/src/libs/script-loader/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|