@azzas/azzas-tracker-web 1.0.98 → 1.0.99-preview.0
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 +618 -93
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.global.js +618 -93
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +618 -93
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +735 -116
- package/package.json +1 -1
package/dist/mod.vtex.global.js
CHANGED
|
@@ -242,7 +242,7 @@ function _ts_generator(thisArg, body) {
|
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
var AzzasTracker = function() {
|
|
245
|
-
var pushToDataLayer = // src/
|
|
245
|
+
var pushToDataLayer = // src/pushToDatalayer.ts
|
|
246
246
|
function pushToDataLayer(event, context) {
|
|
247
247
|
var targetWindow = context.window || (typeof window !== "undefined" ? window : null);
|
|
248
248
|
if (!targetWindow) return;
|
|
@@ -256,86 +256,16 @@ var AzzasTracker = function() {
|
|
|
256
256
|
ecommerce: null
|
|
257
257
|
});
|
|
258
258
|
targetWindow.dataLayer.push({
|
|
259
|
-
event: event,
|
|
259
|
+
event: event.toLowerCase(),
|
|
260
260
|
ecommerce: payload
|
|
261
261
|
});
|
|
262
262
|
} else {
|
|
263
263
|
targetWindow.dataLayer.push(Object.assign({
|
|
264
|
-
event: event
|
|
264
|
+
event: event.toLowerCase()
|
|
265
265
|
}, payload));
|
|
266
266
|
}
|
|
267
267
|
};
|
|
268
|
-
var
|
|
269
|
-
function dataTrackingLog(data, color) {
|
|
270
|
-
console.log("%c[DT] EVENTO DISPARADO:%c ", "background: ".concat(color, "; color: white; font-weight: bold; padding: 2px 4px; border-radius: 3px;"), "color: #fff;", data || "");
|
|
271
|
-
};
|
|
272
|
-
var pushToDito = // src/adapters/dito.ts
|
|
273
|
-
function pushToDito(event, ecomm) {
|
|
274
|
-
dataTrackingLog({
|
|
275
|
-
id: event,
|
|
276
|
-
custom_data: ecomm
|
|
277
|
-
}, "#00c851");
|
|
278
|
-
};
|
|
279
|
-
var dispatchTrackEvent = function dispatchTrackEvent(eventName, data) {
|
|
280
|
-
return _async_to_generator(function() {
|
|
281
|
-
var eventConfig;
|
|
282
|
-
return _ts_generator(this, function(_state) {
|
|
283
|
-
switch(_state.label){
|
|
284
|
-
case 0:
|
|
285
|
-
eventConfig = EVENTS[eventName];
|
|
286
|
-
if (!eventConfig) return [
|
|
287
|
-
2
|
|
288
|
-
];
|
|
289
|
-
return [
|
|
290
|
-
4,
|
|
291
|
-
Promise.allSettled(eventConfig.destinations.map(function(dest) {
|
|
292
|
-
return _async_to_generator(function() {
|
|
293
|
-
var err;
|
|
294
|
-
return _ts_generator(this, function(_state) {
|
|
295
|
-
switch(_state.label){
|
|
296
|
-
case 0:
|
|
297
|
-
_state.trys.push([
|
|
298
|
-
0,
|
|
299
|
-
2,
|
|
300
|
-
,
|
|
301
|
-
3
|
|
302
|
-
]);
|
|
303
|
-
return [
|
|
304
|
-
4,
|
|
305
|
-
adapters[dest](eventName.toLowerCase(), data)
|
|
306
|
-
];
|
|
307
|
-
case 1:
|
|
308
|
-
_state.sent();
|
|
309
|
-
return [
|
|
310
|
-
3,
|
|
311
|
-
3
|
|
312
|
-
];
|
|
313
|
-
case 2:
|
|
314
|
-
err = _state.sent();
|
|
315
|
-
console.error("[DT] Failed to send ".concat(eventName, " to ").concat(dest, ":"), err);
|
|
316
|
-
return [
|
|
317
|
-
3,
|
|
318
|
-
3
|
|
319
|
-
];
|
|
320
|
-
case 3:
|
|
321
|
-
return [
|
|
322
|
-
2
|
|
323
|
-
];
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
})();
|
|
327
|
-
}))
|
|
328
|
-
];
|
|
329
|
-
case 1:
|
|
330
|
-
_state.sent();
|
|
331
|
-
return [
|
|
332
|
-
2
|
|
333
|
-
];
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
})();
|
|
337
|
-
};
|
|
338
|
-
var getProductDataById = // src/params/utils/index.ts
|
|
268
|
+
var getProductDataById = // src/params/legacy/utils/index.ts
|
|
339
269
|
function getProductDataById(id) {
|
|
340
270
|
return _async_to_generator(function() {
|
|
341
271
|
var response, e;
|
|
@@ -680,20 +610,20 @@ var AzzasTracker = function() {
|
|
|
680
610
|
var uniqueSortedCodes = _to_consumable_array(new Set(brandCodes)).sort();
|
|
681
611
|
return uniqueSortedCodes.length > 0 ? uniqueSortedCodes.join("_") : null;
|
|
682
612
|
};
|
|
683
|
-
var brandFromOrderForm = // src/params/resolvers/brand/fromOrderForm.ts
|
|
613
|
+
var brandFromOrderForm = // src/params/legacy/resolvers/brand/fromOrderForm.ts
|
|
684
614
|
function brandFromOrderForm(context) {
|
|
685
615
|
var _context_orderForm_items;
|
|
686
616
|
if (!context.orderForm && !((_context_orderForm_items = context.orderForm.items) === null || _context_orderForm_items === void 0 ? void 0 : _context_orderForm_items.length)) return null;
|
|
687
617
|
var items = context.orderForm.items;
|
|
688
618
|
return normalizeBrand(items);
|
|
689
619
|
};
|
|
690
|
-
var brandFromItem = // src/params/resolvers/brand/fromItem.ts
|
|
620
|
+
var brandFromItem = // src/params/legacy/resolvers/brand/fromItem.ts
|
|
691
621
|
function brandFromItem(context) {
|
|
692
622
|
var _item_additionalInfo;
|
|
693
623
|
var item = context.item;
|
|
694
624
|
return normalizeBrand((item === null || item === void 0 ? void 0 : (_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) || item.brand || item.item_brand);
|
|
695
625
|
};
|
|
696
|
-
var getBrand = // src/params/brand.ts
|
|
626
|
+
var getBrand = // src/params/legacy/brand.ts
|
|
697
627
|
function getBrand(context, eventName) {
|
|
698
628
|
if (context === null || context === void 0 ? void 0 : context.brand) return normalizeBrand(context.brand) || context.brand || null;
|
|
699
629
|
switch(eventName){
|
|
@@ -894,7 +824,7 @@ var AzzasTracker = function() {
|
|
|
894
824
|
var listName = (_ref = (_ref1 = (_ref2 = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.item_list_name) !== null && _ref2 !== void 0 ? _ref2 : source === null || source === void 0 ? void 0 : source.itemListName) !== null && _ref1 !== void 0 ? _ref1 : source === null || source === void 0 ? void 0 : source.item_list_name) !== null && _ref !== void 0 ? _ref : null;
|
|
895
825
|
saveSelectedItem(productId, listName);
|
|
896
826
|
};
|
|
897
|
-
var itemsFromOrderForm = // src/params/resolvers/items/fromOrderForm.ts
|
|
827
|
+
var itemsFromOrderForm = // src/params/legacy/resolvers/items/fromOrderForm.ts
|
|
898
828
|
function itemsFromOrderForm(context) {
|
|
899
829
|
return _async_to_generator(function() {
|
|
900
830
|
var _context_orderForm, items, cartHistoryMap;
|
|
@@ -948,7 +878,7 @@ var AzzasTracker = function() {
|
|
|
948
878
|
});
|
|
949
879
|
})();
|
|
950
880
|
};
|
|
951
|
-
var itemsFromItem = // src/params/resolvers/items/fromItem.ts
|
|
881
|
+
var itemsFromItem = // src/params/legacy/resolvers/items/fromItem.ts
|
|
952
882
|
function itemsFromItem(context, event) {
|
|
953
883
|
return _async_to_generator(function() {
|
|
954
884
|
var _item_additionalProperty, _item_itemOffered, _item_itemOffered1, _item_additionalInfo, _item_brand, _item_itemOffered_brand, _item_itemOffered2, _item_itemOffered3, _item_name, _item_name1, _item_item_name, _item_itemOffered_isVariantOf_name, _item_itemOffered_isVariantOf, _item_itemOffered4, _split_, _item_itemAttributes, _split_1, _this, item, orderForm, itemListName, resolvedListName, resolvedItemId, _tmp, _tmp1;
|
|
@@ -1004,7 +934,7 @@ var AzzasTracker = function() {
|
|
|
1004
934
|
});
|
|
1005
935
|
})();
|
|
1006
936
|
};
|
|
1007
|
-
var itemsFromList = // src/params/resolvers/items/fromList.ts
|
|
937
|
+
var itemsFromList = // src/params/legacy/resolvers/items/fromList.ts
|
|
1008
938
|
function itemsFromList(context) {
|
|
1009
939
|
return _async_to_generator(function() {
|
|
1010
940
|
return _ts_generator(this, function(_state) {
|
|
@@ -1033,7 +963,7 @@ var AzzasTracker = function() {
|
|
|
1033
963
|
});
|
|
1034
964
|
})();
|
|
1035
965
|
};
|
|
1036
|
-
var itemsFromPDP = // src/params/resolvers/items/fromPdp.ts
|
|
966
|
+
var itemsFromPDP = // src/params/legacy/resolvers/items/fromPdp.ts
|
|
1037
967
|
function itemsFromPDP(context, event) {
|
|
1038
968
|
return _async_to_generator(function() {
|
|
1039
969
|
var _item_additionalProperty, _item_name, _item_category_split_, _item_category, item, value, brand, resolvedListName, resolvedItemId;
|
|
@@ -1076,7 +1006,7 @@ var AzzasTracker = function() {
|
|
|
1076
1006
|
});
|
|
1077
1007
|
})();
|
|
1078
1008
|
};
|
|
1079
|
-
var itemsFromBanner = // src/params/resolvers/items/fromBanner.ts
|
|
1009
|
+
var itemsFromBanner = // src/params/legacy/resolvers/items/fromBanner.ts
|
|
1080
1010
|
function itemsFromBanner(context) {
|
|
1081
1011
|
return _async_to_generator(function() {
|
|
1082
1012
|
var _item_name, isUrlFromPDP, product, item;
|
|
@@ -1114,7 +1044,7 @@ var AzzasTracker = function() {
|
|
|
1114
1044
|
});
|
|
1115
1045
|
})();
|
|
1116
1046
|
};
|
|
1117
|
-
var getItems = // src/params/items.ts
|
|
1047
|
+
var getItems = // src/params/legacy/items.ts
|
|
1118
1048
|
function getItems(context, eventName) {
|
|
1119
1049
|
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
1120
1050
|
switch(eventName){
|
|
@@ -1147,7 +1077,7 @@ var AzzasTracker = function() {
|
|
|
1147
1077
|
return null;
|
|
1148
1078
|
}
|
|
1149
1079
|
};
|
|
1150
|
-
var paymentTypeFromOrderForm = // src/params/resolvers/paymentType/fromOrderForm.ts
|
|
1080
|
+
var paymentTypeFromOrderForm = // src/params/legacy/resolvers/paymentType/fromOrderForm.ts
|
|
1151
1081
|
function paymentTypeFromOrderForm(context) {
|
|
1152
1082
|
var _context_orderForm_paymentData, _context_orderForm_paymentData1, _system_name;
|
|
1153
1083
|
if (context.payment_type) return context.payment_type;
|
|
@@ -1170,7 +1100,7 @@ var AzzasTracker = function() {
|
|
|
1170
1100
|
});
|
|
1171
1101
|
return match ? match[1] : null;
|
|
1172
1102
|
};
|
|
1173
|
-
var paymentTypeFromOrderGroup = // src/params/resolvers/paymentType/fromOrderGroup.ts
|
|
1103
|
+
var paymentTypeFromOrderGroup = // src/params/legacy/resolvers/paymentType/fromOrderGroup.ts
|
|
1174
1104
|
function paymentTypeFromOrderGroup(context) {
|
|
1175
1105
|
var _context_orderForm_paymentData, _transactions_, _payments__paymentSystemName, _payments_;
|
|
1176
1106
|
if (!context.orderForm) return null;
|
|
@@ -1185,7 +1115,7 @@ var AzzasTracker = function() {
|
|
|
1185
1115
|
});
|
|
1186
1116
|
return match ? match[1] : null;
|
|
1187
1117
|
};
|
|
1188
|
-
var getPaymentType = // src/params/paymentType.ts
|
|
1118
|
+
var getPaymentType = // src/params/legacy/paymentType.ts
|
|
1189
1119
|
function getPaymentType(context, eventName) {
|
|
1190
1120
|
if (context === null || context === void 0 ? void 0 : context.paymentType) return context.paymentType;
|
|
1191
1121
|
switch(eventName){
|
|
@@ -1375,10 +1305,13 @@ var AzzasTracker = function() {
|
|
|
1375
1305
|
});
|
|
1376
1306
|
})();
|
|
1377
1307
|
};
|
|
1378
|
-
var
|
|
1379
|
-
|
|
1308
|
+
var resizeVtexImage3 = function resizeVtexImage3(url) {
|
|
1309
|
+
var width = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 500, height = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 500;
|
|
1310
|
+
return url === null || url === void 0 ? void 0 : url.replace(/(\/arquivos\/ids\/\d+)-\d+-\d+\//, "$1-".concat(width, "-").concat(height, "/"));
|
|
1311
|
+
};
|
|
1312
|
+
var getParameters = function getParameters(_0) {
|
|
1380
1313
|
return _async_to_generator(function() {
|
|
1381
|
-
var context, eventName, eventConfig,
|
|
1314
|
+
var context, eventName, _adapters_source, eventConfig, source, sourceAdapters, entries;
|
|
1382
1315
|
var _arguments = arguments;
|
|
1383
1316
|
return _ts_generator(this, function(_state) {
|
|
1384
1317
|
switch(_state.label){
|
|
@@ -1388,18 +1321,19 @@ var AzzasTracker = function() {
|
|
|
1388
1321
|
if (!eventConfig) return [
|
|
1389
1322
|
2
|
|
1390
1323
|
];
|
|
1391
|
-
|
|
1324
|
+
source = context.adapter;
|
|
1325
|
+
sourceAdapters = (_adapters_source = adapters[source]) !== null && _adapters_source !== void 0 ? _adapters_source : paramGetters;
|
|
1392
1326
|
return [
|
|
1393
1327
|
4,
|
|
1394
1328
|
Promise.all(eventConfig.requiredParams.map(function(param) {
|
|
1395
1329
|
return _async_to_generator(function() {
|
|
1396
|
-
var
|
|
1330
|
+
var adapter, _tmp;
|
|
1397
1331
|
return _ts_generator(this, function(_state) {
|
|
1398
1332
|
switch(_state.label){
|
|
1399
1333
|
case 0:
|
|
1400
|
-
|
|
1401
|
-
if (typeof
|
|
1402
|
-
console.error(
|
|
1334
|
+
adapter = sourceAdapters[param];
|
|
1335
|
+
if (typeof adapter !== "function") {
|
|
1336
|
+
console.error('[DT] Missing adapter "'.concat(param, '" for source "').concat(source !== null && source !== void 0 ? source : "default", '"'));
|
|
1403
1337
|
return [
|
|
1404
1338
|
2,
|
|
1405
1339
|
[
|
|
@@ -1413,7 +1347,7 @@ var AzzasTracker = function() {
|
|
|
1413
1347
|
];
|
|
1414
1348
|
return [
|
|
1415
1349
|
4,
|
|
1416
|
-
|
|
1350
|
+
adapter(context, eventName)
|
|
1417
1351
|
];
|
|
1418
1352
|
case 1:
|
|
1419
1353
|
return [
|
|
@@ -1428,12 +1362,10 @@ var AzzasTracker = function() {
|
|
|
1428
1362
|
}))
|
|
1429
1363
|
];
|
|
1430
1364
|
case 1:
|
|
1431
|
-
|
|
1432
|
-
_state.sent()
|
|
1433
|
-
]);
|
|
1365
|
+
entries = _state.sent();
|
|
1434
1366
|
return [
|
|
1435
1367
|
2,
|
|
1436
|
-
|
|
1368
|
+
Object.fromEntries(entries)
|
|
1437
1369
|
];
|
|
1438
1370
|
}
|
|
1439
1371
|
});
|
|
@@ -1464,7 +1396,7 @@ var AzzasTracker = function() {
|
|
|
1464
1396
|
parameters = _state.sent();
|
|
1465
1397
|
return [
|
|
1466
1398
|
4,
|
|
1467
|
-
|
|
1399
|
+
pushToDataLayer(event, Object.assign({}, parameters, {
|
|
1468
1400
|
window: context.window
|
|
1469
1401
|
}))
|
|
1470
1402
|
];
|
|
@@ -1963,6 +1895,17 @@ var AzzasTracker = function() {
|
|
|
1963
1895
|
]
|
|
1964
1896
|
}
|
|
1965
1897
|
};
|
|
1898
|
+
var BRAND_CODES = {
|
|
1899
|
+
farm: "farmrio",
|
|
1900
|
+
"farm etc": "farmetc",
|
|
1901
|
+
"farm rio": "farmrio"
|
|
1902
|
+
};
|
|
1903
|
+
// src/params/legacy/utils/itemListAttribution.ts
|
|
1904
|
+
var LAST_SELECTED_ITEM_KEY = "last_selected_item";
|
|
1905
|
+
var STORAGE_VIEWED = "last_viewed_item";
|
|
1906
|
+
var CART_LIST_HISTORY_KEY = "cart_list_history";
|
|
1907
|
+
var DAY_IN_MS = 24 * 60 * 60 * 1e3;
|
|
1908
|
+
// src/core/utils.ts
|
|
1966
1909
|
var paymentTypeMap = [
|
|
1967
1910
|
[
|
|
1968
1911
|
"vale",
|
|
@@ -2061,27 +2004,13 @@ var AzzasTracker = function() {
|
|
|
2061
2004
|
});
|
|
2062
2005
|
})();
|
|
2063
2006
|
};
|
|
2064
|
-
// src/
|
|
2065
|
-
var adapters = {
|
|
2066
|
-
DataLayer: pushToDataLayer,
|
|
2067
|
-
Dito: pushToDito
|
|
2068
|
-
};
|
|
2069
|
-
var BRAND_CODES = {
|
|
2070
|
-
farm: "farmrio",
|
|
2071
|
-
"farm etc": "farmetc",
|
|
2072
|
-
"farm rio": "farmrio"
|
|
2073
|
-
};
|
|
2074
|
-
// src/params/utils/itemListAttribution.ts
|
|
2075
|
-
var LAST_SELECTED_ITEM_KEY = "last_selected_item";
|
|
2076
|
-
var STORAGE_VIEWED = "last_viewed_item";
|
|
2077
|
-
var CART_LIST_HISTORY_KEY = "cart_list_history";
|
|
2078
|
-
var DAY_IN_MS = 24 * 60 * 60 * 1e3;
|
|
2079
|
-
// src/params/index.ts
|
|
2007
|
+
// src/params/legacy/index.ts
|
|
2080
2008
|
var paramGetters = {
|
|
2081
2009
|
brand: getBrand,
|
|
2082
2010
|
items: getItems,
|
|
2083
2011
|
payment_type: getPaymentType,
|
|
2084
2012
|
user_info: getUserInfo,
|
|
2013
|
+
// global
|
|
2085
2014
|
content_type: function(context, eventName) {
|
|
2086
2015
|
if (context === null || context === void 0 ? void 0 : context.content_type) return context.content_type;
|
|
2087
2016
|
return "regiao".concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
|
|
@@ -2333,6 +2262,696 @@ var AzzasTracker = function() {
|
|
|
2333
2262
|
return context.type || null;
|
|
2334
2263
|
}
|
|
2335
2264
|
};
|
|
2265
|
+
// src/params/adapters/deco/index.ts
|
|
2266
|
+
var IN_STOCK_SCHEMA = "https://schema.org/InStock";
|
|
2267
|
+
var LIST_PRICE_SCHEMA = "https://schema.org/ListPrice";
|
|
2268
|
+
var decoAdapter = {
|
|
2269
|
+
brand: function(context, eventName) {
|
|
2270
|
+
if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
|
|
2271
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2272
|
+
var _context_products__brand;
|
|
2273
|
+
return (_context_products__brand = context.products[0].brand) === null || _context_products__brand === void 0 ? void 0 : _context_products__brand.name;
|
|
2274
|
+
}
|
|
2275
|
+
return null;
|
|
2276
|
+
},
|
|
2277
|
+
line_items: function(context, eventName) {
|
|
2278
|
+
if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
|
|
2279
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2280
|
+
return context.products.map(function(item) {
|
|
2281
|
+
return item === null || item === void 0 ? void 0 : item.inProductGroupWithID;
|
|
2282
|
+
}).filter(function(id) {
|
|
2283
|
+
return Boolean(id);
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
return null;
|
|
2287
|
+
},
|
|
2288
|
+
currency: function(context, eventName) {
|
|
2289
|
+
if (context === null || context === void 0 ? void 0 : context.currency) return context.currency;
|
|
2290
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2291
|
+
var _context_products__offers, _context_products;
|
|
2292
|
+
return ((_context_products = context.products) === null || _context_products === void 0 ? void 0 : (_context_products__offers = _context_products[0].offers) === null || _context_products__offers === void 0 ? void 0 : _context_products__offers.priceCurrency) || null;
|
|
2293
|
+
}
|
|
2294
|
+
return null;
|
|
2295
|
+
},
|
|
2296
|
+
value: function(context, eventName) {
|
|
2297
|
+
if (context === null || context === void 0 ? void 0 : context.value) return context.value;
|
|
2298
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2299
|
+
return context.products.map(function(item) {
|
|
2300
|
+
var _item_offers;
|
|
2301
|
+
return (_item_offers = item.offers) === null || _item_offers === void 0 ? void 0 : _item_offers.lowPrice;
|
|
2302
|
+
}).filter(function(price) {
|
|
2303
|
+
return price !== void 0;
|
|
2304
|
+
}).reduce(function(sum, price) {
|
|
2305
|
+
return sum + price;
|
|
2306
|
+
}, 0);
|
|
2307
|
+
}
|
|
2308
|
+
return null;
|
|
2309
|
+
},
|
|
2310
|
+
available_grid: function(context, eventName) {
|
|
2311
|
+
if (context === null || context === void 0 ? void 0 : context.available_grid) return context.available_grid;
|
|
2312
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2313
|
+
var result = context.products.flatMap(function(product) {
|
|
2314
|
+
var _ref;
|
|
2315
|
+
var _product_isVariantOf_hasVariant, _product_isVariantOf;
|
|
2316
|
+
return (_ref = (_product_isVariantOf = product.isVariantOf) === null || _product_isVariantOf === void 0 ? void 0 : (_product_isVariantOf_hasVariant = _product_isVariantOf.hasVariant) === null || _product_isVariantOf_hasVariant === void 0 ? void 0 : _product_isVariantOf_hasVariant.filter(function(variant) {
|
|
2317
|
+
var _variant_offers_offers, _variant_offers;
|
|
2318
|
+
return (_variant_offers = variant.offers) === null || _variant_offers === void 0 ? void 0 : (_variant_offers_offers = _variant_offers.offers) === null || _variant_offers_offers === void 0 ? void 0 : _variant_offers_offers.some(function(o) {
|
|
2319
|
+
return o.availability === IN_STOCK_SCHEMA;
|
|
2320
|
+
});
|
|
2321
|
+
}).map(function(variant) {
|
|
2322
|
+
return variant.name;
|
|
2323
|
+
}).filter(function(name) {
|
|
2324
|
+
return Boolean(name);
|
|
2325
|
+
})) !== null && _ref !== void 0 ? _ref : [];
|
|
2326
|
+
}).join(",").trim();
|
|
2327
|
+
return result || null;
|
|
2328
|
+
}
|
|
2329
|
+
return null;
|
|
2330
|
+
},
|
|
2331
|
+
items: function(context, eventName) {
|
|
2332
|
+
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2333
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2334
|
+
return context.products.map(function(item) {
|
|
2335
|
+
var _ref, _item_alternateName, _ref1, _ref2, _ref3, _ref4, _ref5, _item_sku, _item_url, _resizeVtexImage2, _ref6;
|
|
2336
|
+
var _item_offers_offers__priceSpecification_find, _item_offers_offers, _item_offers, _item_brand, _item_offers1, _item_offers2, _item_additionalProperty_find, _item_additionalProperty, _item_additionalProperty_find1, _item_additionalProperty1, _item_category_split_pop, _item_category, _item_isVariantOf, _item_image, _item_offers_offers_, _item_offers_offers1, _item_offers3;
|
|
2337
|
+
var listPrice = item === null || item === void 0 ? void 0 : (_item_offers = item.offers) === null || _item_offers === void 0 ? void 0 : (_item_offers_offers = _item_offers.offers) === null || _item_offers_offers === void 0 ? void 0 : (_item_offers_offers__priceSpecification_find = _item_offers_offers[0].priceSpecification.find(function(s) {
|
|
2338
|
+
return s.priceType === LIST_PRICE_SCHEMA;
|
|
2339
|
+
})) === null || _item_offers_offers__priceSpecification_find === void 0 ? void 0 : _item_offers_offers__priceSpecification_find.price;
|
|
2340
|
+
return {
|
|
2341
|
+
quantity: 1,
|
|
2342
|
+
item_brand: (_ref = (_item_brand = item.brand) === null || _item_brand === void 0 ? void 0 : _item_brand.name) !== null && _ref !== void 0 ? _ref : null,
|
|
2343
|
+
item_name: (_item_alternateName = item.alternateName) !== null && _item_alternateName !== void 0 ? _item_alternateName : null,
|
|
2344
|
+
price: (_ref1 = (_item_offers1 = item.offers) === null || _item_offers1 === void 0 ? void 0 : _item_offers1.lowPrice) !== null && _ref1 !== void 0 ? _ref1 : null,
|
|
2345
|
+
discount: Number(listPrice) - Number(item === null || item === void 0 ? void 0 : (_item_offers2 = item.offers) === null || _item_offers2 === void 0 ? void 0 : _item_offers2.lowPrice),
|
|
2346
|
+
item_variant: (_ref2 = (_item_additionalProperty = item.additionalProperty) === null || _item_additionalProperty === void 0 ? void 0 : (_item_additionalProperty_find = _item_additionalProperty.find(function(p) {
|
|
2347
|
+
return p.name === "Cores";
|
|
2348
|
+
})) === null || _item_additionalProperty_find === void 0 ? void 0 : _item_additionalProperty_find.value) !== null && _ref2 !== void 0 ? _ref2 : null,
|
|
2349
|
+
item_ref: (_ref3 = (_item_additionalProperty1 = item.additionalProperty) === null || _item_additionalProperty1 === void 0 ? void 0 : (_item_additionalProperty_find1 = _item_additionalProperty1.find(function(i) {
|
|
2350
|
+
return i.name === "RefId";
|
|
2351
|
+
})) === null || _item_additionalProperty_find1 === void 0 ? void 0 : _item_additionalProperty_find1.value) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
2352
|
+
item_category: getItemCategory3(item),
|
|
2353
|
+
item_category2: (_ref4 = (_item_category = item.category) === null || _item_category === void 0 ? void 0 : (_item_category_split_pop = _item_category.split(">").pop()) === null || _item_category_split_pop === void 0 ? void 0 : _item_category_split_pop.toLowerCase().replace(/^./, function(c) {
|
|
2354
|
+
return c.toUpperCase();
|
|
2355
|
+
})) !== null && _ref4 !== void 0 ? _ref4 : null,
|
|
2356
|
+
item_id: (_ref5 = item === null || item === void 0 ? void 0 : (_item_isVariantOf = item.isVariantOf) === null || _item_isVariantOf === void 0 ? void 0 : _item_isVariantOf.productGroupID) !== null && _ref5 !== void 0 ? _ref5 : null,
|
|
2357
|
+
item_sku: (_item_sku = item.sku) !== null && _item_sku !== void 0 ? _item_sku : null,
|
|
2358
|
+
item_url: (_item_url = item.url) !== null && _item_url !== void 0 ? _item_url : null,
|
|
2359
|
+
image_url: (_resizeVtexImage2 = resizeVtexImage2(item === null || item === void 0 ? void 0 : (_item_image = item.image) === null || _item_image === void 0 ? void 0 : _item_image[0].url)) !== null && _resizeVtexImage2 !== void 0 ? _resizeVtexImage2 : null,
|
|
2360
|
+
seller_id: (_ref6 = (_item_offers3 = item.offers) === null || _item_offers3 === void 0 ? void 0 : (_item_offers_offers1 = _item_offers3.offers) === null || _item_offers_offers1 === void 0 ? void 0 : (_item_offers_offers_ = _item_offers_offers1[0]) === null || _item_offers_offers_ === void 0 ? void 0 : _item_offers_offers_.seller) !== null && _ref6 !== void 0 ? _ref6 : null,
|
|
2361
|
+
item_list_name: ""
|
|
2362
|
+
};
|
|
2363
|
+
});
|
|
2364
|
+
}
|
|
2365
|
+
return null;
|
|
2366
|
+
},
|
|
2367
|
+
// legacy/global params TO BE DONE (move to a global file or other adapter)
|
|
2368
|
+
payment_type: getPaymentType,
|
|
2369
|
+
user_info: getUserInfo,
|
|
2370
|
+
// global
|
|
2371
|
+
content_type: function(context, eventName) {
|
|
2372
|
+
if (context === null || context === void 0 ? void 0 : context.content_type) return context.content_type;
|
|
2373
|
+
return "regiao".concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
|
|
2374
|
+
},
|
|
2375
|
+
region: function(context, eventName) {
|
|
2376
|
+
return context.region || null;
|
|
2377
|
+
},
|
|
2378
|
+
total_discount: function(context, eventName) {
|
|
2379
|
+
var _context_orderForm, _context_orderForm1;
|
|
2380
|
+
if (context === null || context === void 0 ? void 0 : context.totalDiscount) return context.totalDiscount;
|
|
2381
|
+
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) || [];
|
|
2382
|
+
var items = context.orderForm.items;
|
|
2383
|
+
var totalDiscount = items.reduce(function(acc, item) {
|
|
2384
|
+
var unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
|
|
2385
|
+
return acc + unitDiscount * item.quantity;
|
|
2386
|
+
}, 0);
|
|
2387
|
+
var discounts = totalsList.find(function(t) {
|
|
2388
|
+
return t.id === "Discounts";
|
|
2389
|
+
});
|
|
2390
|
+
return Math.abs(((discounts === null || discounts === void 0 ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
|
|
2391
|
+
},
|
|
2392
|
+
subtotal: function(context, eventName) {
|
|
2393
|
+
var _context_orderForm, _context_orderForm1;
|
|
2394
|
+
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) || [];
|
|
2395
|
+
var subtotal = totalsList.filter(function(t) {
|
|
2396
|
+
return t.id === "Items";
|
|
2397
|
+
}).reduce(function(acc, t) {
|
|
2398
|
+
return acc + (t.value || 0);
|
|
2399
|
+
}, 0) / 100 || 0;
|
|
2400
|
+
return subtotal;
|
|
2401
|
+
},
|
|
2402
|
+
coupon_message: function(context, eventName) {
|
|
2403
|
+
var _context_orderForm;
|
|
2404
|
+
if (context.couponMessage) return context.couponMessage;
|
|
2405
|
+
var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
|
|
2406
|
+
if (messages.length === 0) return null;
|
|
2407
|
+
var couponMessages = messages.filter(function(msg) {
|
|
2408
|
+
return msg.text.toLowerCase().includes("cupom");
|
|
2409
|
+
});
|
|
2410
|
+
if (couponMessages.length === 0) return null;
|
|
2411
|
+
return couponMessages.map(function(msg) {
|
|
2412
|
+
return msg.text;
|
|
2413
|
+
}).join(" | ");
|
|
2414
|
+
},
|
|
2415
|
+
seller_cod_name: function(context, eventName) {
|
|
2416
|
+
return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
|
|
2417
|
+
},
|
|
2418
|
+
coupon: function(context, eventName) {
|
|
2419
|
+
var _context_orderForm_marketingData, _context_orderForm;
|
|
2420
|
+
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;
|
|
2421
|
+
},
|
|
2422
|
+
pre_filled: function(context, eventName) {
|
|
2423
|
+
return !!context.preFilled;
|
|
2424
|
+
},
|
|
2425
|
+
search_term: function(context, eventName) {
|
|
2426
|
+
return context.searchTerm || null;
|
|
2427
|
+
},
|
|
2428
|
+
search_found: function(context, eventName) {
|
|
2429
|
+
return !!context.searchFound;
|
|
2430
|
+
},
|
|
2431
|
+
search_quantity: function(context, eventName) {
|
|
2432
|
+
return context.searchQuantity || 0;
|
|
2433
|
+
},
|
|
2434
|
+
promotion_name: function(context, eventName) {
|
|
2435
|
+
return context.promotionName || null;
|
|
2436
|
+
},
|
|
2437
|
+
creative_name: function(context, eventName) {
|
|
2438
|
+
return context.creativeName || null;
|
|
2439
|
+
},
|
|
2440
|
+
creative_slot: function(context, eventName) {
|
|
2441
|
+
return context.creativeSlot || null;
|
|
2442
|
+
},
|
|
2443
|
+
zipcode: function(context, eventName) {
|
|
2444
|
+
return context.zipCode || null;
|
|
2445
|
+
},
|
|
2446
|
+
size: function(context, eventName) {
|
|
2447
|
+
return context.size || null;
|
|
2448
|
+
},
|
|
2449
|
+
item_ref: function(context, eventName) {
|
|
2450
|
+
return context.itemRef || null;
|
|
2451
|
+
},
|
|
2452
|
+
flag_pickup: function(context, eventName) {
|
|
2453
|
+
var _orderForm_shippingData;
|
|
2454
|
+
var orderForm = context.orderForm;
|
|
2455
|
+
if (!orderForm) return null;
|
|
2456
|
+
var logisticsInfo = ((_orderForm_shippingData = orderForm.shippingData) === null || _orderForm_shippingData === void 0 ? void 0 : _orderForm_shippingData.logisticsInfo) || [];
|
|
2457
|
+
var hasPickup = logisticsInfo.some(function(info) {
|
|
2458
|
+
var _info_slas;
|
|
2459
|
+
return (_info_slas = info.slas) === null || _info_slas === void 0 ? void 0 : _info_slas.some(function(sla) {
|
|
2460
|
+
return sla.deliveryChannel === "pickup-in-point";
|
|
2461
|
+
});
|
|
2462
|
+
});
|
|
2463
|
+
return hasPickup;
|
|
2464
|
+
},
|
|
2465
|
+
shippings: function(context, eventName) {
|
|
2466
|
+
var orderForm = context.orderForm;
|
|
2467
|
+
if (!orderForm) return null;
|
|
2468
|
+
var groupShipping = {};
|
|
2469
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2470
|
+
try {
|
|
2471
|
+
for(var _iterator = orderForm.shippingData.logisticsInfo[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2472
|
+
var info = _step.value;
|
|
2473
|
+
var item = orderForm.items[info.itemIndex];
|
|
2474
|
+
if (!item) continue;
|
|
2475
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
2476
|
+
try {
|
|
2477
|
+
for(var _iterator1 = info.slas[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
2478
|
+
var sla = _step1.value;
|
|
2479
|
+
var key = sla.name;
|
|
2480
|
+
if (!groupShipping[key]) {
|
|
2481
|
+
groupShipping[key] = {
|
|
2482
|
+
shipping_tier: sla.name,
|
|
2483
|
+
delivery_time: parseInt(sla.shippingEstimate),
|
|
2484
|
+
shipping: parseFloat((sla.price / 100).toFixed(1)),
|
|
2485
|
+
line_items: []
|
|
2486
|
+
};
|
|
2487
|
+
}
|
|
2488
|
+
groupShipping[key].line_items.push(item.id);
|
|
2489
|
+
}
|
|
2490
|
+
} catch (err) {
|
|
2491
|
+
_didIteratorError1 = true;
|
|
2492
|
+
_iteratorError1 = err;
|
|
2493
|
+
} finally{
|
|
2494
|
+
try {
|
|
2495
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
2496
|
+
_iterator1.return();
|
|
2497
|
+
}
|
|
2498
|
+
} finally{
|
|
2499
|
+
if (_didIteratorError1) {
|
|
2500
|
+
throw _iteratorError1;
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
} catch (err) {
|
|
2506
|
+
_didIteratorError = true;
|
|
2507
|
+
_iteratorError = err;
|
|
2508
|
+
} finally{
|
|
2509
|
+
try {
|
|
2510
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2511
|
+
_iterator.return();
|
|
2512
|
+
}
|
|
2513
|
+
} finally{
|
|
2514
|
+
if (_didIteratorError) {
|
|
2515
|
+
throw _iteratorError;
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
var shippings = Object.values(groupShipping).map(function(s) {
|
|
2520
|
+
return {
|
|
2521
|
+
shipping: s.shipping,
|
|
2522
|
+
shipping_tier: s.shipping_tier,
|
|
2523
|
+
delivery_time: s.delivery_time,
|
|
2524
|
+
line_items: s.line_items.join(",")
|
|
2525
|
+
};
|
|
2526
|
+
});
|
|
2527
|
+
return shippings || null;
|
|
2528
|
+
},
|
|
2529
|
+
shipping: function(context, eventName) {
|
|
2530
|
+
var _ref;
|
|
2531
|
+
var _context_orderForm_shippingData, _context_orderForm;
|
|
2532
|
+
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 : [];
|
|
2533
|
+
return logistics.reduce(function(total, item) {
|
|
2534
|
+
var _ref;
|
|
2535
|
+
var _item_slas;
|
|
2536
|
+
var selected = (_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
2537
|
+
return sla.id === item.selectedSla;
|
|
2538
|
+
});
|
|
2539
|
+
return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
|
|
2540
|
+
}, 0);
|
|
2541
|
+
},
|
|
2542
|
+
shipping_tier: function(context, eventName) {
|
|
2543
|
+
var _ref;
|
|
2544
|
+
var _context_orderForm_shippingData, _context_orderForm;
|
|
2545
|
+
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 : [];
|
|
2546
|
+
var selectedSlas = logistics.map(function(item) {
|
|
2547
|
+
var _item_slas;
|
|
2548
|
+
if (!item.selectedSla) return null;
|
|
2549
|
+
return ((_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
2550
|
+
return sla.id === item.selectedSla;
|
|
2551
|
+
})) || null;
|
|
2552
|
+
}).filter(Boolean);
|
|
2553
|
+
if (selectedSlas.length === 0) return null;
|
|
2554
|
+
var uniqueTiers = Array.from(new Map(selectedSlas.map(function(sla) {
|
|
2555
|
+
var _sla_pickupStoreInfo;
|
|
2556
|
+
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 || "");
|
|
2557
|
+
return [
|
|
2558
|
+
key,
|
|
2559
|
+
sla
|
|
2560
|
+
];
|
|
2561
|
+
})).values());
|
|
2562
|
+
var sortedTiers = uniqueTiers.sort(function(a, b) {
|
|
2563
|
+
var _a_pickupStoreInfo, _b_pickupStoreInfo;
|
|
2564
|
+
var aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
2565
|
+
var bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
2566
|
+
if (aOrder !== bOrder) return aOrder - bOrder;
|
|
2567
|
+
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 || "";
|
|
2568
|
+
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 || "";
|
|
2569
|
+
return aLabel.localeCompare(bLabel, "pt-BR");
|
|
2570
|
+
});
|
|
2571
|
+
var shippingTier = sortedTiers.map(function(sla) {
|
|
2572
|
+
var _sla_pickupStoreInfo;
|
|
2573
|
+
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;
|
|
2574
|
+
}).filter(Boolean).join(", ");
|
|
2575
|
+
return shippingTier || null;
|
|
2576
|
+
},
|
|
2577
|
+
transaction_id: function(context, eventName) {
|
|
2578
|
+
var _context_orderForm_orderGroup, _context_orderForm;
|
|
2579
|
+
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;
|
|
2580
|
+
},
|
|
2581
|
+
method: function(context, eventName) {
|
|
2582
|
+
return context.method || null;
|
|
2583
|
+
},
|
|
2584
|
+
type: function(context, eventName) {
|
|
2585
|
+
return context.type || null;
|
|
2586
|
+
}
|
|
2587
|
+
};
|
|
2588
|
+
var getItemCategory3 = function(item) {
|
|
2589
|
+
var keywords = [
|
|
2590
|
+
"outlet",
|
|
2591
|
+
"bazar",
|
|
2592
|
+
"sale"
|
|
2593
|
+
];
|
|
2594
|
+
var regex = new RegExp(keywords.join("|"), "i");
|
|
2595
|
+
var value = item === null || item === void 0 ? void 0 : item.category;
|
|
2596
|
+
if (value) {
|
|
2597
|
+
var textToTest = Array.isArray(value) ? value.join(" ") : String(value);
|
|
2598
|
+
var match = textToTest.match(regex);
|
|
2599
|
+
if (match) {
|
|
2600
|
+
return match[0].toLowerCase();
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
return "Cole\xE7\xE3o";
|
|
2604
|
+
};
|
|
2605
|
+
var resizeVtexImage2 = function(url) {
|
|
2606
|
+
var width = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 500, height = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 500;
|
|
2607
|
+
return url === null || url === void 0 ? void 0 : url.replace(/(\/arquivos\/ids\/\d+)-\d+-\d+\//, "$1-".concat(width, "-").concat(height, "/"));
|
|
2608
|
+
};
|
|
2609
|
+
// src/params/adapters/IntelligentSearch/index.ts
|
|
2610
|
+
var intelligentSearchAdapter = {
|
|
2611
|
+
brand: function(context, eventName) {
|
|
2612
|
+
if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
|
|
2613
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2614
|
+
return context.products.map(function(p) {
|
|
2615
|
+
var isPDP2 = "items" in p;
|
|
2616
|
+
return isPDP2 ? p.brand : p.brand.name;
|
|
2617
|
+
}).join().trim();
|
|
2618
|
+
}
|
|
2619
|
+
return null;
|
|
2620
|
+
},
|
|
2621
|
+
line_items: function(context, eventName) {
|
|
2622
|
+
if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
|
|
2623
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2624
|
+
return context.products.map(function(item) {
|
|
2625
|
+
return "productId" in item ? item.productId : item.id;
|
|
2626
|
+
}).filter(function(id) {
|
|
2627
|
+
return Boolean(id);
|
|
2628
|
+
});
|
|
2629
|
+
}
|
|
2630
|
+
return null;
|
|
2631
|
+
},
|
|
2632
|
+
currency: function(context, eventName) {
|
|
2633
|
+
if (context === null || context === void 0 ? void 0 : context.currency) return context.currency;
|
|
2634
|
+
return "BRL";
|
|
2635
|
+
},
|
|
2636
|
+
value: function(context, eventName) {
|
|
2637
|
+
if (context === null || context === void 0 ? void 0 : context.value) return context.value;
|
|
2638
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2639
|
+
return context.products.map(function(item) {
|
|
2640
|
+
var _item_items__sellers;
|
|
2641
|
+
return "items" in item ? 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.Price : item.offers.lowPrice;
|
|
2642
|
+
}).filter(function(price) {
|
|
2643
|
+
return price !== void 0;
|
|
2644
|
+
}).reduce(function(sum, price) {
|
|
2645
|
+
return sum + price;
|
|
2646
|
+
}, 0);
|
|
2647
|
+
}
|
|
2648
|
+
return null;
|
|
2649
|
+
},
|
|
2650
|
+
available_grid: function(context, eventName) {
|
|
2651
|
+
if (context === null || context === void 0 ? void 0 : context.available_grid) return context.available_grid;
|
|
2652
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2653
|
+
var _context_products;
|
|
2654
|
+
var result = context === null || context === void 0 ? void 0 : (_context_products = context.products) === null || _context_products === void 0 ? void 0 : _context_products.map(function(p) {
|
|
2655
|
+
var isPDP2 = "items" in p;
|
|
2656
|
+
return isPDP2 ? p.items.map(function(i) {
|
|
2657
|
+
return i.Tamanho[0];
|
|
2658
|
+
}) : [];
|
|
2659
|
+
}).join(",").trim();
|
|
2660
|
+
return result || null;
|
|
2661
|
+
}
|
|
2662
|
+
return null;
|
|
2663
|
+
},
|
|
2664
|
+
items: function(context, eventName) {
|
|
2665
|
+
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2666
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2667
|
+
return context.products.map(function(item) {
|
|
2668
|
+
var _item_brand_name, _item_name, _ref, _ref1, _getItemCategory22, _item_isVariantOf_productGroupID, _item_sku, _resizeVtexImage3, _ref2;
|
|
2669
|
+
var _item_items__sellers, _item_items__sellers1, _item_items__name, _item_items_, _item_isVariantOf_hasVariant, _item_isVariantOf, _item_items__name1, _item_items_1, _item_additionalProperty_find, _item_items, _item_items__images, _item_items1, _item_image, _item_items__sellers2, _item_items_2, _item_items2, _item_offers_offers_find_seller, _item_offers_offers_find, _item_offers_offers, _item_offers;
|
|
2670
|
+
var isPDP2 = "items" in item;
|
|
2671
|
+
var listPrice = isPDP2 ? 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 : item.offers.highPrice;
|
|
2672
|
+
var price = isPDP2 ? 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 : item.offers.lowPrice;
|
|
2673
|
+
return {
|
|
2674
|
+
quantity: 1,
|
|
2675
|
+
item_brand: isPDP2 ? item.brand : (_item_brand_name = item.brand.name) !== null && _item_brand_name !== void 0 ? _item_brand_name : null,
|
|
2676
|
+
item_name: isPDP2 ? item.productName : (_item_name = item.name) !== null && _item_name !== void 0 ? _item_name : null,
|
|
2677
|
+
price: price !== null && price !== void 0 ? price : null,
|
|
2678
|
+
discount: Number(listPrice) - Number(price),
|
|
2679
|
+
item_variant: isPDP2 ? (_item_items_ = item.items[0]) === null || _item_items_ === void 0 ? void 0 : (_item_items__name = _item_items_.name) === null || _item_items__name === void 0 ? void 0 : _item_items__name.split(" - ")[0] : (_ref = (_item_isVariantOf = item.isVariantOf) === null || _item_isVariantOf === void 0 ? void 0 : (_item_isVariantOf_hasVariant = _item_isVariantOf.hasVariant) === null || _item_isVariantOf_hasVariant === void 0 ? void 0 : _item_isVariantOf_hasVariant[0].name.split(" - ")[0]) !== null && _ref !== void 0 ? _ref : null,
|
|
2680
|
+
item_variant2: isPDP2 ? (_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] : (_ref1 = (_item_additionalProperty_find = item.additionalProperty.find(function(p) {
|
|
2681
|
+
return p.name === "Tamanho";
|
|
2682
|
+
})) === null || _item_additionalProperty_find === void 0 ? void 0 : _item_additionalProperty_find.value) !== null && _ref1 !== void 0 ? _ref1 : null,
|
|
2683
|
+
item_ref: isPDP2 ? item.productReference : null,
|
|
2684
|
+
// sem ref no retorno do IS na multi-lib produtos PDC
|
|
2685
|
+
item_category: getItemCategory5(item),
|
|
2686
|
+
item_category2: (_getItemCategory22 = getItemCategory22(item)) !== null && _getItemCategory22 !== void 0 ? _getItemCategory22 : null,
|
|
2687
|
+
item_id: isPDP2 ? item === null || item === void 0 ? void 0 : item.productId : (_item_isVariantOf_productGroupID = item.isVariantOf.productGroupID) !== null && _item_isVariantOf_productGroupID !== void 0 ? _item_isVariantOf_productGroupID : null,
|
|
2688
|
+
item_sku: isPDP2 ? (_item_items = item.items) === null || _item_items === void 0 ? void 0 : _item_items[0].itemId : (_item_sku = item.sku) !== null && _item_sku !== void 0 ? _item_sku : null,
|
|
2689
|
+
item_url: isPDP2 ? item.link : null,
|
|
2690
|
+
// sem link/url no retorno do IS na multi-lib produtos PDC
|
|
2691
|
+
image_url: isPDP2 ? resizeVtexImage3(item === null || item === void 0 ? void 0 : (_item_items1 = item.items) === null || _item_items1 === void 0 ? void 0 : (_item_items__images = _item_items1[0].images) === null || _item_items__images === void 0 ? void 0 : _item_items__images[0].imageUrl) : (_resizeVtexImage3 = resizeVtexImage3(item === null || item === void 0 ? void 0 : (_item_image = item.image) === null || _item_image === void 0 ? void 0 : _item_image[0].url)) !== null && _resizeVtexImage3 !== void 0 ? _resizeVtexImage3 : null,
|
|
2692
|
+
seller_id: isPDP2 ? (_item_items2 = item.items) === null || _item_items2 === void 0 ? void 0 : (_item_items_2 = _item_items2[0]) === null || _item_items_2 === void 0 ? void 0 : (_item_items__sellers2 = _item_items_2.sellers) === null || _item_items__sellers2 === void 0 ? void 0 : _item_items__sellers2[0].sellerId : (_ref2 = (_item_offers = item.offers) === null || _item_offers === void 0 ? void 0 : (_item_offers_offers = _item_offers.offers) === null || _item_offers_offers === void 0 ? void 0 : (_item_offers_offers_find = _item_offers_offers.find(function(o) {
|
|
2693
|
+
return o.availability;
|
|
2694
|
+
})) === null || _item_offers_offers_find === void 0 ? void 0 : (_item_offers_offers_find_seller = _item_offers_offers_find.seller) === null || _item_offers_offers_find_seller === void 0 ? void 0 : _item_offers_offers_find_seller.identifier) !== null && _ref2 !== void 0 ? _ref2 : null,
|
|
2695
|
+
item_list_name: ""
|
|
2696
|
+
};
|
|
2697
|
+
});
|
|
2698
|
+
}
|
|
2699
|
+
return null;
|
|
2700
|
+
},
|
|
2701
|
+
// legacy/global params TO BE DONE (move to a global file or other adapter)
|
|
2702
|
+
payment_type: getPaymentType,
|
|
2703
|
+
user_info: getUserInfo,
|
|
2704
|
+
// global
|
|
2705
|
+
content_type: function(context, eventName) {
|
|
2706
|
+
if (context === null || context === void 0 ? void 0 : context.content_type) return context.content_type;
|
|
2707
|
+
return "regiao".concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
|
|
2708
|
+
},
|
|
2709
|
+
region: function(context, eventName) {
|
|
2710
|
+
return context.region || null;
|
|
2711
|
+
},
|
|
2712
|
+
total_discount: function(context, eventName) {
|
|
2713
|
+
var _context_orderForm, _context_orderForm1;
|
|
2714
|
+
if (context === null || context === void 0 ? void 0 : context.totalDiscount) return context.totalDiscount;
|
|
2715
|
+
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) || [];
|
|
2716
|
+
var items = context.orderForm.items;
|
|
2717
|
+
var totalDiscount = items.reduce(function(acc, item) {
|
|
2718
|
+
var unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
|
|
2719
|
+
return acc + unitDiscount * item.quantity;
|
|
2720
|
+
}, 0);
|
|
2721
|
+
var discounts = totalsList.find(function(t) {
|
|
2722
|
+
return t.id === "Discounts";
|
|
2723
|
+
});
|
|
2724
|
+
return Math.abs(((discounts === null || discounts === void 0 ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
|
|
2725
|
+
},
|
|
2726
|
+
subtotal: function(context, eventName) {
|
|
2727
|
+
var _context_orderForm, _context_orderForm1;
|
|
2728
|
+
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) || [];
|
|
2729
|
+
var subtotal = totalsList.filter(function(t) {
|
|
2730
|
+
return t.id === "Items";
|
|
2731
|
+
}).reduce(function(acc, t) {
|
|
2732
|
+
return acc + (t.value || 0);
|
|
2733
|
+
}, 0) / 100 || 0;
|
|
2734
|
+
return subtotal;
|
|
2735
|
+
},
|
|
2736
|
+
coupon_message: function(context, eventName) {
|
|
2737
|
+
var _context_orderForm;
|
|
2738
|
+
if (context.couponMessage) return context.couponMessage;
|
|
2739
|
+
var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
|
|
2740
|
+
if (messages.length === 0) return null;
|
|
2741
|
+
var couponMessages = messages.filter(function(msg) {
|
|
2742
|
+
return msg.text.toLowerCase().includes("cupom");
|
|
2743
|
+
});
|
|
2744
|
+
if (couponMessages.length === 0) return null;
|
|
2745
|
+
return couponMessages.map(function(msg) {
|
|
2746
|
+
return msg.text;
|
|
2747
|
+
}).join(" | ");
|
|
2748
|
+
},
|
|
2749
|
+
seller_cod_name: function(context, eventName) {
|
|
2750
|
+
return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
|
|
2751
|
+
},
|
|
2752
|
+
coupon: function(context, eventName) {
|
|
2753
|
+
var _context_orderForm_marketingData, _context_orderForm;
|
|
2754
|
+
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;
|
|
2755
|
+
},
|
|
2756
|
+
pre_filled: function(context, eventName) {
|
|
2757
|
+
return !!context.preFilled;
|
|
2758
|
+
},
|
|
2759
|
+
search_term: function(context, eventName) {
|
|
2760
|
+
return context.searchTerm || null;
|
|
2761
|
+
},
|
|
2762
|
+
search_found: function(context, eventName) {
|
|
2763
|
+
return !!context.searchFound;
|
|
2764
|
+
},
|
|
2765
|
+
search_quantity: function(context, eventName) {
|
|
2766
|
+
return context.searchQuantity || 0;
|
|
2767
|
+
},
|
|
2768
|
+
promotion_name: function(context, eventName) {
|
|
2769
|
+
return context.promotionName || null;
|
|
2770
|
+
},
|
|
2771
|
+
creative_name: function(context, eventName) {
|
|
2772
|
+
return context.creativeName || null;
|
|
2773
|
+
},
|
|
2774
|
+
creative_slot: function(context, eventName) {
|
|
2775
|
+
return context.creativeSlot || null;
|
|
2776
|
+
},
|
|
2777
|
+
zipcode: function(context, eventName) {
|
|
2778
|
+
return context.zipCode || null;
|
|
2779
|
+
},
|
|
2780
|
+
size: function(context, eventName) {
|
|
2781
|
+
return context.size || null;
|
|
2782
|
+
},
|
|
2783
|
+
item_ref: function(context, eventName) {
|
|
2784
|
+
return context.itemRef || null;
|
|
2785
|
+
},
|
|
2786
|
+
flag_pickup: function(context, eventName) {
|
|
2787
|
+
var _orderForm_shippingData;
|
|
2788
|
+
var orderForm = context.orderForm;
|
|
2789
|
+
if (!orderForm) return null;
|
|
2790
|
+
var logisticsInfo = ((_orderForm_shippingData = orderForm.shippingData) === null || _orderForm_shippingData === void 0 ? void 0 : _orderForm_shippingData.logisticsInfo) || [];
|
|
2791
|
+
var hasPickup = logisticsInfo.some(function(info) {
|
|
2792
|
+
var _info_slas;
|
|
2793
|
+
return (_info_slas = info.slas) === null || _info_slas === void 0 ? void 0 : _info_slas.some(function(sla) {
|
|
2794
|
+
return sla.deliveryChannel === "pickup-in-point";
|
|
2795
|
+
});
|
|
2796
|
+
});
|
|
2797
|
+
return hasPickup;
|
|
2798
|
+
},
|
|
2799
|
+
shippings: function(context, eventName) {
|
|
2800
|
+
var orderForm = context.orderForm;
|
|
2801
|
+
if (!orderForm) return null;
|
|
2802
|
+
var groupShipping = {};
|
|
2803
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2804
|
+
try {
|
|
2805
|
+
for(var _iterator = orderForm.shippingData.logisticsInfo[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2806
|
+
var info = _step.value;
|
|
2807
|
+
var item = orderForm.items[info.itemIndex];
|
|
2808
|
+
if (!item) continue;
|
|
2809
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
2810
|
+
try {
|
|
2811
|
+
for(var _iterator1 = info.slas[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
2812
|
+
var sla = _step1.value;
|
|
2813
|
+
var key = sla.name;
|
|
2814
|
+
if (!groupShipping[key]) {
|
|
2815
|
+
groupShipping[key] = {
|
|
2816
|
+
shipping_tier: sla.name,
|
|
2817
|
+
delivery_time: parseInt(sla.shippingEstimate),
|
|
2818
|
+
shipping: parseFloat((sla.price / 100).toFixed(1)),
|
|
2819
|
+
line_items: []
|
|
2820
|
+
};
|
|
2821
|
+
}
|
|
2822
|
+
groupShipping[key].line_items.push(item.id);
|
|
2823
|
+
}
|
|
2824
|
+
} catch (err) {
|
|
2825
|
+
_didIteratorError1 = true;
|
|
2826
|
+
_iteratorError1 = err;
|
|
2827
|
+
} finally{
|
|
2828
|
+
try {
|
|
2829
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
2830
|
+
_iterator1.return();
|
|
2831
|
+
}
|
|
2832
|
+
} finally{
|
|
2833
|
+
if (_didIteratorError1) {
|
|
2834
|
+
throw _iteratorError1;
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
} catch (err) {
|
|
2840
|
+
_didIteratorError = true;
|
|
2841
|
+
_iteratorError = err;
|
|
2842
|
+
} finally{
|
|
2843
|
+
try {
|
|
2844
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2845
|
+
_iterator.return();
|
|
2846
|
+
}
|
|
2847
|
+
} finally{
|
|
2848
|
+
if (_didIteratorError) {
|
|
2849
|
+
throw _iteratorError;
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
var shippings = Object.values(groupShipping).map(function(s) {
|
|
2854
|
+
return {
|
|
2855
|
+
shipping: s.shipping,
|
|
2856
|
+
shipping_tier: s.shipping_tier,
|
|
2857
|
+
delivery_time: s.delivery_time,
|
|
2858
|
+
line_items: s.line_items.join(",")
|
|
2859
|
+
};
|
|
2860
|
+
});
|
|
2861
|
+
return shippings || null;
|
|
2862
|
+
},
|
|
2863
|
+
shipping: function(context, eventName) {
|
|
2864
|
+
var _ref;
|
|
2865
|
+
var _context_orderForm_shippingData, _context_orderForm;
|
|
2866
|
+
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 : [];
|
|
2867
|
+
return logistics.reduce(function(total, item) {
|
|
2868
|
+
var _ref;
|
|
2869
|
+
var _item_slas;
|
|
2870
|
+
var selected = (_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
2871
|
+
return sla.id === item.selectedSla;
|
|
2872
|
+
});
|
|
2873
|
+
return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
|
|
2874
|
+
}, 0);
|
|
2875
|
+
},
|
|
2876
|
+
shipping_tier: function(context, eventName) {
|
|
2877
|
+
var _ref;
|
|
2878
|
+
var _context_orderForm_shippingData, _context_orderForm;
|
|
2879
|
+
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 : [];
|
|
2880
|
+
var selectedSlas = logistics.map(function(item) {
|
|
2881
|
+
var _item_slas;
|
|
2882
|
+
if (!item.selectedSla) return null;
|
|
2883
|
+
return ((_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
2884
|
+
return sla.id === item.selectedSla;
|
|
2885
|
+
})) || null;
|
|
2886
|
+
}).filter(Boolean);
|
|
2887
|
+
if (selectedSlas.length === 0) return null;
|
|
2888
|
+
var uniqueTiers = Array.from(new Map(selectedSlas.map(function(sla) {
|
|
2889
|
+
var _sla_pickupStoreInfo;
|
|
2890
|
+
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 || "");
|
|
2891
|
+
return [
|
|
2892
|
+
key,
|
|
2893
|
+
sla
|
|
2894
|
+
];
|
|
2895
|
+
})).values());
|
|
2896
|
+
var sortedTiers = uniqueTiers.sort(function(a, b) {
|
|
2897
|
+
var _a_pickupStoreInfo, _b_pickupStoreInfo;
|
|
2898
|
+
var aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
2899
|
+
var bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
2900
|
+
if (aOrder !== bOrder) return aOrder - bOrder;
|
|
2901
|
+
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 || "";
|
|
2902
|
+
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 || "";
|
|
2903
|
+
return aLabel.localeCompare(bLabel, "pt-BR");
|
|
2904
|
+
});
|
|
2905
|
+
var shippingTier = sortedTiers.map(function(sla) {
|
|
2906
|
+
var _sla_pickupStoreInfo;
|
|
2907
|
+
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;
|
|
2908
|
+
}).filter(Boolean).join(", ");
|
|
2909
|
+
return shippingTier || null;
|
|
2910
|
+
},
|
|
2911
|
+
transaction_id: function(context, eventName) {
|
|
2912
|
+
var _context_orderForm_orderGroup, _context_orderForm;
|
|
2913
|
+
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;
|
|
2914
|
+
},
|
|
2915
|
+
method: function(context, eventName) {
|
|
2916
|
+
return context.method || null;
|
|
2917
|
+
},
|
|
2918
|
+
type: function(context, eventName) {
|
|
2919
|
+
return context.type || null;
|
|
2920
|
+
}
|
|
2921
|
+
};
|
|
2922
|
+
var getItemCategory5 = function(item) {
|
|
2923
|
+
var keywords = [
|
|
2924
|
+
"outlet",
|
|
2925
|
+
"bazar",
|
|
2926
|
+
"sale"
|
|
2927
|
+
];
|
|
2928
|
+
var regex = new RegExp(keywords.join("|"), "i");
|
|
2929
|
+
var value = item === null || item === void 0 ? void 0 : item.categories;
|
|
2930
|
+
if (value) {
|
|
2931
|
+
var textToTest = Array.isArray(value) ? value.join(" ") : String(value);
|
|
2932
|
+
var match = textToTest.match(regex);
|
|
2933
|
+
if (match) {
|
|
2934
|
+
return match[0].toLowerCase();
|
|
2935
|
+
}
|
|
2936
|
+
}
|
|
2937
|
+
return "Cole\xE7\xE3o";
|
|
2938
|
+
};
|
|
2939
|
+
var getItemCategory22 = function(item) {
|
|
2940
|
+
var _ref, _reverse_find;
|
|
2941
|
+
var _item_categories;
|
|
2942
|
+
var avoidList = /outlet|bazar|sale/i;
|
|
2943
|
+
var lastCategory = (_ref = (_item_categories = item.categories) === null || _item_categories === void 0 ? void 0 : _item_categories[item.categories.length - 1]) !== null && _ref !== void 0 ? _ref : "";
|
|
2944
|
+
var categoryHierarchy = lastCategory.split("/").filter(Boolean);
|
|
2945
|
+
var deepestCategory = (_reverse_find = _to_consumable_array(categoryHierarchy).reverse().find(function(c) {
|
|
2946
|
+
return !avoidList.test(c);
|
|
2947
|
+
})) !== null && _reverse_find !== void 0 ? _reverse_find : "";
|
|
2948
|
+
return deepestCategory && deepestCategory[0].toUpperCase() + deepestCategory.slice(1).toLowerCase();
|
|
2949
|
+
};
|
|
2950
|
+
// src/formatter.ts
|
|
2951
|
+
var adapters = {
|
|
2952
|
+
DECO: decoAdapter,
|
|
2953
|
+
IS: intelligentSearchAdapter
|
|
2954
|
+
};
|
|
2336
2955
|
var src_default = {
|
|
2337
2956
|
trackWebEvent: trackWebEvent,
|
|
2338
2957
|
EVENTS: EVENTS
|