@azzas/azzas-tracker-web 2.0.0-preview.0 → 2.0.0-preview.10
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 +378 -198
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.d.cts +524 -18
- package/dist/mod.d.ts +524 -18
- package/dist/mod.global.js +377 -198
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +377 -198
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +432 -238
- package/package.json +1 -1
package/dist/mod.js
CHANGED
|
@@ -290,7 +290,19 @@ var EVENTS = {
|
|
|
290
290
|
name: "notify_me",
|
|
291
291
|
hasEcommerce: false,
|
|
292
292
|
destinations: ["DataLayer"],
|
|
293
|
-
requiredParams: ["brand", "
|
|
293
|
+
requiredParams: ["brand", "size", "item_ref"]
|
|
294
|
+
},
|
|
295
|
+
REFINE_RESULTS: {
|
|
296
|
+
name: "refine_results",
|
|
297
|
+
hasEcommerce: false,
|
|
298
|
+
destinations: ["DataLayer"],
|
|
299
|
+
requiredParams: ["brand", "region", "color", "price_range", "size", "category", "ordering"]
|
|
300
|
+
},
|
|
301
|
+
GRID_SIZE: {
|
|
302
|
+
name: "grid_size",
|
|
303
|
+
hasEcommerce: false,
|
|
304
|
+
destinations: ["DataLayer"],
|
|
305
|
+
requiredParams: ["brand", "slot_per_line"]
|
|
294
306
|
}
|
|
295
307
|
};
|
|
296
308
|
|
|
@@ -972,6 +984,12 @@ var sortSizes = (sizes) => {
|
|
|
972
984
|
return unique;
|
|
973
985
|
};
|
|
974
986
|
var capitalize = (str) => str ? str[0].toUpperCase() + str.slice(1).toLowerCase() : "";
|
|
987
|
+
var resizeVtexImage2 = (url, width = 500, height = 500) => {
|
|
988
|
+
return url == null ? void 0 : url.replace(
|
|
989
|
+
/(\/arquivos\/ids\/\d+)-\d+-\d+\//,
|
|
990
|
+
`$1-${width}-${height}/`
|
|
991
|
+
);
|
|
992
|
+
};
|
|
975
993
|
|
|
976
994
|
// src/params/legacy/resolvers/paymentType/fromOrderForm.ts
|
|
977
995
|
function paymentTypeFromOrderForm(context) {
|
|
@@ -1024,7 +1042,7 @@ var PROD_DOMAINS = {
|
|
|
1024
1042
|
"store": "https://www.animale.com.br",
|
|
1025
1043
|
"checkout": "https://secure.animale.com.br"
|
|
1026
1044
|
},
|
|
1027
|
-
"
|
|
1045
|
+
"lojafarm": {
|
|
1028
1046
|
"store": "https://lojafarm.myvtex.com"
|
|
1029
1047
|
},
|
|
1030
1048
|
"mariafilo": {
|
|
@@ -1042,7 +1060,7 @@ var PROD_DOMAINS = {
|
|
|
1042
1060
|
"bynv": {
|
|
1043
1061
|
"store": "https://bynv.myvtex.com"
|
|
1044
1062
|
},
|
|
1045
|
-
"
|
|
1063
|
+
"lojafabula": {
|
|
1046
1064
|
"store": "https://lojafabula.myvtex.com"
|
|
1047
1065
|
}
|
|
1048
1066
|
};
|
|
@@ -1107,7 +1125,7 @@ async function getUserInfo(context) {
|
|
|
1107
1125
|
}
|
|
1108
1126
|
|
|
1109
1127
|
// src/params/legacy/index.ts
|
|
1110
|
-
var
|
|
1128
|
+
var legacyGetters = {
|
|
1111
1129
|
brand: getBrand,
|
|
1112
1130
|
items: getItems,
|
|
1113
1131
|
payment_type: getPaymentType,
|
|
@@ -1311,12 +1329,8 @@ var paramGetters = {
|
|
|
1311
1329
|
// src/params/adapters/meta/index.ts
|
|
1312
1330
|
var metaAdapters = {
|
|
1313
1331
|
user_info: getUserInfo,
|
|
1314
|
-
brand: (context) => {
|
|
1315
|
-
return context.meta.brand || null;
|
|
1316
|
-
},
|
|
1317
1332
|
content_type: (context) => {
|
|
1318
|
-
|
|
1319
|
-
return `regiao`.concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
|
|
1333
|
+
return context.meta.content_type || null;
|
|
1320
1334
|
},
|
|
1321
1335
|
region: (context) => {
|
|
1322
1336
|
return context.meta.region || null;
|
|
@@ -1324,18 +1338,22 @@ var metaAdapters = {
|
|
|
1324
1338
|
pre_filled: (context) => {
|
|
1325
1339
|
return !!context.preFilled;
|
|
1326
1340
|
},
|
|
1327
|
-
currency: (
|
|
1328
|
-
if (
|
|
1341
|
+
currency: (_, config2) => {
|
|
1342
|
+
if (config2 == null ? void 0 : config2.currency) return config2.currency;
|
|
1329
1343
|
return "BRL";
|
|
1330
1344
|
},
|
|
1345
|
+
slot_per_line: (context) => {
|
|
1346
|
+
var _a;
|
|
1347
|
+
return (_a = context.meta.slot_per_line) != null ? _a : null;
|
|
1348
|
+
},
|
|
1331
1349
|
search_term: (context) => {
|
|
1332
|
-
return context.
|
|
1350
|
+
return context.meta.search_term || null;
|
|
1333
1351
|
},
|
|
1334
1352
|
search_found: (context) => {
|
|
1335
|
-
return
|
|
1353
|
+
return context.meta.search_found || null;
|
|
1336
1354
|
},
|
|
1337
1355
|
search_quantity: (context) => {
|
|
1338
|
-
return context.
|
|
1356
|
+
return context.meta.search_quantity || 0;
|
|
1339
1357
|
},
|
|
1340
1358
|
promotion_name: (context) => {
|
|
1341
1359
|
return context.meta.promotion_name || null;
|
|
@@ -1346,153 +1364,66 @@ var metaAdapters = {
|
|
|
1346
1364
|
creative_slot: (context) => {
|
|
1347
1365
|
return context.meta.creative_slot || null;
|
|
1348
1366
|
},
|
|
1349
|
-
zipcode: (context) => {
|
|
1350
|
-
return context.zipCode || null;
|
|
1351
|
-
},
|
|
1352
|
-
size: (context) => {
|
|
1353
|
-
return context.size || null;
|
|
1354
|
-
},
|
|
1355
1367
|
item_ref: (context) => {
|
|
1356
|
-
return context.
|
|
1368
|
+
return context.meta.item_ref || null;
|
|
1357
1369
|
},
|
|
1358
1370
|
method: (context) => {
|
|
1359
|
-
return context.method || null;
|
|
1371
|
+
return context.meta.method || null;
|
|
1360
1372
|
},
|
|
1361
1373
|
type: (context) => {
|
|
1362
|
-
return context.type || null;
|
|
1363
|
-
}
|
|
1364
|
-
};
|
|
1365
|
-
|
|
1366
|
-
// src/params/adapters/orderForm/index.ts
|
|
1367
|
-
var orderFormAdapters = {
|
|
1368
|
-
// orderform
|
|
1369
|
-
payment_type: getPaymentType,
|
|
1370
|
-
total_discount: (context) => {
|
|
1371
|
-
var _a, _b;
|
|
1372
|
-
if (context == null ? void 0 : context.totalDiscount) return context.totalDiscount;
|
|
1373
|
-
const totalsList = ((_a = context.orderForm) == null ? void 0 : _a.totalizers) || ((_b = context.orderForm) == null ? void 0 : _b.totals) || [];
|
|
1374
|
-
const items = context.orderForm.items;
|
|
1375
|
-
const totalDiscount = items.reduce((acc, item) => {
|
|
1376
|
-
const unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
|
|
1377
|
-
return acc + unitDiscount * item.quantity;
|
|
1378
|
-
}, 0);
|
|
1379
|
-
const discounts = totalsList.find((t) => t.id === "Discounts");
|
|
1380
|
-
return Math.abs(((discounts == null ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
|
|
1374
|
+
return context.meta.type || null;
|
|
1381
1375
|
},
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
const totalsList = ((_a = context.orderForm) == null ? void 0 : _a.totalizers) || ((_b = context.orderForm) == null ? void 0 : _b.totals) || [];
|
|
1385
|
-
const subtotal = totalsList.filter((t) => t.id === "Items").reduce((acc, t) => acc + (t.value || 0), 0) / 100 || 0;
|
|
1386
|
-
return subtotal;
|
|
1376
|
+
color: (context) => {
|
|
1377
|
+
return context.meta.color || null;
|
|
1387
1378
|
},
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
if (context.couponMessage) return context.couponMessage;
|
|
1391
|
-
const messages = ((_a = context.orderForm) == null ? void 0 : _a.messages) || [];
|
|
1392
|
-
if (messages.length === 0) return null;
|
|
1393
|
-
const couponMessages = messages.filter(
|
|
1394
|
-
(msg) => msg.text.toLowerCase().includes("cupom")
|
|
1395
|
-
);
|
|
1396
|
-
if (couponMessages.length === 0) return null;
|
|
1397
|
-
return couponMessages.map((msg) => msg.text).join(" | ");
|
|
1379
|
+
price_range: (context) => {
|
|
1380
|
+
return context.meta.price_range || null;
|
|
1398
1381
|
},
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
const orderForm = context.orderForm;
|
|
1402
|
-
if (!orderForm) return null;
|
|
1403
|
-
const logisticsInfo = ((_a = orderForm.shippingData) == null ? void 0 : _a.logisticsInfo) || [];
|
|
1404
|
-
const hasPickup = logisticsInfo.some(
|
|
1405
|
-
(info) => {
|
|
1406
|
-
var _a2;
|
|
1407
|
-
return (_a2 = info.slas) == null ? void 0 : _a2.some((sla) => sla.deliveryChannel === "pickup-in-point");
|
|
1408
|
-
}
|
|
1409
|
-
);
|
|
1410
|
-
return hasPickup;
|
|
1382
|
+
category: (context) => {
|
|
1383
|
+
return context.meta.category || null;
|
|
1411
1384
|
},
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
if (!orderForm) return null;
|
|
1415
|
-
const groupShipping = {};
|
|
1416
|
-
for (const info of orderForm.shippingData.logisticsInfo) {
|
|
1417
|
-
const item = orderForm.items[info.itemIndex];
|
|
1418
|
-
if (!item) continue;
|
|
1419
|
-
for (const sla of info.slas) {
|
|
1420
|
-
const key = sla.name;
|
|
1421
|
-
if (!groupShipping[key]) {
|
|
1422
|
-
groupShipping[key] = {
|
|
1423
|
-
shipping_tier: sla.name,
|
|
1424
|
-
delivery_time: parseInt(sla.shippingEstimate),
|
|
1425
|
-
shipping: parseFloat((sla.price / 100).toFixed(1)),
|
|
1426
|
-
line_items: []
|
|
1427
|
-
};
|
|
1428
|
-
}
|
|
1429
|
-
groupShipping[key].line_items.push(item.id);
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
const shippings = Object.values(groupShipping).map((s) => ({
|
|
1433
|
-
shipping: s.shipping,
|
|
1434
|
-
shipping_tier: s.shipping_tier,
|
|
1435
|
-
delivery_time: s.delivery_time,
|
|
1436
|
-
line_items: s.line_items.join(",")
|
|
1437
|
-
}));
|
|
1438
|
-
return shippings || null;
|
|
1385
|
+
ordering: (context) => {
|
|
1386
|
+
return context.meta.ordering || null;
|
|
1439
1387
|
},
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1388
|
+
size: (context) => {
|
|
1389
|
+
return context.meta.size || null;
|
|
1390
|
+
}
|
|
1391
|
+
};
|
|
1392
|
+
|
|
1393
|
+
// src/core/farm.ts
|
|
1394
|
+
var BRAND_CODES2 = {
|
|
1395
|
+
farm: "farmrio",
|
|
1396
|
+
"farm etc": "farmetc",
|
|
1397
|
+
"farm rio": "farmrio"
|
|
1398
|
+
};
|
|
1399
|
+
function getBrandCode2(brand) {
|
|
1400
|
+
if (!brand) return null;
|
|
1401
|
+
const standardized = brand.toLowerCase().trim();
|
|
1402
|
+
return BRAND_CODES2[standardized] || null;
|
|
1403
|
+
}
|
|
1404
|
+
function normalizeBrand2(input) {
|
|
1405
|
+
var _a;
|
|
1406
|
+
let brandStrings = [];
|
|
1407
|
+
if (Array.isArray(input) && input.every((item) => typeof item === "string")) {
|
|
1408
|
+
brandStrings = input;
|
|
1409
|
+
} else if (Array.isArray(input)) {
|
|
1410
|
+
brandStrings = input.map((item) => {
|
|
1453
1411
|
var _a2;
|
|
1454
|
-
|
|
1455
|
-
return ((_a2 = item.slas) == null ? void 0 : _a2.find((sla) => sla.id === item.selectedSla)) || null;
|
|
1456
|
-
}).filter(Boolean);
|
|
1457
|
-
if (selectedSlas.length === 0) return null;
|
|
1458
|
-
const uniqueTiers = Array.from(
|
|
1459
|
-
new Map(
|
|
1460
|
-
selectedSlas.map((sla) => {
|
|
1461
|
-
var _a2;
|
|
1462
|
-
const key = sla.deliveryChannel === "pickup-in-point" ? `pickup:${((_a2 = sla.pickupStoreInfo) == null ? void 0 : _a2.friendlyName) || sla.name || ""}` : `delivery:${sla.name || ""}`;
|
|
1463
|
-
return [key, sla];
|
|
1464
|
-
})
|
|
1465
|
-
).values()
|
|
1466
|
-
);
|
|
1467
|
-
const sortedTiers = uniqueTiers.sort((a, b) => {
|
|
1468
|
-
var _a2, _b2;
|
|
1469
|
-
const aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
1470
|
-
const bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
1471
|
-
if (aOrder !== bOrder) return aOrder - bOrder;
|
|
1472
|
-
const aLabel = a.deliveryChannel === "pickup-in-point" ? ((_a2 = a.pickupStoreInfo) == null ? void 0 : _a2.friendlyName) || a.name || "" : a.name || "";
|
|
1473
|
-
const bLabel = b.deliveryChannel === "pickup-in-point" ? ((_b2 = b.pickupStoreInfo) == null ? void 0 : _b2.friendlyName) || b.name || "" : b.name || "";
|
|
1474
|
-
return aLabel.localeCompare(bLabel, "pt-BR");
|
|
1412
|
+
return ((_a2 = item.additionalInfo) == null ? void 0 : _a2.brandName) || item.brand;
|
|
1475
1413
|
});
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
transaction_id: (context) => {
|
|
1483
|
-
var _a, _b;
|
|
1484
|
-
return ((_b = (_a = context.orderForm) == null ? void 0 : _a.orderGroup) == null ? void 0 : _b.toString()) || null;
|
|
1485
|
-
},
|
|
1486
|
-
coupon: (context) => {
|
|
1487
|
-
var _a, _b;
|
|
1488
|
-
return context.appliedCoupon || ((_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.marketingData) == null ? void 0 : _b.coupon) || null;
|
|
1489
|
-
},
|
|
1490
|
-
seller_cod_name: (context) => {
|
|
1491
|
-
return context.appliedSellerCodName || (context == null ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
|
|
1414
|
+
} else if (typeof input === "object" && input !== null && "brand" in input) {
|
|
1415
|
+
brandStrings = [((_a = input.additionalInfo) == null ? void 0 : _a.brandName) || input.brand];
|
|
1416
|
+
} else if (typeof input === "string") {
|
|
1417
|
+
return getBrandCode2(input);
|
|
1418
|
+
} else {
|
|
1419
|
+
return null;
|
|
1492
1420
|
}
|
|
1493
|
-
|
|
1421
|
+
const brandCodes = brandStrings.map(getBrandCode2).filter((code) => code !== null);
|
|
1422
|
+
const uniqueSortedCodes = [...new Set(brandCodes)].sort();
|
|
1423
|
+
return uniqueSortedCodes.length > 0 ? uniqueSortedCodes.join("_") : null;
|
|
1424
|
+
}
|
|
1494
1425
|
|
|
1495
|
-
// src/params/adapters/deco/utils
|
|
1426
|
+
// src/params/adapters/deco/utils.ts
|
|
1496
1427
|
var getItemCategory3 = (item) => {
|
|
1497
1428
|
var _a;
|
|
1498
1429
|
const value = item == null ? void 0 : item.category;
|
|
@@ -1510,15 +1441,6 @@ var getItemCategory22 = (item) => {
|
|
|
1510
1441
|
const deepest = (_d = validHierarchy[validHierarchy.length - 1]) != null ? _d : "";
|
|
1511
1442
|
return capitalize(deepest);
|
|
1512
1443
|
};
|
|
1513
|
-
var resizeVtexImage2 = (url, width = 500, height = 500) => {
|
|
1514
|
-
return url == null ? void 0 : url.replace(
|
|
1515
|
-
/(\/arquivos\/ids\/\d+)-\d+-\d+\//,
|
|
1516
|
-
`$1-${width}-${height}/`
|
|
1517
|
-
);
|
|
1518
|
-
};
|
|
1519
|
-
function getItemShippingTier2() {
|
|
1520
|
-
return null;
|
|
1521
|
-
}
|
|
1522
1444
|
|
|
1523
1445
|
// src/params/adapters/deco/index.ts
|
|
1524
1446
|
var IN_STOCK_SCHEMA = "https://schema.org/InStock";
|
|
@@ -1526,13 +1448,11 @@ var LIST_PRICE_SCHEMA = "https://schema.org/ListPrice";
|
|
|
1526
1448
|
var decoAdapter = {
|
|
1527
1449
|
...metaAdapters,
|
|
1528
1450
|
// global adapters
|
|
1529
|
-
...orderFormAdapters,
|
|
1530
|
-
// orderform adapters
|
|
1531
1451
|
items: (context) => {
|
|
1532
1452
|
if (context == null ? void 0 : context.items) return context.items;
|
|
1533
1453
|
if (context == null ? void 0 : context.products) {
|
|
1534
1454
|
return context.products.map((item) => {
|
|
1535
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D;
|
|
1455
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E;
|
|
1536
1456
|
const COLOR_REGEX = /^[^_]+_/;
|
|
1537
1457
|
const listPrice = (_c = (_b = (_a = item == null ? void 0 : item.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b[0].priceSpecification.find(
|
|
1538
1458
|
(s) => s.priceType === LIST_PRICE_SCHEMA
|
|
@@ -1543,33 +1463,37 @@ var decoAdapter = {
|
|
|
1543
1463
|
item_brand: (_g = (_f = (_e = item.brand) == null ? void 0 : _e.name) == null ? void 0 : _f.toLowerCase()) != null ? _g : null,
|
|
1544
1464
|
item_name: (_h = item.alternateName) != null ? _h : null,
|
|
1545
1465
|
price: (_j = (_i = item.offers) == null ? void 0 : _i.lowPrice) != null ? _j : null,
|
|
1546
|
-
discount: Number(listPrice) - Number((_k = item == null ? void 0 : item.offers) == null ? void 0 : _k.lowPrice),
|
|
1466
|
+
discount: Math.round((Number(listPrice) - Number((_k = item == null ? void 0 : item.offers) == null ? void 0 : _k.lowPrice)) * 100) / 100,
|
|
1547
1467
|
item_variant: ((_m = (_l = item == null ? void 0 : item.name) == null ? void 0 : _l.split(" - ")[0]) == null ? void 0 : _m.replace(COLOR_REGEX, "").replace(/_/g, " ")) || null,
|
|
1548
1468
|
// cor
|
|
1549
1469
|
item_variant2: (_o = (_n = item == null ? void 0 : item.name) == null ? void 0 : _n.split(" - ")[1]) != null ? _o : null,
|
|
1550
1470
|
// tamanho
|
|
1551
|
-
item_shipping_tier:
|
|
1552
|
-
item_ref: (_r = (_q = (_p = item.additionalProperty) == null ? void 0 : _p.find((
|
|
1553
|
-
item_category: (
|
|
1554
|
-
item_category2: (
|
|
1555
|
-
item_id: (
|
|
1556
|
-
item_sku: (
|
|
1557
|
-
item_url: (
|
|
1558
|
-
image_url: (
|
|
1559
|
-
seller_id: (
|
|
1560
|
-
item_list_name: (
|
|
1471
|
+
item_shipping_tier: "",
|
|
1472
|
+
item_ref: (_s = (_r = (_q = (_p = item.additionalProperty) == null ? void 0 : _p.find((i) => i.name === "RefId")) == null ? void 0 : _q.value) == null ? void 0 : _r.replace(/_\d+$/, "")) != null ? _s : null,
|
|
1473
|
+
item_category: (_t = getItemCategory3(item)) != null ? _t : null,
|
|
1474
|
+
item_category2: (_u = getItemCategory22(item)) != null ? _u : null,
|
|
1475
|
+
item_id: (_v = item == null ? void 0 : item.inProductGroupWithID) != null ? _v : null,
|
|
1476
|
+
item_sku: (_w = item.sku) != null ? _w : null,
|
|
1477
|
+
item_url: (_x = item.url) != null ? _x : null,
|
|
1478
|
+
image_url: (_z = resizeVtexImage2((_y = item == null ? void 0 : item.image) == null ? void 0 : _y[0].url)) != null ? _z : null,
|
|
1479
|
+
seller_id: (_D = (_C = (_B = (_A = item.offers) == null ? void 0 : _A.offers) == null ? void 0 : _B[0]) == null ? void 0 : _C.seller) != null ? _D : null,
|
|
1480
|
+
item_list_name: (_E = item == null ? void 0 : item.item_list_name) != null ? _E : null
|
|
1561
1481
|
};
|
|
1562
1482
|
});
|
|
1563
1483
|
}
|
|
1564
1484
|
return null;
|
|
1565
1485
|
},
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1486
|
+
brand: (context, config2) => {
|
|
1487
|
+
if (config2 == null ? void 0 : config2.brand) return config2.brand;
|
|
1488
|
+
if (context == null ? void 0 : context.brand) return context.brand;
|
|
1489
|
+
if (context == null ? void 0 : context.products) {
|
|
1490
|
+
return normalizeBrand2(context.products.map((p) => {
|
|
1491
|
+
var _a;
|
|
1492
|
+
return (_a = p == null ? void 0 : p.brand) == null ? void 0 : _a.name;
|
|
1493
|
+
}));
|
|
1494
|
+
}
|
|
1495
|
+
return null;
|
|
1496
|
+
},
|
|
1573
1497
|
line_items: (context) => {
|
|
1574
1498
|
if (context == null ? void 0 : context.line_items) return context.line_items;
|
|
1575
1499
|
if (context == null ? void 0 : context.products) {
|
|
@@ -1611,7 +1535,7 @@ var decoAdapter = {
|
|
|
1611
1535
|
}
|
|
1612
1536
|
};
|
|
1613
1537
|
|
|
1614
|
-
// src/params/adapters/headless/utils
|
|
1538
|
+
// src/params/adapters/headless/utils.ts
|
|
1615
1539
|
var getItemCategory5 = (item) => {
|
|
1616
1540
|
const keywords = ["outlet", "bazar", "sale"];
|
|
1617
1541
|
const regex = new RegExp(keywords.join("|"), "i");
|
|
@@ -1633,12 +1557,6 @@ var getItemCategory23 = (item) => {
|
|
|
1633
1557
|
const deepestCategory = (_c = [...categoryHierarchy].reverse().find((c) => !avoidList.test(c))) != null ? _c : "";
|
|
1634
1558
|
return deepestCategory && deepestCategory[0].toUpperCase() + deepestCategory.slice(1).toLowerCase();
|
|
1635
1559
|
};
|
|
1636
|
-
function resizeVtexImage3(url, width = 500, height = 500) {
|
|
1637
|
-
return url == null ? void 0 : url.replace(
|
|
1638
|
-
/(\/arquivos\/ids\/\d+)-\d+-\d+\//,
|
|
1639
|
-
`$1-${width}-${height}/`
|
|
1640
|
-
);
|
|
1641
|
-
}
|
|
1642
1560
|
|
|
1643
1561
|
// src/params/adapters/headless/zones/PDP.ts
|
|
1644
1562
|
var HeadlessPdpZone = {
|
|
@@ -1655,6 +1573,7 @@ var HeadlessPdpZone = {
|
|
|
1655
1573
|
item_brand: (_d = item.brand) != null ? _d : null,
|
|
1656
1574
|
item_name: (_e = item.productName) != null ? _e : null,
|
|
1657
1575
|
price: price != null ? price : null,
|
|
1576
|
+
item_shipping_tier: null,
|
|
1658
1577
|
discount: Number(listPrice) - Number(price),
|
|
1659
1578
|
item_variant: (_h = (_g = (_f = item.items[0]) == null ? void 0 : _f.name) == null ? void 0 : _g.split(" - ")[0]) != null ? _h : null,
|
|
1660
1579
|
item_variant2: (_k = (_j = (_i = item.items[0]) == null ? void 0 : _i.name) == null ? void 0 : _j.split(" - ")[1]) != null ? _k : null,
|
|
@@ -1666,7 +1585,7 @@ var HeadlessPdpZone = {
|
|
|
1666
1585
|
item_sku: (_p = (_o = item.items) == null ? void 0 : _o[0].itemId) != null ? _p : null,
|
|
1667
1586
|
item_url: (_q = item.link) != null ? _q : null,
|
|
1668
1587
|
// sem link/url no retorno do IS na multi-lib produtos PDC
|
|
1669
|
-
image_url: (_t =
|
|
1588
|
+
image_url: (_t = resizeVtexImage2((_s = (_r = item == null ? void 0 : item.items) == null ? void 0 : _r[0].images) == null ? void 0 : _s[0].imageUrl)) != null ? _t : null,
|
|
1670
1589
|
seller_id: (_x = (_w = (_v = (_u = item.items) == null ? void 0 : _u[0]) == null ? void 0 : _v.sellers) == null ? void 0 : _w[0].sellerId) != null ? _x : null,
|
|
1671
1590
|
item_list_name: (_y = item.item_list_name) != null ? _y : null
|
|
1672
1591
|
};
|
|
@@ -1691,7 +1610,8 @@ var HeadlessPdpZone = {
|
|
|
1691
1610
|
}
|
|
1692
1611
|
return null;
|
|
1693
1612
|
},
|
|
1694
|
-
brand: (context) => {
|
|
1613
|
+
brand: (context, config2) => {
|
|
1614
|
+
if (config2 == null ? void 0 : config2.brand) return config2.brand;
|
|
1695
1615
|
if (context == null ? void 0 : context.brand) return context.brand;
|
|
1696
1616
|
if (context == null ? void 0 : context.products) {
|
|
1697
1617
|
return context.products.map((p) => p.brand).join().trim();
|
|
@@ -1715,6 +1635,7 @@ var HeadlessPdcZone = {
|
|
|
1715
1635
|
item_brand: (_b = item.brand.name) != null ? _b : null,
|
|
1716
1636
|
item_name: (_c = item.name) != null ? _c : null,
|
|
1717
1637
|
price: price != null ? price : null,
|
|
1638
|
+
item_shipping_tier: null,
|
|
1718
1639
|
discount: Number(listPrice) - Number(price),
|
|
1719
1640
|
item_variant: (_f = (_e = (_d = item.isVariantOf) == null ? void 0 : _d.hasVariant) == null ? void 0 : _e[0].name.split(" - ")[0]) != null ? _f : null,
|
|
1720
1641
|
item_variant2: (_i = (_h = ((_g = item.additionalProperty) != null ? _g : []).find((p) => p.name === "Tamanho")) == null ? void 0 : _h.value) != null ? _i : null,
|
|
@@ -1726,7 +1647,7 @@ var HeadlessPdcZone = {
|
|
|
1726
1647
|
item_sku: (_l = item.sku) != null ? _l : null,
|
|
1727
1648
|
item_url: null,
|
|
1728
1649
|
// sem link/url no retorno do IS na multi-lib produtos PDC
|
|
1729
|
-
image_url: (_n =
|
|
1650
|
+
image_url: (_n = resizeVtexImage2((_m = item == null ? void 0 : item.image) == null ? void 0 : _m[0].url)) != null ? _n : null,
|
|
1730
1651
|
seller_id: (_s = (_r = (_q = (_p = (_o = item.offers) == null ? void 0 : _o.offers) == null ? void 0 : _p.find((o) => o.availability)) == null ? void 0 : _q.seller) == null ? void 0 : _r.identifier) != null ? _s : null,
|
|
1731
1652
|
item_list_name: (_t = item.item_list_name) != null ? _t : null
|
|
1732
1653
|
};
|
|
@@ -1748,7 +1669,8 @@ var HeadlessPdcZone = {
|
|
|
1748
1669
|
}
|
|
1749
1670
|
return null;
|
|
1750
1671
|
},
|
|
1751
|
-
brand: (context) => {
|
|
1672
|
+
brand: (context, config2) => {
|
|
1673
|
+
if (config2 == null ? void 0 : config2.brand) return config2.brand;
|
|
1752
1674
|
if (context == null ? void 0 : context.brand) return context.brand;
|
|
1753
1675
|
if (context == null ? void 0 : context.products) {
|
|
1754
1676
|
return context.products.map((p) => p.brand.name).join().trim();
|
|
@@ -1761,14 +1683,12 @@ var HeadlessPdcZone = {
|
|
|
1761
1683
|
var headlessAdapter = {
|
|
1762
1684
|
...metaAdapters,
|
|
1763
1685
|
// global adapters
|
|
1764
|
-
|
|
1765
|
-
// orderForm adapters, confirmar se no storefront tem evento que usa essses params
|
|
1766
|
-
brand: (context) => {
|
|
1686
|
+
brand: (context, config2) => {
|
|
1767
1687
|
if (context.zone === "PDP") {
|
|
1768
|
-
return HeadlessPdpZone.brand(context);
|
|
1688
|
+
return HeadlessPdpZone.brand(context, config2);
|
|
1769
1689
|
}
|
|
1770
1690
|
if (context.zone === "PDC") {
|
|
1771
|
-
return HeadlessPdcZone.brand(context);
|
|
1691
|
+
return HeadlessPdcZone.brand(context, config2);
|
|
1772
1692
|
}
|
|
1773
1693
|
return null;
|
|
1774
1694
|
},
|
|
@@ -1810,17 +1730,271 @@ var headlessAdapter = {
|
|
|
1810
1730
|
}
|
|
1811
1731
|
};
|
|
1812
1732
|
|
|
1733
|
+
// src/params/adapters/pickup/utils.ts
|
|
1734
|
+
var getShippingTier = (sla) => {
|
|
1735
|
+
var _a, _b;
|
|
1736
|
+
const isPickup = sla.deliveryChannel === "pickup-in-point" /* PickupInPoint */;
|
|
1737
|
+
if (isPickup) {
|
|
1738
|
+
const storeName = (_b = (_a = sla.pickupStoreInfo) == null ? void 0 : _a.friendlyName) == null ? void 0 : _b.trim();
|
|
1739
|
+
return storeName ? `retirada em loja: ${storeName}` : "retirada em loja";
|
|
1740
|
+
}
|
|
1741
|
+
return sla.name ? `receba em casa: ${sla.name.toLowerCase()}` : "receba em casa";
|
|
1742
|
+
};
|
|
1743
|
+
var getDeliveryTime = (sla) => {
|
|
1744
|
+
const estimate = sla.shippingEstimate;
|
|
1745
|
+
if (!estimate) return 0;
|
|
1746
|
+
const days = parseInt(estimate, 10);
|
|
1747
|
+
return isNaN(days) ? 0 : days;
|
|
1748
|
+
};
|
|
1749
|
+
|
|
1750
|
+
// src/params/adapters/pickup/index.ts
|
|
1751
|
+
var pickupAdapter = {
|
|
1752
|
+
...metaAdapters,
|
|
1753
|
+
flag_pickup: (context) => {
|
|
1754
|
+
var _a;
|
|
1755
|
+
return (_a = context == null ? void 0 : context.flag_pickup) != null ? _a : null;
|
|
1756
|
+
},
|
|
1757
|
+
shippings: (context) => {
|
|
1758
|
+
if (context.shippings) {
|
|
1759
|
+
return context.shippings.map((s) => {
|
|
1760
|
+
var _a;
|
|
1761
|
+
return {
|
|
1762
|
+
line_items: (_a = s.line_items) != null ? _a : "",
|
|
1763
|
+
shipping: s.price / 100,
|
|
1764
|
+
shipping_tier: getShippingTier(s),
|
|
1765
|
+
delivery_time: getDeliveryTime(s)
|
|
1766
|
+
};
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
return null;
|
|
1770
|
+
},
|
|
1771
|
+
brand: (context, config2) => {
|
|
1772
|
+
if (config2 == null ? void 0 : config2.brand) return config2.brand;
|
|
1773
|
+
if (context == null ? void 0 : context.brand) return context.brand;
|
|
1774
|
+
return null;
|
|
1775
|
+
},
|
|
1776
|
+
zipcode: (context) => {
|
|
1777
|
+
var _a;
|
|
1778
|
+
return (_a = context.meta.zipcode) != null ? _a : null;
|
|
1779
|
+
}
|
|
1780
|
+
};
|
|
1781
|
+
|
|
1782
|
+
// src/params/adapters/orderForm/utils.ts
|
|
1783
|
+
var getItemCategory6 = (item) => {
|
|
1784
|
+
var _a;
|
|
1785
|
+
const categories = item == null ? void 0 : item.productCategories;
|
|
1786
|
+
if (!categories) return "Cole\xE7\xE3o";
|
|
1787
|
+
const text = Object.values(categories).join(" ");
|
|
1788
|
+
const match = (_a = text.match(/outlet|bazar|sale/i)) == null ? void 0 : _a[0].toLowerCase();
|
|
1789
|
+
return match != null ? match : "Cole\xE7\xE3o";
|
|
1790
|
+
};
|
|
1791
|
+
var getItemCategory24 = (item) => {
|
|
1792
|
+
var _a, _b;
|
|
1793
|
+
const AVOID_CATEGORIES = /outlet|bazar|sale/i;
|
|
1794
|
+
const categories = Object.values((_a = item == null ? void 0 : item.productCategories) != null ? _a : {});
|
|
1795
|
+
const validHierarchy = categories.map((c) => c.trim()).filter((c) => c && !AVOID_CATEGORIES.test(c));
|
|
1796
|
+
const deepest = (_b = validHierarchy[validHierarchy.length - 1]) != null ? _b : "";
|
|
1797
|
+
return capitalize(deepest);
|
|
1798
|
+
};
|
|
1799
|
+
function getItemShippingTier2(orderForm, item) {
|
|
1800
|
+
var _a, _b, _c, _d;
|
|
1801
|
+
const info = (_b = (_a = orderForm == null ? void 0 : orderForm.shippingData) == null ? void 0 : _a.logisticsInfo) == null ? void 0 : _b.find(
|
|
1802
|
+
(li) => li.itemId === item.id
|
|
1803
|
+
);
|
|
1804
|
+
const selectedSla = (_c = info == null ? void 0 : info.slas) == null ? void 0 : _c.find((sla) => sla.id === info.selectedSla);
|
|
1805
|
+
return ((_d = selectedSla == null ? void 0 : selectedSla.pickupStoreInfo) == null ? void 0 : _d.friendlyName) ? `retirada em loja: ${selectedSla.pickupStoreInfo.friendlyName}` : (selectedSla == null ? void 0 : selectedSla.name) ? `Receba em casa: ${selectedSla.name}` : null;
|
|
1806
|
+
}
|
|
1807
|
+
var getOrderFormItems = (orderForm) => {
|
|
1808
|
+
const idSelected = orderForm == null ? void 0 : orderForm.selected;
|
|
1809
|
+
return idSelected ? orderForm.items.filter((item) => item.id === idSelected) : orderForm.items;
|
|
1810
|
+
};
|
|
1811
|
+
|
|
1812
|
+
// src/params/adapters/orderForm/index.ts
|
|
1813
|
+
var orderFormAdapter = {
|
|
1814
|
+
...metaAdapters,
|
|
1815
|
+
items: (context) => {
|
|
1816
|
+
if (context == null ? void 0 : context.items) return context.items;
|
|
1817
|
+
if ((context == null ? void 0 : context.orderForm) && (context == null ? void 0 : context.orderForm.items)) {
|
|
1818
|
+
return getOrderFormItems(context.orderForm).map((item, index) => {
|
|
1819
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
1820
|
+
return {
|
|
1821
|
+
quantity: (_a = item == null ? void 0 : item.quantity) != null ? _a : 1,
|
|
1822
|
+
index: (_d = (_c = (_b = context == null ? void 0 : context.orderForm) == null ? void 0 : _b.index) != null ? _c : index) != null ? _d : null,
|
|
1823
|
+
item_brand: (_f = (_e = item.additionalInfo) == null ? void 0 : _e.brandName) != null ? _f : null,
|
|
1824
|
+
item_name: (_g = item == null ? void 0 : item.name.replace(item == null ? void 0 : item.skuName, "").trim()) != null ? _g : null,
|
|
1825
|
+
price: (item == null ? void 0 : item.price) / 100,
|
|
1826
|
+
discount: ((item == null ? void 0 : item.listPrice) - (item == null ? void 0 : item.sellingPrice)) / 100,
|
|
1827
|
+
item_variant: (_k = (_j = (_i = (_h = item == null ? void 0 : item.skuName) == null ? void 0 : _h.split(" - ")[0]) == null ? void 0 : _i.split("_").pop()) == null ? void 0 : _j.trim()) != null ? _k : null,
|
|
1828
|
+
item_variant2: (_n = (_m = (_l = item == null ? void 0 : item.skuName) == null ? void 0 : _l.split(" - ")[1]) == null ? void 0 : _m.trim()) != null ? _n : null,
|
|
1829
|
+
item_shipping_tier: getItemShippingTier2(context.orderForm, item),
|
|
1830
|
+
item_ref: (item == null ? void 0 : item.productRefId) || (item == null ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
|
|
1831
|
+
item_category: (_o = getItemCategory6(item)) != null ? _o : null,
|
|
1832
|
+
item_category2: (_p = getItemCategory24(item)) != null ? _p : null,
|
|
1833
|
+
item_id: (_q = item == null ? void 0 : item.productId) != null ? _q : null,
|
|
1834
|
+
item_sku: (_r = item == null ? void 0 : item.id) != null ? _r : null,
|
|
1835
|
+
item_url: (_s = item.detailUrl) != null ? _s : null,
|
|
1836
|
+
image_url: (_t = resizeVtexImage2(item.imageUrl)) != null ? _t : null,
|
|
1837
|
+
seller_id: (_u = item == null ? void 0 : item.seller) != null ? _u : null,
|
|
1838
|
+
item_list_name: (_w = (_v = context == null ? void 0 : context.orderForm) == null ? void 0 : _v.item_list_name) != null ? _w : null
|
|
1839
|
+
};
|
|
1840
|
+
});
|
|
1841
|
+
}
|
|
1842
|
+
return null;
|
|
1843
|
+
},
|
|
1844
|
+
brand: (context, config2) => {
|
|
1845
|
+
var _a;
|
|
1846
|
+
if (config2 == null ? void 0 : config2.brand) return config2.brand;
|
|
1847
|
+
if (context == null ? void 0 : context.brand) return context.brand;
|
|
1848
|
+
if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
|
|
1849
|
+
const brands = getOrderFormItems(context.orderForm).map((item) => item.additionalInfo.brandName);
|
|
1850
|
+
return normalizeBrand2(brands);
|
|
1851
|
+
},
|
|
1852
|
+
line_items: (context) => {
|
|
1853
|
+
var _a;
|
|
1854
|
+
if (context == null ? void 0 : context.line_items) return context.line_items;
|
|
1855
|
+
if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
|
|
1856
|
+
return getOrderFormItems(context.orderForm).map((item) => item == null ? void 0 : item.productId).filter((id) => Boolean(id));
|
|
1857
|
+
},
|
|
1858
|
+
value: (context) => {
|
|
1859
|
+
var _a;
|
|
1860
|
+
if (context == null ? void 0 : context.value) return context.value;
|
|
1861
|
+
if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
|
|
1862
|
+
return getOrderFormItems(context.orderForm).map((item) => (item == null ? void 0 : item.price) / 100 * item.quantity).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
|
|
1863
|
+
},
|
|
1864
|
+
payment_type: getPaymentType,
|
|
1865
|
+
total_discount: (context) => {
|
|
1866
|
+
var _a, _b;
|
|
1867
|
+
if (context == null ? void 0 : context.total_discount) return context.total_discount;
|
|
1868
|
+
if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
|
|
1869
|
+
const totalsList = ((_b = context.orderForm) == null ? void 0 : _b.totalizers) || [];
|
|
1870
|
+
const totalDiscount = getOrderFormItems(context.orderForm).reduce((acc, item) => {
|
|
1871
|
+
const unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
|
|
1872
|
+
return acc + unitDiscount * item.quantity;
|
|
1873
|
+
}, 0);
|
|
1874
|
+
const discounts = totalsList.find((t) => t.id === "Discounts");
|
|
1875
|
+
return Math.abs(((discounts == null ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
|
|
1876
|
+
},
|
|
1877
|
+
subtotal: (context) => {
|
|
1878
|
+
var _a, _b;
|
|
1879
|
+
const totalsList = ((_a = context.orderForm) == null ? void 0 : _a.totalizers) || ((_b = context.orderForm) == null ? void 0 : _b.totals) || [];
|
|
1880
|
+
const subtotal = totalsList.filter((t) => t.id === "Items").reduce((acc, t) => acc + (t.value || 0), 0) / 100 || 0;
|
|
1881
|
+
return subtotal;
|
|
1882
|
+
},
|
|
1883
|
+
coupon_message: (context) => {
|
|
1884
|
+
var _a;
|
|
1885
|
+
if (context.couponMessage) return context.couponMessage;
|
|
1886
|
+
const messages = ((_a = context.orderForm) == null ? void 0 : _a.messages) || [];
|
|
1887
|
+
if (messages.length === 0) return null;
|
|
1888
|
+
const couponMessages = messages.filter(
|
|
1889
|
+
(msg) => msg.text.toLowerCase().includes("cupom")
|
|
1890
|
+
);
|
|
1891
|
+
if (couponMessages.length === 0) return null;
|
|
1892
|
+
return couponMessages.map((msg) => msg.text).join(" | ");
|
|
1893
|
+
},
|
|
1894
|
+
zipcode: (context) => {
|
|
1895
|
+
var _a;
|
|
1896
|
+
return (_a = context.meta.zipcode) != null ? _a : null;
|
|
1897
|
+
},
|
|
1898
|
+
flag_pickup: (context) => {
|
|
1899
|
+
var _a;
|
|
1900
|
+
const orderForm = context.orderForm;
|
|
1901
|
+
if (!orderForm) return null;
|
|
1902
|
+
const logisticsInfo = ((_a = orderForm.shippingData) == null ? void 0 : _a.logisticsInfo) || [];
|
|
1903
|
+
const hasPickup = logisticsInfo.some(
|
|
1904
|
+
(info) => {
|
|
1905
|
+
var _a2;
|
|
1906
|
+
return (_a2 = info.slas) == null ? void 0 : _a2.some((sla) => sla.deliveryChannel === "pickup-in-point");
|
|
1907
|
+
}
|
|
1908
|
+
);
|
|
1909
|
+
return hasPickup;
|
|
1910
|
+
},
|
|
1911
|
+
shippings: (context) => {
|
|
1912
|
+
if (!context.orderForm) return null;
|
|
1913
|
+
const { items, shippingData } = context.orderForm;
|
|
1914
|
+
const acc = {};
|
|
1915
|
+
shippingData.logisticsInfo.forEach(({ itemIndex, slas }) => {
|
|
1916
|
+
const item = items[itemIndex];
|
|
1917
|
+
if (!item) return;
|
|
1918
|
+
slas.forEach((sla) => {
|
|
1919
|
+
if (!acc[sla.name]) acc[sla.name] = {
|
|
1920
|
+
shipping_tier: sla.name,
|
|
1921
|
+
delivery_time: parseInt(sla.shippingEstimate),
|
|
1922
|
+
shipping: parseFloat((sla.price / 100).toFixed(1)),
|
|
1923
|
+
line_items: []
|
|
1924
|
+
};
|
|
1925
|
+
acc[sla.name].line_items.push(item.id);
|
|
1926
|
+
});
|
|
1927
|
+
});
|
|
1928
|
+
return Object.values(acc).map((s) => ({ ...s, line_items: s.line_items.join(",") }));
|
|
1929
|
+
},
|
|
1930
|
+
shipping: (context) => {
|
|
1931
|
+
var _a, _b, _c;
|
|
1932
|
+
const logistics = (_c = (_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.shippingData) == null ? void 0 : _b.logisticsInfo) != null ? _c : [];
|
|
1933
|
+
return logistics.reduce((total, item) => {
|
|
1934
|
+
var _a2, _b2;
|
|
1935
|
+
const selected = (_a2 = item.slas) == null ? void 0 : _a2.find((sla) => sla.id === item.selectedSla);
|
|
1936
|
+
return total + ((_b2 = selected == null ? void 0 : selected.price) != null ? _b2 : 0);
|
|
1937
|
+
}, 0);
|
|
1938
|
+
},
|
|
1939
|
+
shipping_tier: (context) => {
|
|
1940
|
+
var _a, _b, _c;
|
|
1941
|
+
const logistics = (_c = (_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.shippingData) == null ? void 0 : _b.logisticsInfo) != null ? _c : [];
|
|
1942
|
+
const selectedSlas = logistics.map((item) => {
|
|
1943
|
+
var _a2;
|
|
1944
|
+
if (!item.selectedSla) return null;
|
|
1945
|
+
return ((_a2 = item.slas) == null ? void 0 : _a2.find((sla) => sla.id === item.selectedSla)) || null;
|
|
1946
|
+
}).filter(Boolean);
|
|
1947
|
+
if (selectedSlas.length === 0) return null;
|
|
1948
|
+
const uniqueTiers = Array.from(
|
|
1949
|
+
new Map(
|
|
1950
|
+
selectedSlas.map((sla) => {
|
|
1951
|
+
var _a2;
|
|
1952
|
+
const key = sla.deliveryChannel === "pickup-in-point" ? `pickup:${((_a2 = sla.pickupStoreInfo) == null ? void 0 : _a2.friendlyName) || sla.name || ""}` : `delivery:${sla.name || ""}`;
|
|
1953
|
+
return [key, sla];
|
|
1954
|
+
})
|
|
1955
|
+
).values()
|
|
1956
|
+
);
|
|
1957
|
+
const sortedTiers = uniqueTiers.sort((a, b) => {
|
|
1958
|
+
var _a2, _b2;
|
|
1959
|
+
const aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
1960
|
+
const bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
1961
|
+
if (aOrder !== bOrder) return aOrder - bOrder;
|
|
1962
|
+
const aLabel = a.deliveryChannel === "pickup-in-point" ? ((_a2 = a.pickupStoreInfo) == null ? void 0 : _a2.friendlyName) || a.name || "" : a.name || "";
|
|
1963
|
+
const bLabel = b.deliveryChannel === "pickup-in-point" ? ((_b2 = b.pickupStoreInfo) == null ? void 0 : _b2.friendlyName) || b.name || "" : b.name || "";
|
|
1964
|
+
return aLabel.localeCompare(bLabel, "pt-BR");
|
|
1965
|
+
});
|
|
1966
|
+
const shippingTier = sortedTiers.map((sla) => {
|
|
1967
|
+
var _a2;
|
|
1968
|
+
return sla.deliveryChannel === "pickup-in-point" ? `retirada em loja${((_a2 = sla.pickupStoreInfo) == null ? void 0 : _a2.friendlyName) ? `: ${sla.pickupStoreInfo.friendlyName}` : ""}` : sla.deliveryChannel === "delivery" ? `receba em casa${sla.name ? `: ${sla.name}` : ""}` : null;
|
|
1969
|
+
}).filter(Boolean).join(", ");
|
|
1970
|
+
return shippingTier || null;
|
|
1971
|
+
},
|
|
1972
|
+
transaction_id: (context) => {
|
|
1973
|
+
var _a, _b;
|
|
1974
|
+
return ((_b = (_a = context.orderForm) == null ? void 0 : _a.orderGroup) == null ? void 0 : _b.toString()) || null;
|
|
1975
|
+
},
|
|
1976
|
+
coupon: (context) => {
|
|
1977
|
+
var _a, _b;
|
|
1978
|
+
return context.appliedCoupon || ((_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.marketingData) == null ? void 0 : _b.coupon) || null;
|
|
1979
|
+
},
|
|
1980
|
+
seller_cod_name: (context) => {
|
|
1981
|
+
return context.appliedSellerCodName || (context == null ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
|
|
1982
|
+
}
|
|
1983
|
+
};
|
|
1984
|
+
|
|
1813
1985
|
// src/formatter.ts
|
|
1814
1986
|
var adapters = {
|
|
1815
1987
|
DECO: decoAdapter,
|
|
1816
|
-
HEADLESS: headlessAdapter
|
|
1988
|
+
HEADLESS: headlessAdapter,
|
|
1989
|
+
PICKUP: pickupAdapter,
|
|
1990
|
+
ORDERFORM: orderFormAdapter
|
|
1817
1991
|
};
|
|
1818
|
-
async function getParameters(context, eventName) {
|
|
1992
|
+
async function getParameters(context, eventName, config2) {
|
|
1819
1993
|
var _a;
|
|
1820
1994
|
const eventConfig = EVENTS[eventName];
|
|
1821
1995
|
if (!eventConfig) return;
|
|
1822
1996
|
const currentAdapter = context.adapter;
|
|
1823
|
-
const getters = (_a = adapters[currentAdapter]) != null ? _a :
|
|
1997
|
+
const getters = (_a = adapters[currentAdapter]) != null ? _a : legacyGetters;
|
|
1824
1998
|
const entries = await Promise.all(
|
|
1825
1999
|
eventConfig.requiredParams.map(async (param) => {
|
|
1826
2000
|
const getter = getters[param];
|
|
@@ -1828,16 +2002,20 @@ async function getParameters(context, eventName) {
|
|
|
1828
2002
|
console.error(`[DT] Missing getter "${param}" for adapter "${currentAdapter}"`);
|
|
1829
2003
|
return [param, null];
|
|
1830
2004
|
}
|
|
1831
|
-
return [param, await getter(context,
|
|
2005
|
+
return [param, await getter(context, config2)];
|
|
1832
2006
|
})
|
|
1833
2007
|
);
|
|
1834
2008
|
return Object.fromEntries(entries);
|
|
1835
2009
|
}
|
|
1836
2010
|
|
|
1837
2011
|
// src/index.ts
|
|
2012
|
+
var config = { brand: "", currency: "BRL" };
|
|
2013
|
+
function initTracker(c) {
|
|
2014
|
+
config = c;
|
|
2015
|
+
}
|
|
1838
2016
|
async function trackWebEvent(event, context) {
|
|
1839
2017
|
try {
|
|
1840
|
-
const parameters = await getParameters(context, event);
|
|
2018
|
+
const parameters = await getParameters(context, event, config);
|
|
1841
2019
|
if (isDebugMode()) {
|
|
1842
2020
|
console.log(`[DT v2] ${event}, context e parameters: `, {
|
|
1843
2021
|
context,
|
|
@@ -1859,6 +2037,7 @@ var src_default = {
|
|
|
1859
2037
|
export {
|
|
1860
2038
|
EVENTS,
|
|
1861
2039
|
src_default as default,
|
|
2040
|
+
initTracker,
|
|
1862
2041
|
trackWebEvent
|
|
1863
2042
|
};
|
|
1864
2043
|
//# sourceMappingURL=mod.js.map
|