shopkit-analytics 1.2.1 → 1.2.2
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/adapters/index.d.mts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +71 -25
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +2 -2
- package/dist/{chunk-ZTIVTB5J.mjs → chunk-5E7HVZ7Z.mjs} +2 -2
- package/dist/{chunk-UFDN3A6M.mjs → chunk-WPCXFATR.mjs} +15 -7
- package/dist/{chunk-UFDN3A6M.mjs.map → chunk-WPCXFATR.mjs.map} +1 -1
- package/dist/{chunk-YJE5NOFF.mjs → chunk-XGOJHFHL.mjs} +73 -27
- package/dist/chunk-XGOJHFHL.mjs.map +1 -0
- package/dist/events/index.js +71 -25
- package/dist/events/index.js.map +1 -1
- package/dist/events/index.mjs +3 -3
- package/dist/{index-fYvOG_to.d.mts → index-BJbaJQAQ.d.mts} +2 -0
- package/dist/{index-B-TnPt4F.d.ts → index-Dm7lrTiD.d.ts} +2 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +71 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +14 -6
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-YJE5NOFF.mjs.map +0 -1
- /package/dist/{chunk-ZTIVTB5J.mjs.map → chunk-5E7HVZ7Z.mjs.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BaseAdapter, c as GoogleAdapter, G as GoogleAdapterConfig, d as MoengageAdapter, a as MoengageAdapterConfig, b as MultiPixelAdapter, M as MultiPixelAdapterConfig, e as PostHogAdapter, P as PostHogAdapterConfig, f as ShopifyAdapter, S as ShopifyAdapterConfig } from '../index-
|
|
1
|
+
export { B as BaseAdapter, c as GoogleAdapter, G as GoogleAdapterConfig, d as MoengageAdapter, a as MoengageAdapterConfig, b as MultiPixelAdapter, M as MultiPixelAdapterConfig, e as PostHogAdapter, P as PostHogAdapterConfig, f as ShopifyAdapter, S as ShopifyAdapterConfig } from '../index-BJbaJQAQ.mjs';
|
|
2
2
|
import '../types.mjs';
|
|
3
3
|
import '../subscriber-90r_t90W.mjs';
|
|
4
4
|
import '../types-BBZbvq9-.mjs';
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BaseAdapter, c as GoogleAdapter, G as GoogleAdapterConfig, d as MoengageAdapter, a as MoengageAdapterConfig, b as MultiPixelAdapter, M as MultiPixelAdapterConfig, e as PostHogAdapter, P as PostHogAdapterConfig, f as ShopifyAdapter, S as ShopifyAdapterConfig } from '../index-
|
|
1
|
+
export { B as BaseAdapter, c as GoogleAdapter, G as GoogleAdapterConfig, d as MoengageAdapter, a as MoengageAdapterConfig, b as MultiPixelAdapter, M as MultiPixelAdapterConfig, e as PostHogAdapter, P as PostHogAdapterConfig, f as ShopifyAdapter, S as ShopifyAdapterConfig } from '../index-Dm7lrTiD.js';
|
|
2
2
|
import '../types.js';
|
|
3
3
|
import '../subscriber-AtiHiP3i.js';
|
|
4
4
|
import '../types-BBZbvq9-.js';
|
package/dist/adapters/index.js
CHANGED
|
@@ -398,6 +398,39 @@ var SKIP_GOKWIK_EVENT = [
|
|
|
398
398
|
"purchase" /* PURCHASE */
|
|
399
399
|
];
|
|
400
400
|
|
|
401
|
+
// src/utils/pii-hashing.ts
|
|
402
|
+
async function hashString(value, normalize) {
|
|
403
|
+
if (!value) {
|
|
404
|
+
return void 0;
|
|
405
|
+
}
|
|
406
|
+
try {
|
|
407
|
+
const normalizedValue = normalize ? normalize(value) : value;
|
|
408
|
+
if (typeof crypto !== "undefined" && crypto.subtle) {
|
|
409
|
+
const encoder = new TextEncoder();
|
|
410
|
+
const data = encoder.encode(normalizedValue);
|
|
411
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
412
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
413
|
+
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
414
|
+
return hashHex;
|
|
415
|
+
}
|
|
416
|
+
} catch (error) {
|
|
417
|
+
console.error("Error hashing with SHA-256:", error);
|
|
418
|
+
}
|
|
419
|
+
return fallbackHash(value);
|
|
420
|
+
}
|
|
421
|
+
function fallbackHash(value) {
|
|
422
|
+
let hash = 0;
|
|
423
|
+
if (value.length === 0) {
|
|
424
|
+
return "0";
|
|
425
|
+
}
|
|
426
|
+
for (let i = 0; i < value.length; i++) {
|
|
427
|
+
const char = value.charCodeAt(i);
|
|
428
|
+
hash = (hash << 5) - hash + char;
|
|
429
|
+
hash = hash & hash;
|
|
430
|
+
}
|
|
431
|
+
return Math.abs(hash).toString(16).padStart(16, "0");
|
|
432
|
+
}
|
|
433
|
+
|
|
401
434
|
// src/adapters/multi-pixel-adapter.ts
|
|
402
435
|
var MultiPixelAdapter = class extends BaseAdapter {
|
|
403
436
|
constructor(config) {
|
|
@@ -462,10 +495,12 @@ var MultiPixelAdapter = class extends BaseAdapter {
|
|
|
462
495
|
if (this.shouldSkipEvent(event.type)) {
|
|
463
496
|
return;
|
|
464
497
|
}
|
|
498
|
+
const timestamp = Date.now();
|
|
465
499
|
const transformEvent = {
|
|
466
500
|
...event,
|
|
467
501
|
eventId: event.eventId || generateEventId(event.type),
|
|
468
|
-
timestamp:
|
|
502
|
+
timestamp: event.timestamp || timestamp,
|
|
503
|
+
event_source_url: event.event_source_url || !(typeof window === "undefined") ? window.location.href : ""
|
|
469
504
|
};
|
|
470
505
|
await this.trackClientSide(transformEvent, adapterParams);
|
|
471
506
|
if (this.pixels.some((pixel) => pixel.config.enableCAPI)) {
|
|
@@ -494,9 +529,12 @@ var MultiPixelAdapter = class extends BaseAdapter {
|
|
|
494
529
|
if (!eventName) {
|
|
495
530
|
return;
|
|
496
531
|
}
|
|
532
|
+
const browserInfo = getBrowserInfo();
|
|
497
533
|
try {
|
|
498
534
|
window.fbq("track", eventName, enhancedParams, {
|
|
499
|
-
eventID: event.eventId
|
|
535
|
+
eventID: event.eventId,
|
|
536
|
+
fbc: browserInfo.fbc,
|
|
537
|
+
fbp: browserInfo.fbp
|
|
500
538
|
});
|
|
501
539
|
} catch (error) {
|
|
502
540
|
console.error("Facebook Pixel tracking error:", error);
|
|
@@ -546,55 +584,58 @@ var MultiPixelAdapter = class extends BaseAdapter {
|
|
|
546
584
|
let baseParams = {};
|
|
547
585
|
let eventName = "";
|
|
548
586
|
switch (event.type) {
|
|
549
|
-
case "page_view" /* PAGE_VIEW */:
|
|
587
|
+
case "page_view" /* PAGE_VIEW */: {
|
|
550
588
|
const pageViewEvent = event;
|
|
551
589
|
eventName = this.getEventName(adapterParams, "PageView");
|
|
552
590
|
baseParams = {
|
|
553
|
-
|
|
554
|
-
content_category: pageViewEvent.event_category,
|
|
555
|
-
page_location: pageViewEvent.page_location || pageViewEvent.path,
|
|
556
|
-
page_title: pageViewEvent.page_title || pageViewEvent.title,
|
|
557
|
-
page_referrer: pageViewEvent.page_referrer || pageViewEvent.referrer,
|
|
558
|
-
page_path: pageViewEvent.page_path || pageViewEvent.path
|
|
591
|
+
event_source_url: pageViewEvent.event_source_url
|
|
559
592
|
};
|
|
560
593
|
break;
|
|
561
|
-
|
|
594
|
+
}
|
|
595
|
+
case "view_content" /* VIEW_CONTENT */: {
|
|
562
596
|
const viewContentEvent = event;
|
|
563
597
|
eventName = this.getEventName(adapterParams, "ViewContent");
|
|
564
598
|
baseParams = {
|
|
599
|
+
event_source_url: viewContentEvent.event_source_url,
|
|
565
600
|
content_type: viewContentEvent.content_type || "product",
|
|
566
601
|
content_ids: viewContentEvent.content_ids || [],
|
|
567
|
-
content_name: viewContentEvent.content_name
|
|
568
|
-
content_category: viewContentEvent.content_category || "",
|
|
602
|
+
content_name: viewContentEvent.content_name,
|
|
603
|
+
content_category: viewContentEvent.content_category || "product",
|
|
569
604
|
value: viewContentEvent.value || 0,
|
|
570
605
|
currency: viewContentEvent.currency || "INR"
|
|
571
606
|
};
|
|
572
607
|
break;
|
|
573
|
-
|
|
608
|
+
}
|
|
609
|
+
case "add_to_cart" /* ADD_TO_CART */: {
|
|
574
610
|
const cartEvent = event;
|
|
575
611
|
eventName = this.getEventName(adapterParams, "AddToCart");
|
|
576
612
|
baseParams = {
|
|
577
|
-
|
|
613
|
+
event_source_url: cartEvent.event_source_url,
|
|
614
|
+
content_type: cartEvent.content_type || "product",
|
|
578
615
|
content_ids: [cartEvent.productId],
|
|
579
616
|
content_name: cartEvent.productName,
|
|
580
617
|
value: cartEvent.price,
|
|
581
618
|
currency: cartEvent.currency || "INR"
|
|
582
619
|
};
|
|
583
620
|
break;
|
|
584
|
-
|
|
621
|
+
}
|
|
622
|
+
case "search" /* SEARCH */: {
|
|
585
623
|
const searchEvent = event;
|
|
586
624
|
eventName = this.getEventName(adapterParams, "Search");
|
|
587
625
|
baseParams = {
|
|
626
|
+
event_source_url: searchEvent.event_source_url,
|
|
588
627
|
search_string: searchEvent.searchTerm,
|
|
589
628
|
content_category: "product",
|
|
590
629
|
content_ids: searchEvent.content_ids || []
|
|
591
630
|
};
|
|
592
631
|
break;
|
|
593
|
-
|
|
632
|
+
}
|
|
633
|
+
case "initiate_checkout" /* INITIATE_CHECKOUT */: {
|
|
594
634
|
const checkoutEvent = event;
|
|
595
635
|
eventName = this.getEventName(adapterParams, "InitiateCheckout");
|
|
596
636
|
baseParams = {
|
|
597
|
-
|
|
637
|
+
event_source_url: checkoutEvent.event_source_url,
|
|
638
|
+
content_type: checkoutEvent.content_type || "product",
|
|
598
639
|
currency: checkoutEvent.currency || "INR",
|
|
599
640
|
value: checkoutEvent.cartValue,
|
|
600
641
|
num_items: checkoutEvent.itemCount || checkoutEvent.items?.length || 0,
|
|
@@ -605,25 +646,30 @@ var MultiPixelAdapter = class extends BaseAdapter {
|
|
|
605
646
|
})) || []
|
|
606
647
|
};
|
|
607
648
|
break;
|
|
608
|
-
|
|
649
|
+
}
|
|
650
|
+
case "purchase" /* PURCHASE */: {
|
|
609
651
|
const purchaseEvent = event;
|
|
610
652
|
eventName = this.getEventName(adapterParams, "Purchase");
|
|
611
653
|
baseParams = {
|
|
654
|
+
event_source_url: purchaseEvent.event_source_url,
|
|
612
655
|
content_type: purchaseEvent.content_type || "product",
|
|
613
|
-
|
|
656
|
+
contents: purchaseEvent.contents || [],
|
|
614
657
|
currency: purchaseEvent.currency || "INR",
|
|
615
|
-
value: purchaseEvent.value,
|
|
616
658
|
num_items: purchaseEvent.num_items || purchaseEvent.contents?.length || 0,
|
|
617
|
-
|
|
659
|
+
value: purchaseEvent.value,
|
|
660
|
+
order_id: purchaseEvent.order_id,
|
|
661
|
+
city: hashString(purchaseEvent.city),
|
|
662
|
+
postal_code: hashString(purchaseEvent.postal_code),
|
|
663
|
+
surname: hashString(purchaseEvent.surname)
|
|
618
664
|
};
|
|
619
665
|
break;
|
|
620
|
-
|
|
666
|
+
}
|
|
667
|
+
default: {
|
|
621
668
|
this.logger.warn(`Skipping unknown event type: ${event.type}`);
|
|
622
669
|
return { eventName: "", enhancedParams: {} };
|
|
670
|
+
}
|
|
623
671
|
}
|
|
624
|
-
const
|
|
625
|
-
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
626
|
-
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
672
|
+
const enhancedParams = this.mergeEventData(baseParams, adapterParams);
|
|
627
673
|
return { eventName, enhancedParams };
|
|
628
674
|
}
|
|
629
675
|
/**
|