@azzas/azzas-tracker-web 1.0.65 → 1.0.72
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 +130 -130
- package/dist/mod.cjs +80 -19
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.d.cts +0 -0
- package/dist/mod.d.ts +0 -0
- package/dist/mod.global.js +80 -19
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +80 -19
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +133 -53
- package/package.json +38 -38
package/dist/mod.vtex.global.js
CHANGED
|
@@ -462,7 +462,51 @@ var AzzasTracker = function() {
|
|
|
462
462
|
})();
|
|
463
463
|
};
|
|
464
464
|
var getDiscount = function getDiscount(item) {
|
|
465
|
-
|
|
465
|
+
var strategies = [
|
|
466
|
+
// 1. listPrice - sellingPrice
|
|
467
|
+
function() {
|
|
468
|
+
if ((item === null || item === void 0 ? void 0 : item.listPrice) != null && (item === null || item === void 0 ? void 0 : item.sellingPrice) != null) {
|
|
469
|
+
var diff = Math.max(item.listPrice - item.sellingPrice, 0);
|
|
470
|
+
return diff ? parseFloat((diff / 100).toFixed(2)) : 0;
|
|
471
|
+
}
|
|
472
|
+
return null;
|
|
473
|
+
},
|
|
474
|
+
// 2. listPrice - price
|
|
475
|
+
function() {
|
|
476
|
+
if ((item === null || item === void 0 ? void 0 : item.listPrice) != null && (item === null || item === void 0 ? void 0 : item.price) != null) {
|
|
477
|
+
return Math.max(item.listPrice - item.price, 0);
|
|
478
|
+
}
|
|
479
|
+
return null;
|
|
480
|
+
},
|
|
481
|
+
// 3. desconto calculado.
|
|
482
|
+
function() {
|
|
483
|
+
return (item === null || item === void 0 ? void 0 : item.discount) || (item === null || item === void 0 ? void 0 : item.discount) === 0 ? item.discount : null;
|
|
484
|
+
}
|
|
485
|
+
];
|
|
486
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
487
|
+
try {
|
|
488
|
+
for(var _iterator = strategies[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
489
|
+
var getValue = _step.value;
|
|
490
|
+
var value = getValue();
|
|
491
|
+
if (value !== null && value !== void 0) {
|
|
492
|
+
return value;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
} catch (err) {
|
|
496
|
+
_didIteratorError = true;
|
|
497
|
+
_iteratorError = err;
|
|
498
|
+
} finally{
|
|
499
|
+
try {
|
|
500
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
501
|
+
_iterator.return();
|
|
502
|
+
}
|
|
503
|
+
} finally{
|
|
504
|
+
if (_didIteratorError) {
|
|
505
|
+
throw _iteratorError;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return 0;
|
|
466
510
|
};
|
|
467
511
|
var getItemCategory = function getItemCategory(item) {
|
|
468
512
|
var strategies = [
|
|
@@ -478,6 +522,18 @@ var AzzasTracker = function() {
|
|
|
478
522
|
},
|
|
479
523
|
function() {
|
|
480
524
|
return item === null || item === void 0 ? void 0 : item.categories[0];
|
|
525
|
+
},
|
|
526
|
+
function() {
|
|
527
|
+
var _item_itemOffered_breadcrumbList, _item_itemOffered;
|
|
528
|
+
var breadcrumb = item === null || item === void 0 ? void 0 : (_item_itemOffered = item.itemOffered) === null || _item_itemOffered === void 0 ? void 0 : (_item_itemOffered_breadcrumbList = _item_itemOffered.breadcrumbList) === null || _item_itemOffered_breadcrumbList === void 0 ? void 0 : _item_itemOffered_breadcrumbList.itemListElement;
|
|
529
|
+
if (!Array.isArray(breadcrumb)) return null;
|
|
530
|
+
var level1 = breadcrumb.find(function(el) {
|
|
531
|
+
var path = el === null || el === void 0 ? void 0 : el.item;
|
|
532
|
+
if (!path) return false;
|
|
533
|
+
var parts = path.replace(/^\/|\/$/g, "").split("/");
|
|
534
|
+
return parts.length === 1;
|
|
535
|
+
});
|
|
536
|
+
return (level1 === null || level1 === void 0 ? void 0 : level1.name) || null;
|
|
481
537
|
}
|
|
482
538
|
];
|
|
483
539
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
@@ -523,6 +579,10 @@ var AzzasTracker = function() {
|
|
|
523
579
|
// deco select_item context
|
|
524
580
|
function() {
|
|
525
581
|
return item.item_category2;
|
|
582
|
+
},
|
|
583
|
+
// deco add_to_cart context PDP
|
|
584
|
+
function() {
|
|
585
|
+
return item === null || item === void 0 ? void 0 : item.subGrup;
|
|
526
586
|
}
|
|
527
587
|
];
|
|
528
588
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
@@ -679,7 +739,7 @@ var AzzasTracker = function() {
|
|
|
679
739
|
var itemsFromItem = // src/params/resolvers/items/fromItem.ts
|
|
680
740
|
function itemsFromItem(context, event) {
|
|
681
741
|
return _async_to_generator(function() {
|
|
682
|
-
var _item_additionalProperty, _item_additionalInfo, _item_brand, _item_itemAttributes, _split_pop, _this, item, orderForm, itemListName, _tmp, _tmp1;
|
|
742
|
+
var _item_additionalProperty, _item_itemOffered, _item_itemOffered1, _item_additionalInfo, _item_brand, _item_itemOffered_brand, _item_itemOffered2, _item_itemOffered3, _item_itemOffered_isVariantOf, _item_itemOffered4, _item_itemAttributes, _split_pop, _this, item, orderForm, itemListName, _tmp, _tmp1;
|
|
683
743
|
return _ts_generator(this, function(_state) {
|
|
684
744
|
switch(_state.label){
|
|
685
745
|
case 0:
|
|
@@ -687,17 +747,17 @@ var AzzasTracker = function() {
|
|
|
687
747
|
_tmp = {
|
|
688
748
|
index: typeof (item === null || item === void 0 ? void 0 : item.index) === "number" ? item.index : null,
|
|
689
749
|
quantity: 1,
|
|
690
|
-
item_id: (item === null || item === void 0 ? void 0 : item.productId) || (item === null || item === void 0 ? void 0 : item.item_group_id) || (item === null || item === void 0 ? void 0 : item.sku) || null,
|
|
750
|
+
item_id: (item === null || item === void 0 ? void 0 : item.productId) || (item === null || item === void 0 ? void 0 : item.item_group_id) || (item === null || item === void 0 ? void 0 : item.sku) || (item === null || item === void 0 ? void 0 : item.id) || null,
|
|
691
751
|
item_category2: getItemCategory2(item),
|
|
692
752
|
item_category4: getItemCategory4(item),
|
|
693
753
|
item_shipping_tier: event === "REMOVE_FROM_CART" ? getItemShippingTier(orderForm, item) : null,
|
|
694
754
|
price: (item === null || item === void 0 ? void 0 : item.listPrice) || (item === null || item === void 0 ? void 0 : item.price) || 0,
|
|
695
755
|
item_ref: (item === null || item === void 0 ? void 0 : item.ref) || (item === null || item === void 0 ? void 0 : item.refId) || (item === null || item === void 0 ? void 0 : item.item_ref) || (item === null || item === void 0 ? void 0 : (_item_additionalProperty = item.additionalProperty) === null || _item_additionalProperty === void 0 ? void 0 : _item_additionalProperty.find(function(i) {
|
|
696
756
|
return i.name === "RefId";
|
|
697
|
-
}).value) || null,
|
|
698
|
-
item_brand: (item === null || item === void 0 ? void 0 : (_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) || (item === null || item === void 0 ? void 0 : item.item_brand) || (item === null || item === void 0 ? void 0 : (_item_brand = item.brand) === null || _item_brand === void 0 ? void 0 : _item_brand.name) || null
|
|
757
|
+
}).value) || (item === null || item === void 0 ? void 0 : (_item_itemOffered1 = item.itemOffered) === null || _item_itemOffered1 === void 0 ? void 0 : _item_itemOffered1.gtin.substring(0, item === null || item === void 0 ? void 0 : (_item_itemOffered = item.itemOffered) === null || _item_itemOffered === void 0 ? void 0 : _item_itemOffered.gtin.lastIndexOf("_"))) || null,
|
|
758
|
+
item_brand: (item === null || item === void 0 ? void 0 : (_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) || (item === null || item === void 0 ? void 0 : item.item_brand) || (item === null || item === void 0 ? void 0 : (_item_brand = item.brand) === null || _item_brand === void 0 ? void 0 : _item_brand.name) || (item === null || item === void 0 ? void 0 : (_item_itemOffered2 = item.itemOffered) === null || _item_itemOffered2 === void 0 ? void 0 : (_item_itemOffered_brand = _item_itemOffered2.brand) === null || _item_itemOffered_brand === void 0 ? void 0 : _item_itemOffered_brand.name) || null
|
|
699
759
|
};
|
|
700
|
-
_tmp1 = (item === null || item === void 0 ? void 0 : item.sku) || (item === null || item === void 0 ? void 0 : item.
|
|
760
|
+
_tmp1 = (item === null || item === void 0 ? void 0 : item.sku) || (item === null || item === void 0 ? void 0 : (_item_itemOffered3 = item.itemOffered) === null || _item_itemOffered3 === void 0 ? void 0 : _item_itemOffered3.sku) || (item === null || item === void 0 ? void 0 : item.item_id) || (item === null || item === void 0 ? void 0 : item.id);
|
|
701
761
|
if (_tmp1) return [
|
|
702
762
|
3,
|
|
703
763
|
2
|
|
@@ -713,7 +773,7 @@ var AzzasTracker = function() {
|
|
|
713
773
|
return [
|
|
714
774
|
2,
|
|
715
775
|
[
|
|
716
|
-
(_tmp.item_sku = _tmp1 || null, _tmp.item_name = (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.item_name) || null, _tmp.item_category = getItemCategory(item) || null, _tmp.item_variant = ((item === null || item === void 0 ? void 0 : item.skuName) || (item === null || item === void 0 ? void 0 : item.item_variant) || (item === null || item === void 0 ? void 0 : item.name)).split(/[-/]/)[0].trim() || null, _tmp.item_variant2 = (item === null || item === void 0 ? void 0 : item.size) || (item === null || item === void 0 ? void 0 : (_item_itemAttributes = item.itemAttributes) === null || _item_itemAttributes === void 0 ? void 0 : _item_itemAttributes.size) || ((_this = (item === null || item === void 0 ? void 0 : item.skuName) || (item === null || item === void 0 ? void 0 : item.name)) === null || _this === void 0 ? void 0 : (_split_pop = _this.split(/[-/]/).pop()) === null || _split_pop === void 0 ? void 0 : _split_pop.trim()) || null, _tmp.discount = getDiscount(item), _tmp.item_list_name = itemListName || null, _tmp.item_url = (item === null || item === void 0 ? void 0 : item.item_url) || null, _tmp)
|
|
776
|
+
(_tmp.item_sku = _tmp1 || null, _tmp.item_name = (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.item_name) || (item === null || item === void 0 ? void 0 : (_item_itemOffered4 = item.itemOffered) === null || _item_itemOffered4 === void 0 ? void 0 : (_item_itemOffered_isVariantOf = _item_itemOffered4.isVariantOf) === null || _item_itemOffered_isVariantOf === void 0 ? void 0 : _item_itemOffered_isVariantOf.name) || null, _tmp.item_category = getItemCategory(item) || null, _tmp.item_variant = ((item === null || item === void 0 ? void 0 : item.skuName) || (item === null || item === void 0 ? void 0 : item.item_variant) || (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.itemOffered.name)).split(/[-/]/)[0].trim() || null, _tmp.item_variant2 = (item === null || item === void 0 ? void 0 : item.size) || (item === null || item === void 0 ? void 0 : (_item_itemAttributes = item.itemAttributes) === null || _item_itemAttributes === void 0 ? void 0 : _item_itemAttributes.size) || ((_this = (item === null || item === void 0 ? void 0 : item.skuName) || (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.itemOffered.name)) === null || _this === void 0 ? void 0 : (_split_pop = _this.split(/[-/]/).pop()) === null || _split_pop === void 0 ? void 0 : _split_pop.trim()) || null, _tmp.discount = getDiscount(item), _tmp.item_list_name = itemListName || null, _tmp.item_url = (item === null || item === void 0 ? void 0 : item.item_url) || null, _tmp)
|
|
717
777
|
]
|
|
718
778
|
];
|
|
719
779
|
}
|
|
@@ -735,7 +795,7 @@ var AzzasTracker = function() {
|
|
|
735
795
|
return i.name === "RefId";
|
|
736
796
|
}).value) || null,
|
|
737
797
|
index: typeof (context === null || context === void 0 ? void 0 : context.index) === "number" ? context.index : Number(item === null || item === void 0 ? void 0 : item.index),
|
|
738
|
-
item_brand: item.isNotFarm ? item === null || item === void 0 ? void 0 : item.item_brand : normalizeBrand(item === null || item === void 0 ? void 0 : (_item_brand = item.brand) === null || _item_brand === void 0 ? void 0 : _item_brand.name) || normalizeBrand(context.brand) || normalizeBrand(item === null || item === void 0 ? void 0 : item.item_brand) || null,
|
|
798
|
+
item_brand: (item === null || item === void 0 ? void 0 : item.item_brand) ? item.item_brand : item.isNotFarm ? item === null || item === void 0 ? void 0 : item.item_brand : normalizeBrand(item === null || item === void 0 ? void 0 : (_item_brand = item.brand) === null || _item_brand === void 0 ? void 0 : _item_brand.name) || normalizeBrand(context.brand) || normalizeBrand(item === null || item === void 0 ? void 0 : item.item_brand) || null,
|
|
739
799
|
item_name: (item === null || item === void 0 ? void 0 : (_item_productName = item.productName) === null || _item_productName === void 0 ? void 0 : _item_productName.split(" - ").shift()) || (item === null || item === void 0 ? void 0 : (_item_alternateName = item.alternateName) === null || _item_alternateName === void 0 ? void 0 : _item_alternateName.split(" - ").shift()) || (item === null || item === void 0 ? void 0 : (_item_item_name = item.item_name) === null || _item_item_name === void 0 ? void 0 : _item_item_name.split(" - ").shift()) || (item === null || item === void 0 ? void 0 : (_item_seo = item.seo) === null || _item_seo === void 0 ? void 0 : (_item_seo_title = _item_seo.title) === null || _item_seo_title === void 0 ? void 0 : _item_seo_title.split(" - ").shift()) || null,
|
|
740
800
|
item_category: getItemCategory(item) || null,
|
|
741
801
|
item_variant: (item === null || item === void 0 ? void 0 : (_item_name = item.name) === null || _item_name === void 0 ? void 0 : (_item_name_split = _item_name.split("-")) === null || _item_name_split === void 0 ? void 0 : _item_name_split[0].trim()) || (item === null || item === void 0 ? void 0 : item.item_variant) || (item === null || item === void 0 ? void 0 : (_item_productName1 = item.productName) === null || _item_productName1 === void 0 ? void 0 : (_item_productName_split = _item_productName1.split("-")) === null || _item_productName_split === void 0 ? void 0 : _item_productName_split[1].trim()) || null,
|
|
@@ -1015,20 +1075,20 @@ var AzzasTracker = function() {
|
|
|
1015
1075
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
1016
1076
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
1017
1077
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1018
|
-
var __export = function(target, all) {
|
|
1078
|
+
var __export = function __export(target, all) {
|
|
1019
1079
|
for(var name in all)__defProp(target, name, {
|
|
1020
1080
|
get: all[name],
|
|
1021
1081
|
enumerable: true
|
|
1022
1082
|
});
|
|
1023
1083
|
};
|
|
1024
|
-
var __copyProps = function(to, from, except, desc) {
|
|
1084
|
+
var __copyProps = function __copyProps(to, from, except, desc) {
|
|
1025
1085
|
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
1026
1086
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1027
1087
|
try {
|
|
1028
1088
|
var _loop = function() {
|
|
1029
1089
|
var key = _step.value;
|
|
1030
1090
|
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
1031
|
-
get: function() {
|
|
1091
|
+
get: function get() {
|
|
1032
1092
|
return from[key];
|
|
1033
1093
|
},
|
|
1034
1094
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
@@ -1052,7 +1112,7 @@ var AzzasTracker = function() {
|
|
|
1052
1112
|
}
|
|
1053
1113
|
return to;
|
|
1054
1114
|
};
|
|
1055
|
-
var __toCommonJS = function(mod) {
|
|
1115
|
+
var __toCommonJS = function __toCommonJS(mod) {
|
|
1056
1116
|
return __copyProps(__defProp({}, "__esModule", {
|
|
1057
1117
|
value: true
|
|
1058
1118
|
}), mod);
|
|
@@ -1060,13 +1120,13 @@ var AzzasTracker = function() {
|
|
|
1060
1120
|
// src/index.ts
|
|
1061
1121
|
var src_exports = {};
|
|
1062
1122
|
__export(src_exports, {
|
|
1063
|
-
EVENTS: function() {
|
|
1123
|
+
EVENTS: function EVENTS1() {
|
|
1064
1124
|
return EVENTS;
|
|
1065
1125
|
},
|
|
1066
|
-
default: function() {
|
|
1126
|
+
default: function _default() {
|
|
1067
1127
|
return src_default;
|
|
1068
1128
|
},
|
|
1069
|
-
trackWebEvent: function() {
|
|
1129
|
+
trackWebEvent: function trackWebEvent1() {
|
|
1070
1130
|
return trackWebEvent;
|
|
1071
1131
|
}
|
|
1072
1132
|
});
|
|
@@ -1517,7 +1577,7 @@ var AzzasTracker = function() {
|
|
|
1517
1577
|
"cart\xE3o"
|
|
1518
1578
|
]
|
|
1519
1579
|
];
|
|
1520
|
-
var toNum = function(val) {
|
|
1580
|
+
var toNum = function toNum(val) {
|
|
1521
1581
|
return typeof val === "string" ? Number(val.replace(/[^\d,]/g, "").replace(",", ".")) : val;
|
|
1522
1582
|
};
|
|
1523
1583
|
// src/adapters/index.ts
|
|
@@ -1535,7 +1595,7 @@ var AzzasTracker = function() {
|
|
|
1535
1595
|
brand: getBrand,
|
|
1536
1596
|
items: getItems,
|
|
1537
1597
|
payment_type: getPaymentType,
|
|
1538
|
-
user_info: function(context, eventName) {
|
|
1598
|
+
user_info: function user_info(context, eventName) {
|
|
1539
1599
|
return _async_to_generator(function() {
|
|
1540
1600
|
var _PROD_DOMAINS_, PROD_DOMAINS, domain, api, response, _;
|
|
1541
1601
|
return _ts_generator(this, function(_state) {
|
|
@@ -1634,13 +1694,13 @@ var AzzasTracker = function() {
|
|
|
1634
1694
|
});
|
|
1635
1695
|
})();
|
|
1636
1696
|
},
|
|
1637
|
-
content_type: function(context, eventName) {
|
|
1697
|
+
content_type: function content_type(context, eventName) {
|
|
1638
1698
|
return "regiao".concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
|
|
1639
1699
|
},
|
|
1640
|
-
region: function(context, eventName) {
|
|
1700
|
+
region: function region(context, eventName) {
|
|
1641
1701
|
return context.region || null;
|
|
1642
1702
|
},
|
|
1643
|
-
line_items: function(context, eventName) {
|
|
1703
|
+
line_items: function line_items(context, eventName) {
|
|
1644
1704
|
if (context === null || context === void 0 ? void 0 : context.lineItems) return context.lineItems;
|
|
1645
1705
|
if (context === null || context === void 0 ? void 0 : context.item) {
|
|
1646
1706
|
return [
|
|
@@ -1656,7 +1716,7 @@ var AzzasTracker = function() {
|
|
|
1656
1716
|
return item.productId;
|
|
1657
1717
|
}).join(",");
|
|
1658
1718
|
},
|
|
1659
|
-
currency: function(context, eventName) {
|
|
1719
|
+
currency: function currency(context, eventName) {
|
|
1660
1720
|
var _context_orderForm_storePreferencesData, _context_orderForm;
|
|
1661
1721
|
if (context === null || context === void 0 ? void 0 : context.currency) return context.currency;
|
|
1662
1722
|
if (context === null || context === void 0 ? void 0 : context.bannerUrl) return "BRL";
|
|
@@ -1666,12 +1726,12 @@ var AzzasTracker = function() {
|
|
|
1666
1726
|
}
|
|
1667
1727
|
return ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_storePreferencesData = _context_orderForm.storePreferencesData) === null || _context_orderForm_storePreferencesData === void 0 ? void 0 : _context_orderForm_storePreferencesData.currencyCode) || null;
|
|
1668
1728
|
},
|
|
1669
|
-
value: function(context, eventName) {
|
|
1729
|
+
value: function value(context, eventName) {
|
|
1670
1730
|
var _context_item, _context_orderForm;
|
|
1671
1731
|
if (context === null || context === void 0 ? void 0 : context.value) return toNum(context.value);
|
|
1672
1732
|
return context.item ? toNum((_context_item = context.item) === null || _context_item === void 0 ? void 0 : _context_item.price) : ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.value) != null ? context.orderForm.value / 100 : null;
|
|
1673
1733
|
},
|
|
1674
|
-
total_discount: function(context, eventName) {
|
|
1734
|
+
total_discount: function total_discount(context, eventName) {
|
|
1675
1735
|
var _context_orderForm, _context_orderForm1;
|
|
1676
1736
|
if (context === null || context === void 0 ? void 0 : context.totalDiscount) return context.totalDiscount;
|
|
1677
1737
|
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) || [];
|
|
@@ -1685,7 +1745,7 @@ var AzzasTracker = function() {
|
|
|
1685
1745
|
});
|
|
1686
1746
|
return Math.abs(((discounts === null || discounts === void 0 ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
|
|
1687
1747
|
},
|
|
1688
|
-
subtotal: function(context, eventName) {
|
|
1748
|
+
subtotal: function subtotal(context, eventName) {
|
|
1689
1749
|
var _context_orderForm, _context_orderForm1;
|
|
1690
1750
|
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) || [];
|
|
1691
1751
|
var subtotal = totalsList.filter(function(t) {
|
|
@@ -1695,7 +1755,7 @@ var AzzasTracker = function() {
|
|
|
1695
1755
|
}, 0) / 100 || 0;
|
|
1696
1756
|
return subtotal;
|
|
1697
1757
|
},
|
|
1698
|
-
coupon_message: function(context, eventName) {
|
|
1758
|
+
coupon_message: function coupon_message(context, eventName) {
|
|
1699
1759
|
var _context_orderForm;
|
|
1700
1760
|
if (context.couponMessage) return context.couponMessage;
|
|
1701
1761
|
var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
|
|
@@ -1708,44 +1768,44 @@ var AzzasTracker = function() {
|
|
|
1708
1768
|
return msg.text;
|
|
1709
1769
|
}).join(" | ");
|
|
1710
1770
|
},
|
|
1711
|
-
seller_cod_name: function(context, eventName) {
|
|
1771
|
+
seller_cod_name: function seller_cod_name(context, eventName) {
|
|
1712
1772
|
return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
|
|
1713
1773
|
},
|
|
1714
|
-
coupon: function(context, eventName) {
|
|
1774
|
+
coupon: function coupon(context, eventName) {
|
|
1715
1775
|
var _context_orderForm_marketingData, _context_orderForm;
|
|
1716
1776
|
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;
|
|
1717
1777
|
},
|
|
1718
|
-
pre_filled: function(context, eventName) {
|
|
1778
|
+
pre_filled: function pre_filled(context, eventName) {
|
|
1719
1779
|
return !!context.preFilled;
|
|
1720
1780
|
},
|
|
1721
|
-
search_term: function(context, eventName) {
|
|
1781
|
+
search_term: function search_term(context, eventName) {
|
|
1722
1782
|
return context.searchTerm || null;
|
|
1723
1783
|
},
|
|
1724
|
-
search_found: function(context, eventName) {
|
|
1784
|
+
search_found: function search_found(context, eventName) {
|
|
1725
1785
|
return !!context.searchFound;
|
|
1726
1786
|
},
|
|
1727
|
-
search_quantity: function(context, eventName) {
|
|
1787
|
+
search_quantity: function search_quantity(context, eventName) {
|
|
1728
1788
|
return context.searchQuantity || 0;
|
|
1729
1789
|
},
|
|
1730
|
-
promotion_name: function(context, eventName) {
|
|
1790
|
+
promotion_name: function promotion_name(context, eventName) {
|
|
1731
1791
|
return context.promotionName || null;
|
|
1732
1792
|
},
|
|
1733
|
-
creative_name: function(context, eventName) {
|
|
1793
|
+
creative_name: function creative_name(context, eventName) {
|
|
1734
1794
|
return context.creativeName || null;
|
|
1735
1795
|
},
|
|
1736
|
-
creative_slot: function(context, eventName) {
|
|
1796
|
+
creative_slot: function creative_slot(context, eventName) {
|
|
1737
1797
|
return context.creativeSlot || null;
|
|
1738
1798
|
},
|
|
1739
|
-
zipcode: function(context, eventName) {
|
|
1799
|
+
zipcode: function zipcode(context, eventName) {
|
|
1740
1800
|
return context.zipCode || null;
|
|
1741
1801
|
},
|
|
1742
|
-
size: function(context, eventName) {
|
|
1802
|
+
size: function size(context, eventName) {
|
|
1743
1803
|
return context.size || null;
|
|
1744
1804
|
},
|
|
1745
|
-
item_ref: function(context, eventName) {
|
|
1805
|
+
item_ref: function item_ref(context, eventName) {
|
|
1746
1806
|
return context.itemRef || null;
|
|
1747
1807
|
},
|
|
1748
|
-
flag_pickup: function(context, eventName) {
|
|
1808
|
+
flag_pickup: function flag_pickup(context, eventName) {
|
|
1749
1809
|
var _orderForm_shippingData;
|
|
1750
1810
|
var orderForm = context.orderForm;
|
|
1751
1811
|
if (!orderForm) return null;
|
|
@@ -1758,7 +1818,7 @@ var AzzasTracker = function() {
|
|
|
1758
1818
|
});
|
|
1759
1819
|
return hasPickup;
|
|
1760
1820
|
},
|
|
1761
|
-
shippings: function(context, eventName) {
|
|
1821
|
+
shippings: function shippings(context, eventName) {
|
|
1762
1822
|
var orderForm = context.orderForm;
|
|
1763
1823
|
if (!orderForm) return null;
|
|
1764
1824
|
var groupShipping = {};
|
|
@@ -1822,7 +1882,7 @@ var AzzasTracker = function() {
|
|
|
1822
1882
|
});
|
|
1823
1883
|
return shippings || null;
|
|
1824
1884
|
},
|
|
1825
|
-
shipping: function(context, eventName) {
|
|
1885
|
+
shipping: function shipping(context, eventName) {
|
|
1826
1886
|
var _ref;
|
|
1827
1887
|
var _context_orderForm_shippingData, _context_orderForm;
|
|
1828
1888
|
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 : [];
|
|
@@ -1835,26 +1895,46 @@ var AzzasTracker = function() {
|
|
|
1835
1895
|
return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
|
|
1836
1896
|
}, 0);
|
|
1837
1897
|
},
|
|
1838
|
-
shipping_tier: function(context, eventName) {
|
|
1898
|
+
shipping_tier: function shipping_tier(context, eventName) {
|
|
1839
1899
|
var _ref;
|
|
1840
|
-
var _context_orderForm_shippingData, _context_orderForm
|
|
1900
|
+
var _context_orderForm_shippingData, _context_orderForm;
|
|
1841
1901
|
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 : [];
|
|
1842
|
-
var
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1902
|
+
var selectedSlas = logistics.map(function(item) {
|
|
1903
|
+
var _item_slas;
|
|
1904
|
+
if (!item.selectedSla) return null;
|
|
1905
|
+
return ((_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
1906
|
+
return sla.id === item.selectedSla;
|
|
1907
|
+
})) || null;
|
|
1908
|
+
}).filter(Boolean);
|
|
1909
|
+
if (selectedSlas.length === 0) return null;
|
|
1910
|
+
var uniqueTiers = Array.from(new Map(selectedSlas.map(function(sla) {
|
|
1911
|
+
var _sla_pickupStoreInfo;
|
|
1912
|
+
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 || "");
|
|
1913
|
+
return [
|
|
1914
|
+
key,
|
|
1915
|
+
sla
|
|
1916
|
+
];
|
|
1917
|
+
})).values());
|
|
1918
|
+
var sortedTiers = uniqueTiers.sort(function(a, b) {
|
|
1919
|
+
var _a_pickupStoreInfo, _b_pickupStoreInfo;
|
|
1920
|
+
var aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
1921
|
+
var bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
1922
|
+
if (aOrder !== bOrder) return aOrder - bOrder;
|
|
1923
|
+
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 || "";
|
|
1924
|
+
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 || "";
|
|
1925
|
+
return aLabel.localeCompare(bLabel, "pt-BR");
|
|
1848
1926
|
});
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1927
|
+
var shippingTier = sortedTiers.map(function(sla) {
|
|
1928
|
+
var _sla_pickupStoreInfo;
|
|
1929
|
+
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;
|
|
1930
|
+
}).filter(Boolean).join(", ");
|
|
1931
|
+
return shippingTier || null;
|
|
1852
1932
|
},
|
|
1853
|
-
transaction_id: function(context, eventName) {
|
|
1933
|
+
transaction_id: function transaction_id(context, eventName) {
|
|
1854
1934
|
var _context_orderForm_orderGroup, _context_orderForm;
|
|
1855
1935
|
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;
|
|
1856
1936
|
},
|
|
1857
|
-
available_grid: function(context, eventName) {
|
|
1937
|
+
available_grid: function available_grid(context, eventName) {
|
|
1858
1938
|
return context.availableGrid || null;
|
|
1859
1939
|
}
|
|
1860
1940
|
};
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@azzas/azzas-tracker-web",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "./dist/mod.cjs",
|
|
6
|
-
"module": "./dist/mod.js",
|
|
7
|
-
"types": "./dist/mod.d.ts",
|
|
8
|
-
"unpkg": "./dist/mod.global.js",
|
|
9
|
-
"jsdelivr": "./dist/mod.global.js",
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"import": "./dist/mod.js",
|
|
13
|
-
"require": "./dist/mod.cjs",
|
|
14
|
-
"default": "./dist/legacy/mod.cjs"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"files": [
|
|
18
|
-
"dist"
|
|
19
|
-
],
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "tsup",
|
|
22
|
-
"prepublishOnly": "npm run build",
|
|
23
|
-
"release:homolog": "npm run build && npm version prepatch --preid=beta && npm publish --tag beta --access public",
|
|
24
|
-
"release:prod": "npm run build && npm version patch && npm publish --access public",
|
|
25
|
-
"pack:copy": "VERSION=$(npm pkg get version | tr -d '\"') && npm pack && tar -xzf azzas-azzas-tracker-web-$VERSION.tgz",
|
|
26
|
-
"start:deno": "deno run --allow-net --allow-read https://deno.land/std@0.207.0/http/file_server.ts ./package",
|
|
27
|
-
"dev:deno": "npm run build && npm run pack:copy && npm run start:deno",
|
|
28
|
-
"dev:npm": "npm run build -- --watch"
|
|
29
|
-
},
|
|
30
|
-
"publishConfig": {
|
|
31
|
-
"access": "public"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@swc/core": "^1.15.7",
|
|
35
|
-
"tsup": "^8.5.0",
|
|
36
|
-
"typescript": "^5.9.2"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@azzas/azzas-tracker-web",
|
|
3
|
+
"version": "1.0.72",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/mod.cjs",
|
|
6
|
+
"module": "./dist/mod.js",
|
|
7
|
+
"types": "./dist/mod.d.ts",
|
|
8
|
+
"unpkg": "./dist/mod.global.js",
|
|
9
|
+
"jsdelivr": "./dist/mod.global.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/mod.js",
|
|
13
|
+
"require": "./dist/mod.cjs",
|
|
14
|
+
"default": "./dist/legacy/mod.cjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsup",
|
|
22
|
+
"prepublishOnly": "npm run build",
|
|
23
|
+
"release:homolog": "npm run build && npm version prepatch --preid=beta && npm publish --tag beta --access public",
|
|
24
|
+
"release:prod": "npm run build && npm version patch && npm publish --access public",
|
|
25
|
+
"pack:copy": "VERSION=$(npm pkg get version | tr -d '\"') && npm pack && tar -xzf azzas-azzas-tracker-web-$VERSION.tgz",
|
|
26
|
+
"start:deno": "deno run --allow-net --allow-read https://deno.land/std@0.207.0/http/file_server.ts ./package",
|
|
27
|
+
"dev:deno": "npm run build && npm run pack:copy && npm run start:deno",
|
|
28
|
+
"dev:npm": "npm run build -- --watch"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@swc/core": "^1.15.7",
|
|
35
|
+
"tsup": "^8.5.0",
|
|
36
|
+
"typescript": "^5.9.2"
|
|
37
|
+
}
|
|
38
|
+
}
|