@shware/analytics 3.8.1 → 3.8.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/_virtual/_rolldown/runtime.cjs +2 -0
- package/dist/_virtual/_rolldown/runtime.mjs +24 -0
- package/dist/node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.cjs +1725 -0
- package/dist/node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.cjs.map +1 -0
- package/dist/node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.mjs +1722 -0
- package/dist/node_modules/.pnpm/bowser@2.14.1/node_modules/bowser/es5.mjs.map +1 -0
- package/dist/schema/index.cjs +32 -0
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +130 -1
- package/dist/schema/index.d.cts.map +1 -1
- package/dist/schema/index.d.mts +130 -1
- package/dist/schema/index.d.mts.map +1 -1
- package/dist/schema/index.mjs +33 -2
- package/dist/schema/index.mjs.map +1 -1
- package/dist/third-parties/google-analytics.cjs +2 -2
- package/dist/third-parties/google-analytics.cjs.map +1 -1
- package/dist/third-parties/google-analytics.d.cts +2 -2
- package/dist/third-parties/google-analytics.d.cts.map +1 -1
- package/dist/third-parties/google-analytics.d.mts +2 -2
- package/dist/third-parties/google-analytics.d.mts.map +1 -1
- package/dist/third-parties/google-analytics.mjs +2 -2
- package/dist/third-parties/google-analytics.mjs.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.cjs +2 -2
- package/dist/third-parties/linkedin-insight-tag.cjs.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.d.cts +2 -2
- package/dist/third-parties/linkedin-insight-tag.d.cts.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.d.mts +2 -2
- package/dist/third-parties/linkedin-insight-tag.d.mts.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.mjs +2 -2
- package/dist/third-parties/linkedin-insight-tag.mjs.map +1 -1
- package/dist/third-parties/meta-pixel.cjs +4 -4
- package/dist/third-parties/meta-pixel.cjs.map +1 -1
- package/dist/third-parties/meta-pixel.d.cts +2 -2
- package/dist/third-parties/meta-pixel.d.cts.map +1 -1
- package/dist/third-parties/meta-pixel.d.mts +2 -2
- package/dist/third-parties/meta-pixel.d.mts.map +1 -1
- package/dist/third-parties/meta-pixel.mjs +4 -4
- package/dist/third-parties/meta-pixel.mjs.map +1 -1
- package/dist/third-parties/openai-pixel.cjs +3 -3
- package/dist/third-parties/openai-pixel.cjs.map +1 -1
- package/dist/third-parties/openai-pixel.d.cts +2 -2
- package/dist/third-parties/openai-pixel.d.cts.map +1 -1
- package/dist/third-parties/openai-pixel.d.mts +2 -2
- package/dist/third-parties/openai-pixel.d.mts.map +1 -1
- package/dist/third-parties/openai-pixel.mjs +3 -3
- package/dist/third-parties/openai-pixel.mjs.map +1 -1
- package/dist/third-parties/posthog.cjs +2 -2
- package/dist/third-parties/posthog.cjs.map +1 -1
- package/dist/third-parties/posthog.d.cts +2 -2
- package/dist/third-parties/posthog.d.cts.map +1 -1
- package/dist/third-parties/posthog.d.mts +2 -2
- package/dist/third-parties/posthog.d.mts.map +1 -1
- package/dist/third-parties/posthog.mjs +2 -2
- package/dist/third-parties/posthog.mjs.map +1 -1
- package/dist/third-parties/reddit-pixel.cjs +3 -3
- package/dist/third-parties/reddit-pixel.cjs.map +1 -1
- package/dist/third-parties/reddit-pixel.d.cts +2 -2
- package/dist/third-parties/reddit-pixel.d.cts.map +1 -1
- package/dist/third-parties/reddit-pixel.d.mts +2 -2
- package/dist/third-parties/reddit-pixel.d.mts.map +1 -1
- package/dist/third-parties/reddit-pixel.mjs +3 -3
- package/dist/third-parties/reddit-pixel.mjs.map +1 -1
- package/dist/visitor/index.cjs +6 -5
- package/dist/visitor/index.cjs.map +1 -1
- package/dist/visitor/index.d.cts +3 -2
- package/dist/visitor/index.d.cts.map +1 -1
- package/dist/visitor/index.d.mts +3 -2
- package/dist/visitor/index.d.mts.map +1 -1
- package/dist/visitor/index.mjs +6 -5
- package/dist/visitor/index.mjs.map +1 -1
- package/dist/visitor/types.d.cts +2 -8
- package/dist/visitor/types.d.cts.map +1 -1
- package/dist/visitor/types.d.mts +2 -8
- package/dist/visitor/types.d.mts.map +1 -1
- package/dist/web/index.cjs +3 -3
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.mjs +4 -2
- package/dist/web/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/schema/index.d.mts
CHANGED
|
@@ -365,9 +365,137 @@ declare const createVisitorSchema: z.ZodMiniObject<{
|
|
|
365
365
|
}, z.core.$strip>;
|
|
366
366
|
properties: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull]>>>;
|
|
367
367
|
}, z.core.$strip>;
|
|
368
|
+
/**
|
|
369
|
+
* User-provided data (UPD) used for enhanced conversions, Customer Match, and demographics.
|
|
370
|
+
* Values are sent unhashed; Google normalizes and hashes them before they reach its servers.
|
|
371
|
+
*
|
|
372
|
+
* Multiple values may be sent to increase the match rate: up to 3 emails, 3 phone numbers, and
|
|
373
|
+
* 2 addresses.
|
|
374
|
+
*
|
|
375
|
+
* @see https://support.google.com/analytics/answer/14078702
|
|
376
|
+
* @see https://support.google.com/google-ads/answer/13258081
|
|
377
|
+
*/
|
|
378
|
+
declare const userProvidedDataSchema: z.ZodMiniObject<{
|
|
379
|
+
email: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniEmail>, z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniEmail>>]>>;
|
|
380
|
+
phone_number: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniE164>, z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniE164>>]>>;
|
|
381
|
+
address: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniObject<{
|
|
382
|
+
first_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
383
|
+
last_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
384
|
+
street: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
385
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
386
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
387
|
+
postal_code: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
388
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
389
|
+
}, z.core.$strip>, z.ZodMiniArray<z.ZodMiniObject<{
|
|
390
|
+
first_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
391
|
+
last_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
392
|
+
street: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
393
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
394
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
395
|
+
postal_code: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
396
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
397
|
+
}, z.core.$strip>>]>>;
|
|
398
|
+
}, z.core.$strip>;
|
|
368
399
|
declare const updateVisitorSchema: z.ZodMiniObject<{
|
|
369
400
|
user_id: z.ZodMiniOptional<z.ZodMiniUUID>;
|
|
401
|
+
user_data: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
402
|
+
email: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniEmail>, z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniEmail>>]>>;
|
|
403
|
+
phone_number: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniE164>, z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniE164>>]>>;
|
|
404
|
+
address: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniObject<{
|
|
405
|
+
first_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
406
|
+
last_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
407
|
+
street: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
408
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
409
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
410
|
+
postal_code: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
411
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
412
|
+
}, z.core.$strip>, z.ZodMiniArray<z.ZodMiniObject<{
|
|
413
|
+
first_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
414
|
+
last_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
415
|
+
street: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
416
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
417
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
418
|
+
postal_code: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
419
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
420
|
+
}, z.core.$strip>>]>>;
|
|
421
|
+
}, z.core.$strip>>;
|
|
370
422
|
distinct_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
423
|
+
tags: z.ZodMiniObject<{
|
|
424
|
+
os: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
425
|
+
os_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
426
|
+
os_version: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
427
|
+
browser: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
428
|
+
browser_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
429
|
+
browser_version: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
430
|
+
platform: z.ZodMiniEnum<{
|
|
431
|
+
android: "android";
|
|
432
|
+
ios: "ios";
|
|
433
|
+
linux: "linux";
|
|
434
|
+
macos: "macos";
|
|
435
|
+
unknown: "unknown";
|
|
436
|
+
web: "web";
|
|
437
|
+
windows: "windows";
|
|
438
|
+
}>;
|
|
439
|
+
device: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
440
|
+
device_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
441
|
+
device_type: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
442
|
+
device_vendor: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
443
|
+
device_pixel_ratio: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
444
|
+
screen_width: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
445
|
+
screen_height: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
446
|
+
screen_resolution: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<`${number}x${number}`, string>>>;
|
|
447
|
+
release: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
448
|
+
language: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
449
|
+
time_zone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
450
|
+
environment: z.ZodMiniEnum<{
|
|
451
|
+
development: "development";
|
|
452
|
+
production: "production";
|
|
453
|
+
}>;
|
|
454
|
+
source_url: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
455
|
+
source: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
456
|
+
app: "app";
|
|
457
|
+
offline: "offline";
|
|
458
|
+
web: "web";
|
|
459
|
+
}>>;
|
|
460
|
+
page_referrer: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
461
|
+
advertising_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
462
|
+
install_referrer: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
463
|
+
fbc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
464
|
+
fbp: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
465
|
+
fbclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
466
|
+
ad_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
467
|
+
ad_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
468
|
+
adset_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
469
|
+
adset_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
470
|
+
campaign_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
471
|
+
campaign_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
472
|
+
placement: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
473
|
+
site_source_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
474
|
+
gclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
475
|
+
gclsrc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
476
|
+
gad_source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
477
|
+
gad_campaignid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
478
|
+
rdt_cid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
479
|
+
rdt_uuid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
480
|
+
dclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
481
|
+
ko_click_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
482
|
+
li_fat_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
483
|
+
msclkid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
484
|
+
sccid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
485
|
+
ttclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
486
|
+
twclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
487
|
+
wbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
488
|
+
yclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
489
|
+
utm_source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
490
|
+
utm_medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
491
|
+
utm_campaign: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
492
|
+
utm_term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
493
|
+
utm_content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
494
|
+
utm_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
495
|
+
utm_source_platform: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
496
|
+
utm_creative_format: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
497
|
+
utm_marketing_tactic: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
498
|
+
}, z.core.$strip>;
|
|
371
499
|
properties: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull]>>>;
|
|
372
500
|
}, z.core.$strip>;
|
|
373
501
|
declare const createFeedbackSchema: z.ZodMiniObject<{
|
|
@@ -395,7 +523,8 @@ type CreateTrackEventDTO = z.output<typeof createTrackEventSchema>;
|
|
|
395
523
|
type CreateFeedbackDTO = z.output<typeof createFeedbackSchema>;
|
|
396
524
|
type CreateLinkDTO = z.output<typeof createLinkSchema>;
|
|
397
525
|
type CreateVisitorDTO = z.output<typeof createVisitorSchema>;
|
|
526
|
+
type UserProvidedDataDTO = z.output<typeof userProvidedDataSchema>;
|
|
398
527
|
type UpdateVisitorDTO = z.output<typeof updateVisitorSchema>;
|
|
399
528
|
//#endregion
|
|
400
|
-
export { ALL_ENVIRONMENTS, ALL_PLATFORMS, CreateFeedbackDTO, CreateLinkDTO, CreateTrackEventDTO, CreateVisitorDTO, UpdateVisitorDTO, createFeedbackSchema, createLinkSchema, createTrackEventSchema, createTrackEventSchemaV1, createVisitorSchema, propertiesSchema, tagsSchema, updateVisitorSchema };
|
|
529
|
+
export { ALL_ENVIRONMENTS, ALL_PLATFORMS, CreateFeedbackDTO, CreateLinkDTO, CreateTrackEventDTO, CreateVisitorDTO, UpdateVisitorDTO, UserProvidedDataDTO, createFeedbackSchema, createLinkSchema, createTrackEventSchema, createTrackEventSchemaV1, createVisitorSchema, propertiesSchema, tagsSchema, updateVisitorSchema, userProvidedDataSchema };
|
|
401
530
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/schema/index.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/schema/index.ts"],"mappings":";;cAqCa;cAUA;cAEA,YAAU,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAyEV,kBAAgB,EAAA,gBAAA,EAAA,cAAA,EAAA,uBAAA,EAAA,uBAAA,EAAA,uBAAA,EAAA,uBAAA,EAAA,yBAAA,EAAA,aAAA,EAAA,aAAA,EAAA,cAAA,EAAA,uBAAA,EAAA,uBAAA,EAAA,uBAAA,EAAA,uBAAA,EAAA,yBAAA,EAAA;;cAQhB,0BAAwB,EAAA,aAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAaxB,wBAAsB,EAAA,aAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAatB,qBAAmB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwCnB,wBAAsB,EAAA;;;;;;;;;;;;;;;;;;;;;cAMtB,qBAAmB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAanB,sBAAoB,EAAA;;;;;;;;;cAepB,kBAAgB,EAAA;;;;;;;;;;;;KAiDjB,sBAAsB,EAAE,cAAc;KACtC,oBAAoB,EAAE,cAAc;KACpC,gBAAgB,EAAE,cAAc;KAChC,mBAAmB,EAAE,cAAc;KACnC,sBAAsB,EAAE,cAAc;KACtC,mBAAmB,EAAE,cAAc"}
|
package/dist/schema/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { array, boolean, coerce, email, enum as enum$1, iso, maxLength, minLength, null as null$1, number, object, optional, pipe, record, refine, regex, string, transform, trim, union, url, uuid } from "zod/mini";
|
|
1
|
+
import { array, boolean, coerce, e164, email, enum as enum$1, iso, maxLength, minLength, null as null$1, number, object, optional, pipe, record, refine, regex, string, toLowerCase, toUpperCase, transform, trim, union, url, uuid } from "zod/mini";
|
|
2
2
|
//#region src/schema/index.ts
|
|
3
3
|
const items = array(record(string().check(trim(), minLength(1), maxLength(128)), union([
|
|
4
4
|
string().check(maxLength(512)),
|
|
@@ -121,9 +121,40 @@ const createVisitorSchema = object({
|
|
|
121
121
|
null$1()
|
|
122
122
|
])).check(refine((data) => Object.keys(data).length <= 64)))
|
|
123
123
|
});
|
|
124
|
+
const emailValue = pipe(string().check(trim(), toLowerCase(), maxLength(320)), email());
|
|
125
|
+
/** E.164: a plus sign (+) prefix, country code, then digits only, no dashes/parens/spaces. */
|
|
126
|
+
const phoneValue = pipe(string().check(trim()), e164());
|
|
127
|
+
const addressValue = object({
|
|
128
|
+
first_name: optional(string().check(trim(), maxLength(128))),
|
|
129
|
+
last_name: optional(string().check(trim(), maxLength(128))),
|
|
130
|
+
street: optional(string().check(trim(), maxLength(256))),
|
|
131
|
+
city: optional(string().check(trim(), maxLength(128))),
|
|
132
|
+
/** User province, state, or region. Example: `Hampshire` */
|
|
133
|
+
region: optional(string().check(trim(), maxLength(128))),
|
|
134
|
+
postal_code: optional(string().check(trim(), maxLength(32))),
|
|
135
|
+
/** 2-letter country code, per the ISO 3166-1 alpha-2 standard. Example: `UK` */
|
|
136
|
+
country: optional(string().check(trim(), toUpperCase(), regex(/^[A-Z]{2}$/)))
|
|
137
|
+
});
|
|
138
|
+
/**
|
|
139
|
+
* User-provided data (UPD) used for enhanced conversions, Customer Match, and demographics.
|
|
140
|
+
* Values are sent unhashed; Google normalizes and hashes them before they reach its servers.
|
|
141
|
+
*
|
|
142
|
+
* Multiple values may be sent to increase the match rate: up to 3 emails, 3 phone numbers, and
|
|
143
|
+
* 2 addresses.
|
|
144
|
+
*
|
|
145
|
+
* @see https://support.google.com/analytics/answer/14078702
|
|
146
|
+
* @see https://support.google.com/google-ads/answer/13258081
|
|
147
|
+
*/
|
|
148
|
+
const userProvidedDataSchema = object({
|
|
149
|
+
email: optional(union([emailValue, array(emailValue).check(minLength(1), maxLength(3))])),
|
|
150
|
+
phone_number: optional(union([phoneValue, array(phoneValue).check(minLength(1), maxLength(3))])),
|
|
151
|
+
address: optional(union([addressValue, array(addressValue).check(minLength(1), maxLength(2))]))
|
|
152
|
+
});
|
|
124
153
|
const updateVisitorSchema = object({
|
|
125
154
|
user_id: optional(uuid()),
|
|
155
|
+
user_data: optional(userProvidedDataSchema),
|
|
126
156
|
distinct_id: optional(string().check(trim(), minLength(1), maxLength(36))),
|
|
157
|
+
tags: tagsSchema,
|
|
127
158
|
properties: optional(record(string().check(trim(), minLength(1), maxLength(128)), union([
|
|
128
159
|
string().check(maxLength(512)),
|
|
129
160
|
number(),
|
|
@@ -181,6 +212,6 @@ const createLinkSchema = object({
|
|
|
181
212
|
utm_marketing_tactic: optional(noEmptyString)
|
|
182
213
|
});
|
|
183
214
|
//#endregion
|
|
184
|
-
export { ALL_ENVIRONMENTS, ALL_PLATFORMS, createFeedbackSchema, createLinkSchema, createTrackEventSchema, createTrackEventSchemaV1, createVisitorSchema, propertiesSchema, tagsSchema, updateVisitorSchema };
|
|
215
|
+
export { ALL_ENVIRONMENTS, ALL_PLATFORMS, createFeedbackSchema, createLinkSchema, createTrackEventSchema, createTrackEventSchemaV1, createVisitorSchema, propertiesSchema, tagsSchema, updateVisitorSchema, userProvidedDataSchema };
|
|
185
216
|
|
|
186
217
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["_null","_enum"],"sources":["../../src/schema/index.ts"],"sourcesContent":["import {\n enum as _enum,\n null as _null,\n array,\n boolean,\n coerce,\n email,\n iso,\n maxLength,\n minLength,\n number,\n object,\n optional,\n pipe,\n record,\n refine,\n regex,\n string,\n transform,\n trim,\n union,\n url,\n uuid,\n type z,\n} from 'zod/mini';\nimport type { Environment, Platform } from '../track/types';\n\nconst items = array(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null()])\n )\n);\n\nexport const ALL_PLATFORMS = [\n 'ios',\n 'android',\n 'web',\n 'macos',\n 'windows',\n 'linux',\n 'unknown',\n] as const satisfies Platform[];\n\nexport const ALL_ENVIRONMENTS = ['development', 'production'] as const satisfies Environment[];\n\nexport const tagsSchema = object({\n os: optional(string()),\n os_name: optional(string()),\n os_version: optional(string()),\n browser: optional(string()),\n browser_name: optional(string()),\n browser_version: optional(string()),\n platform: _enum(ALL_PLATFORMS),\n device: optional(string()),\n device_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n device_type: optional(string()),\n device_vendor: optional(string()),\n device_pixel_ratio: optional(number()),\n screen_width: optional(number()),\n screen_height: optional(number()),\n screen_resolution: optional(\n pipe(\n string().check(regex(/^\\d+x\\d+$/)),\n transform((v) => v as `${number}x${number}`)\n )\n ),\n release: optional(string()),\n language: optional(string()),\n time_zone: optional(string()),\n environment: _enum(ALL_ENVIRONMENTS),\n source_url: optional(string()),\n source: optional(_enum(['web', 'app', 'offline'])),\n page_referrer: optional(string()),\n // app info\n advertising_id: optional(string()),\n install_referrer: optional(string()),\n // Meta Ads\n fbc: optional(string()),\n fbp: optional(string()),\n fbclid: optional(string()),\n ad_id: optional(string()),\n ad_name: optional(string()),\n adset_id: optional(string()),\n adset_name: optional(string()),\n campaign_id: optional(string()),\n campaign_name: optional(string()),\n placement: optional(string()),\n site_source_name: optional(string()),\n // Google Ads\n gclid: optional(string()),\n gclsrc: optional(string()),\n gad_source: optional(string()),\n gad_campaignid: optional(string()),\n // Reddit ads\n rdt_cid: optional(string()),\n rdt_uuid: optional(string()),\n // click ids\n dclid: optional(string()),\n ko_click_id: optional(string()),\n li_fat_id: optional(string()),\n msclkid: optional(string()),\n sccid: optional(string()),\n ttclid: optional(string()),\n twclid: optional(string()),\n wbraid: optional(string()),\n yclid: optional(string()),\n // utm params\n utm_source: optional(string()),\n utm_medium: optional(string()),\n utm_campaign: optional(string()),\n utm_term: optional(string()),\n utm_content: optional(string()),\n utm_id: optional(string()),\n utm_source_platform: optional(string()),\n utm_creative_format: optional(string()),\n utm_marketing_tactic: optional(string()),\n});\n\nexport const propertiesSchema = optional(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null(), items])\n ).check(refine((data) => Object.keys(data).length <= 64))\n);\n\n/** @deprecated */\nexport const createTrackEventSchemaV1 = array(\n object({\n name: string().check(trim(), minLength(1), maxLength(64)),\n visitor_id: coerce.bigint(),\n session_id: uuid(),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n).check(minLength(1), maxLength(100));\n\nexport const createTrackEventSchema = array(\n object({\n name: string().check(trim(), minLength(1), maxLength(64)),\n visitor_id: uuid(),\n session_id: uuid(),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n).check(minLength(1), maxLength(100));\n\nexport const createVisitorSchema = object({\n device_id: string().check(trim(), minLength(1), maxLength(36)),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n tags: tagsSchema,\n properties: optional(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null()])\n ).check(refine((data) => Object.keys(data).length <= 64))\n ),\n});\n\nexport const updateVisitorSchema = object({\n user_id: optional(uuid()),\n distinct_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n properties: optional(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null()])\n ).check(refine((data) => Object.keys(data).length <= 64))\n ),\n});\n\nexport const createFeedbackSchema = object({\n name: string().check(minLength(1), maxLength(256)),\n email: email().check(maxLength(320)),\n message: string().check(minLength(1), maxLength(65536)),\n});\n\nconst noEmptyString = pipe(\n string().check(maxLength(256)),\n transform((v) => (v ? v : undefined))\n);\n\n/**\n * The schema for creating a link.\n * @see https://support.google.com/analytics/answer/10917952\n * */\nexport const createLinkSchema = object({\n /** The URL that the user is redirected to. */\n url: url().check(minLength(1), maxLength(1024)), // required\n\n /**\n * Campaign ID. Used to identify a specific campaign or promotion. This is a required key for GA4\n * data import. Use the same IDs that you use when uploading campaign cost data.\n */\n utm_id: optional(noEmptyString),\n\n /** Referrer, for example: google, newsletter4, billboard */\n utm_source: string().check(minLength(1), maxLength(256)), // required\n\n /** Marketing medium, for example: cpc, banner, email */\n utm_medium: string().check(minLength(1), maxLength(256)), // required\n\n /** Product, slogan, promo code, for example, spring_sale */\n utm_campaign: string().check(minLength(1), maxLength(256)), // required\n\n /** Paid keyword */\n utm_term: optional(noEmptyString),\n\n /**\n * Use to differentiate creatives. For example, if you have two call-to-action links within the\n * same email message, you can use utm_content and set different values for each so you can tell\n * which version is more effective.\n */\n utm_content: optional(noEmptyString),\n\n /**\n * The platform responsible for directing traffic to a given Analytics property (such as a buying\n * platform that sets budgets and targeting criteria or a platform that manages organic traffic\n * data). For example, Search Ads 360 or Display & Video 360.\n */\n utm_source_platform: optional(noEmptyString),\n\n /**\n * Type of creative, for example, display, native, video, search, utm_creative_format is not\n * currently reported in Google Analytics 4 properties.\n */\n utm_creative_format: optional(noEmptyString),\n\n /**\n * Targeting criteria applied to a campaign, for example, remarketing, prospecting,\n * utm_marketing_tactic is not currently reported in Google Analytics 4 properties.\n * */\n utm_marketing_tactic: optional(noEmptyString),\n});\n\nexport type CreateTrackEventDTO = z.output<typeof createTrackEventSchema>;\nexport type CreateFeedbackDTO = z.output<typeof createFeedbackSchema>;\nexport type CreateLinkDTO = z.output<typeof createLinkSchema>;\nexport type CreateVisitorDTO = z.output<typeof createVisitorSchema>;\nexport type UpdateVisitorDTO = z.output<typeof updateVisitorSchema>;\n"],"mappings":";;AA2BA,MAAM,QAAQ,MACZ,OACE,OAAO,CAAC,CAAC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,GACnD,MAAM;CAAC,OAAO,CAAC,CAAC,MAAM,UAAU,GAAG,CAAC;CAAG,OAAO;CAAG,QAAQ;CAAGA,OAAM;AAAC,CAAC,CACtE,CACF;AAEA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,mBAAmB,CAAC,eAAe,YAAY;AAE5D,MAAa,aAAa,OAAO;CAC/B,IAAI,SAAS,OAAO,CAAC;CACrB,SAAS,SAAS,OAAO,CAAC;CAC1B,YAAY,SAAS,OAAO,CAAC;CAC7B,SAAS,SAAS,OAAO,CAAC;CAC1B,cAAc,SAAS,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C,CAAC,MAAM,QAAQ,SAAS,OAAO,KAAK,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC,CAC1D;AACF,CAAC;AAED,MAAa,uBAAuB,OAAO;CACzC,MAAM,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;CACjD,OAAO,MAAM,CAAC,CAAC,MAAM,UAAU,GAAG,CAAC;CACnC,SAAS,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,KAAK,CAAC;AACxD,CAAC;AAED,MAAM,gBAAgB,KACpB,OAAO,CAAC,CAAC,MAAM,UAAU,GAAG,CAAC,GAC7B,WAAW,MAAO,IAAI,IAAI,KAAA,CAAU,CACtC;;;;;AAMA,MAAa,mBAAmB,OAAO;;CAErC,KAAK,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,IAAI,CAAC;;;;;CAM9C,QAAQ,SAAS,aAAa;;CAG9B,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,cAAc,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGzD,UAAU,SAAS,aAAa;;;;;;CAOhC,aAAa,SAAS,aAAa;;;;;;CAOnC,qBAAqB,SAAS,aAAa;;;;;CAM3C,qBAAqB,SAAS,aAAa;;;;;CAM3C,sBAAsB,SAAS,aAAa;AAC9C,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["_null","_enum"],"sources":["../../src/schema/index.ts"],"sourcesContent":["import {\n enum as _enum,\n null as _null,\n array,\n boolean,\n coerce,\n e164,\n email,\n iso,\n maxLength,\n minLength,\n number,\n object,\n optional,\n pipe,\n record,\n refine,\n regex,\n string,\n toLowerCase,\n toUpperCase,\n transform,\n trim,\n union,\n url,\n uuid,\n type z,\n} from 'zod/mini';\nimport type { Environment, Platform } from '../track/types';\n\nconst items = array(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null()])\n )\n);\n\nexport const ALL_PLATFORMS = [\n 'ios',\n 'android',\n 'web',\n 'macos',\n 'windows',\n 'linux',\n 'unknown',\n] as const satisfies Platform[];\n\nexport const ALL_ENVIRONMENTS = ['development', 'production'] as const satisfies Environment[];\n\nexport const tagsSchema = object({\n os: optional(string()),\n os_name: optional(string()),\n os_version: optional(string()),\n browser: optional(string()),\n browser_name: optional(string()),\n browser_version: optional(string()),\n platform: _enum(ALL_PLATFORMS),\n device: optional(string()),\n device_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n device_type: optional(string()),\n device_vendor: optional(string()),\n device_pixel_ratio: optional(number()),\n screen_width: optional(number()),\n screen_height: optional(number()),\n screen_resolution: optional(\n pipe(\n string().check(regex(/^\\d+x\\d+$/)),\n transform((v) => v as `${number}x${number}`)\n )\n ),\n release: optional(string()),\n language: optional(string()),\n time_zone: optional(string()),\n environment: _enum(ALL_ENVIRONMENTS),\n source_url: optional(string()),\n source: optional(_enum(['web', 'app', 'offline'])),\n page_referrer: optional(string()),\n // app info\n advertising_id: optional(string()),\n install_referrer: optional(string()),\n // Meta Ads\n fbc: optional(string()),\n fbp: optional(string()),\n fbclid: optional(string()),\n ad_id: optional(string()),\n ad_name: optional(string()),\n adset_id: optional(string()),\n adset_name: optional(string()),\n campaign_id: optional(string()),\n campaign_name: optional(string()),\n placement: optional(string()),\n site_source_name: optional(string()),\n // Google Ads\n gclid: optional(string()),\n gclsrc: optional(string()),\n gad_source: optional(string()),\n gad_campaignid: optional(string()),\n // Reddit ads\n rdt_cid: optional(string()),\n rdt_uuid: optional(string()),\n // click ids\n dclid: optional(string()),\n ko_click_id: optional(string()),\n li_fat_id: optional(string()),\n msclkid: optional(string()),\n sccid: optional(string()),\n ttclid: optional(string()),\n twclid: optional(string()),\n wbraid: optional(string()),\n yclid: optional(string()),\n // utm params\n utm_source: optional(string()),\n utm_medium: optional(string()),\n utm_campaign: optional(string()),\n utm_term: optional(string()),\n utm_content: optional(string()),\n utm_id: optional(string()),\n utm_source_platform: optional(string()),\n utm_creative_format: optional(string()),\n utm_marketing_tactic: optional(string()),\n});\n\nexport const propertiesSchema = optional(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null(), items])\n ).check(refine((data) => Object.keys(data).length <= 64))\n);\n\n/** @deprecated */\nexport const createTrackEventSchemaV1 = array(\n object({\n name: string().check(trim(), minLength(1), maxLength(64)),\n visitor_id: coerce.bigint(),\n session_id: uuid(),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n).check(minLength(1), maxLength(100));\n\nexport const createTrackEventSchema = array(\n object({\n name: string().check(trim(), minLength(1), maxLength(64)),\n visitor_id: uuid(),\n session_id: uuid(),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n).check(minLength(1), maxLength(100));\n\nexport const createVisitorSchema = object({\n device_id: string().check(trim(), minLength(1), maxLength(36)),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n tags: tagsSchema,\n properties: optional(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null()])\n ).check(refine((data) => Object.keys(data).length <= 64))\n ),\n});\n\nconst emailValue = pipe(string().check(trim(), toLowerCase(), maxLength(320)), email());\n\n/** E.164: a plus sign (+) prefix, country code, then digits only, no dashes/parens/spaces. */\nconst phoneValue = pipe(string().check(trim()), e164());\n\nconst addressValue = object({\n first_name: optional(string().check(trim(), maxLength(128))),\n last_name: optional(string().check(trim(), maxLength(128))),\n street: optional(string().check(trim(), maxLength(256))),\n city: optional(string().check(trim(), maxLength(128))),\n /** User province, state, or region. Example: `Hampshire` */\n region: optional(string().check(trim(), maxLength(128))),\n postal_code: optional(string().check(trim(), maxLength(32))),\n /** 2-letter country code, per the ISO 3166-1 alpha-2 standard. Example: `UK` */\n country: optional(string().check(trim(), toUpperCase(), regex(/^[A-Z]{2}$/))),\n});\n\n/**\n * User-provided data (UPD) used for enhanced conversions, Customer Match, and demographics.\n * Values are sent unhashed; Google normalizes and hashes them before they reach its servers.\n *\n * Multiple values may be sent to increase the match rate: up to 3 emails, 3 phone numbers, and\n * 2 addresses.\n *\n * @see https://support.google.com/analytics/answer/14078702\n * @see https://support.google.com/google-ads/answer/13258081\n */\nexport const userProvidedDataSchema = object({\n email: optional(union([emailValue, array(emailValue).check(minLength(1), maxLength(3))])),\n phone_number: optional(union([phoneValue, array(phoneValue).check(minLength(1), maxLength(3))])),\n address: optional(union([addressValue, array(addressValue).check(minLength(1), maxLength(2))])),\n});\n\nexport const updateVisitorSchema = object({\n user_id: optional(uuid()),\n user_data: optional(userProvidedDataSchema),\n distinct_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n tags: tagsSchema,\n properties: optional(\n record(\n string().check(trim(), minLength(1), maxLength(128)),\n union([string().check(maxLength(512)), number(), boolean(), _null()])\n ).check(refine((data) => Object.keys(data).length <= 64))\n ),\n});\n\nexport const createFeedbackSchema = object({\n name: string().check(minLength(1), maxLength(256)),\n email: email().check(maxLength(320)),\n message: string().check(minLength(1), maxLength(65536)),\n});\n\nconst noEmptyString = pipe(\n string().check(maxLength(256)),\n transform((v) => (v ? v : undefined))\n);\n\n/**\n * The schema for creating a link.\n * @see https://support.google.com/analytics/answer/10917952\n * */\nexport const createLinkSchema = object({\n /** The URL that the user is redirected to. */\n url: url().check(minLength(1), maxLength(1024)), // required\n\n /**\n * Campaign ID. Used to identify a specific campaign or promotion. This is a required key for GA4\n * data import. Use the same IDs that you use when uploading campaign cost data.\n */\n utm_id: optional(noEmptyString),\n\n /** Referrer, for example: google, newsletter4, billboard */\n utm_source: string().check(minLength(1), maxLength(256)), // required\n\n /** Marketing medium, for example: cpc, banner, email */\n utm_medium: string().check(minLength(1), maxLength(256)), // required\n\n /** Product, slogan, promo code, for example, spring_sale */\n utm_campaign: string().check(minLength(1), maxLength(256)), // required\n\n /** Paid keyword */\n utm_term: optional(noEmptyString),\n\n /**\n * Use to differentiate creatives. For example, if you have two call-to-action links within the\n * same email message, you can use utm_content and set different values for each so you can tell\n * which version is more effective.\n */\n utm_content: optional(noEmptyString),\n\n /**\n * The platform responsible for directing traffic to a given Analytics property (such as a buying\n * platform that sets budgets and targeting criteria or a platform that manages organic traffic\n * data). For example, Search Ads 360 or Display & Video 360.\n */\n utm_source_platform: optional(noEmptyString),\n\n /**\n * Type of creative, for example, display, native, video, search, utm_creative_format is not\n * currently reported in Google Analytics 4 properties.\n */\n utm_creative_format: optional(noEmptyString),\n\n /**\n * Targeting criteria applied to a campaign, for example, remarketing, prospecting,\n * utm_marketing_tactic is not currently reported in Google Analytics 4 properties.\n * */\n utm_marketing_tactic: optional(noEmptyString),\n});\n\nexport type CreateTrackEventDTO = z.output<typeof createTrackEventSchema>;\nexport type CreateFeedbackDTO = z.output<typeof createFeedbackSchema>;\nexport type CreateLinkDTO = z.output<typeof createLinkSchema>;\nexport type CreateVisitorDTO = z.output<typeof createVisitorSchema>;\nexport type UserProvidedDataDTO = z.output<typeof userProvidedDataSchema>;\nexport type UpdateVisitorDTO = z.output<typeof updateVisitorSchema>;\n"],"mappings":";;AA8BA,MAAM,QAAQ,MACZ,OACE,OAAO,CAAC,CAAC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,GACnD,MAAM;CAAC,OAAO,CAAC,CAAC,MAAM,UAAU,GAAG,CAAC;CAAG,OAAO;CAAG,QAAQ;CAAGA,OAAM;AAAC,CAAC,CACtE,CACF;AAEA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA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, properties) {
|
|
|
7
7
|
}
|
|
8
8
|
window.gtag("event", name, properties);
|
|
9
9
|
}
|
|
10
|
-
function setGAUser({ user_id,
|
|
10
|
+
function setGAUser({ user_id, user_data, properties }) {
|
|
11
11
|
if (!window.gtag) {
|
|
12
12
|
console.warn("GA has not been initialized");
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
if (user_id) window.gtag("set", "user_id", user_id);
|
|
16
|
-
if (
|
|
16
|
+
if (user_data) window.gtag("set", "user_data", user_data);
|
|
17
17
|
if (properties) window.gtag("set", "user_properties", properties);
|
|
18
18
|
}
|
|
19
19
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-analytics.cjs","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"google-analytics.cjs","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Gtag } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends Gtag {}\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (!window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n window.gtag('event', name, properties);\n}\n\nexport function setGAUser({ user_id, user_data, properties }: UpdateVisitorDTO) {\n if (!window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n if (user_id) window.gtag('set', 'user_id', user_id);\n if (user_data) window.gtag('set', 'user_data', user_data);\n if (properties) window.gtag('set', 'user_properties', properties as never);\n}\n"],"mappings":";;AASA,SAAgB,YACd,MACA,YACA;CACA,IAAI,CAAC,OAAO,MAAM;EAChB,QAAQ,KAAK,6BAA6B;EAC1C;CACF;CACA,OAAO,KAAK,SAAS,MAAM,UAAU;AACvC;AAEA,SAAgB,UAAU,EAAE,SAAS,WAAW,cAAgC;CAC9E,IAAI,CAAC,OAAO,MAAM;EAChB,QAAQ,KAAK,6BAA6B;EAC1C;CACF;CACA,IAAI,SAAS,OAAO,KAAK,OAAO,WAAW,OAAO;CAClD,IAAI,WAAW,OAAO,KAAK,OAAO,aAAa,SAAS;CACxD,IAAI,YAAY,OAAO,KAAK,OAAO,mBAAmB,UAAmB;AAC3E"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { UpdateVisitorDTO } from "../schema/index.cjs";
|
|
1
2
|
import { Gtag } from "../track/gtag.cjs";
|
|
2
3
|
import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
|
|
3
|
-
import { UpdateVisitorDTO } from "../visitor/types.cjs";
|
|
4
4
|
//#region src/third-parties/google-analytics.d.ts
|
|
5
5
|
declare global {
|
|
6
6
|
interface Window extends Gtag {}
|
|
7
7
|
}
|
|
8
8
|
declare function sendGAEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>): void;
|
|
9
|
-
declare function setGAUser({ user_id,
|
|
9
|
+
declare function setGAUser({ user_id, user_data, properties }: UpdateVisitorDTO): void;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { sendGAEvent, setGAUser };
|
|
12
12
|
//# sourceMappingURL=google-analytics.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-analytics.d.cts","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"mappings":";;;;QAIQ;YAEI,eAAe;;iBAGX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB;iBASf,YAAY,SAAS,
|
|
1
|
+
{"version":3,"file":"google-analytics.d.cts","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"mappings":";;;;QAIQ;YAEI,eAAe;;iBAGX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB;iBASf,YAAY,SAAS,WAAW,cAAc"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { UpdateVisitorDTO } from "../schema/index.mjs";
|
|
1
2
|
import { Gtag } from "../track/gtag.mjs";
|
|
2
3
|
import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
|
|
3
|
-
import { UpdateVisitorDTO } from "../visitor/types.mjs";
|
|
4
4
|
//#region src/third-parties/google-analytics.d.ts
|
|
5
5
|
declare global {
|
|
6
6
|
interface Window extends Gtag {}
|
|
7
7
|
}
|
|
8
8
|
declare function sendGAEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>): void;
|
|
9
|
-
declare function setGAUser({ user_id,
|
|
9
|
+
declare function setGAUser({ user_id, user_data, properties }: UpdateVisitorDTO): void;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { sendGAEvent, setGAUser };
|
|
12
12
|
//# sourceMappingURL=google-analytics.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-analytics.d.mts","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"mappings":";;;;QAIQ;YAEI,eAAe;;iBAGX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB;iBASf,YAAY,SAAS,
|
|
1
|
+
{"version":3,"file":"google-analytics.d.mts","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"mappings":";;;;QAIQ;YAEI,eAAe;;iBAGX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB;iBASf,YAAY,SAAS,WAAW,cAAc"}
|
|
@@ -6,13 +6,13 @@ function sendGAEvent(name, properties) {
|
|
|
6
6
|
}
|
|
7
7
|
window.gtag("event", name, properties);
|
|
8
8
|
}
|
|
9
|
-
function setGAUser({ user_id,
|
|
9
|
+
function setGAUser({ user_id, user_data, properties }) {
|
|
10
10
|
if (!window.gtag) {
|
|
11
11
|
console.warn("GA has not been initialized");
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
if (user_id) window.gtag("set", "user_id", user_id);
|
|
15
|
-
if (
|
|
15
|
+
if (user_data) window.gtag("set", "user_data", user_data);
|
|
16
16
|
if (properties) window.gtag("set", "user_properties", properties);
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-analytics.mjs","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"google-analytics.mjs","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Gtag } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends Gtag {}\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (!window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n window.gtag('event', name, properties);\n}\n\nexport function setGAUser({ user_id, user_data, properties }: UpdateVisitorDTO) {\n if (!window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n if (user_id) window.gtag('set', 'user_id', user_id);\n if (user_data) window.gtag('set', 'user_data', user_data);\n if (properties) window.gtag('set', 'user_properties', properties as never);\n}\n"],"mappings":";AASA,SAAgB,YACd,MACA,YACA;CACA,IAAI,CAAC,OAAO,MAAM;EAChB,QAAQ,KAAK,6BAA6B;EAC1C;CACF;CACA,OAAO,KAAK,SAAS,MAAM,UAAU;AACvC;AAEA,SAAgB,UAAU,EAAE,SAAS,WAAW,cAAgC;CAC9E,IAAI,CAAC,OAAO,MAAM;EAChB,QAAQ,KAAK,6BAA6B;EAC1C;CACF;CACA,IAAI,SAAS,OAAO,KAAK,OAAO,WAAW,OAAO;CAClD,IAAI,WAAW,OAAO,KAAK,OAAO,aAAa,SAAS;CACxD,IAAI,YAAY,OAAO,KAAK,OAAO,mBAAmB,UAAmB;AAC3E"}
|
|
@@ -17,12 +17,12 @@ function sendLinkedinEvent(config) {
|
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
function setLinkedinUser({
|
|
20
|
+
function setLinkedinUser({ user_data }) {
|
|
21
21
|
if (typeof window === "undefined" || !window.lintrk) {
|
|
22
22
|
console.warn("lintrk has not been initialized");
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
const email = require_utils_field.getFirst(
|
|
25
|
+
const email = require_utils_field.getFirst(user_data?.email);
|
|
26
26
|
if (!email) return;
|
|
27
27
|
window.lintrk("setUserData", { email });
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-insight-tag.cjs","names":["getFirst"],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\
|
|
1
|
+
{"version":3,"file":"linkedin-insight-tag.cjs","names":["getFirst"],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends Lintrk {}\n}\n\n/**\n * LinkedIn Conversion Config:\n * example:\n * {\n * purchase: 123,\n * add_to_cart: 456,\n * add_to_wishlist: 789,\n * }\n */\nexport type LinkedinConversionConfig = Record<Lowercase<string>, number>;\n\nexport function sendLinkedinEvent(config: LinkedinConversionConfig) {\n return <T extends EventName>(\n name: TrackName<T>,\n _properties?: TrackProperties<T>,\n event_id?: string\n ) => {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return;\n }\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const conversion_id = config[name as Lowercase<string>];\n if (!conversion_id) return;\n window.lintrk('track', { conversion_id, event_id });\n };\n}\n\nexport function setLinkedinUser({ user_data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return;\n }\n\n const email = getFirst(user_data?.email);\n if (!email) return;\n window.lintrk('setUserData', { email });\n}\n"],"mappings":";;;AAqBA,SAAgB,kBAAkB,QAAkC;CAClE,QACE,MACA,aACA,aACG;EACH,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;GACnD,QAAQ,KAAK,iCAAiC;GAC9C;EACF;EACA,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAEhD,MAAM,gBAAgB,OAAO;EAC7B,IAAI,CAAC,eAAe;EACpB,OAAO,OAAO,SAAS;GAAE;GAAe;EAAS,CAAC;CACpD;AACF;AAEA,SAAgB,gBAAgB,EAAE,aAA+B;CAC/D,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;EACnD,QAAQ,KAAK,iCAAiC;EAC9C;CACF;CAEA,MAAM,QAAQA,oBAAAA,SAAS,WAAW,KAAK;CACvC,IAAI,CAAC,OAAO;CACZ,OAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { UpdateVisitorDTO } from "../schema/index.cjs";
|
|
1
2
|
import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
|
|
2
|
-
import { UpdateVisitorDTO } from "../visitor/types.cjs";
|
|
3
3
|
import { Lintrk } from "../track/lintrk.cjs";
|
|
4
4
|
//#region src/third-parties/linkedin-insight-tag.d.ts
|
|
5
5
|
declare global {
|
|
@@ -16,7 +16,7 @@ declare global {
|
|
|
16
16
|
*/
|
|
17
17
|
type LinkedinConversionConfig = Record<Lowercase<string>, number>;
|
|
18
18
|
declare function sendLinkedinEvent(config: LinkedinConversionConfig): <T extends EventName>(name: TrackName<T>, _properties?: TrackProperties<T>, event_id?: string) => void;
|
|
19
|
-
declare function setLinkedinUser({
|
|
19
|
+
declare function setLinkedinUser({ user_data }: UpdateVisitorDTO): void;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { LinkedinConversionConfig, sendLinkedinEvent, setLinkedinUser };
|
|
22
22
|
//# sourceMappingURL=linkedin-insight-tag.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-insight-tag.d.cts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;;;;;;;;;;KAYf,2BAA2B,OAAO;iBAE9B,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;iBAgBpB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"linkedin-insight-tag.d.cts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;;;;;;;;;;KAYf,2BAA2B,OAAO;iBAE9B,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;iBAgBpB,kBAAkB,aAAa"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { UpdateVisitorDTO } from "../schema/index.mjs";
|
|
1
2
|
import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
|
|
2
|
-
import { UpdateVisitorDTO } from "../visitor/types.mjs";
|
|
3
3
|
import { Lintrk } from "../track/lintrk.mjs";
|
|
4
4
|
//#region src/third-parties/linkedin-insight-tag.d.ts
|
|
5
5
|
declare global {
|
|
@@ -16,7 +16,7 @@ declare global {
|
|
|
16
16
|
*/
|
|
17
17
|
type LinkedinConversionConfig = Record<Lowercase<string>, number>;
|
|
18
18
|
declare function sendLinkedinEvent(config: LinkedinConversionConfig): <T extends EventName>(name: TrackName<T>, _properties?: TrackProperties<T>, event_id?: string) => void;
|
|
19
|
-
declare function setLinkedinUser({
|
|
19
|
+
declare function setLinkedinUser({ user_data }: UpdateVisitorDTO): void;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { LinkedinConversionConfig, sendLinkedinEvent, setLinkedinUser };
|
|
22
22
|
//# sourceMappingURL=linkedin-insight-tag.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-insight-tag.d.mts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;;;;;;;;;;KAYf,2BAA2B,OAAO;iBAE9B,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;iBAgBpB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"linkedin-insight-tag.d.mts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;;;;;;;;;;KAYf,2BAA2B,OAAO;iBAE9B,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;iBAgBpB,kBAAkB,aAAa"}
|
|
@@ -16,12 +16,12 @@ function sendLinkedinEvent(config) {
|
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
function setLinkedinUser({
|
|
19
|
+
function setLinkedinUser({ user_data }) {
|
|
20
20
|
if (typeof window === "undefined" || !window.lintrk) {
|
|
21
21
|
console.warn("lintrk has not been initialized");
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
const email = getFirst(
|
|
24
|
+
const email = getFirst(user_data?.email);
|
|
25
25
|
if (!email) return;
|
|
26
26
|
window.lintrk("setUserData", { email });
|
|
27
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-insight-tag.mjs","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\
|
|
1
|
+
{"version":3,"file":"linkedin-insight-tag.mjs","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends Lintrk {}\n}\n\n/**\n * LinkedIn Conversion Config:\n * example:\n * {\n * purchase: 123,\n * add_to_cart: 456,\n * add_to_wishlist: 789,\n * }\n */\nexport type LinkedinConversionConfig = Record<Lowercase<string>, number>;\n\nexport function sendLinkedinEvent(config: LinkedinConversionConfig) {\n return <T extends EventName>(\n name: TrackName<T>,\n _properties?: TrackProperties<T>,\n event_id?: string\n ) => {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return;\n }\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const conversion_id = config[name as Lowercase<string>];\n if (!conversion_id) return;\n window.lintrk('track', { conversion_id, event_id });\n };\n}\n\nexport function setLinkedinUser({ user_data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return;\n }\n\n const email = getFirst(user_data?.email);\n if (!email) return;\n window.lintrk('setUserData', { email });\n}\n"],"mappings":";;AAqBA,SAAgB,kBAAkB,QAAkC;CAClE,QACE,MACA,aACA,aACG;EACH,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;GACnD,QAAQ,KAAK,iCAAiC;GAC9C;EACF;EACA,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAEhD,MAAM,gBAAgB,OAAO;EAC7B,IAAI,CAAC,eAAe;EACpB,OAAO,OAAO,SAAS;GAAE;GAAe;EAAS,CAAC;CACpD;AACF;AAEA,SAAgB,gBAAgB,EAAE,aAA+B;CAC/D,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;EACnD,QAAQ,KAAK,iCAAiC;EAC9C;CACF;CAEA,MAAM,QAAQ,SAAS,WAAW,KAAK;CACvC,IAAI,CAAC,OAAO;CACZ,OAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC"}
|
|
@@ -24,17 +24,17 @@ function sendFBEvent(name, properties, event_id) {
|
|
|
24
24
|
else window.fbq(type, fbEventName, fbEventProperties, options);
|
|
25
25
|
}
|
|
26
26
|
function setFBUser(pixelId) {
|
|
27
|
-
return ({ user_id,
|
|
27
|
+
return ({ user_id, user_data }) => {
|
|
28
28
|
if (typeof window === "undefined" || !window.fbq) {
|
|
29
29
|
console.warn("fbq has not been initialized");
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
const address = require_utils_field.getFirst(
|
|
32
|
+
const address = require_utils_field.getFirst(user_data?.address);
|
|
33
33
|
window.fbq("init", pixelId, {
|
|
34
|
-
em: require_utils_field.getFirst(
|
|
34
|
+
em: require_utils_field.getFirst(user_data?.email),
|
|
35
35
|
fn: address?.first_name,
|
|
36
36
|
ln: address?.last_name,
|
|
37
|
-
ph: require_utils_field.getFirst(
|
|
37
|
+
ph: require_utils_field.getFirst(user_data?.phone_number),
|
|
38
38
|
external_id: user_id,
|
|
39
39
|
ct: address?.city,
|
|
40
40
|
st: address?.street,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-pixel.cjs","names":["mapFBEvent","getFirst"],"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\
|
|
1
|
+
{"version":3,"file":"meta-pixel.cjs","names":["mapFBEvent","getFirst"],"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends FBQ {}\n}\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n if (metrics.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n window.fbq(type, fbEventName, fbEventProperties, options);\n } else {\n window.fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function setFBUser(pixelId: PixelId) {\n return ({ user_id, user_data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n\n const address = getFirst(user_data?.address);\n\n window.fbq('init', pixelId, {\n em: getFirst(user_data?.email),\n fn: address?.first_name,\n ln: address?.last_name,\n ph: getFirst(user_data?.phone_number),\n external_id: user_id,\n ct: address?.city,\n st: address?.street,\n zp: address?.postal_code,\n country: address?.country,\n });\n };\n}\n"],"mappings":";;;;AAUA,MAAM,UAAU;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;AAAM;AAE1D,SAAgB,YACd,MACA,YACA,UACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;EAChD,QAAQ,KAAK,8BAA8B;EAC3C;CACF;CACA,IAAI,QAAQ,SAAS,IAAI,GAAG;CAC5B,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAEhD,MAAM,UAAU,EAAE,SAAS,SAAS;CACpC,MAAM,CAAC,MAAM,aAAa,qBAAqBA,kBAAAA,WAAW,MAAM,UAAU;CAC1E,IAAI,SAAS,SACX,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;MAExD,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAE5D;AAEA,SAAgB,UAAU,SAAkB;CAC1C,QAAQ,EAAE,SAAS,gBAAkC;EACnD,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;GAChD,QAAQ,KAAK,8BAA8B;GAC3C;EACF;EAEA,MAAM,UAAUC,oBAAAA,SAAS,WAAW,OAAO;EAE3C,OAAO,IAAI,QAAQ,SAAS;GAC1B,IAAIA,oBAAAA,SAAS,WAAW,KAAK;GAC7B,IAAI,SAAS;GACb,IAAI,SAAS;GACb,IAAIA,oBAAAA,SAAS,WAAW,YAAY;GACpC,aAAa;GACb,IAAI,SAAS;GACb,IAAI,SAAS;GACb,IAAI,SAAS;GACb,SAAS,SAAS;EACpB,CAAC;CACH;AACF"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { UpdateVisitorDTO } from "../schema/index.cjs";
|
|
1
2
|
import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
|
|
2
|
-
import { UpdateVisitorDTO } from "../visitor/types.cjs";
|
|
3
3
|
import { FBQ, PixelId } from "../track/fbq.cjs";
|
|
4
4
|
//#region src/third-parties/meta-pixel.d.ts
|
|
5
5
|
declare global {
|
|
6
6
|
interface Window extends FBQ {}
|
|
7
7
|
}
|
|
8
8
|
declare function sendFBEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>, event_id?: string): void;
|
|
9
|
-
declare function setFBUser(pixelId: PixelId): ({ user_id,
|
|
9
|
+
declare function setFBUser(pixelId: PixelId): ({ user_id, user_data }: UpdateVisitorDTO) => void;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { sendFBEvent, setFBUser };
|
|
12
12
|
//# sourceMappingURL=meta-pixel.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-pixel.d.cts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;iBAKX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;iBAmBc,UAAU,SAAS,aAAO,SAAA,
|
|
1
|
+
{"version":3,"file":"meta-pixel.d.cts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;iBAKX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;iBAmBc,UAAU,SAAS,aAAO,SAAA,aACR"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { UpdateVisitorDTO } from "../schema/index.mjs";
|
|
1
2
|
import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
|
|
2
|
-
import { UpdateVisitorDTO } from "../visitor/types.mjs";
|
|
3
3
|
import { FBQ, PixelId } from "../track/fbq.mjs";
|
|
4
4
|
//#region src/third-parties/meta-pixel.d.ts
|
|
5
5
|
declare global {
|
|
6
6
|
interface Window extends FBQ {}
|
|
7
7
|
}
|
|
8
8
|
declare function sendFBEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>, event_id?: string): void;
|
|
9
|
-
declare function setFBUser(pixelId: PixelId): ({ user_id,
|
|
9
|
+
declare function setFBUser(pixelId: PixelId): ({ user_id, user_data }: UpdateVisitorDTO) => void;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { sendFBEvent, setFBUser };
|
|
12
12
|
//# sourceMappingURL=meta-pixel.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-pixel.d.mts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;iBAKX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;iBAmBc,UAAU,SAAS,aAAO,SAAA,
|
|
1
|
+
{"version":3,"file":"meta-pixel.d.mts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;iBAKX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;iBAmBc,UAAU,SAAS,aAAO,SAAA,aACR"}
|
|
@@ -23,17 +23,17 @@ function sendFBEvent(name, properties, event_id) {
|
|
|
23
23
|
else window.fbq(type, fbEventName, fbEventProperties, options);
|
|
24
24
|
}
|
|
25
25
|
function setFBUser(pixelId) {
|
|
26
|
-
return ({ user_id,
|
|
26
|
+
return ({ user_id, user_data }) => {
|
|
27
27
|
if (typeof window === "undefined" || !window.fbq) {
|
|
28
28
|
console.warn("fbq has not been initialized");
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
const address = getFirst(
|
|
31
|
+
const address = getFirst(user_data?.address);
|
|
32
32
|
window.fbq("init", pixelId, {
|
|
33
|
-
em: getFirst(
|
|
33
|
+
em: getFirst(user_data?.email),
|
|
34
34
|
fn: address?.first_name,
|
|
35
35
|
ln: address?.last_name,
|
|
36
|
-
ph: getFirst(
|
|
36
|
+
ph: getFirst(user_data?.phone_number),
|
|
37
37
|
external_id: user_id,
|
|
38
38
|
ct: address?.city,
|
|
39
39
|
st: address?.street,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-pixel.mjs","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\
|
|
1
|
+
{"version":3,"file":"meta-pixel.mjs","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends FBQ {}\n}\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n if (metrics.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n window.fbq(type, fbEventName, fbEventProperties, options);\n } else {\n window.fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function setFBUser(pixelId: PixelId) {\n return ({ user_id, user_data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n\n const address = getFirst(user_data?.address);\n\n window.fbq('init', pixelId, {\n em: getFirst(user_data?.email),\n fn: address?.first_name,\n ln: address?.last_name,\n ph: getFirst(user_data?.phone_number),\n external_id: user_id,\n ct: address?.city,\n st: address?.street,\n zp: address?.postal_code,\n country: address?.country,\n });\n };\n}\n"],"mappings":";;;AAUA,MAAM,UAAU;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;AAAM;AAE1D,SAAgB,YACd,MACA,YACA,UACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;EAChD,QAAQ,KAAK,8BAA8B;EAC3C;CACF;CACA,IAAI,QAAQ,SAAS,IAAI,GAAG;CAC5B,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAEhD,MAAM,UAAU,EAAE,SAAS,SAAS;CACpC,MAAM,CAAC,MAAM,aAAa,qBAAqB,WAAW,MAAM,UAAU;CAC1E,IAAI,SAAS,SACX,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;MAExD,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAE5D;AAEA,SAAgB,UAAU,SAAkB;CAC1C,QAAQ,EAAE,SAAS,gBAAkC;EACnD,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;GAChD,QAAQ,KAAK,8BAA8B;GAC3C;EACF;EAEA,MAAM,UAAU,SAAS,WAAW,OAAO;EAE3C,OAAO,IAAI,QAAQ,SAAS;GAC1B,IAAI,SAAS,WAAW,KAAK;GAC7B,IAAI,SAAS;GACb,IAAI,SAAS;GACb,IAAI,SAAS,WAAW,YAAY;GACpC,aAAa;GACb,IAAI,SAAS;GACb,IAAI,SAAS;GACb,IAAI,SAAS;GACb,SAAS,SAAS;EACpB,CAAC;CACH;AACF"}
|