@azzas/azzas-tracker-web 2.0.0-preview.5 → 2.0.0-preview.7
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/mod.cjs +229 -224
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.d.cts +28 -21
- package/dist/mod.d.ts +28 -21
- package/dist/mod.global.js +228 -224
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +228 -224
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +266 -255
- package/package.json +1 -1
package/dist/mod.vtex.global.js
CHANGED
|
@@ -1350,7 +1350,7 @@ var AzzasTracker = function() {
|
|
|
1350
1350
|
});
|
|
1351
1351
|
return (selectedSla === null || selectedSla === void 0 ? void 0 : (_selectedSla_pickupStoreInfo = selectedSla.pickupStoreInfo) === null || _selectedSla_pickupStoreInfo === void 0 ? void 0 : _selectedSla_pickupStoreInfo.friendlyName) ? "retirada em loja: ".concat(selectedSla.pickupStoreInfo.friendlyName) : (selectedSla === null || selectedSla === void 0 ? void 0 : selectedSla.name) ? "Receba em casa: ".concat(selectedSla.name) : null;
|
|
1352
1352
|
};
|
|
1353
|
-
var getParameters = function getParameters(context, eventName) {
|
|
1353
|
+
var getParameters = function getParameters(context, eventName, config2) {
|
|
1354
1354
|
return _async_to_generator(function() {
|
|
1355
1355
|
var _adapters_currentAdapter, eventConfig, currentAdapter, getters, entries;
|
|
1356
1356
|
return _ts_generator(this, function(_state) {
|
|
@@ -1386,7 +1386,7 @@ var AzzasTracker = function() {
|
|
|
1386
1386
|
];
|
|
1387
1387
|
return [
|
|
1388
1388
|
4,
|
|
1389
|
-
getter(context,
|
|
1389
|
+
getter(context, config2)
|
|
1390
1390
|
];
|
|
1391
1391
|
case 1:
|
|
1392
1392
|
return [
|
|
@@ -1410,8 +1410,10 @@ var AzzasTracker = function() {
|
|
|
1410
1410
|
});
|
|
1411
1411
|
})();
|
|
1412
1412
|
};
|
|
1413
|
-
var
|
|
1414
|
-
|
|
1413
|
+
var initTracker = function initTracker(c) {
|
|
1414
|
+
config = c;
|
|
1415
|
+
};
|
|
1416
|
+
var trackWebEvent = function trackWebEvent(event, context) {
|
|
1415
1417
|
return _async_to_generator(function() {
|
|
1416
1418
|
var parameters, err;
|
|
1417
1419
|
return _ts_generator(this, function(_state) {
|
|
@@ -1425,7 +1427,7 @@ var AzzasTracker = function() {
|
|
|
1425
1427
|
]);
|
|
1426
1428
|
return [
|
|
1427
1429
|
4,
|
|
1428
|
-
getParameters(context, event)
|
|
1430
|
+
getParameters(context, event, config)
|
|
1429
1431
|
];
|
|
1430
1432
|
case 1:
|
|
1431
1433
|
parameters = _state.sent();
|
|
@@ -1515,6 +1517,9 @@ var AzzasTracker = function() {
|
|
|
1515
1517
|
default: function() {
|
|
1516
1518
|
return src_default;
|
|
1517
1519
|
},
|
|
1520
|
+
initTracker: function() {
|
|
1521
|
+
return initTracker;
|
|
1522
|
+
},
|
|
1518
1523
|
trackWebEvent: function() {
|
|
1519
1524
|
return trackWebEvent;
|
|
1520
1525
|
}
|
|
@@ -2434,9 +2439,6 @@ var AzzasTracker = function() {
|
|
|
2434
2439
|
// src/params/adapters/meta/index.ts
|
|
2435
2440
|
var metaAdapters = {
|
|
2436
2441
|
user_info: getUserInfo,
|
|
2437
|
-
// brand: (context: MetaBrandContext) => {
|
|
2438
|
-
// return context.meta.brand || null;
|
|
2439
|
-
// },
|
|
2440
2442
|
content_type: function(context) {
|
|
2441
2443
|
return context.meta.content_type || null;
|
|
2442
2444
|
},
|
|
@@ -2446,8 +2448,8 @@ var AzzasTracker = function() {
|
|
|
2446
2448
|
pre_filled: function(context) {
|
|
2447
2449
|
return !!context.preFilled;
|
|
2448
2450
|
},
|
|
2449
|
-
currency: function(
|
|
2450
|
-
if (
|
|
2451
|
+
currency: function(_, config2) {
|
|
2452
|
+
if (config2 === null || config2 === void 0 ? void 0 : config2.currency) return config2.currency;
|
|
2451
2453
|
return "BRL";
|
|
2452
2454
|
},
|
|
2453
2455
|
slot_per_line: function(context) {
|
|
@@ -2566,7 +2568,8 @@ var AzzasTracker = function() {
|
|
|
2566
2568
|
}
|
|
2567
2569
|
return null;
|
|
2568
2570
|
},
|
|
2569
|
-
brand: function(context) {
|
|
2571
|
+
brand: function(context, config2) {
|
|
2572
|
+
if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
|
|
2570
2573
|
if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
|
|
2571
2574
|
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2572
2575
|
return normalizeBrand2(context.products.map(function(p) {
|
|
@@ -2625,237 +2628,8 @@ var AzzasTracker = function() {
|
|
|
2625
2628
|
return null;
|
|
2626
2629
|
}
|
|
2627
2630
|
});
|
|
2628
|
-
// src/params/adapters/orderForm/utils.ts
|
|
2629
|
-
var getItemCategory5 = function(item) {
|
|
2630
|
-
var _text_match;
|
|
2631
|
-
var categories = item === null || item === void 0 ? void 0 : item.productCategories;
|
|
2632
|
-
if (!categories) return "Cole\xE7\xE3o";
|
|
2633
|
-
var text = Object.values(categories).join(" ");
|
|
2634
|
-
var match = (_text_match = text.match(/outlet|bazar|sale/i)) === null || _text_match === void 0 ? void 0 : _text_match[0].toLowerCase();
|
|
2635
|
-
return match !== null && match !== void 0 ? match : "Cole\xE7\xE3o";
|
|
2636
|
-
};
|
|
2637
|
-
var getItemCategory23 = function(item) {
|
|
2638
|
-
var _ref, _validHierarchy_;
|
|
2639
|
-
var AVOID_CATEGORIES = /outlet|bazar|sale/i;
|
|
2640
|
-
var categories = Object.values((_ref = item === null || item === void 0 ? void 0 : item.productCategories) !== null && _ref !== void 0 ? _ref : {});
|
|
2641
|
-
var validHierarchy = categories.map(function(c) {
|
|
2642
|
-
return c.trim();
|
|
2643
|
-
}).filter(function(c) {
|
|
2644
|
-
return c && !AVOID_CATEGORIES.test(c);
|
|
2645
|
-
});
|
|
2646
|
-
var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
|
|
2647
|
-
return capitalize(deepest);
|
|
2648
|
-
};
|
|
2649
|
-
var getOrderFormItems = function(orderForm) {
|
|
2650
|
-
var idSelected = orderForm === null || orderForm === void 0 ? void 0 : orderForm.selected;
|
|
2651
|
-
return idSelected ? orderForm.items.filter(function(item) {
|
|
2652
|
-
return item.id === idSelected;
|
|
2653
|
-
}) : orderForm.items;
|
|
2654
|
-
};
|
|
2655
|
-
// src/params/adapters/orderForm/index.ts
|
|
2656
|
-
var orderFormAdapter = _object_spread_props(_object_spread({}, metaAdapters), {
|
|
2657
|
-
items: function(context) {
|
|
2658
|
-
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2659
|
-
if ((context === null || context === void 0 ? void 0 : context.orderForm) && (context === null || context === void 0 ? void 0 : context.orderForm.items)) {
|
|
2660
|
-
return getOrderFormItems(context.orderForm).map(function(item, index) {
|
|
2661
|
-
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _getItemCategory5, _getItemCategory23, _ref7, _ref8, _item_detailUrl, _resizeVtexImage2, _ref9, _ref10;
|
|
2662
|
-
var _context_orderForm, _item_additionalInfo, _item_skuName_split__split_pop, _item_skuName_split_, _item_skuName, _item_skuName_split_1, _item_skuName1, _context_orderForm1;
|
|
2663
|
-
return {
|
|
2664
|
-
quantity: (_ref = item === null || item === void 0 ? void 0 : item.quantity) !== null && _ref !== void 0 ? _ref : 1,
|
|
2665
|
-
index: (_ref1 = (_ref2 = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.index) !== null && _ref2 !== void 0 ? _ref2 : index) !== null && _ref1 !== void 0 ? _ref1 : null,
|
|
2666
|
-
item_brand: (_ref3 = (_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
2667
|
-
item_name: (_ref4 = item === null || item === void 0 ? void 0 : item.name.replace(item === null || item === void 0 ? void 0 : item.skuName, "").trim()) !== null && _ref4 !== void 0 ? _ref4 : null,
|
|
2668
|
-
price: (item === null || item === void 0 ? void 0 : item.price) / 100,
|
|
2669
|
-
discount: ((item === null || item === void 0 ? void 0 : item.listPrice) - (item === null || item === void 0 ? void 0 : item.sellingPrice)) / 100,
|
|
2670
|
-
item_variant: (_ref5 = item === null || item === void 0 ? void 0 : (_item_skuName = item.skuName) === null || _item_skuName === void 0 ? void 0 : (_item_skuName_split_ = _item_skuName.split(" - ")[0]) === null || _item_skuName_split_ === void 0 ? void 0 : (_item_skuName_split__split_pop = _item_skuName_split_.split("_").pop()) === null || _item_skuName_split__split_pop === void 0 ? void 0 : _item_skuName_split__split_pop.trim()) !== null && _ref5 !== void 0 ? _ref5 : null,
|
|
2671
|
-
item_variant2: (_ref6 = item === null || item === void 0 ? void 0 : (_item_skuName1 = item.skuName) === null || _item_skuName1 === void 0 ? void 0 : (_item_skuName_split_1 = _item_skuName1.split(" - ")[1]) === null || _item_skuName_split_1 === void 0 ? void 0 : _item_skuName_split_1.trim()) !== null && _ref6 !== void 0 ? _ref6 : null,
|
|
2672
|
-
item_shipping_tier: getItemShippingTier2(context.orderForm, item),
|
|
2673
|
-
item_ref: (item === null || item === void 0 ? void 0 : item.productRefId) || (item === null || item === void 0 ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
|
|
2674
|
-
item_category: (_getItemCategory5 = getItemCategory5(item)) !== null && _getItemCategory5 !== void 0 ? _getItemCategory5 : null,
|
|
2675
|
-
item_category2: (_getItemCategory23 = getItemCategory23(item)) !== null && _getItemCategory23 !== void 0 ? _getItemCategory23 : null,
|
|
2676
|
-
item_id: (_ref7 = item === null || item === void 0 ? void 0 : item.productId) !== null && _ref7 !== void 0 ? _ref7 : null,
|
|
2677
|
-
item_sku: (_ref8 = item === null || item === void 0 ? void 0 : item.id) !== null && _ref8 !== void 0 ? _ref8 : null,
|
|
2678
|
-
item_url: (_item_detailUrl = item.detailUrl) !== null && _item_detailUrl !== void 0 ? _item_detailUrl : null,
|
|
2679
|
-
image_url: (_resizeVtexImage2 = resizeVtexImage2(item.imageUrl)) !== null && _resizeVtexImage2 !== void 0 ? _resizeVtexImage2 : null,
|
|
2680
|
-
seller_id: (_ref9 = item === null || item === void 0 ? void 0 : item.seller) !== null && _ref9 !== void 0 ? _ref9 : null,
|
|
2681
|
-
item_list_name: (_ref10 = context === null || context === void 0 ? void 0 : (_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.item_list_name) !== null && _ref10 !== void 0 ? _ref10 : null
|
|
2682
|
-
};
|
|
2683
|
-
});
|
|
2684
|
-
}
|
|
2685
|
-
return null;
|
|
2686
|
-
},
|
|
2687
|
-
brand: function(context) {
|
|
2688
|
-
var _context_orderForm;
|
|
2689
|
-
if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
|
|
2690
|
-
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2691
|
-
var brands = getOrderFormItems(context.orderForm).map(function(item) {
|
|
2692
|
-
return item.additionalInfo.brandName;
|
|
2693
|
-
});
|
|
2694
|
-
return normalizeBrand2(brands);
|
|
2695
|
-
},
|
|
2696
|
-
line_items: function(context) {
|
|
2697
|
-
var _context_orderForm;
|
|
2698
|
-
if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
|
|
2699
|
-
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2700
|
-
return getOrderFormItems(context.orderForm).map(function(item) {
|
|
2701
|
-
return item === null || item === void 0 ? void 0 : item.productId;
|
|
2702
|
-
}).filter(function(id) {
|
|
2703
|
-
return Boolean(id);
|
|
2704
|
-
});
|
|
2705
|
-
},
|
|
2706
|
-
value: function(context) {
|
|
2707
|
-
var _context_orderForm;
|
|
2708
|
-
if (context === null || context === void 0 ? void 0 : context.value) return context.value;
|
|
2709
|
-
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2710
|
-
return getOrderFormItems(context.orderForm).map(function(item) {
|
|
2711
|
-
return (item === null || item === void 0 ? void 0 : item.price) / 100 * item.quantity;
|
|
2712
|
-
}).filter(function(price) {
|
|
2713
|
-
return price !== void 0;
|
|
2714
|
-
}).reduce(function(sum, price) {
|
|
2715
|
-
return sum + price;
|
|
2716
|
-
}, 0);
|
|
2717
|
-
},
|
|
2718
|
-
payment_type: getPaymentType,
|
|
2719
|
-
total_discount: function(context) {
|
|
2720
|
-
var _context_orderForm, _context_orderForm1;
|
|
2721
|
-
if (context === null || context === void 0 ? void 0 : context.total_discount) return context.total_discount;
|
|
2722
|
-
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2723
|
-
var totalsList = ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totalizers) || [];
|
|
2724
|
-
var totalDiscount = getOrderFormItems(context.orderForm).reduce(function(acc, item) {
|
|
2725
|
-
var unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
|
|
2726
|
-
return acc + unitDiscount * item.quantity;
|
|
2727
|
-
}, 0);
|
|
2728
|
-
var discounts = totalsList.find(function(t) {
|
|
2729
|
-
return t.id === "Discounts";
|
|
2730
|
-
});
|
|
2731
|
-
return Math.abs(((discounts === null || discounts === void 0 ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
|
|
2732
|
-
},
|
|
2733
|
-
subtotal: function(context) {
|
|
2734
|
-
var _context_orderForm, _context_orderForm1;
|
|
2735
|
-
var totalsList = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.totalizers) || ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totals) || [];
|
|
2736
|
-
var subtotal = totalsList.filter(function(t) {
|
|
2737
|
-
return t.id === "Items";
|
|
2738
|
-
}).reduce(function(acc, t) {
|
|
2739
|
-
return acc + (t.value || 0);
|
|
2740
|
-
}, 0) / 100 || 0;
|
|
2741
|
-
return subtotal;
|
|
2742
|
-
},
|
|
2743
|
-
coupon_message: function(context) {
|
|
2744
|
-
var _context_orderForm;
|
|
2745
|
-
if (context.couponMessage) return context.couponMessage;
|
|
2746
|
-
var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
|
|
2747
|
-
if (messages.length === 0) return null;
|
|
2748
|
-
var couponMessages = messages.filter(function(msg) {
|
|
2749
|
-
return msg.text.toLowerCase().includes("cupom");
|
|
2750
|
-
});
|
|
2751
|
-
if (couponMessages.length === 0) return null;
|
|
2752
|
-
return couponMessages.map(function(msg) {
|
|
2753
|
-
return msg.text;
|
|
2754
|
-
}).join(" | ");
|
|
2755
|
-
},
|
|
2756
|
-
zipcode: function(context) {
|
|
2757
|
-
var _context_zipcode;
|
|
2758
|
-
return (_context_zipcode = context.zipcode) !== null && _context_zipcode !== void 0 ? _context_zipcode : null;
|
|
2759
|
-
},
|
|
2760
|
-
flag_pickup: function(context) {
|
|
2761
|
-
var _orderForm_shippingData;
|
|
2762
|
-
var orderForm = context.orderForm;
|
|
2763
|
-
if (!orderForm) return null;
|
|
2764
|
-
var logisticsInfo = ((_orderForm_shippingData = orderForm.shippingData) === null || _orderForm_shippingData === void 0 ? void 0 : _orderForm_shippingData.logisticsInfo) || [];
|
|
2765
|
-
var hasPickup = logisticsInfo.some(function(info) {
|
|
2766
|
-
var _info_slas;
|
|
2767
|
-
return (_info_slas = info.slas) === null || _info_slas === void 0 ? void 0 : _info_slas.some(function(sla) {
|
|
2768
|
-
return sla.deliveryChannel === "pickup-in-point";
|
|
2769
|
-
});
|
|
2770
|
-
});
|
|
2771
|
-
return hasPickup;
|
|
2772
|
-
},
|
|
2773
|
-
shippings: function(context) {
|
|
2774
|
-
if (!context.orderForm) return null;
|
|
2775
|
-
var _context_orderForm = context.orderForm, items = _context_orderForm.items, shippingData = _context_orderForm.shippingData;
|
|
2776
|
-
var acc = {};
|
|
2777
|
-
shippingData.logisticsInfo.forEach(function(param) {
|
|
2778
|
-
var itemIndex = param.itemIndex, slas = param.slas;
|
|
2779
|
-
var item = items[itemIndex];
|
|
2780
|
-
if (!item) return;
|
|
2781
|
-
slas.forEach(function(sla) {
|
|
2782
|
-
if (!acc[sla.name]) acc[sla.name] = {
|
|
2783
|
-
shipping_tier: sla.name,
|
|
2784
|
-
delivery_time: parseInt(sla.shippingEstimate),
|
|
2785
|
-
shipping: parseFloat((sla.price / 100).toFixed(1)),
|
|
2786
|
-
line_items: []
|
|
2787
|
-
};
|
|
2788
|
-
acc[sla.name].line_items.push(item.id);
|
|
2789
|
-
});
|
|
2790
|
-
});
|
|
2791
|
-
return Object.values(acc).map(function(s) {
|
|
2792
|
-
return _object_spread_props(_object_spread({}, s), {
|
|
2793
|
-
line_items: s.line_items.join(",")
|
|
2794
|
-
});
|
|
2795
|
-
});
|
|
2796
|
-
},
|
|
2797
|
-
shipping: function(context) {
|
|
2798
|
-
var _ref;
|
|
2799
|
-
var _context_orderForm_shippingData, _context_orderForm;
|
|
2800
|
-
var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
|
|
2801
|
-
return logistics.reduce(function(total, item) {
|
|
2802
|
-
var _ref;
|
|
2803
|
-
var _item_slas;
|
|
2804
|
-
var selected = (_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
2805
|
-
return sla.id === item.selectedSla;
|
|
2806
|
-
});
|
|
2807
|
-
return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
|
|
2808
|
-
}, 0);
|
|
2809
|
-
},
|
|
2810
|
-
shipping_tier: function(context) {
|
|
2811
|
-
var _ref;
|
|
2812
|
-
var _context_orderForm_shippingData, _context_orderForm;
|
|
2813
|
-
var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
|
|
2814
|
-
var selectedSlas = logistics.map(function(item) {
|
|
2815
|
-
var _item_slas;
|
|
2816
|
-
if (!item.selectedSla) return null;
|
|
2817
|
-
return ((_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
2818
|
-
return sla.id === item.selectedSla;
|
|
2819
|
-
})) || null;
|
|
2820
|
-
}).filter(Boolean);
|
|
2821
|
-
if (selectedSlas.length === 0) return null;
|
|
2822
|
-
var uniqueTiers = Array.from(new Map(selectedSlas.map(function(sla) {
|
|
2823
|
-
var _sla_pickupStoreInfo;
|
|
2824
|
-
var key = sla.deliveryChannel === "pickup-in-point" ? "pickup:".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) || sla.name || "") : "delivery:".concat(sla.name || "");
|
|
2825
|
-
return [
|
|
2826
|
-
key,
|
|
2827
|
-
sla
|
|
2828
|
-
];
|
|
2829
|
-
})).values());
|
|
2830
|
-
var sortedTiers = uniqueTiers.sort(function(a, b) {
|
|
2831
|
-
var _a_pickupStoreInfo, _b_pickupStoreInfo;
|
|
2832
|
-
var aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
2833
|
-
var bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
2834
|
-
if (aOrder !== bOrder) return aOrder - bOrder;
|
|
2835
|
-
var aLabel = a.deliveryChannel === "pickup-in-point" ? ((_a_pickupStoreInfo = a.pickupStoreInfo) === null || _a_pickupStoreInfo === void 0 ? void 0 : _a_pickupStoreInfo.friendlyName) || a.name || "" : a.name || "";
|
|
2836
|
-
var bLabel = b.deliveryChannel === "pickup-in-point" ? ((_b_pickupStoreInfo = b.pickupStoreInfo) === null || _b_pickupStoreInfo === void 0 ? void 0 : _b_pickupStoreInfo.friendlyName) || b.name || "" : b.name || "";
|
|
2837
|
-
return aLabel.localeCompare(bLabel, "pt-BR");
|
|
2838
|
-
});
|
|
2839
|
-
var shippingTier = sortedTiers.map(function(sla) {
|
|
2840
|
-
var _sla_pickupStoreInfo;
|
|
2841
|
-
return sla.deliveryChannel === "pickup-in-point" ? "retirada em loja".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) ? ": ".concat(sla.pickupStoreInfo.friendlyName) : "") : sla.deliveryChannel === "delivery" ? "receba em casa".concat(sla.name ? ": ".concat(sla.name) : "") : null;
|
|
2842
|
-
}).filter(Boolean).join(", ");
|
|
2843
|
-
return shippingTier || null;
|
|
2844
|
-
},
|
|
2845
|
-
transaction_id: function(context) {
|
|
2846
|
-
var _context_orderForm_orderGroup, _context_orderForm;
|
|
2847
|
-
return ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_orderGroup = _context_orderForm.orderGroup) === null || _context_orderForm_orderGroup === void 0 ? void 0 : _context_orderForm_orderGroup.toString()) || null;
|
|
2848
|
-
},
|
|
2849
|
-
coupon: function(context) {
|
|
2850
|
-
var _context_orderForm_marketingData, _context_orderForm;
|
|
2851
|
-
return context.appliedCoupon || (context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_marketingData = _context_orderForm.marketingData) === null || _context_orderForm_marketingData === void 0 ? void 0 : _context_orderForm_marketingData.coupon) || null;
|
|
2852
|
-
},
|
|
2853
|
-
seller_cod_name: function(context) {
|
|
2854
|
-
return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
|
|
2855
|
-
}
|
|
2856
|
-
});
|
|
2857
2631
|
// src/params/adapters/headless/utils.ts
|
|
2858
|
-
var
|
|
2632
|
+
var getItemCategory5 = function(item) {
|
|
2859
2633
|
var keywords = [
|
|
2860
2634
|
"outlet",
|
|
2861
2635
|
"bazar",
|
|
@@ -2872,7 +2646,7 @@ var AzzasTracker = function() {
|
|
|
2872
2646
|
}
|
|
2873
2647
|
return "Cole\xE7\xE3o";
|
|
2874
2648
|
};
|
|
2875
|
-
var
|
|
2649
|
+
var getItemCategory23 = function(item) {
|
|
2876
2650
|
var _ref, _reverse_find;
|
|
2877
2651
|
var _item_categories;
|
|
2878
2652
|
var avoidList = /outlet|bazar|sale/i;
|
|
@@ -2889,7 +2663,7 @@ var AzzasTracker = function() {
|
|
|
2889
2663
|
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2890
2664
|
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2891
2665
|
return context.products.map(function(item) {
|
|
2892
|
-
var _ref, _item_brand, _item_productName, _ref1, _ref2, _item_productReference,
|
|
2666
|
+
var _ref, _item_brand, _item_productName, _ref1, _ref2, _item_productReference, _getItemCategory23, _ref3, _ref4, _item_link, _resizeVtexImage2, _ref5, _item_item_list_name;
|
|
2893
2667
|
var _item_items__sellers, _item_items__sellers1, _item_items__name, _item_items_, _item_items__name1, _item_items_1, _item_items, _item_items__images, _item_items1, _item_items__sellers2, _item_items_2, _item_items2;
|
|
2894
2668
|
var listPrice = item === null || item === void 0 ? void 0 : (_item_items__sellers = item.items[0].sellers) === null || _item_items__sellers === void 0 ? void 0 : _item_items__sellers[0].commertialOffer.ListPrice;
|
|
2895
2669
|
var price = item === null || item === void 0 ? void 0 : (_item_items__sellers1 = item.items[0].sellers) === null || _item_items__sellers1 === void 0 ? void 0 : _item_items__sellers1[0].commertialOffer.Price;
|
|
@@ -2905,8 +2679,8 @@ var AzzasTracker = function() {
|
|
|
2905
2679
|
item_variant2: (_ref2 = (_item_items_1 = item.items[0]) === null || _item_items_1 === void 0 ? void 0 : (_item_items__name1 = _item_items_1.name) === null || _item_items__name1 === void 0 ? void 0 : _item_items__name1.split(" - ")[1]) !== null && _ref2 !== void 0 ? _ref2 : null,
|
|
2906
2680
|
item_ref: (_item_productReference = item.productReference) !== null && _item_productReference !== void 0 ? _item_productReference : null,
|
|
2907
2681
|
// sem ref no retorno do IS na multi-lib produtos PDC
|
|
2908
|
-
item_category:
|
|
2909
|
-
item_category2: (
|
|
2682
|
+
item_category: getItemCategory5(item),
|
|
2683
|
+
item_category2: (_getItemCategory23 = getItemCategory23(item)) !== null && _getItemCategory23 !== void 0 ? _getItemCategory23 : null,
|
|
2910
2684
|
item_id: (_ref3 = item === null || item === void 0 ? void 0 : item.productId) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
2911
2685
|
item_sku: (_ref4 = (_item_items = item.items) === null || _item_items === void 0 ? void 0 : _item_items[0].itemId) !== null && _ref4 !== void 0 ? _ref4 : null,
|
|
2912
2686
|
item_url: (_item_link = item.link) !== null && _item_link !== void 0 ? _item_link : null,
|
|
@@ -2944,7 +2718,8 @@ var AzzasTracker = function() {
|
|
|
2944
2718
|
}
|
|
2945
2719
|
return null;
|
|
2946
2720
|
},
|
|
2947
|
-
brand: function(context) {
|
|
2721
|
+
brand: function(context, config2) {
|
|
2722
|
+
if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
|
|
2948
2723
|
if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
|
|
2949
2724
|
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2950
2725
|
return context.products.map(function(p) {
|
|
@@ -2960,7 +2735,7 @@ var AzzasTracker = function() {
|
|
|
2960
2735
|
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2961
2736
|
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2962
2737
|
return context.products.map(function(item) {
|
|
2963
|
-
var _ref, _item_brand_name, _item_name, _ref1, _ref2, _item_additionalProperty,
|
|
2738
|
+
var _ref, _item_brand_name, _item_name, _ref1, _ref2, _item_additionalProperty, _getItemCategory23, _item_isVariantOf_productGroupID, _item_sku, _resizeVtexImage2, _ref3, _item_item_list_name;
|
|
2964
2739
|
var _item_isVariantOf_hasVariant, _item_isVariantOf, _find, _item_image, _item_offers_offers_find_seller, _item_offers_offers_find, _item_offers_offers, _item_offers;
|
|
2965
2740
|
var listPrice = item.offers.highPrice;
|
|
2966
2741
|
var price = item.offers.lowPrice;
|
|
@@ -2978,8 +2753,8 @@ var AzzasTracker = function() {
|
|
|
2978
2753
|
})) === null || _find === void 0 ? void 0 : _find.value) !== null && _ref2 !== void 0 ? _ref2 : null,
|
|
2979
2754
|
item_ref: null,
|
|
2980
2755
|
// sem ref no retorno do IS na multi-lib produtos PDC
|
|
2981
|
-
item_category:
|
|
2982
|
-
item_category2: (
|
|
2756
|
+
item_category: getItemCategory5(item),
|
|
2757
|
+
item_category2: (_getItemCategory23 = getItemCategory23(item)) !== null && _getItemCategory23 !== void 0 ? _getItemCategory23 : null,
|
|
2983
2758
|
item_id: (_item_isVariantOf_productGroupID = item.isVariantOf.productGroupID) !== null && _item_isVariantOf_productGroupID !== void 0 ? _item_isVariantOf_productGroupID : null,
|
|
2984
2759
|
item_sku: (_item_sku = item.sku) !== null && _item_sku !== void 0 ? _item_sku : null,
|
|
2985
2760
|
item_url: null,
|
|
@@ -3018,7 +2793,8 @@ var AzzasTracker = function() {
|
|
|
3018
2793
|
}
|
|
3019
2794
|
return null;
|
|
3020
2795
|
},
|
|
3021
|
-
brand: function(context) {
|
|
2796
|
+
brand: function(context, config2) {
|
|
2797
|
+
if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
|
|
3022
2798
|
if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
|
|
3023
2799
|
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
3024
2800
|
return context.products.map(function(p) {
|
|
@@ -3029,14 +2805,14 @@ var AzzasTracker = function() {
|
|
|
3029
2805
|
}
|
|
3030
2806
|
};
|
|
3031
2807
|
// src/params/adapters/headless/index.ts
|
|
3032
|
-
var headlessAdapter = _object_spread_props(_object_spread({}, metaAdapters
|
|
3033
|
-
//
|
|
3034
|
-
brand: function(context) {
|
|
2808
|
+
var headlessAdapter = _object_spread_props(_object_spread({}, metaAdapters), {
|
|
2809
|
+
// global adapters
|
|
2810
|
+
brand: function(context, config2) {
|
|
3035
2811
|
if (context.zone === "PDP") {
|
|
3036
|
-
return HeadlessPdpZone.brand(context);
|
|
2812
|
+
return HeadlessPdpZone.brand(context, config2);
|
|
3037
2813
|
}
|
|
3038
2814
|
if (context.zone === "PDC") {
|
|
3039
|
-
return HeadlessPdcZone.brand(context);
|
|
2815
|
+
return HeadlessPdcZone.brand(context, config2);
|
|
3040
2816
|
}
|
|
3041
2817
|
return null;
|
|
3042
2818
|
},
|
|
@@ -3122,6 +2898,236 @@ var AzzasTracker = function() {
|
|
|
3122
2898
|
return (_context_zipcode = context.zipcode) !== null && _context_zipcode !== void 0 ? _context_zipcode : null;
|
|
3123
2899
|
}
|
|
3124
2900
|
});
|
|
2901
|
+
// src/params/adapters/orderForm/utils.ts
|
|
2902
|
+
var getItemCategory6 = function(item) {
|
|
2903
|
+
var _text_match;
|
|
2904
|
+
var categories = item === null || item === void 0 ? void 0 : item.productCategories;
|
|
2905
|
+
if (!categories) return "Cole\xE7\xE3o";
|
|
2906
|
+
var text = Object.values(categories).join(" ");
|
|
2907
|
+
var match = (_text_match = text.match(/outlet|bazar|sale/i)) === null || _text_match === void 0 ? void 0 : _text_match[0].toLowerCase();
|
|
2908
|
+
return match !== null && match !== void 0 ? match : "Cole\xE7\xE3o";
|
|
2909
|
+
};
|
|
2910
|
+
var getItemCategory24 = function(item) {
|
|
2911
|
+
var _ref, _validHierarchy_;
|
|
2912
|
+
var AVOID_CATEGORIES = /outlet|bazar|sale/i;
|
|
2913
|
+
var categories = Object.values((_ref = item === null || item === void 0 ? void 0 : item.productCategories) !== null && _ref !== void 0 ? _ref : {});
|
|
2914
|
+
var validHierarchy = categories.map(function(c) {
|
|
2915
|
+
return c.trim();
|
|
2916
|
+
}).filter(function(c) {
|
|
2917
|
+
return c && !AVOID_CATEGORIES.test(c);
|
|
2918
|
+
});
|
|
2919
|
+
var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
|
|
2920
|
+
return capitalize(deepest);
|
|
2921
|
+
};
|
|
2922
|
+
var getOrderFormItems = function(orderForm) {
|
|
2923
|
+
var idSelected = orderForm === null || orderForm === void 0 ? void 0 : orderForm.selected;
|
|
2924
|
+
return idSelected ? orderForm.items.filter(function(item) {
|
|
2925
|
+
return item.id === idSelected;
|
|
2926
|
+
}) : orderForm.items;
|
|
2927
|
+
};
|
|
2928
|
+
// src/params/adapters/orderForm/index.ts
|
|
2929
|
+
var orderFormAdapter = _object_spread_props(_object_spread({}, metaAdapters), {
|
|
2930
|
+
items: function(context) {
|
|
2931
|
+
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2932
|
+
if ((context === null || context === void 0 ? void 0 : context.orderForm) && (context === null || context === void 0 ? void 0 : context.orderForm.items)) {
|
|
2933
|
+
return getOrderFormItems(context.orderForm).map(function(item, index) {
|
|
2934
|
+
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _getItemCategory6, _getItemCategory24, _ref7, _ref8, _item_detailUrl, _resizeVtexImage2, _ref9, _ref10;
|
|
2935
|
+
var _context_orderForm, _item_additionalInfo, _item_skuName_split__split_pop, _item_skuName_split_, _item_skuName, _item_skuName_split_1, _item_skuName1, _context_orderForm1;
|
|
2936
|
+
return {
|
|
2937
|
+
quantity: (_ref = item === null || item === void 0 ? void 0 : item.quantity) !== null && _ref !== void 0 ? _ref : 1,
|
|
2938
|
+
index: (_ref1 = (_ref2 = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.index) !== null && _ref2 !== void 0 ? _ref2 : index) !== null && _ref1 !== void 0 ? _ref1 : null,
|
|
2939
|
+
item_brand: (_ref3 = (_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
2940
|
+
item_name: (_ref4 = item === null || item === void 0 ? void 0 : item.name.replace(item === null || item === void 0 ? void 0 : item.skuName, "").trim()) !== null && _ref4 !== void 0 ? _ref4 : null,
|
|
2941
|
+
price: (item === null || item === void 0 ? void 0 : item.price) / 100,
|
|
2942
|
+
discount: ((item === null || item === void 0 ? void 0 : item.listPrice) - (item === null || item === void 0 ? void 0 : item.sellingPrice)) / 100,
|
|
2943
|
+
item_variant: (_ref5 = item === null || item === void 0 ? void 0 : (_item_skuName = item.skuName) === null || _item_skuName === void 0 ? void 0 : (_item_skuName_split_ = _item_skuName.split(" - ")[0]) === null || _item_skuName_split_ === void 0 ? void 0 : (_item_skuName_split__split_pop = _item_skuName_split_.split("_").pop()) === null || _item_skuName_split__split_pop === void 0 ? void 0 : _item_skuName_split__split_pop.trim()) !== null && _ref5 !== void 0 ? _ref5 : null,
|
|
2944
|
+
item_variant2: (_ref6 = item === null || item === void 0 ? void 0 : (_item_skuName1 = item.skuName) === null || _item_skuName1 === void 0 ? void 0 : (_item_skuName_split_1 = _item_skuName1.split(" - ")[1]) === null || _item_skuName_split_1 === void 0 ? void 0 : _item_skuName_split_1.trim()) !== null && _ref6 !== void 0 ? _ref6 : null,
|
|
2945
|
+
item_shipping_tier: getItemShippingTier2(context.orderForm, item),
|
|
2946
|
+
item_ref: (item === null || item === void 0 ? void 0 : item.productRefId) || (item === null || item === void 0 ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
|
|
2947
|
+
item_category: (_getItemCategory6 = getItemCategory6(item)) !== null && _getItemCategory6 !== void 0 ? _getItemCategory6 : null,
|
|
2948
|
+
item_category2: (_getItemCategory24 = getItemCategory24(item)) !== null && _getItemCategory24 !== void 0 ? _getItemCategory24 : null,
|
|
2949
|
+
item_id: (_ref7 = item === null || item === void 0 ? void 0 : item.productId) !== null && _ref7 !== void 0 ? _ref7 : null,
|
|
2950
|
+
item_sku: (_ref8 = item === null || item === void 0 ? void 0 : item.id) !== null && _ref8 !== void 0 ? _ref8 : null,
|
|
2951
|
+
item_url: (_item_detailUrl = item.detailUrl) !== null && _item_detailUrl !== void 0 ? _item_detailUrl : null,
|
|
2952
|
+
image_url: (_resizeVtexImage2 = resizeVtexImage2(item.imageUrl)) !== null && _resizeVtexImage2 !== void 0 ? _resizeVtexImage2 : null,
|
|
2953
|
+
seller_id: (_ref9 = item === null || item === void 0 ? void 0 : item.seller) !== null && _ref9 !== void 0 ? _ref9 : null,
|
|
2954
|
+
item_list_name: (_ref10 = context === null || context === void 0 ? void 0 : (_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.item_list_name) !== null && _ref10 !== void 0 ? _ref10 : null
|
|
2955
|
+
};
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
return null;
|
|
2959
|
+
},
|
|
2960
|
+
brand: function(context, config2) {
|
|
2961
|
+
var _context_orderForm;
|
|
2962
|
+
if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
|
|
2963
|
+
if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
|
|
2964
|
+
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2965
|
+
var brands = getOrderFormItems(context.orderForm).map(function(item) {
|
|
2966
|
+
return item.additionalInfo.brandName;
|
|
2967
|
+
});
|
|
2968
|
+
return normalizeBrand2(brands);
|
|
2969
|
+
},
|
|
2970
|
+
line_items: function(context) {
|
|
2971
|
+
var _context_orderForm;
|
|
2972
|
+
if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
|
|
2973
|
+
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2974
|
+
return getOrderFormItems(context.orderForm).map(function(item) {
|
|
2975
|
+
return item === null || item === void 0 ? void 0 : item.productId;
|
|
2976
|
+
}).filter(function(id) {
|
|
2977
|
+
return Boolean(id);
|
|
2978
|
+
});
|
|
2979
|
+
},
|
|
2980
|
+
value: function(context) {
|
|
2981
|
+
var _context_orderForm;
|
|
2982
|
+
if (context === null || context === void 0 ? void 0 : context.value) return context.value;
|
|
2983
|
+
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2984
|
+
return getOrderFormItems(context.orderForm).map(function(item) {
|
|
2985
|
+
return (item === null || item === void 0 ? void 0 : item.price) / 100 * item.quantity;
|
|
2986
|
+
}).filter(function(price) {
|
|
2987
|
+
return price !== void 0;
|
|
2988
|
+
}).reduce(function(sum, price) {
|
|
2989
|
+
return sum + price;
|
|
2990
|
+
}, 0);
|
|
2991
|
+
},
|
|
2992
|
+
payment_type: getPaymentType,
|
|
2993
|
+
total_discount: function(context) {
|
|
2994
|
+
var _context_orderForm, _context_orderForm1;
|
|
2995
|
+
if (context === null || context === void 0 ? void 0 : context.total_discount) return context.total_discount;
|
|
2996
|
+
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2997
|
+
var totalsList = ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totalizers) || [];
|
|
2998
|
+
var totalDiscount = getOrderFormItems(context.orderForm).reduce(function(acc, item) {
|
|
2999
|
+
var unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
|
|
3000
|
+
return acc + unitDiscount * item.quantity;
|
|
3001
|
+
}, 0);
|
|
3002
|
+
var discounts = totalsList.find(function(t) {
|
|
3003
|
+
return t.id === "Discounts";
|
|
3004
|
+
});
|
|
3005
|
+
return Math.abs(((discounts === null || discounts === void 0 ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
|
|
3006
|
+
},
|
|
3007
|
+
subtotal: function(context) {
|
|
3008
|
+
var _context_orderForm, _context_orderForm1;
|
|
3009
|
+
var totalsList = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.totalizers) || ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totals) || [];
|
|
3010
|
+
var subtotal = totalsList.filter(function(t) {
|
|
3011
|
+
return t.id === "Items";
|
|
3012
|
+
}).reduce(function(acc, t) {
|
|
3013
|
+
return acc + (t.value || 0);
|
|
3014
|
+
}, 0) / 100 || 0;
|
|
3015
|
+
return subtotal;
|
|
3016
|
+
},
|
|
3017
|
+
coupon_message: function(context) {
|
|
3018
|
+
var _context_orderForm;
|
|
3019
|
+
if (context.couponMessage) return context.couponMessage;
|
|
3020
|
+
var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
|
|
3021
|
+
if (messages.length === 0) return null;
|
|
3022
|
+
var couponMessages = messages.filter(function(msg) {
|
|
3023
|
+
return msg.text.toLowerCase().includes("cupom");
|
|
3024
|
+
});
|
|
3025
|
+
if (couponMessages.length === 0) return null;
|
|
3026
|
+
return couponMessages.map(function(msg) {
|
|
3027
|
+
return msg.text;
|
|
3028
|
+
}).join(" | ");
|
|
3029
|
+
},
|
|
3030
|
+
zipcode: function(context) {
|
|
3031
|
+
var _context_zipcode;
|
|
3032
|
+
return (_context_zipcode = context.zipcode) !== null && _context_zipcode !== void 0 ? _context_zipcode : null;
|
|
3033
|
+
},
|
|
3034
|
+
flag_pickup: function(context) {
|
|
3035
|
+
var _orderForm_shippingData;
|
|
3036
|
+
var orderForm = context.orderForm;
|
|
3037
|
+
if (!orderForm) return null;
|
|
3038
|
+
var logisticsInfo = ((_orderForm_shippingData = orderForm.shippingData) === null || _orderForm_shippingData === void 0 ? void 0 : _orderForm_shippingData.logisticsInfo) || [];
|
|
3039
|
+
var hasPickup = logisticsInfo.some(function(info) {
|
|
3040
|
+
var _info_slas;
|
|
3041
|
+
return (_info_slas = info.slas) === null || _info_slas === void 0 ? void 0 : _info_slas.some(function(sla) {
|
|
3042
|
+
return sla.deliveryChannel === "pickup-in-point";
|
|
3043
|
+
});
|
|
3044
|
+
});
|
|
3045
|
+
return hasPickup;
|
|
3046
|
+
},
|
|
3047
|
+
shippings: function(context) {
|
|
3048
|
+
if (!context.orderForm) return null;
|
|
3049
|
+
var _context_orderForm = context.orderForm, items = _context_orderForm.items, shippingData = _context_orderForm.shippingData;
|
|
3050
|
+
var acc = {};
|
|
3051
|
+
shippingData.logisticsInfo.forEach(function(param) {
|
|
3052
|
+
var itemIndex = param.itemIndex, slas = param.slas;
|
|
3053
|
+
var item = items[itemIndex];
|
|
3054
|
+
if (!item) return;
|
|
3055
|
+
slas.forEach(function(sla) {
|
|
3056
|
+
if (!acc[sla.name]) acc[sla.name] = {
|
|
3057
|
+
shipping_tier: sla.name,
|
|
3058
|
+
delivery_time: parseInt(sla.shippingEstimate),
|
|
3059
|
+
shipping: parseFloat((sla.price / 100).toFixed(1)),
|
|
3060
|
+
line_items: []
|
|
3061
|
+
};
|
|
3062
|
+
acc[sla.name].line_items.push(item.id);
|
|
3063
|
+
});
|
|
3064
|
+
});
|
|
3065
|
+
return Object.values(acc).map(function(s) {
|
|
3066
|
+
return _object_spread_props(_object_spread({}, s), {
|
|
3067
|
+
line_items: s.line_items.join(",")
|
|
3068
|
+
});
|
|
3069
|
+
});
|
|
3070
|
+
},
|
|
3071
|
+
shipping: function(context) {
|
|
3072
|
+
var _ref;
|
|
3073
|
+
var _context_orderForm_shippingData, _context_orderForm;
|
|
3074
|
+
var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
|
|
3075
|
+
return logistics.reduce(function(total, item) {
|
|
3076
|
+
var _ref;
|
|
3077
|
+
var _item_slas;
|
|
3078
|
+
var selected = (_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
3079
|
+
return sla.id === item.selectedSla;
|
|
3080
|
+
});
|
|
3081
|
+
return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
|
|
3082
|
+
}, 0);
|
|
3083
|
+
},
|
|
3084
|
+
shipping_tier: function(context) {
|
|
3085
|
+
var _ref;
|
|
3086
|
+
var _context_orderForm_shippingData, _context_orderForm;
|
|
3087
|
+
var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
|
|
3088
|
+
var selectedSlas = logistics.map(function(item) {
|
|
3089
|
+
var _item_slas;
|
|
3090
|
+
if (!item.selectedSla) return null;
|
|
3091
|
+
return ((_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
3092
|
+
return sla.id === item.selectedSla;
|
|
3093
|
+
})) || null;
|
|
3094
|
+
}).filter(Boolean);
|
|
3095
|
+
if (selectedSlas.length === 0) return null;
|
|
3096
|
+
var uniqueTiers = Array.from(new Map(selectedSlas.map(function(sla) {
|
|
3097
|
+
var _sla_pickupStoreInfo;
|
|
3098
|
+
var key = sla.deliveryChannel === "pickup-in-point" ? "pickup:".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) || sla.name || "") : "delivery:".concat(sla.name || "");
|
|
3099
|
+
return [
|
|
3100
|
+
key,
|
|
3101
|
+
sla
|
|
3102
|
+
];
|
|
3103
|
+
})).values());
|
|
3104
|
+
var sortedTiers = uniqueTiers.sort(function(a, b) {
|
|
3105
|
+
var _a_pickupStoreInfo, _b_pickupStoreInfo;
|
|
3106
|
+
var aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
3107
|
+
var bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
3108
|
+
if (aOrder !== bOrder) return aOrder - bOrder;
|
|
3109
|
+
var aLabel = a.deliveryChannel === "pickup-in-point" ? ((_a_pickupStoreInfo = a.pickupStoreInfo) === null || _a_pickupStoreInfo === void 0 ? void 0 : _a_pickupStoreInfo.friendlyName) || a.name || "" : a.name || "";
|
|
3110
|
+
var bLabel = b.deliveryChannel === "pickup-in-point" ? ((_b_pickupStoreInfo = b.pickupStoreInfo) === null || _b_pickupStoreInfo === void 0 ? void 0 : _b_pickupStoreInfo.friendlyName) || b.name || "" : b.name || "";
|
|
3111
|
+
return aLabel.localeCompare(bLabel, "pt-BR");
|
|
3112
|
+
});
|
|
3113
|
+
var shippingTier = sortedTiers.map(function(sla) {
|
|
3114
|
+
var _sla_pickupStoreInfo;
|
|
3115
|
+
return sla.deliveryChannel === "pickup-in-point" ? "retirada em loja".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) ? ": ".concat(sla.pickupStoreInfo.friendlyName) : "") : sla.deliveryChannel === "delivery" ? "receba em casa".concat(sla.name ? ": ".concat(sla.name) : "") : null;
|
|
3116
|
+
}).filter(Boolean).join(", ");
|
|
3117
|
+
return shippingTier || null;
|
|
3118
|
+
},
|
|
3119
|
+
transaction_id: function(context) {
|
|
3120
|
+
var _context_orderForm_orderGroup, _context_orderForm;
|
|
3121
|
+
return ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_orderGroup = _context_orderForm.orderGroup) === null || _context_orderForm_orderGroup === void 0 ? void 0 : _context_orderForm_orderGroup.toString()) || null;
|
|
3122
|
+
},
|
|
3123
|
+
coupon: function(context) {
|
|
3124
|
+
var _context_orderForm_marketingData, _context_orderForm;
|
|
3125
|
+
return context.appliedCoupon || (context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_marketingData = _context_orderForm.marketingData) === null || _context_orderForm_marketingData === void 0 ? void 0 : _context_orderForm_marketingData.coupon) || null;
|
|
3126
|
+
},
|
|
3127
|
+
seller_cod_name: function(context) {
|
|
3128
|
+
return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
|
|
3129
|
+
}
|
|
3130
|
+
});
|
|
3125
3131
|
// src/formatter.ts
|
|
3126
3132
|
var adapters = {
|
|
3127
3133
|
DECO: decoAdapter,
|
|
@@ -3129,6 +3135,11 @@ var AzzasTracker = function() {
|
|
|
3129
3135
|
PICKUP: pickupAdapter,
|
|
3130
3136
|
ORDERFORM: orderFormAdapter
|
|
3131
3137
|
};
|
|
3138
|
+
// src/index.ts
|
|
3139
|
+
var config = {
|
|
3140
|
+
brand: "",
|
|
3141
|
+
currency: "BRL"
|
|
3142
|
+
};
|
|
3132
3143
|
var src_default = {
|
|
3133
3144
|
trackWebEvent: trackWebEvent,
|
|
3134
3145
|
EVENTS: EVENTS
|