@datalyr/web 1.5.0 → 1.6.1
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/README.md +2 -2
- package/dist/attribution.d.ts.map +1 -1
- package/dist/container.d.ts +1 -1
- package/dist/container.d.ts.map +1 -1
- package/dist/datalyr.cjs.js +136 -18
- package/dist/datalyr.cjs.js.map +1 -1
- package/dist/datalyr.esm.js +133 -18
- package/dist/datalyr.esm.js.map +1 -1
- package/dist/datalyr.esm.min.js +1 -1
- package/dist/datalyr.esm.min.js.map +1 -1
- package/dist/datalyr.js +140 -20
- package/dist/datalyr.js.map +1 -1
- package/dist/datalyr.min.js +1 -1
- package/dist/datalyr.min.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -438,7 +438,7 @@ interface Attribution {
|
|
|
438
438
|
term?: string | null;
|
|
439
439
|
content?: string | null;
|
|
440
440
|
clickId?: string | null;
|
|
441
|
-
clickIdType?: string | null; // 'fbclid', 'gclid', etc.
|
|
441
|
+
clickIdType?: string | null; // 'fbclid', 'gclid', 'oppref', etc.
|
|
442
442
|
referrer?: string | null;
|
|
443
443
|
referrerHost?: string | null;
|
|
444
444
|
landingPage?: string | null;
|
|
@@ -453,7 +453,7 @@ Captured automatically from URLs:
|
|
|
453
453
|
| Type | Parameters |
|
|
454
454
|
|------|------------|
|
|
455
455
|
| UTM | `utm_source`, `utm_medium`, `utm_campaign`, `utm_content`, `utm_term` |
|
|
456
|
-
| Click IDs | `fbclid`, `gclid`, `ttclid`, `twclid`, `li_fat_id`, `msclkid` |
|
|
456
|
+
| Click IDs | `fbclid`, `gclid`, `ttclid`, `oppref`, `twclid`, `li_fat_id`, `msclkid` |
|
|
457
457
|
| Referrer | `referrer`, `landing_page` |
|
|
458
458
|
|
|
459
459
|
Attribution supports first-touch (90-day window), last-touch, and journey tracking.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../src/attribution.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEvD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,gBAAgB,CAAuC;IAC/D,OAAO,CAAC,UAAU,CAA2E;IAE7F,OAAO,CAAC,SAAS,CAgBf;IAEF,OAAO,CAAC,sBAAsB,CAO5B;gBAEU,OAAO,GAAE;QACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB;IAMN;;;OAGG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,kBAAkB,IAAI,WAAW;IA8DjC;;;;;OAKG;IACH,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAwB/C;;;OAGG;IACH,aAAa,IAAI,WAAW,GAAG,IAAI;IASnC;;OAEG;IACH,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAQ9C;;;OAGG;IACH,YAAY,IAAI,WAAW,GAAG,IAAI;IASlC;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI;IAqBhE;;OAEG;IACH,UAAU,IAAI,UAAU,EAAE;IAI1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;
|
|
1
|
+
{"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../src/attribution.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEvD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,gBAAgB,CAAuC;IAC/D,OAAO,CAAC,UAAU,CAA2E;IAE7F,OAAO,CAAC,SAAS,CAgBf;IAEF,OAAO,CAAC,sBAAsB,CAO5B;gBAEU,OAAO,GAAE;QACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB;IAMN;;;OAGG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,kBAAkB,IAAI,WAAW;IA8DjC;;;;;OAKG;IACH,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAwB/C;;;OAGG;IACH,aAAa,IAAI,WAAW,GAAG,IAAI;IASnC;;OAEG;IACH,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAQ9C;;;OAGG;IACH,YAAY,IAAI,WAAW,GAAG,IAAI;IASlC;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI;IAqBhE;;OAEG;IACH,UAAU,IAAI,UAAU,EAAE;IAI1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAiDxB;;;OAGG;IACH,OAAO,CAAC,UAAU;IAKlB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAKxB;;OAEG;IACH,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IA0EzC;;OAEG;IACH,OAAO,CAAC,eAAe;IA6CvB;;OAEG;IACH,OAAO,CAAC,eAAe;IA2BvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAQvB;;OAEG;IACH,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO;IAKvD;;OAEG;IACH,uBAAuB,IAAI,IAAI;CAYhC"}
|
package/dist/container.d.ts
CHANGED
|
@@ -123,7 +123,7 @@ export declare class ContainerManager {
|
|
|
123
123
|
/**
|
|
124
124
|
* Track event to all initialized pixels
|
|
125
125
|
*/
|
|
126
|
-
trackToPixels(eventName: string, properties?: any): void;
|
|
126
|
+
trackToPixels(eventName: string, properties?: any, eventId?: string): void;
|
|
127
127
|
/**
|
|
128
128
|
* Manually trigger a custom script
|
|
129
129
|
*/
|
package/dist/container.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,QAAQ,CAAC;IAC9D,SAAS,EAAE,QAAQ,GAAG,eAAe,GAAG,kBAAkB,CAAC;IAC3D,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,KAAK,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,GAAG,CAAC;KACZ,CAAC,CAAC;IACH,QAAQ,CAAC,EAAE;QACT,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE;QACL,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;KAChC,CAAC;IACF,MAAM,CAAC,EAAE;QACP,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,oBAAoB,CAAC,EAAE,OAAO,CAAC;KAChC,CAAC;IACF,MAAM,CA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B;IAoBxB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAyB1B;;OAEG;IACH,OAAO,CAAC,aAAa;IA0BrB;;OAEG;IACH,OAAO,CAAC,GAAG;CAKZ"}
|
package/dist/datalyr.cjs.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @datalyr/web v1.
|
|
2
|
+
* @datalyr/web v1.6.1
|
|
3
3
|
* Datalyr Web SDK - Modern attribution tracking for web applications
|
|
4
4
|
* (c) 2026 Datalyr Inc.
|
|
5
5
|
* Released under the MIT License
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
10
|
+
|
|
9
11
|
/******************************************************************************
|
|
10
12
|
Copyright (c) Microsoft Corporation.
|
|
11
13
|
|
|
@@ -1506,10 +1508,13 @@ class AttributionManager {
|
|
|
1506
1508
|
// Optionally set the cookie for future use
|
|
1507
1509
|
cookies.set('_fbp', adCookies._fbp, 90);
|
|
1508
1510
|
}
|
|
1509
|
-
// Generate _fbc if we have fbclid but no _fbc
|
|
1511
|
+
// Generate _fbc if we have fbclid but no _fbc.
|
|
1512
|
+
// Meta's fbc format is `fb.{subdomainIndex}.{creationTime}.{fbclid}` where
|
|
1513
|
+
// creationTime is UNIX time in MILLISECONDS (matches the _fbp generation above
|
|
1514
|
+
// and the real _fbc cookie the Meta Pixel writes). Do NOT use seconds here.
|
|
1510
1515
|
const fbclid = this.getCurrentFbclid();
|
|
1511
1516
|
if (fbclid && !adCookies._fbc) {
|
|
1512
|
-
const timestamp =
|
|
1517
|
+
const timestamp = Date.now();
|
|
1513
1518
|
adCookies._fbc = `fb.1.${timestamp}.${fbclid}`;
|
|
1514
1519
|
// Optionally set the cookie for future use
|
|
1515
1520
|
cookies.set('_fbc', adCookies._fbc, 90);
|
|
@@ -2674,9 +2679,12 @@ class ContainerManager {
|
|
|
2674
2679
|
s = b.getElementsByTagName(e)[0];
|
|
2675
2680
|
s.parentNode.insertBefore(t, s);
|
|
2676
2681
|
})(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
|
|
2677
|
-
// Initialize pixel
|
|
2682
|
+
// Initialize pixel only — do NOT fire PageView here. The SDK's own pageview
|
|
2683
|
+
// tracking (track('pageview')) routes through trackToPixels and fires a single
|
|
2684
|
+
// mapped PageView with a shared eventID. Firing it again here produced TWO
|
|
2685
|
+
// PageViews per load (one un-deduped). Note: if the host app disables pageview
|
|
2686
|
+
// tracking entirely, no PageView is sent — which is the correct outcome.
|
|
2678
2687
|
window.fbq('init', config.pixel_id);
|
|
2679
|
-
window.fbq('track', 'PageView');
|
|
2680
2688
|
this.log('Meta Pixel initialized:', config.pixel_id);
|
|
2681
2689
|
}
|
|
2682
2690
|
catch (error) {
|
|
@@ -2758,22 +2766,63 @@ class ContainerManager {
|
|
|
2758
2766
|
/**
|
|
2759
2767
|
* Track event to all initialized pixels
|
|
2760
2768
|
*/
|
|
2761
|
-
trackToPixels(eventName, properties = {}) {
|
|
2762
|
-
var _a, _b, _c, _e, _f, _g;
|
|
2769
|
+
trackToPixels(eventName, properties = {}, eventId) {
|
|
2770
|
+
var _a, _b, _c, _e, _f, _g, _h, _j;
|
|
2771
|
+
// Datalyr-internal events ($identify, $group, $alias, $auto_identify,
|
|
2772
|
+
// $app_download_click, …) are not conversions — never forward them to ad
|
|
2773
|
+
// pixels. (Previously they fired as noise custom events with the $ stripped.)
|
|
2774
|
+
if (eventName.startsWith('$'))
|
|
2775
|
+
return;
|
|
2763
2776
|
// Sanitize inputs to prevent XSS
|
|
2764
2777
|
const sanitizedEventName = this.sanitizeEventName(eventName);
|
|
2765
2778
|
const sanitizedProperties = this.sanitizeProperties(properties);
|
|
2766
2779
|
// Track to Meta Pixel
|
|
2767
2780
|
if (((_b = (_a = this.pixels) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.enabled) && window.fbq) {
|
|
2768
2781
|
try {
|
|
2769
|
-
|
|
2782
|
+
// Map our event name to Meta's standard event vocabulary so the browser
|
|
2783
|
+
// Pixel fires e.g. "Purchase", not "purchase". This MUST match the
|
|
2784
|
+
// platform_standard_event the postback worker sends server-side, or Meta
|
|
2785
|
+
// won't dedupe (dedup = event_name + event_id). These defaults mirror the
|
|
2786
|
+
// server-side auto-detect map; custom rule choices may not line up.
|
|
2787
|
+
const metaEventMap = {
|
|
2788
|
+
page_view: 'PageView', pageview: 'PageView',
|
|
2789
|
+
view_content: 'ViewContent', product_viewed: 'ViewContent', view_item: 'ViewContent',
|
|
2790
|
+
add_to_cart: 'AddToCart', product_added: 'AddToCart',
|
|
2791
|
+
add_to_wishlist: 'AddToWishlist',
|
|
2792
|
+
initiate_checkout: 'InitiateCheckout', begin_checkout: 'InitiateCheckout', checkout_started: 'InitiateCheckout',
|
|
2793
|
+
add_payment_info: 'AddPaymentInfo',
|
|
2794
|
+
purchase: 'Purchase', order_completed: 'Purchase', order_paid: 'Purchase',
|
|
2795
|
+
lead: 'Lead',
|
|
2796
|
+
complete_registration: 'CompleteRegistration', sign_up: 'CompleteRegistration', signup: 'CompleteRegistration',
|
|
2797
|
+
search: 'Search',
|
|
2798
|
+
subscribe: 'Subscribe', subscription_created: 'Subscribe',
|
|
2799
|
+
start_trial: 'StartTrial', trial_started: 'StartTrial',
|
|
2800
|
+
contact: 'Contact',
|
|
2801
|
+
schedule: 'Schedule',
|
|
2802
|
+
};
|
|
2803
|
+
// Source of truth: the workspace's Meta conversion-rule map (from
|
|
2804
|
+
// /container-scripts, keyed by the exact trigger event name) — this is what
|
|
2805
|
+
// the server-side CAPI sends, so it guarantees event_name dedup alignment.
|
|
2806
|
+
// Fall back to the static default map, then the sanitized raw name.
|
|
2807
|
+
const ruleEventMap = (_e = (_c = this.pixels) === null || _c === void 0 ? void 0 : _c.meta) === null || _e === void 0 ? void 0 : _e.event_mappings;
|
|
2808
|
+
const metaEvent = (ruleEventMap === null || ruleEventMap === void 0 ? void 0 : ruleEventMap[eventName])
|
|
2809
|
+
|| metaEventMap[String(eventName).toLowerCase()]
|
|
2810
|
+
|| sanitizedEventName;
|
|
2811
|
+
// Pass the shared eventID so this Pixel event dedupes against the
|
|
2812
|
+
// server-side CAPI event carrying the same event_id.
|
|
2813
|
+
if (eventId) {
|
|
2814
|
+
window.fbq('track', metaEvent, sanitizedProperties, { eventID: eventId });
|
|
2815
|
+
}
|
|
2816
|
+
else {
|
|
2817
|
+
window.fbq('track', metaEvent, sanitizedProperties);
|
|
2818
|
+
}
|
|
2770
2819
|
}
|
|
2771
2820
|
catch (error) {
|
|
2772
2821
|
this.log('Error tracking Meta Pixel event:', error);
|
|
2773
2822
|
}
|
|
2774
2823
|
}
|
|
2775
2824
|
// Track to Google Tag
|
|
2776
|
-
if (((
|
|
2825
|
+
if (((_g = (_f = this.pixels) === null || _f === void 0 ? void 0 : _f.google) === null || _g === void 0 ? void 0 : _g.enabled) && window.gtag) {
|
|
2777
2826
|
try {
|
|
2778
2827
|
window.gtag('event', sanitizedEventName, sanitizedProperties);
|
|
2779
2828
|
}
|
|
@@ -2782,7 +2831,7 @@ class ContainerManager {
|
|
|
2782
2831
|
}
|
|
2783
2832
|
}
|
|
2784
2833
|
// Track to TikTok Pixel
|
|
2785
|
-
if (((
|
|
2834
|
+
if (((_j = (_h = this.pixels) === null || _h === void 0 ? void 0 : _h.tiktok) === null || _j === void 0 ? void 0 : _j.enabled) && window.ttq) {
|
|
2786
2835
|
try {
|
|
2787
2836
|
// Map common events to TikTok names
|
|
2788
2837
|
const tiktokEventMap = {
|
|
@@ -3490,6 +3539,15 @@ class Datalyr {
|
|
|
3490
3539
|
this.identify(email, { email });
|
|
3491
3540
|
});
|
|
3492
3541
|
}
|
|
3542
|
+
// Stamp attribution signals into the Shopify cart (OPT-IN, default off).
|
|
3543
|
+
// Lets server-side order webhooks recover the browser visitor + Meta click
|
|
3544
|
+
// signals (the postback webhook reads these as note_attributes). Inert unless
|
|
3545
|
+
// enabled; best-effort and never blocks init.
|
|
3546
|
+
if (this.config.shopifyCartAttributes === true) {
|
|
3547
|
+
this.syncShopifyCartAttributes().catch((error) => {
|
|
3548
|
+
this.log('Shopify cart attribute sync failed:', error);
|
|
3549
|
+
});
|
|
3550
|
+
}
|
|
3493
3551
|
// Track initial page view if enabled (AFTER encryption ready)
|
|
3494
3552
|
if (this.config.trackPageViews) {
|
|
3495
3553
|
this.page();
|
|
@@ -3531,13 +3589,19 @@ class Datalyr {
|
|
|
3531
3589
|
// PRIVACY: Heavy fingerprinting removed - using minimal fingerprinting only
|
|
3532
3590
|
// Update session activity
|
|
3533
3591
|
this.session.updateActivity(eventName);
|
|
3592
|
+
// Generate the event_id ONCE here so the same value is used for both the
|
|
3593
|
+
// ingested event (→ CAPI dedup key in the postback worker) and the browser
|
|
3594
|
+
// Meta Pixel co-fire below. Sharing it is what lets Meta dedupe the Pixel
|
|
3595
|
+
// event against the server-side CAPI event (dedup = event_id + event_name).
|
|
3596
|
+
const eventId = generateUUID();
|
|
3534
3597
|
// Create event payload
|
|
3535
|
-
const payload = this.createEventPayload(eventName, properties);
|
|
3598
|
+
const payload = this.createEventPayload(eventName, properties, eventId);
|
|
3536
3599
|
// Queue event
|
|
3537
3600
|
this.queue.enqueue(payload);
|
|
3538
|
-
// Track to third-party pixels if container is initialized
|
|
3601
|
+
// Track to third-party pixels if container is initialized.
|
|
3602
|
+
// Pass the shared eventId so the Meta Pixel fires with the same { eventID }.
|
|
3539
3603
|
if (this.container) {
|
|
3540
|
-
this.container.trackToPixels(eventName, properties);
|
|
3604
|
+
this.container.trackToPixels(eventName, properties, eventId);
|
|
3541
3605
|
}
|
|
3542
3606
|
// Call plugin handlers
|
|
3543
3607
|
if (this.config.plugins) {
|
|
@@ -3928,10 +3992,61 @@ class Datalyr {
|
|
|
3928
3992
|
getSuperProperties() {
|
|
3929
3993
|
return Object.assign({}, this.superProperties);
|
|
3930
3994
|
}
|
|
3995
|
+
/**
|
|
3996
|
+
* Stamp Datalyr attribution signals into the Shopify cart as cart attributes.
|
|
3997
|
+
* Cart attributes become `order.note_attributes` with the same names, which the
|
|
3998
|
+
* server-side order webhook reads to recover the browser visitor_id + Meta click
|
|
3999
|
+
* signals (_fbc/_fbp/fbclid) — enabling accurate Meta CAPI attribution for orders.
|
|
4000
|
+
*
|
|
4001
|
+
* Opt-in (config.shopifyCartAttributes), best-effort, runs once during init.
|
|
4002
|
+
* Merges via Shopify's /cart/update.js (does not clobber other cart attributes).
|
|
4003
|
+
*/
|
|
4004
|
+
syncShopifyCartAttributes() {
|
|
4005
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4006
|
+
if (typeof window === "undefined" || typeof document === "undefined")
|
|
4007
|
+
return;
|
|
4008
|
+
const isShopify = !!(window.Shopify ||
|
|
4009
|
+
document.querySelector('meta[name="shopify-checkout-api-token"]') ||
|
|
4010
|
+
window.location.hostname.includes(".myshopify.com"));
|
|
4011
|
+
if (!isShopify)
|
|
4012
|
+
return;
|
|
4013
|
+
const attribution = this.attribution.getAttributionData();
|
|
4014
|
+
const fbclid = attribution.clickIdType === "fbclid" ? attribution.clickId : null;
|
|
4015
|
+
// Cookies are freshest (the real Meta Pixel may have just written them);
|
|
4016
|
+
// fall back to whatever the SDK captured in attribution.
|
|
4017
|
+
const attributes = {};
|
|
4018
|
+
const visitorId = this.identity.getAnonymousId();
|
|
4019
|
+
const fbc = this.cookies.get("_fbc") || attribution._fbc;
|
|
4020
|
+
const fbp = this.cookies.get("_fbp") || attribution._fbp;
|
|
4021
|
+
if (visitorId)
|
|
4022
|
+
attributes._datalyr_visitor_id = visitorId;
|
|
4023
|
+
if (fbc)
|
|
4024
|
+
attributes._datalyr_fbc = String(fbc);
|
|
4025
|
+
if (fbp)
|
|
4026
|
+
attributes._datalyr_fbp = String(fbp);
|
|
4027
|
+
if (fbclid)
|
|
4028
|
+
attributes._datalyr_fbclid = String(fbclid);
|
|
4029
|
+
if (Object.keys(attributes).length === 0)
|
|
4030
|
+
return;
|
|
4031
|
+
try {
|
|
4032
|
+
yield fetch("/cart/update.js", {
|
|
4033
|
+
method: "POST",
|
|
4034
|
+
headers: { "Content-Type": "application/json" },
|
|
4035
|
+
credentials: "same-origin",
|
|
4036
|
+
body: JSON.stringify({ attributes }),
|
|
4037
|
+
});
|
|
4038
|
+
this.log("Shopify cart attributes stamped:", Object.keys(attributes));
|
|
4039
|
+
}
|
|
4040
|
+
catch (error) {
|
|
4041
|
+
// Never let cart sync affect tracking — swallow (e.g. no cart yet / CSP).
|
|
4042
|
+
this.log("Shopify /cart/update.js failed:", error);
|
|
4043
|
+
}
|
|
4044
|
+
});
|
|
4045
|
+
}
|
|
3931
4046
|
/**
|
|
3932
4047
|
* Create event payload
|
|
3933
4048
|
*/
|
|
3934
|
-
createEventPayload(eventName, properties) {
|
|
4049
|
+
createEventPayload(eventName, properties, eventIdArg) {
|
|
3935
4050
|
// Sanitize and merge properties
|
|
3936
4051
|
const sanitizedProperties = sanitizeEventData(properties);
|
|
3937
4052
|
const eventData = deepMerge({}, this.superProperties, sanitizedProperties);
|
|
@@ -3961,7 +4076,9 @@ class Datalyr {
|
|
|
3961
4076
|
});
|
|
3962
4077
|
// Create payload using snake_case only (matches backend API and production script)
|
|
3963
4078
|
const identityFields = this.identity.getIdentityFields();
|
|
3964
|
-
|
|
4079
|
+
// Use the caller-provided event_id (shared with the Meta Pixel co-fire for
|
|
4080
|
+
// dedup); fall back to a fresh UUID for any direct caller that omits it.
|
|
4081
|
+
const eventId = eventIdArg !== null && eventIdArg !== void 0 ? eventIdArg : generateUUID();
|
|
3965
4082
|
// Ensure we have all required identity fields
|
|
3966
4083
|
const distinctId = identityFields.distinct_id;
|
|
3967
4084
|
const anonymousId = identityFields.anonymous_id;
|
|
@@ -3985,8 +4102,8 @@ class Datalyr {
|
|
|
3985
4102
|
// Resolution metadata
|
|
3986
4103
|
resolution_method: 'browser_sdk',
|
|
3987
4104
|
resolution_confidence: 1.0,
|
|
3988
|
-
// SDK metadata
|
|
3989
|
-
sdk_version: '1.
|
|
4105
|
+
// SDK metadata (keep in sync with package.json version)
|
|
4106
|
+
sdk_version: '1.6.0',
|
|
3990
4107
|
sdk_name: 'datalyr-web-sdk'
|
|
3991
4108
|
};
|
|
3992
4109
|
return payload;
|
|
@@ -4206,5 +4323,6 @@ if (typeof window !== 'undefined') {
|
|
|
4206
4323
|
window.datalyr = datalyr;
|
|
4207
4324
|
}
|
|
4208
4325
|
|
|
4209
|
-
|
|
4326
|
+
exports.datalyr = datalyr;
|
|
4327
|
+
exports.default = datalyr;
|
|
4210
4328
|
//# sourceMappingURL=datalyr.cjs.js.map
|