@azzas/azzas-tracker-web 2.0.0-preview.15 → 2.0.0-preview.17
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 +43 -30
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.global.js +43 -30
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +43 -30
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +52 -30
- package/package.json +1 -1
package/dist/mod.vtex.global.js
CHANGED
|
@@ -2464,7 +2464,7 @@ var AzzasTracker = function() {
|
|
|
2464
2464
|
return context.meta.search_term || null;
|
|
2465
2465
|
},
|
|
2466
2466
|
search_found: function(context) {
|
|
2467
|
-
return context.meta.search_found ||
|
|
2467
|
+
return context.meta.search_found || false;
|
|
2468
2468
|
},
|
|
2469
2469
|
search_quantity: function(context) {
|
|
2470
2470
|
return context.meta.search_quantity || 0;
|
|
@@ -2909,6 +2909,12 @@ var AzzasTracker = function() {
|
|
|
2909
2909
|
}
|
|
2910
2910
|
});
|
|
2911
2911
|
// src/params/adapters/orderForm/utils.ts
|
|
2912
|
+
var getOrderFormItems = function(orderForm) {
|
|
2913
|
+
var idSelected = orderForm === null || orderForm === void 0 ? void 0 : orderForm.selected;
|
|
2914
|
+
return idSelected ? orderForm.items.filter(function(item) {
|
|
2915
|
+
return item.id === idSelected;
|
|
2916
|
+
}) : orderForm.items;
|
|
2917
|
+
};
|
|
2912
2918
|
var getItemCategory6 = function(item) {
|
|
2913
2919
|
var _text_match;
|
|
2914
2920
|
var categories = item === null || item === void 0 ? void 0 : item.productCategories;
|
|
@@ -2929,11 +2935,27 @@ var AzzasTracker = function() {
|
|
|
2929
2935
|
var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
|
|
2930
2936
|
return capitalize(deepest);
|
|
2931
2937
|
};
|
|
2932
|
-
var
|
|
2933
|
-
var
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2938
|
+
var getPaymentType2 = function(context) {
|
|
2939
|
+
var _context_orderForm_paymentData, _context_orderForm_paymentData1, _system_name;
|
|
2940
|
+
if (context.payment_type) return context.payment_type;
|
|
2941
|
+
if (!context.orderForm) return null;
|
|
2942
|
+
var payments = ((_context_orderForm_paymentData = context.orderForm.paymentData) === null || _context_orderForm_paymentData === void 0 ? void 0 : _context_orderForm_paymentData.payments) || [];
|
|
2943
|
+
var systems = ((_context_orderForm_paymentData1 = context.orderForm.paymentData) === null || _context_orderForm_paymentData1 === void 0 ? void 0 : _context_orderForm_paymentData1.paymentSystems) || [];
|
|
2944
|
+
if (!payments.length || !systems.length) return null;
|
|
2945
|
+
var selectedPayment = payments.find(function(p) {
|
|
2946
|
+
return p === null || p === void 0 ? void 0 : p.paymentSystem;
|
|
2947
|
+
}) || payments[0];
|
|
2948
|
+
var id = String((selectedPayment === null || selectedPayment === void 0 ? void 0 : selectedPayment.paymentSystem) || "").trim();
|
|
2949
|
+
if (!id) return null;
|
|
2950
|
+
var system = systems.find(function(s) {
|
|
2951
|
+
return String(s.id) === id;
|
|
2952
|
+
});
|
|
2953
|
+
var name = (system === null || system === void 0 ? void 0 : (_system_name = system.name) === null || _system_name === void 0 ? void 0 : _system_name.toLowerCase()) || "";
|
|
2954
|
+
var match = paymentTypeMap.find(function(param) {
|
|
2955
|
+
var _param = _sliced_to_array(param, 1), key = _param[0];
|
|
2956
|
+
return name.includes(key);
|
|
2957
|
+
});
|
|
2958
|
+
return match ? match[1] : null;
|
|
2937
2959
|
};
|
|
2938
2960
|
// src/params/adapters/orderForm/index.ts
|
|
2939
2961
|
var orderFormAdapter = _object_spread_props(_object_spread({}, metaAdapter), {
|
|
@@ -2941,27 +2963,27 @@ var AzzasTracker = function() {
|
|
|
2941
2963
|
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2942
2964
|
if ((context === null || context === void 0 ? void 0 : context.orderForm) && (context === null || context === void 0 ? void 0 : context.orderForm.items)) {
|
|
2943
2965
|
return getOrderFormItems(context.orderForm).map(function(item, index) {
|
|
2944
|
-
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5,
|
|
2966
|
+
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _getItemCategory6, _getItemCategory24, _ref6, _ref7, _item_detailUrl, _resizeVtexImage2, _ref8, _ref9;
|
|
2945
2967
|
var _context_orderForm, _item_additionalInfo, _item_skuName_split__split_pop, _item_skuName_split_, _item_skuName, _item_skuName_split_1, _item_skuName1, _context_orderForm1;
|
|
2946
2968
|
return {
|
|
2947
2969
|
quantity: (_ref = item === null || item === void 0 ? void 0 : item.quantity) !== null && _ref !== void 0 ? _ref : 1,
|
|
2948
|
-
index: (_ref1 =
|
|
2949
|
-
item_brand: (
|
|
2950
|
-
item_name: (
|
|
2970
|
+
index: (_ref1 = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.index) !== null && _ref1 !== void 0 ? _ref1 : index + 1,
|
|
2971
|
+
item_brand: (_ref2 = (_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) !== null && _ref2 !== void 0 ? _ref2 : null,
|
|
2972
|
+
item_name: (_ref3 = item === null || item === void 0 ? void 0 : item.name.replace(item === null || item === void 0 ? void 0 : item.skuName, "").trim()) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
2951
2973
|
price: (item === null || item === void 0 ? void 0 : item.price) / 100,
|
|
2952
2974
|
discount: ((item === null || item === void 0 ? void 0 : item.listPrice) - (item === null || item === void 0 ? void 0 : item.sellingPrice)) / 100,
|
|
2953
|
-
item_variant: (
|
|
2954
|
-
item_variant2: (
|
|
2975
|
+
item_variant: (_ref4 = 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 && _ref4 !== void 0 ? _ref4 : null,
|
|
2976
|
+
item_variant2: (_ref5 = 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 && _ref5 !== void 0 ? _ref5 : null,
|
|
2955
2977
|
item_shipping_tier: getItemShippingTier2(context.orderForm, item),
|
|
2956
2978
|
item_ref: (item === null || item === void 0 ? void 0 : item.productRefId) || (item === null || item === void 0 ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
|
|
2957
2979
|
item_category: (_getItemCategory6 = getItemCategory6(item)) !== null && _getItemCategory6 !== void 0 ? _getItemCategory6 : null,
|
|
2958
2980
|
item_category2: (_getItemCategory24 = getItemCategory24(item)) !== null && _getItemCategory24 !== void 0 ? _getItemCategory24 : null,
|
|
2959
|
-
item_id: (
|
|
2960
|
-
item_sku: (
|
|
2981
|
+
item_id: (_ref6 = item === null || item === void 0 ? void 0 : item.productId) !== null && _ref6 !== void 0 ? _ref6 : null,
|
|
2982
|
+
item_sku: (_ref7 = item === null || item === void 0 ? void 0 : item.id) !== null && _ref7 !== void 0 ? _ref7 : null,
|
|
2961
2983
|
item_url: (_item_detailUrl = item.detailUrl) !== null && _item_detailUrl !== void 0 ? _item_detailUrl : null,
|
|
2962
2984
|
image_url: (_resizeVtexImage2 = resizeVtexImage2(item.imageUrl)) !== null && _resizeVtexImage2 !== void 0 ? _resizeVtexImage2 : null,
|
|
2963
|
-
seller_id: (
|
|
2964
|
-
item_list_name: (
|
|
2985
|
+
seller_id: (_ref8 = item === null || item === void 0 ? void 0 : item.seller) !== null && _ref8 !== void 0 ? _ref8 : null,
|
|
2986
|
+
item_list_name: (_ref9 = context === null || context === void 0 ? void 0 : (_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.item_list_name) !== null && _ref9 !== void 0 ? _ref9 : null
|
|
2965
2987
|
};
|
|
2966
2988
|
});
|
|
2967
2989
|
}
|
|
@@ -2999,7 +3021,7 @@ var AzzasTracker = function() {
|
|
|
2999
3021
|
return sum + price;
|
|
3000
3022
|
}, 0);
|
|
3001
3023
|
},
|
|
3002
|
-
payment_type:
|
|
3024
|
+
payment_type: getPaymentType2,
|
|
3003
3025
|
total_discount: function(context) {
|
|
3004
3026
|
var _context_orderForm, _context_orderForm1;
|
|
3005
3027
|
if (context === null || context === void 0 ? void 0 : context.total_discount) return context.total_discount;
|
|
@@ -3024,19 +3046,6 @@ var AzzasTracker = function() {
|
|
|
3024
3046
|
}, 0) / 100 || 0;
|
|
3025
3047
|
return subtotal;
|
|
3026
3048
|
},
|
|
3027
|
-
coupon_message: function(context) {
|
|
3028
|
-
var _context_orderForm;
|
|
3029
|
-
if (context.couponMessage) return context.couponMessage;
|
|
3030
|
-
var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
|
|
3031
|
-
if (messages.length === 0) return null;
|
|
3032
|
-
var couponMessages = messages.filter(function(msg) {
|
|
3033
|
-
return msg.text.toLowerCase().includes("cupom");
|
|
3034
|
-
});
|
|
3035
|
-
if (couponMessages.length === 0) return null;
|
|
3036
|
-
return couponMessages.map(function(msg) {
|
|
3037
|
-
return msg.text;
|
|
3038
|
-
}).join(" | ");
|
|
3039
|
-
},
|
|
3040
3049
|
zipcode: function(context) {
|
|
3041
3050
|
var _context_meta_zipcode;
|
|
3042
3051
|
return (_context_meta_zipcode = context.meta.zipcode) !== null && _context_meta_zipcode !== void 0 ? _context_meta_zipcode : null;
|
|
@@ -3130,6 +3139,19 @@ var AzzasTracker = function() {
|
|
|
3130
3139
|
var _context_orderForm_orderGroup, _context_orderForm;
|
|
3131
3140
|
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;
|
|
3132
3141
|
},
|
|
3142
|
+
coupon_message: function(context) {
|
|
3143
|
+
var _context_orderForm;
|
|
3144
|
+
if (context.couponMessage) return context.couponMessage;
|
|
3145
|
+
var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
|
|
3146
|
+
if (messages.length === 0) return "C\xF3digo de desconto aplicado com sucesso";
|
|
3147
|
+
var couponMessages = messages.filter(function(msg) {
|
|
3148
|
+
return msg.text.toLowerCase().includes("cupom");
|
|
3149
|
+
});
|
|
3150
|
+
if (couponMessages.length === 0) return "C\xF3digo de desconto aplicado com sucesso";
|
|
3151
|
+
return couponMessages.map(function(msg) {
|
|
3152
|
+
return msg.text;
|
|
3153
|
+
}).join(" | ");
|
|
3154
|
+
},
|
|
3133
3155
|
coupon: function(context) {
|
|
3134
3156
|
var _context_orderForm_marketingData, _context_orderForm;
|
|
3135
3157
|
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;
|