mytart 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +330 -13
- package/dist/index.d.ts +330 -13
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -37,12 +37,64 @@ interface ConsentSettings {
|
|
|
37
37
|
}
|
|
38
38
|
type ProviderName = 'google-analytics' | 'mixpanel' | 'segment' | 'amplitude' | 'plausible' | 'posthog' | 'meta-pixel' | 'clarity';
|
|
39
39
|
type GoogleAnalyticsAppType = 'browser' | 'server';
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for the Google Analytics (GA4) provider.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* {
|
|
46
|
+
* provider: 'google-analytics',
|
|
47
|
+
* enabled: true,
|
|
48
|
+
* measurementId: 'G-XXXXXXXXXX',
|
|
49
|
+
* appType: 'browser',
|
|
50
|
+
* debug: true,
|
|
51
|
+
* signals: true,
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
40
55
|
interface GoogleAnalyticsConfig extends BaseProviderConfig {
|
|
41
56
|
provider: 'google-analytics';
|
|
57
|
+
/**
|
|
58
|
+
* The GA4 Measurement ID for your data stream.
|
|
59
|
+
* Found in GA4 under Admin › Data Streams › your stream.
|
|
60
|
+
*
|
|
61
|
+
* @example 'G-XXXXXXXXXX'
|
|
62
|
+
*/
|
|
42
63
|
measurementId: string;
|
|
64
|
+
/**
|
|
65
|
+
* API secret for the GA4 Measurement Protocol (server-side).
|
|
66
|
+
* Generate one in GA4 under Admin › Data Streams › Measurement Protocol API secrets.
|
|
67
|
+
* Required when `appType` is `'server'`.
|
|
68
|
+
*
|
|
69
|
+
* @example 'xYzAbCdEfGhIjKlM'
|
|
70
|
+
*/
|
|
43
71
|
apiSecret?: string;
|
|
72
|
+
/**
|
|
73
|
+
* A unique identifier for the client (device/browser instance).
|
|
74
|
+
* In server mode this is required to associate hits with a user session.
|
|
75
|
+
* In browser mode it is managed automatically by gtag.js and can be omitted.
|
|
76
|
+
*
|
|
77
|
+
* @example 'client-123456.7890123456'
|
|
78
|
+
*/
|
|
44
79
|
clientId?: string;
|
|
80
|
+
/**
|
|
81
|
+
* When `true`, enables GA4 debug mode.
|
|
82
|
+
* In browser mode this sends events to the DebugView in the GA4 dashboard.
|
|
83
|
+
* In server mode this sets `debug_mode: true` on Measurement Protocol payloads.
|
|
84
|
+
*
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
45
87
|
debug?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Determines how events are sent to Google Analytics.
|
|
90
|
+
*
|
|
91
|
+
* - `'browser'` — injects the gtag.js snippet and uses `window.gtag()` calls.
|
|
92
|
+
* Suitable for client-side web apps.
|
|
93
|
+
* - `'server'` — sends events via the GA4 Measurement Protocol HTTP API.
|
|
94
|
+
* Requires `apiSecret` and `clientId`. Suitable for Node.js / edge / SSR.
|
|
95
|
+
*
|
|
96
|
+
* @default 'browser'
|
|
97
|
+
*/
|
|
46
98
|
appType?: GoogleAnalyticsAppType;
|
|
47
99
|
/**
|
|
48
100
|
* Default consent state set before gtag('config'). In browser mode this
|
|
@@ -83,31 +135,198 @@ interface GoogleAnalyticsConfig extends BaseProviderConfig {
|
|
|
83
135
|
*/
|
|
84
136
|
signals?: boolean;
|
|
85
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Configuration for the Mixpanel provider.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* {
|
|
144
|
+
* provider: 'mixpanel',
|
|
145
|
+
* enabled: true,
|
|
146
|
+
* token: 'abc123def456',
|
|
147
|
+
* }
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
86
150
|
interface MixpanelConfig extends BaseProviderConfig {
|
|
87
151
|
provider: 'mixpanel';
|
|
152
|
+
/**
|
|
153
|
+
* Your Mixpanel project token.
|
|
154
|
+
* Found in Mixpanel under Settings › Project Settings › Project Token.
|
|
155
|
+
*
|
|
156
|
+
* @example 'abc123def456'
|
|
157
|
+
*/
|
|
88
158
|
token: string;
|
|
159
|
+
/**
|
|
160
|
+
* Custom Mixpanel API endpoint. Use this if you are routing events through
|
|
161
|
+
* a proxy or using Mixpanel's EU residency endpoint.
|
|
162
|
+
*
|
|
163
|
+
* @default 'https://api.mixpanel.com'
|
|
164
|
+
* @example 'https://api-eu.mixpanel.com'
|
|
165
|
+
*/
|
|
89
166
|
apiUrl?: string;
|
|
90
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Configuration for the Segment provider.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* {
|
|
174
|
+
* provider: 'segment',
|
|
175
|
+
* enabled: true,
|
|
176
|
+
* writeKey: 'wk_abc123...',
|
|
177
|
+
* }
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
91
180
|
interface SegmentConfig extends BaseProviderConfig {
|
|
92
181
|
provider: 'segment';
|
|
182
|
+
/**
|
|
183
|
+
* The Segment source Write Key.
|
|
184
|
+
* Found in Segment under Sources › your source › Settings › API Keys.
|
|
185
|
+
*
|
|
186
|
+
* @example 'wk_abc123def456ghi789'
|
|
187
|
+
*/
|
|
93
188
|
writeKey: string;
|
|
189
|
+
/**
|
|
190
|
+
* Custom Segment API endpoint. Use this if you are routing events through
|
|
191
|
+
* a proxy or a custom Segment data plane.
|
|
192
|
+
*
|
|
193
|
+
* @default 'https://api.segment.io/v1'
|
|
194
|
+
* @example 'https://events.yourdomain.com/v1'
|
|
195
|
+
*/
|
|
94
196
|
apiUrl?: string;
|
|
95
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Configuration for the Amplitude provider.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* {
|
|
204
|
+
* provider: 'amplitude',
|
|
205
|
+
* enabled: true,
|
|
206
|
+
* apiKey: 'your-amplitude-api-key',
|
|
207
|
+
* }
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
96
210
|
interface AmplitudeConfig extends BaseProviderConfig {
|
|
97
211
|
provider: 'amplitude';
|
|
212
|
+
/**
|
|
213
|
+
* Your Amplitude project API key.
|
|
214
|
+
* Found in Amplitude under Settings › Projects › your project › General.
|
|
215
|
+
*
|
|
216
|
+
* @example 'a1b2c3d4e5f6a1b2c3d4e5f6'
|
|
217
|
+
*/
|
|
98
218
|
apiKey: string;
|
|
219
|
+
/**
|
|
220
|
+
* Custom Amplitude API endpoint. Use this if you are routing events through
|
|
221
|
+
* a proxy or using Amplitude's EU data centre.
|
|
222
|
+
*
|
|
223
|
+
* @default 'https://api2.amplitude.com/2/httpapi'
|
|
224
|
+
* @example 'https://api.eu.amplitude.com/2/httpapi'
|
|
225
|
+
*/
|
|
99
226
|
apiUrl?: string;
|
|
100
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Configuration for the Plausible Analytics provider.
|
|
230
|
+
*
|
|
231
|
+
* Plausible is a privacy-focused analytics platform. Server-side usage
|
|
232
|
+
* requires `userAgent` and `xForwardedFor` so Plausible can attribute
|
|
233
|
+
* visits without cookies.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* // Browser usage
|
|
238
|
+
* {
|
|
239
|
+
* provider: 'plausible',
|
|
240
|
+
* enabled: true,
|
|
241
|
+
* domain: 'example.com',
|
|
242
|
+
* }
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```ts
|
|
247
|
+
* // Server-side usage
|
|
248
|
+
* {
|
|
249
|
+
* provider: 'plausible',
|
|
250
|
+
* enabled: true,
|
|
251
|
+
* domain: 'example.com',
|
|
252
|
+
* apiUrl: 'https://plausible.example.com',
|
|
253
|
+
* userAgent: req.headers['user-agent'],
|
|
254
|
+
* xForwardedFor: req.headers['x-forwarded-for'],
|
|
255
|
+
* }
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
101
258
|
interface PlausibleConfig extends BaseProviderConfig {
|
|
102
259
|
provider: 'plausible';
|
|
260
|
+
/**
|
|
261
|
+
* The domain name of the site as configured in your Plausible dashboard.
|
|
262
|
+
* Must match exactly (no protocol, no trailing slash).
|
|
263
|
+
*
|
|
264
|
+
* @example 'example.com'
|
|
265
|
+
*/
|
|
103
266
|
domain: string;
|
|
267
|
+
/**
|
|
268
|
+
* Custom Plausible API endpoint. Use this if you self-host Plausible
|
|
269
|
+
* or route events through a proxy to avoid ad-blockers.
|
|
270
|
+
*
|
|
271
|
+
* @default 'https://plausible.io'
|
|
272
|
+
* @example 'https://plausible.example.com'
|
|
273
|
+
*/
|
|
104
274
|
apiUrl?: string;
|
|
275
|
+
/**
|
|
276
|
+
* The visitor's User-Agent string. Required for server-side usage so
|
|
277
|
+
* Plausible can perform unique-visitor counting without cookies.
|
|
278
|
+
*
|
|
279
|
+
* @example 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) ...'
|
|
280
|
+
*/
|
|
105
281
|
userAgent?: string;
|
|
282
|
+
/**
|
|
283
|
+
* The visitor's IP address, used by Plausible for geolocation and
|
|
284
|
+
* unique-visitor hashing. Required for server-side usage.
|
|
285
|
+
* Pass the `X-Forwarded-For` header value from the incoming request.
|
|
286
|
+
*
|
|
287
|
+
* @example '203.0.113.42'
|
|
288
|
+
*/
|
|
106
289
|
xForwardedFor?: string;
|
|
107
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Configuration for the PostHog provider.
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```ts
|
|
296
|
+
* {
|
|
297
|
+
* provider: 'posthog',
|
|
298
|
+
* enabled: true,
|
|
299
|
+
* apiKey: 'phc_abc123def456',
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```ts
|
|
305
|
+
* // Self-hosted PostHog
|
|
306
|
+
* {
|
|
307
|
+
* provider: 'posthog',
|
|
308
|
+
* enabled: true,
|
|
309
|
+
* apiKey: 'phc_abc123def456',
|
|
310
|
+
* apiUrl: 'https://posthog.example.com',
|
|
311
|
+
* }
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
108
314
|
interface PostHogConfig extends BaseProviderConfig {
|
|
109
315
|
provider: 'posthog';
|
|
316
|
+
/**
|
|
317
|
+
* Your PostHog project API key (starts with `phc_`).
|
|
318
|
+
* Found in PostHog under Project Settings › Project API Key.
|
|
319
|
+
*
|
|
320
|
+
* @example 'phc_abc123def456ghi789'
|
|
321
|
+
*/
|
|
110
322
|
apiKey: string;
|
|
323
|
+
/**
|
|
324
|
+
* Custom PostHog API endpoint. Use this if you self-host PostHog
|
|
325
|
+
* or use PostHog's EU cloud instance.
|
|
326
|
+
*
|
|
327
|
+
* @default 'https://us.i.posthog.com' (PostHog US Cloud)
|
|
328
|
+
* @example 'https://eu.i.posthog.com'
|
|
329
|
+
*/
|
|
111
330
|
apiUrl?: string;
|
|
112
331
|
}
|
|
113
332
|
/**
|
|
@@ -116,35 +335,113 @@ interface PostHogConfig extends BaseProviderConfig {
|
|
|
116
335
|
* In server mode they are included in the `user_data` object sent to the
|
|
117
336
|
* Conversions API — plain-text values are automatically SHA-256 hashed before
|
|
118
337
|
* sending.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```ts
|
|
341
|
+
* {
|
|
342
|
+
* em: 'user@example.com',
|
|
343
|
+
* fn: 'jane',
|
|
344
|
+
* ln: 'doe',
|
|
345
|
+
* country: 'us',
|
|
346
|
+
* }
|
|
347
|
+
* ```
|
|
119
348
|
*/
|
|
120
349
|
interface MetaPixelAdvancedMatching {
|
|
121
|
-
/**
|
|
350
|
+
/**
|
|
351
|
+
* Email address. Lowercased before hashing.
|
|
352
|
+
* @example 'user@example.com'
|
|
353
|
+
*/
|
|
122
354
|
em?: string;
|
|
123
|
-
/**
|
|
355
|
+
/**
|
|
356
|
+
* Phone number including country code, digits only (no dashes or spaces).
|
|
357
|
+
* @example '15551234567'
|
|
358
|
+
*/
|
|
124
359
|
ph?: string;
|
|
125
|
-
/**
|
|
360
|
+
/**
|
|
361
|
+
* First name. Lowercased before hashing.
|
|
362
|
+
* @example 'jane'
|
|
363
|
+
*/
|
|
126
364
|
fn?: string;
|
|
127
|
-
/**
|
|
365
|
+
/**
|
|
366
|
+
* Last name. Lowercased before hashing.
|
|
367
|
+
* @example 'doe'
|
|
368
|
+
*/
|
|
128
369
|
ln?: string;
|
|
129
|
-
/**
|
|
370
|
+
/**
|
|
371
|
+
* Gender. Single lowercase letter: `'m'` for male, `'f'` for female.
|
|
372
|
+
* @example 'm'
|
|
373
|
+
*/
|
|
130
374
|
ge?: string;
|
|
131
|
-
/**
|
|
375
|
+
/**
|
|
376
|
+
* Date of birth in `YYYYMMDD` format.
|
|
377
|
+
* @example '19900115'
|
|
378
|
+
*/
|
|
132
379
|
db?: string;
|
|
133
|
-
/**
|
|
380
|
+
/**
|
|
381
|
+
* City name. Lowercased, no spaces or punctuation.
|
|
382
|
+
* @example 'newyork'
|
|
383
|
+
*/
|
|
134
384
|
ct?: string;
|
|
135
|
-
/**
|
|
385
|
+
/**
|
|
386
|
+
* State or province as a 2-letter code. Lowercased.
|
|
387
|
+
* @example 'ny'
|
|
388
|
+
*/
|
|
136
389
|
st?: string;
|
|
137
|
-
/**
|
|
390
|
+
/**
|
|
391
|
+
* Zip or postal code. For US, use 5-digit format.
|
|
392
|
+
* @example '10001'
|
|
393
|
+
*/
|
|
138
394
|
zp?: string;
|
|
139
|
-
/**
|
|
395
|
+
/**
|
|
396
|
+
* Country as a 2-letter ISO 3166-1 alpha-2 code. Lowercased.
|
|
397
|
+
* @example 'us'
|
|
398
|
+
*/
|
|
140
399
|
country?: string;
|
|
141
|
-
/**
|
|
400
|
+
/**
|
|
401
|
+
* External ID — your own unique identifier for the user.
|
|
402
|
+
* Useful for deduplicating browser and server events.
|
|
403
|
+
* @example 'user_abc123'
|
|
404
|
+
*/
|
|
142
405
|
external_id?: string;
|
|
143
406
|
}
|
|
144
407
|
type MetaPixelAppType = 'browser' | 'server';
|
|
408
|
+
/**
|
|
409
|
+
* Configuration for the Meta Pixel (Facebook Pixel) provider.
|
|
410
|
+
* Supports both browser-side pixel tracking and server-side Conversions API.
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* ```ts
|
|
414
|
+
* // Browser mode
|
|
415
|
+
* {
|
|
416
|
+
* provider: 'meta-pixel',
|
|
417
|
+
* enabled: true,
|
|
418
|
+
* pixelId: '1234567890',
|
|
419
|
+
* appType: 'browser',
|
|
420
|
+
* debug: true,
|
|
421
|
+
* }
|
|
422
|
+
* ```
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* ```ts
|
|
426
|
+
* // Server mode (Conversions API)
|
|
427
|
+
* {
|
|
428
|
+
* provider: 'meta-pixel',
|
|
429
|
+
* enabled: true,
|
|
430
|
+
* pixelId: '1234567890',
|
|
431
|
+
* appType: 'server',
|
|
432
|
+
* accessToken: 'EAABsb...',
|
|
433
|
+
* testEventCode: 'TEST12345',
|
|
434
|
+
* }
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
145
437
|
interface MetaPixelConfig extends BaseProviderConfig {
|
|
146
438
|
provider: 'meta-pixel';
|
|
147
|
-
/**
|
|
439
|
+
/**
|
|
440
|
+
* The Meta Pixel ID (numeric string).
|
|
441
|
+
* Found in Meta Events Manager under your pixel's settings.
|
|
442
|
+
*
|
|
443
|
+
* @example '1234567890'
|
|
444
|
+
*/
|
|
148
445
|
pixelId: string;
|
|
149
446
|
/**
|
|
150
447
|
* Access token for the Conversions API. Required when `appType` is
|
|
@@ -180,9 +477,29 @@ interface MetaPixelConfig extends BaseProviderConfig {
|
|
|
180
477
|
/** Enable Meta Pixel debug mode (`fbq('set', 'debug', true)`). */
|
|
181
478
|
debug?: boolean;
|
|
182
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* Configuration for the Microsoft Clarity provider.
|
|
482
|
+
* Clarity provides session recordings, heatmaps, and behavioral analytics.
|
|
483
|
+
* Browser-only — this provider is a no-op in server environments.
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* ```ts
|
|
487
|
+
* {
|
|
488
|
+
* provider: 'clarity',
|
|
489
|
+
* enabled: true,
|
|
490
|
+
* projectId: 'abc123def4',
|
|
491
|
+
* cookie: true,
|
|
492
|
+
* }
|
|
493
|
+
* ```
|
|
494
|
+
*/
|
|
183
495
|
interface ClarityConfig extends BaseProviderConfig {
|
|
184
496
|
provider: 'clarity';
|
|
185
|
-
/**
|
|
497
|
+
/**
|
|
498
|
+
* The Clarity project ID found in your Clarity dashboard under
|
|
499
|
+
* Settings › Overview › Project ID.
|
|
500
|
+
*
|
|
501
|
+
* @example 'abc123def4'
|
|
502
|
+
*/
|
|
186
503
|
projectId: string;
|
|
187
504
|
/**
|
|
188
505
|
* Enable Clarity cookie consent mode. When `true`, calls
|
package/dist/index.d.ts
CHANGED
|
@@ -37,12 +37,64 @@ interface ConsentSettings {
|
|
|
37
37
|
}
|
|
38
38
|
type ProviderName = 'google-analytics' | 'mixpanel' | 'segment' | 'amplitude' | 'plausible' | 'posthog' | 'meta-pixel' | 'clarity';
|
|
39
39
|
type GoogleAnalyticsAppType = 'browser' | 'server';
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for the Google Analytics (GA4) provider.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* {
|
|
46
|
+
* provider: 'google-analytics',
|
|
47
|
+
* enabled: true,
|
|
48
|
+
* measurementId: 'G-XXXXXXXXXX',
|
|
49
|
+
* appType: 'browser',
|
|
50
|
+
* debug: true,
|
|
51
|
+
* signals: true,
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
40
55
|
interface GoogleAnalyticsConfig extends BaseProviderConfig {
|
|
41
56
|
provider: 'google-analytics';
|
|
57
|
+
/**
|
|
58
|
+
* The GA4 Measurement ID for your data stream.
|
|
59
|
+
* Found in GA4 under Admin › Data Streams › your stream.
|
|
60
|
+
*
|
|
61
|
+
* @example 'G-XXXXXXXXXX'
|
|
62
|
+
*/
|
|
42
63
|
measurementId: string;
|
|
64
|
+
/**
|
|
65
|
+
* API secret for the GA4 Measurement Protocol (server-side).
|
|
66
|
+
* Generate one in GA4 under Admin › Data Streams › Measurement Protocol API secrets.
|
|
67
|
+
* Required when `appType` is `'server'`.
|
|
68
|
+
*
|
|
69
|
+
* @example 'xYzAbCdEfGhIjKlM'
|
|
70
|
+
*/
|
|
43
71
|
apiSecret?: string;
|
|
72
|
+
/**
|
|
73
|
+
* A unique identifier for the client (device/browser instance).
|
|
74
|
+
* In server mode this is required to associate hits with a user session.
|
|
75
|
+
* In browser mode it is managed automatically by gtag.js and can be omitted.
|
|
76
|
+
*
|
|
77
|
+
* @example 'client-123456.7890123456'
|
|
78
|
+
*/
|
|
44
79
|
clientId?: string;
|
|
80
|
+
/**
|
|
81
|
+
* When `true`, enables GA4 debug mode.
|
|
82
|
+
* In browser mode this sends events to the DebugView in the GA4 dashboard.
|
|
83
|
+
* In server mode this sets `debug_mode: true` on Measurement Protocol payloads.
|
|
84
|
+
*
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
45
87
|
debug?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Determines how events are sent to Google Analytics.
|
|
90
|
+
*
|
|
91
|
+
* - `'browser'` — injects the gtag.js snippet and uses `window.gtag()` calls.
|
|
92
|
+
* Suitable for client-side web apps.
|
|
93
|
+
* - `'server'` — sends events via the GA4 Measurement Protocol HTTP API.
|
|
94
|
+
* Requires `apiSecret` and `clientId`. Suitable for Node.js / edge / SSR.
|
|
95
|
+
*
|
|
96
|
+
* @default 'browser'
|
|
97
|
+
*/
|
|
46
98
|
appType?: GoogleAnalyticsAppType;
|
|
47
99
|
/**
|
|
48
100
|
* Default consent state set before gtag('config'). In browser mode this
|
|
@@ -83,31 +135,198 @@ interface GoogleAnalyticsConfig extends BaseProviderConfig {
|
|
|
83
135
|
*/
|
|
84
136
|
signals?: boolean;
|
|
85
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Configuration for the Mixpanel provider.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* {
|
|
144
|
+
* provider: 'mixpanel',
|
|
145
|
+
* enabled: true,
|
|
146
|
+
* token: 'abc123def456',
|
|
147
|
+
* }
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
86
150
|
interface MixpanelConfig extends BaseProviderConfig {
|
|
87
151
|
provider: 'mixpanel';
|
|
152
|
+
/**
|
|
153
|
+
* Your Mixpanel project token.
|
|
154
|
+
* Found in Mixpanel under Settings › Project Settings › Project Token.
|
|
155
|
+
*
|
|
156
|
+
* @example 'abc123def456'
|
|
157
|
+
*/
|
|
88
158
|
token: string;
|
|
159
|
+
/**
|
|
160
|
+
* Custom Mixpanel API endpoint. Use this if you are routing events through
|
|
161
|
+
* a proxy or using Mixpanel's EU residency endpoint.
|
|
162
|
+
*
|
|
163
|
+
* @default 'https://api.mixpanel.com'
|
|
164
|
+
* @example 'https://api-eu.mixpanel.com'
|
|
165
|
+
*/
|
|
89
166
|
apiUrl?: string;
|
|
90
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Configuration for the Segment provider.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* {
|
|
174
|
+
* provider: 'segment',
|
|
175
|
+
* enabled: true,
|
|
176
|
+
* writeKey: 'wk_abc123...',
|
|
177
|
+
* }
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
91
180
|
interface SegmentConfig extends BaseProviderConfig {
|
|
92
181
|
provider: 'segment';
|
|
182
|
+
/**
|
|
183
|
+
* The Segment source Write Key.
|
|
184
|
+
* Found in Segment under Sources › your source › Settings › API Keys.
|
|
185
|
+
*
|
|
186
|
+
* @example 'wk_abc123def456ghi789'
|
|
187
|
+
*/
|
|
93
188
|
writeKey: string;
|
|
189
|
+
/**
|
|
190
|
+
* Custom Segment API endpoint. Use this if you are routing events through
|
|
191
|
+
* a proxy or a custom Segment data plane.
|
|
192
|
+
*
|
|
193
|
+
* @default 'https://api.segment.io/v1'
|
|
194
|
+
* @example 'https://events.yourdomain.com/v1'
|
|
195
|
+
*/
|
|
94
196
|
apiUrl?: string;
|
|
95
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Configuration for the Amplitude provider.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* {
|
|
204
|
+
* provider: 'amplitude',
|
|
205
|
+
* enabled: true,
|
|
206
|
+
* apiKey: 'your-amplitude-api-key',
|
|
207
|
+
* }
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
96
210
|
interface AmplitudeConfig extends BaseProviderConfig {
|
|
97
211
|
provider: 'amplitude';
|
|
212
|
+
/**
|
|
213
|
+
* Your Amplitude project API key.
|
|
214
|
+
* Found in Amplitude under Settings › Projects › your project › General.
|
|
215
|
+
*
|
|
216
|
+
* @example 'a1b2c3d4e5f6a1b2c3d4e5f6'
|
|
217
|
+
*/
|
|
98
218
|
apiKey: string;
|
|
219
|
+
/**
|
|
220
|
+
* Custom Amplitude API endpoint. Use this if you are routing events through
|
|
221
|
+
* a proxy or using Amplitude's EU data centre.
|
|
222
|
+
*
|
|
223
|
+
* @default 'https://api2.amplitude.com/2/httpapi'
|
|
224
|
+
* @example 'https://api.eu.amplitude.com/2/httpapi'
|
|
225
|
+
*/
|
|
99
226
|
apiUrl?: string;
|
|
100
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Configuration for the Plausible Analytics provider.
|
|
230
|
+
*
|
|
231
|
+
* Plausible is a privacy-focused analytics platform. Server-side usage
|
|
232
|
+
* requires `userAgent` and `xForwardedFor` so Plausible can attribute
|
|
233
|
+
* visits without cookies.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* // Browser usage
|
|
238
|
+
* {
|
|
239
|
+
* provider: 'plausible',
|
|
240
|
+
* enabled: true,
|
|
241
|
+
* domain: 'example.com',
|
|
242
|
+
* }
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```ts
|
|
247
|
+
* // Server-side usage
|
|
248
|
+
* {
|
|
249
|
+
* provider: 'plausible',
|
|
250
|
+
* enabled: true,
|
|
251
|
+
* domain: 'example.com',
|
|
252
|
+
* apiUrl: 'https://plausible.example.com',
|
|
253
|
+
* userAgent: req.headers['user-agent'],
|
|
254
|
+
* xForwardedFor: req.headers['x-forwarded-for'],
|
|
255
|
+
* }
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
101
258
|
interface PlausibleConfig extends BaseProviderConfig {
|
|
102
259
|
provider: 'plausible';
|
|
260
|
+
/**
|
|
261
|
+
* The domain name of the site as configured in your Plausible dashboard.
|
|
262
|
+
* Must match exactly (no protocol, no trailing slash).
|
|
263
|
+
*
|
|
264
|
+
* @example 'example.com'
|
|
265
|
+
*/
|
|
103
266
|
domain: string;
|
|
267
|
+
/**
|
|
268
|
+
* Custom Plausible API endpoint. Use this if you self-host Plausible
|
|
269
|
+
* or route events through a proxy to avoid ad-blockers.
|
|
270
|
+
*
|
|
271
|
+
* @default 'https://plausible.io'
|
|
272
|
+
* @example 'https://plausible.example.com'
|
|
273
|
+
*/
|
|
104
274
|
apiUrl?: string;
|
|
275
|
+
/**
|
|
276
|
+
* The visitor's User-Agent string. Required for server-side usage so
|
|
277
|
+
* Plausible can perform unique-visitor counting without cookies.
|
|
278
|
+
*
|
|
279
|
+
* @example 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) ...'
|
|
280
|
+
*/
|
|
105
281
|
userAgent?: string;
|
|
282
|
+
/**
|
|
283
|
+
* The visitor's IP address, used by Plausible for geolocation and
|
|
284
|
+
* unique-visitor hashing. Required for server-side usage.
|
|
285
|
+
* Pass the `X-Forwarded-For` header value from the incoming request.
|
|
286
|
+
*
|
|
287
|
+
* @example '203.0.113.42'
|
|
288
|
+
*/
|
|
106
289
|
xForwardedFor?: string;
|
|
107
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Configuration for the PostHog provider.
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```ts
|
|
296
|
+
* {
|
|
297
|
+
* provider: 'posthog',
|
|
298
|
+
* enabled: true,
|
|
299
|
+
* apiKey: 'phc_abc123def456',
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```ts
|
|
305
|
+
* // Self-hosted PostHog
|
|
306
|
+
* {
|
|
307
|
+
* provider: 'posthog',
|
|
308
|
+
* enabled: true,
|
|
309
|
+
* apiKey: 'phc_abc123def456',
|
|
310
|
+
* apiUrl: 'https://posthog.example.com',
|
|
311
|
+
* }
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
108
314
|
interface PostHogConfig extends BaseProviderConfig {
|
|
109
315
|
provider: 'posthog';
|
|
316
|
+
/**
|
|
317
|
+
* Your PostHog project API key (starts with `phc_`).
|
|
318
|
+
* Found in PostHog under Project Settings › Project API Key.
|
|
319
|
+
*
|
|
320
|
+
* @example 'phc_abc123def456ghi789'
|
|
321
|
+
*/
|
|
110
322
|
apiKey: string;
|
|
323
|
+
/**
|
|
324
|
+
* Custom PostHog API endpoint. Use this if you self-host PostHog
|
|
325
|
+
* or use PostHog's EU cloud instance.
|
|
326
|
+
*
|
|
327
|
+
* @default 'https://us.i.posthog.com' (PostHog US Cloud)
|
|
328
|
+
* @example 'https://eu.i.posthog.com'
|
|
329
|
+
*/
|
|
111
330
|
apiUrl?: string;
|
|
112
331
|
}
|
|
113
332
|
/**
|
|
@@ -116,35 +335,113 @@ interface PostHogConfig extends BaseProviderConfig {
|
|
|
116
335
|
* In server mode they are included in the `user_data` object sent to the
|
|
117
336
|
* Conversions API — plain-text values are automatically SHA-256 hashed before
|
|
118
337
|
* sending.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```ts
|
|
341
|
+
* {
|
|
342
|
+
* em: 'user@example.com',
|
|
343
|
+
* fn: 'jane',
|
|
344
|
+
* ln: 'doe',
|
|
345
|
+
* country: 'us',
|
|
346
|
+
* }
|
|
347
|
+
* ```
|
|
119
348
|
*/
|
|
120
349
|
interface MetaPixelAdvancedMatching {
|
|
121
|
-
/**
|
|
350
|
+
/**
|
|
351
|
+
* Email address. Lowercased before hashing.
|
|
352
|
+
* @example 'user@example.com'
|
|
353
|
+
*/
|
|
122
354
|
em?: string;
|
|
123
|
-
/**
|
|
355
|
+
/**
|
|
356
|
+
* Phone number including country code, digits only (no dashes or spaces).
|
|
357
|
+
* @example '15551234567'
|
|
358
|
+
*/
|
|
124
359
|
ph?: string;
|
|
125
|
-
/**
|
|
360
|
+
/**
|
|
361
|
+
* First name. Lowercased before hashing.
|
|
362
|
+
* @example 'jane'
|
|
363
|
+
*/
|
|
126
364
|
fn?: string;
|
|
127
|
-
/**
|
|
365
|
+
/**
|
|
366
|
+
* Last name. Lowercased before hashing.
|
|
367
|
+
* @example 'doe'
|
|
368
|
+
*/
|
|
128
369
|
ln?: string;
|
|
129
|
-
/**
|
|
370
|
+
/**
|
|
371
|
+
* Gender. Single lowercase letter: `'m'` for male, `'f'` for female.
|
|
372
|
+
* @example 'm'
|
|
373
|
+
*/
|
|
130
374
|
ge?: string;
|
|
131
|
-
/**
|
|
375
|
+
/**
|
|
376
|
+
* Date of birth in `YYYYMMDD` format.
|
|
377
|
+
* @example '19900115'
|
|
378
|
+
*/
|
|
132
379
|
db?: string;
|
|
133
|
-
/**
|
|
380
|
+
/**
|
|
381
|
+
* City name. Lowercased, no spaces or punctuation.
|
|
382
|
+
* @example 'newyork'
|
|
383
|
+
*/
|
|
134
384
|
ct?: string;
|
|
135
|
-
/**
|
|
385
|
+
/**
|
|
386
|
+
* State or province as a 2-letter code. Lowercased.
|
|
387
|
+
* @example 'ny'
|
|
388
|
+
*/
|
|
136
389
|
st?: string;
|
|
137
|
-
/**
|
|
390
|
+
/**
|
|
391
|
+
* Zip or postal code. For US, use 5-digit format.
|
|
392
|
+
* @example '10001'
|
|
393
|
+
*/
|
|
138
394
|
zp?: string;
|
|
139
|
-
/**
|
|
395
|
+
/**
|
|
396
|
+
* Country as a 2-letter ISO 3166-1 alpha-2 code. Lowercased.
|
|
397
|
+
* @example 'us'
|
|
398
|
+
*/
|
|
140
399
|
country?: string;
|
|
141
|
-
/**
|
|
400
|
+
/**
|
|
401
|
+
* External ID — your own unique identifier for the user.
|
|
402
|
+
* Useful for deduplicating browser and server events.
|
|
403
|
+
* @example 'user_abc123'
|
|
404
|
+
*/
|
|
142
405
|
external_id?: string;
|
|
143
406
|
}
|
|
144
407
|
type MetaPixelAppType = 'browser' | 'server';
|
|
408
|
+
/**
|
|
409
|
+
* Configuration for the Meta Pixel (Facebook Pixel) provider.
|
|
410
|
+
* Supports both browser-side pixel tracking and server-side Conversions API.
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* ```ts
|
|
414
|
+
* // Browser mode
|
|
415
|
+
* {
|
|
416
|
+
* provider: 'meta-pixel',
|
|
417
|
+
* enabled: true,
|
|
418
|
+
* pixelId: '1234567890',
|
|
419
|
+
* appType: 'browser',
|
|
420
|
+
* debug: true,
|
|
421
|
+
* }
|
|
422
|
+
* ```
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* ```ts
|
|
426
|
+
* // Server mode (Conversions API)
|
|
427
|
+
* {
|
|
428
|
+
* provider: 'meta-pixel',
|
|
429
|
+
* enabled: true,
|
|
430
|
+
* pixelId: '1234567890',
|
|
431
|
+
* appType: 'server',
|
|
432
|
+
* accessToken: 'EAABsb...',
|
|
433
|
+
* testEventCode: 'TEST12345',
|
|
434
|
+
* }
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
145
437
|
interface MetaPixelConfig extends BaseProviderConfig {
|
|
146
438
|
provider: 'meta-pixel';
|
|
147
|
-
/**
|
|
439
|
+
/**
|
|
440
|
+
* The Meta Pixel ID (numeric string).
|
|
441
|
+
* Found in Meta Events Manager under your pixel's settings.
|
|
442
|
+
*
|
|
443
|
+
* @example '1234567890'
|
|
444
|
+
*/
|
|
148
445
|
pixelId: string;
|
|
149
446
|
/**
|
|
150
447
|
* Access token for the Conversions API. Required when `appType` is
|
|
@@ -180,9 +477,29 @@ interface MetaPixelConfig extends BaseProviderConfig {
|
|
|
180
477
|
/** Enable Meta Pixel debug mode (`fbq('set', 'debug', true)`). */
|
|
181
478
|
debug?: boolean;
|
|
182
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* Configuration for the Microsoft Clarity provider.
|
|
482
|
+
* Clarity provides session recordings, heatmaps, and behavioral analytics.
|
|
483
|
+
* Browser-only — this provider is a no-op in server environments.
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* ```ts
|
|
487
|
+
* {
|
|
488
|
+
* provider: 'clarity',
|
|
489
|
+
* enabled: true,
|
|
490
|
+
* projectId: 'abc123def4',
|
|
491
|
+
* cookie: true,
|
|
492
|
+
* }
|
|
493
|
+
* ```
|
|
494
|
+
*/
|
|
183
495
|
interface ClarityConfig extends BaseProviderConfig {
|
|
184
496
|
provider: 'clarity';
|
|
185
|
-
/**
|
|
497
|
+
/**
|
|
498
|
+
* The Clarity project ID found in your Clarity dashboard under
|
|
499
|
+
* Settings › Overview › Project ID.
|
|
500
|
+
*
|
|
501
|
+
* @example 'abc123def4'
|
|
502
|
+
*/
|
|
186
503
|
projectId: string;
|
|
187
504
|
/**
|
|
188
505
|
* Enable Clarity cookie consent mode. When `true`, calls
|