@azzas/azzas-tracker-web 2.0.0-preview.1 → 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 +306 -193
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.d.cts +500 -18
- package/dist/mod.d.ts +500 -18
- package/dist/mod.global.js +305 -193
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +305 -193
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +346 -233
- package/package.json +1 -1
package/dist/mod.js
CHANGED
|
@@ -290,7 +290,7 @@ 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
294
|
},
|
|
295
295
|
REFINE_RESULTS: {
|
|
296
296
|
name: "refine_results",
|
|
@@ -984,6 +984,12 @@ var sortSizes = (sizes) => {
|
|
|
984
984
|
return unique;
|
|
985
985
|
};
|
|
986
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
|
+
};
|
|
987
993
|
|
|
988
994
|
// src/params/legacy/resolvers/paymentType/fromOrderForm.ts
|
|
989
995
|
function paymentTypeFromOrderForm(context) {
|
|
@@ -1036,7 +1042,7 @@ var PROD_DOMAINS = {
|
|
|
1036
1042
|
"store": "https://www.animale.com.br",
|
|
1037
1043
|
"checkout": "https://secure.animale.com.br"
|
|
1038
1044
|
},
|
|
1039
|
-
"
|
|
1045
|
+
"lojafarm": {
|
|
1040
1046
|
"store": "https://lojafarm.myvtex.com"
|
|
1041
1047
|
},
|
|
1042
1048
|
"mariafilo": {
|
|
@@ -1054,7 +1060,7 @@ var PROD_DOMAINS = {
|
|
|
1054
1060
|
"bynv": {
|
|
1055
1061
|
"store": "https://bynv.myvtex.com"
|
|
1056
1062
|
},
|
|
1057
|
-
"
|
|
1063
|
+
"lojafabula": {
|
|
1058
1064
|
"store": "https://lojafabula.myvtex.com"
|
|
1059
1065
|
}
|
|
1060
1066
|
};
|
|
@@ -1323,9 +1329,6 @@ var legacyGetters = {
|
|
|
1323
1329
|
// src/params/adapters/meta/index.ts
|
|
1324
1330
|
var metaAdapters = {
|
|
1325
1331
|
user_info: getUserInfo,
|
|
1326
|
-
brand: (context) => {
|
|
1327
|
-
return context.meta.brand || null;
|
|
1328
|
-
},
|
|
1329
1332
|
content_type: (context) => {
|
|
1330
1333
|
return context.meta.content_type || null;
|
|
1331
1334
|
},
|
|
@@ -1335,8 +1338,8 @@ var metaAdapters = {
|
|
|
1335
1338
|
pre_filled: (context) => {
|
|
1336
1339
|
return !!context.preFilled;
|
|
1337
1340
|
},
|
|
1338
|
-
currency: (
|
|
1339
|
-
if (
|
|
1341
|
+
currency: (_, config2) => {
|
|
1342
|
+
if (config2 == null ? void 0 : config2.currency) return config2.currency;
|
|
1340
1343
|
return "BRL";
|
|
1341
1344
|
},
|
|
1342
1345
|
slot_per_line: (context) => {
|
|
@@ -1361,17 +1364,14 @@ var metaAdapters = {
|
|
|
1361
1364
|
creative_slot: (context) => {
|
|
1362
1365
|
return context.meta.creative_slot || null;
|
|
1363
1366
|
},
|
|
1364
|
-
size: (context) => {
|
|
1365
|
-
return context.size || null;
|
|
1366
|
-
},
|
|
1367
1367
|
item_ref: (context) => {
|
|
1368
|
-
return context.
|
|
1368
|
+
return context.meta.item_ref || null;
|
|
1369
1369
|
},
|
|
1370
1370
|
method: (context) => {
|
|
1371
|
-
return context.method || null;
|
|
1371
|
+
return context.meta.method || null;
|
|
1372
1372
|
},
|
|
1373
1373
|
type: (context) => {
|
|
1374
|
-
return context.type || null;
|
|
1374
|
+
return context.meta.type || null;
|
|
1375
1375
|
},
|
|
1376
1376
|
color: (context) => {
|
|
1377
1377
|
return context.meta.color || null;
|
|
@@ -1384,9 +1384,45 @@ var metaAdapters = {
|
|
|
1384
1384
|
},
|
|
1385
1385
|
ordering: (context) => {
|
|
1386
1386
|
return context.meta.ordering || null;
|
|
1387
|
+
},
|
|
1388
|
+
size: (context) => {
|
|
1389
|
+
return context.meta.size || null;
|
|
1387
1390
|
}
|
|
1388
1391
|
};
|
|
1389
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) => {
|
|
1411
|
+
var _a2;
|
|
1412
|
+
return ((_a2 = item.additionalInfo) == null ? void 0 : _a2.brandName) || item.brand;
|
|
1413
|
+
});
|
|
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;
|
|
1420
|
+
}
|
|
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
|
+
}
|
|
1425
|
+
|
|
1390
1426
|
// src/params/adapters/deco/utils.ts
|
|
1391
1427
|
var getItemCategory3 = (item) => {
|
|
1392
1428
|
var _a;
|
|
@@ -1405,15 +1441,6 @@ var getItemCategory22 = (item) => {
|
|
|
1405
1441
|
const deepest = (_d = validHierarchy[validHierarchy.length - 1]) != null ? _d : "";
|
|
1406
1442
|
return capitalize(deepest);
|
|
1407
1443
|
};
|
|
1408
|
-
var resizeVtexImage2 = (url, width = 500, height = 500) => {
|
|
1409
|
-
return url == null ? void 0 : url.replace(
|
|
1410
|
-
/(\/arquivos\/ids\/\d+)-\d+-\d+\//,
|
|
1411
|
-
`$1-${width}-${height}/`
|
|
1412
|
-
);
|
|
1413
|
-
};
|
|
1414
|
-
function getItemShippingTier2() {
|
|
1415
|
-
return null;
|
|
1416
|
-
}
|
|
1417
1444
|
|
|
1418
1445
|
// src/params/adapters/deco/index.ts
|
|
1419
1446
|
var IN_STOCK_SCHEMA = "https://schema.org/InStock";
|
|
@@ -1425,7 +1452,7 @@ var decoAdapter = {
|
|
|
1425
1452
|
if (context == null ? void 0 : context.items) return context.items;
|
|
1426
1453
|
if (context == null ? void 0 : context.products) {
|
|
1427
1454
|
return context.products.map((item) => {
|
|
1428
|
-
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;
|
|
1429
1456
|
const COLOR_REGEX = /^[^_]+_/;
|
|
1430
1457
|
const listPrice = (_c = (_b = (_a = item == null ? void 0 : item.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b[0].priceSpecification.find(
|
|
1431
1458
|
(s) => s.priceType === LIST_PRICE_SCHEMA
|
|
@@ -1436,33 +1463,37 @@ var decoAdapter = {
|
|
|
1436
1463
|
item_brand: (_g = (_f = (_e = item.brand) == null ? void 0 : _e.name) == null ? void 0 : _f.toLowerCase()) != null ? _g : null,
|
|
1437
1464
|
item_name: (_h = item.alternateName) != null ? _h : null,
|
|
1438
1465
|
price: (_j = (_i = item.offers) == null ? void 0 : _i.lowPrice) != null ? _j : null,
|
|
1439
|
-
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,
|
|
1440
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,
|
|
1441
1468
|
// cor
|
|
1442
1469
|
item_variant2: (_o = (_n = item == null ? void 0 : item.name) == null ? void 0 : _n.split(" - ")[1]) != null ? _o : null,
|
|
1443
1470
|
// tamanho
|
|
1444
|
-
item_shipping_tier:
|
|
1445
|
-
item_ref: (_r = (_q = (_p = item.additionalProperty) == null ? void 0 : _p.find((
|
|
1446
|
-
item_category: (
|
|
1447
|
-
item_category2: (
|
|
1448
|
-
item_id: (
|
|
1449
|
-
item_sku: (
|
|
1450
|
-
item_url: (
|
|
1451
|
-
image_url: (
|
|
1452
|
-
seller_id: (
|
|
1453
|
-
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
|
|
1454
1481
|
};
|
|
1455
1482
|
});
|
|
1456
1483
|
}
|
|
1457
1484
|
return null;
|
|
1458
1485
|
},
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
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
|
+
},
|
|
1466
1497
|
line_items: (context) => {
|
|
1467
1498
|
if (context == null ? void 0 : context.line_items) return context.line_items;
|
|
1468
1499
|
if (context == null ? void 0 : context.products) {
|
|
@@ -1504,135 +1535,6 @@ var decoAdapter = {
|
|
|
1504
1535
|
}
|
|
1505
1536
|
};
|
|
1506
1537
|
|
|
1507
|
-
// src/params/adapters/orderForm/index.ts
|
|
1508
|
-
var orderFormAdapters = {
|
|
1509
|
-
// orderform
|
|
1510
|
-
payment_type: getPaymentType,
|
|
1511
|
-
total_discount: (context) => {
|
|
1512
|
-
var _a, _b;
|
|
1513
|
-
if (context == null ? void 0 : context.totalDiscount) return context.totalDiscount;
|
|
1514
|
-
const totalsList = ((_a = context.orderForm) == null ? void 0 : _a.totalizers) || ((_b = context.orderForm) == null ? void 0 : _b.totals) || [];
|
|
1515
|
-
const items = context.orderForm.items;
|
|
1516
|
-
const totalDiscount = items.reduce((acc, item) => {
|
|
1517
|
-
const unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
|
|
1518
|
-
return acc + unitDiscount * item.quantity;
|
|
1519
|
-
}, 0);
|
|
1520
|
-
const discounts = totalsList.find((t) => t.id === "Discounts");
|
|
1521
|
-
return Math.abs(((discounts == null ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
|
|
1522
|
-
},
|
|
1523
|
-
subtotal: (context) => {
|
|
1524
|
-
var _a, _b;
|
|
1525
|
-
const totalsList = ((_a = context.orderForm) == null ? void 0 : _a.totalizers) || ((_b = context.orderForm) == null ? void 0 : _b.totals) || [];
|
|
1526
|
-
const subtotal = totalsList.filter((t) => t.id === "Items").reduce((acc, t) => acc + (t.value || 0), 0) / 100 || 0;
|
|
1527
|
-
return subtotal;
|
|
1528
|
-
},
|
|
1529
|
-
coupon_message: (context) => {
|
|
1530
|
-
var _a;
|
|
1531
|
-
if (context.couponMessage) return context.couponMessage;
|
|
1532
|
-
const messages = ((_a = context.orderForm) == null ? void 0 : _a.messages) || [];
|
|
1533
|
-
if (messages.length === 0) return null;
|
|
1534
|
-
const couponMessages = messages.filter(
|
|
1535
|
-
(msg) => msg.text.toLowerCase().includes("cupom")
|
|
1536
|
-
);
|
|
1537
|
-
if (couponMessages.length === 0) return null;
|
|
1538
|
-
return couponMessages.map((msg) => msg.text).join(" | ");
|
|
1539
|
-
},
|
|
1540
|
-
flag_pickup: (context) => {
|
|
1541
|
-
var _a;
|
|
1542
|
-
const orderForm = context.orderForm;
|
|
1543
|
-
if (!orderForm) return null;
|
|
1544
|
-
const logisticsInfo = ((_a = orderForm.shippingData) == null ? void 0 : _a.logisticsInfo) || [];
|
|
1545
|
-
const hasPickup = logisticsInfo.some(
|
|
1546
|
-
(info) => {
|
|
1547
|
-
var _a2;
|
|
1548
|
-
return (_a2 = info.slas) == null ? void 0 : _a2.some((sla) => sla.deliveryChannel === "pickup-in-point");
|
|
1549
|
-
}
|
|
1550
|
-
);
|
|
1551
|
-
return hasPickup;
|
|
1552
|
-
},
|
|
1553
|
-
shippings: (context) => {
|
|
1554
|
-
const orderForm = context.orderForm;
|
|
1555
|
-
if (!orderForm) return null;
|
|
1556
|
-
const groupShipping = {};
|
|
1557
|
-
for (const info of orderForm.shippingData.logisticsInfo) {
|
|
1558
|
-
const item = orderForm.items[info.itemIndex];
|
|
1559
|
-
if (!item) continue;
|
|
1560
|
-
for (const sla of info.slas) {
|
|
1561
|
-
const key = sla.name;
|
|
1562
|
-
if (!groupShipping[key]) {
|
|
1563
|
-
groupShipping[key] = {
|
|
1564
|
-
shipping_tier: sla.name,
|
|
1565
|
-
delivery_time: parseInt(sla.shippingEstimate),
|
|
1566
|
-
shipping: parseFloat((sla.price / 100).toFixed(1)),
|
|
1567
|
-
line_items: []
|
|
1568
|
-
};
|
|
1569
|
-
}
|
|
1570
|
-
groupShipping[key].line_items.push(item.id);
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
const shippings = Object.values(groupShipping).map((s) => ({
|
|
1574
|
-
shipping: s.shipping,
|
|
1575
|
-
shipping_tier: s.shipping_tier,
|
|
1576
|
-
delivery_time: s.delivery_time,
|
|
1577
|
-
line_items: s.line_items.join(",")
|
|
1578
|
-
}));
|
|
1579
|
-
return shippings || null;
|
|
1580
|
-
},
|
|
1581
|
-
shipping: (context) => {
|
|
1582
|
-
var _a, _b, _c;
|
|
1583
|
-
const logistics = (_c = (_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.shippingData) == null ? void 0 : _b.logisticsInfo) != null ? _c : [];
|
|
1584
|
-
return logistics.reduce((total, item) => {
|
|
1585
|
-
var _a2, _b2;
|
|
1586
|
-
const selected = (_a2 = item.slas) == null ? void 0 : _a2.find((sla) => sla.id === item.selectedSla);
|
|
1587
|
-
return total + ((_b2 = selected == null ? void 0 : selected.price) != null ? _b2 : 0);
|
|
1588
|
-
}, 0);
|
|
1589
|
-
},
|
|
1590
|
-
shipping_tier: (context) => {
|
|
1591
|
-
var _a, _b, _c;
|
|
1592
|
-
const logistics = (_c = (_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.shippingData) == null ? void 0 : _b.logisticsInfo) != null ? _c : [];
|
|
1593
|
-
const selectedSlas = logistics.map((item) => {
|
|
1594
|
-
var _a2;
|
|
1595
|
-
if (!item.selectedSla) return null;
|
|
1596
|
-
return ((_a2 = item.slas) == null ? void 0 : _a2.find((sla) => sla.id === item.selectedSla)) || null;
|
|
1597
|
-
}).filter(Boolean);
|
|
1598
|
-
if (selectedSlas.length === 0) return null;
|
|
1599
|
-
const uniqueTiers = Array.from(
|
|
1600
|
-
new Map(
|
|
1601
|
-
selectedSlas.map((sla) => {
|
|
1602
|
-
var _a2;
|
|
1603
|
-
const key = sla.deliveryChannel === "pickup-in-point" ? `pickup:${((_a2 = sla.pickupStoreInfo) == null ? void 0 : _a2.friendlyName) || sla.name || ""}` : `delivery:${sla.name || ""}`;
|
|
1604
|
-
return [key, sla];
|
|
1605
|
-
})
|
|
1606
|
-
).values()
|
|
1607
|
-
);
|
|
1608
|
-
const sortedTiers = uniqueTiers.sort((a, b) => {
|
|
1609
|
-
var _a2, _b2;
|
|
1610
|
-
const aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
1611
|
-
const bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
1612
|
-
if (aOrder !== bOrder) return aOrder - bOrder;
|
|
1613
|
-
const aLabel = a.deliveryChannel === "pickup-in-point" ? ((_a2 = a.pickupStoreInfo) == null ? void 0 : _a2.friendlyName) || a.name || "" : a.name || "";
|
|
1614
|
-
const bLabel = b.deliveryChannel === "pickup-in-point" ? ((_b2 = b.pickupStoreInfo) == null ? void 0 : _b2.friendlyName) || b.name || "" : b.name || "";
|
|
1615
|
-
return aLabel.localeCompare(bLabel, "pt-BR");
|
|
1616
|
-
});
|
|
1617
|
-
const shippingTier = sortedTiers.map((sla) => {
|
|
1618
|
-
var _a2;
|
|
1619
|
-
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;
|
|
1620
|
-
}).filter(Boolean).join(", ");
|
|
1621
|
-
return shippingTier || null;
|
|
1622
|
-
},
|
|
1623
|
-
transaction_id: (context) => {
|
|
1624
|
-
var _a, _b;
|
|
1625
|
-
return ((_b = (_a = context.orderForm) == null ? void 0 : _a.orderGroup) == null ? void 0 : _b.toString()) || null;
|
|
1626
|
-
},
|
|
1627
|
-
coupon: (context) => {
|
|
1628
|
-
var _a, _b;
|
|
1629
|
-
return context.appliedCoupon || ((_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.marketingData) == null ? void 0 : _b.coupon) || null;
|
|
1630
|
-
},
|
|
1631
|
-
seller_cod_name: (context) => {
|
|
1632
|
-
return context.appliedSellerCodName || (context == null ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
|
|
1633
|
-
}
|
|
1634
|
-
};
|
|
1635
|
-
|
|
1636
1538
|
// src/params/adapters/headless/utils.ts
|
|
1637
1539
|
var getItemCategory5 = (item) => {
|
|
1638
1540
|
const keywords = ["outlet", "bazar", "sale"];
|
|
@@ -1655,12 +1557,6 @@ var getItemCategory23 = (item) => {
|
|
|
1655
1557
|
const deepestCategory = (_c = [...categoryHierarchy].reverse().find((c) => !avoidList.test(c))) != null ? _c : "";
|
|
1656
1558
|
return deepestCategory && deepestCategory[0].toUpperCase() + deepestCategory.slice(1).toLowerCase();
|
|
1657
1559
|
};
|
|
1658
|
-
function resizeVtexImage3(url, width = 500, height = 500) {
|
|
1659
|
-
return url == null ? void 0 : url.replace(
|
|
1660
|
-
/(\/arquivos\/ids\/\d+)-\d+-\d+\//,
|
|
1661
|
-
`$1-${width}-${height}/`
|
|
1662
|
-
);
|
|
1663
|
-
}
|
|
1664
1560
|
|
|
1665
1561
|
// src/params/adapters/headless/zones/PDP.ts
|
|
1666
1562
|
var HeadlessPdpZone = {
|
|
@@ -1677,6 +1573,7 @@ var HeadlessPdpZone = {
|
|
|
1677
1573
|
item_brand: (_d = item.brand) != null ? _d : null,
|
|
1678
1574
|
item_name: (_e = item.productName) != null ? _e : null,
|
|
1679
1575
|
price: price != null ? price : null,
|
|
1576
|
+
item_shipping_tier: null,
|
|
1680
1577
|
discount: Number(listPrice) - Number(price),
|
|
1681
1578
|
item_variant: (_h = (_g = (_f = item.items[0]) == null ? void 0 : _f.name) == null ? void 0 : _g.split(" - ")[0]) != null ? _h : null,
|
|
1682
1579
|
item_variant2: (_k = (_j = (_i = item.items[0]) == null ? void 0 : _i.name) == null ? void 0 : _j.split(" - ")[1]) != null ? _k : null,
|
|
@@ -1688,7 +1585,7 @@ var HeadlessPdpZone = {
|
|
|
1688
1585
|
item_sku: (_p = (_o = item.items) == null ? void 0 : _o[0].itemId) != null ? _p : null,
|
|
1689
1586
|
item_url: (_q = item.link) != null ? _q : null,
|
|
1690
1587
|
// sem link/url no retorno do IS na multi-lib produtos PDC
|
|
1691
|
-
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,
|
|
1692
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,
|
|
1693
1590
|
item_list_name: (_y = item.item_list_name) != null ? _y : null
|
|
1694
1591
|
};
|
|
@@ -1713,7 +1610,8 @@ var HeadlessPdpZone = {
|
|
|
1713
1610
|
}
|
|
1714
1611
|
return null;
|
|
1715
1612
|
},
|
|
1716
|
-
brand: (context) => {
|
|
1613
|
+
brand: (context, config2) => {
|
|
1614
|
+
if (config2 == null ? void 0 : config2.brand) return config2.brand;
|
|
1717
1615
|
if (context == null ? void 0 : context.brand) return context.brand;
|
|
1718
1616
|
if (context == null ? void 0 : context.products) {
|
|
1719
1617
|
return context.products.map((p) => p.brand).join().trim();
|
|
@@ -1737,6 +1635,7 @@ var HeadlessPdcZone = {
|
|
|
1737
1635
|
item_brand: (_b = item.brand.name) != null ? _b : null,
|
|
1738
1636
|
item_name: (_c = item.name) != null ? _c : null,
|
|
1739
1637
|
price: price != null ? price : null,
|
|
1638
|
+
item_shipping_tier: null,
|
|
1740
1639
|
discount: Number(listPrice) - Number(price),
|
|
1741
1640
|
item_variant: (_f = (_e = (_d = item.isVariantOf) == null ? void 0 : _d.hasVariant) == null ? void 0 : _e[0].name.split(" - ")[0]) != null ? _f : null,
|
|
1742
1641
|
item_variant2: (_i = (_h = ((_g = item.additionalProperty) != null ? _g : []).find((p) => p.name === "Tamanho")) == null ? void 0 : _h.value) != null ? _i : null,
|
|
@@ -1748,7 +1647,7 @@ var HeadlessPdcZone = {
|
|
|
1748
1647
|
item_sku: (_l = item.sku) != null ? _l : null,
|
|
1749
1648
|
item_url: null,
|
|
1750
1649
|
// sem link/url no retorno do IS na multi-lib produtos PDC
|
|
1751
|
-
image_url: (_n =
|
|
1650
|
+
image_url: (_n = resizeVtexImage2((_m = item == null ? void 0 : item.image) == null ? void 0 : _m[0].url)) != null ? _n : null,
|
|
1752
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,
|
|
1753
1652
|
item_list_name: (_t = item.item_list_name) != null ? _t : null
|
|
1754
1653
|
};
|
|
@@ -1770,7 +1669,8 @@ var HeadlessPdcZone = {
|
|
|
1770
1669
|
}
|
|
1771
1670
|
return null;
|
|
1772
1671
|
},
|
|
1773
|
-
brand: (context) => {
|
|
1672
|
+
brand: (context, config2) => {
|
|
1673
|
+
if (config2 == null ? void 0 : config2.brand) return config2.brand;
|
|
1774
1674
|
if (context == null ? void 0 : context.brand) return context.brand;
|
|
1775
1675
|
if (context == null ? void 0 : context.products) {
|
|
1776
1676
|
return context.products.map((p) => p.brand.name).join().trim();
|
|
@@ -1783,14 +1683,12 @@ var HeadlessPdcZone = {
|
|
|
1783
1683
|
var headlessAdapter = {
|
|
1784
1684
|
...metaAdapters,
|
|
1785
1685
|
// global adapters
|
|
1786
|
-
|
|
1787
|
-
// orderForm adapters, confirmar se no storefront tem evento que usa essses params
|
|
1788
|
-
brand: (context) => {
|
|
1686
|
+
brand: (context, config2) => {
|
|
1789
1687
|
if (context.zone === "PDP") {
|
|
1790
|
-
return HeadlessPdpZone.brand(context);
|
|
1688
|
+
return HeadlessPdpZone.brand(context, config2);
|
|
1791
1689
|
}
|
|
1792
1690
|
if (context.zone === "PDC") {
|
|
1793
|
-
return HeadlessPdcZone.brand(context);
|
|
1691
|
+
return HeadlessPdcZone.brand(context, config2);
|
|
1794
1692
|
}
|
|
1795
1693
|
return null;
|
|
1796
1694
|
},
|
|
@@ -1859,10 +1757,10 @@ var pickupAdapter = {
|
|
|
1859
1757
|
shippings: (context) => {
|
|
1860
1758
|
if (context.shippings) {
|
|
1861
1759
|
return context.shippings.map((s) => {
|
|
1862
|
-
var _a
|
|
1760
|
+
var _a;
|
|
1863
1761
|
return {
|
|
1864
1762
|
line_items: (_a = s.line_items) != null ? _a : "",
|
|
1865
|
-
shipping:
|
|
1763
|
+
shipping: s.price / 100,
|
|
1866
1764
|
shipping_tier: getShippingTier(s),
|
|
1867
1765
|
delivery_time: getDeliveryTime(s)
|
|
1868
1766
|
};
|
|
@@ -1870,9 +1768,217 @@ var pickupAdapter = {
|
|
|
1870
1768
|
}
|
|
1871
1769
|
return null;
|
|
1872
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
|
+
},
|
|
1873
1894
|
zipcode: (context) => {
|
|
1874
1895
|
var _a;
|
|
1875
|
-
return (_a = context.zipcode) != null ? _a : null;
|
|
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;
|
|
1876
1982
|
}
|
|
1877
1983
|
};
|
|
1878
1984
|
|
|
@@ -1880,9 +1986,10 @@ var pickupAdapter = {
|
|
|
1880
1986
|
var adapters = {
|
|
1881
1987
|
DECO: decoAdapter,
|
|
1882
1988
|
HEADLESS: headlessAdapter,
|
|
1883
|
-
PICKUP: pickupAdapter
|
|
1989
|
+
PICKUP: pickupAdapter,
|
|
1990
|
+
ORDERFORM: orderFormAdapter
|
|
1884
1991
|
};
|
|
1885
|
-
async function getParameters(context, eventName) {
|
|
1992
|
+
async function getParameters(context, eventName, config2) {
|
|
1886
1993
|
var _a;
|
|
1887
1994
|
const eventConfig = EVENTS[eventName];
|
|
1888
1995
|
if (!eventConfig) return;
|
|
@@ -1895,16 +2002,20 @@ async function getParameters(context, eventName) {
|
|
|
1895
2002
|
console.error(`[DT] Missing getter "${param}" for adapter "${currentAdapter}"`);
|
|
1896
2003
|
return [param, null];
|
|
1897
2004
|
}
|
|
1898
|
-
return [param, await getter(context,
|
|
2005
|
+
return [param, await getter(context, config2)];
|
|
1899
2006
|
})
|
|
1900
2007
|
);
|
|
1901
2008
|
return Object.fromEntries(entries);
|
|
1902
2009
|
}
|
|
1903
2010
|
|
|
1904
2011
|
// src/index.ts
|
|
2012
|
+
var config = { brand: "", currency: "BRL" };
|
|
2013
|
+
function initTracker(c) {
|
|
2014
|
+
config = c;
|
|
2015
|
+
}
|
|
1905
2016
|
async function trackWebEvent(event, context) {
|
|
1906
2017
|
try {
|
|
1907
|
-
const parameters = await getParameters(context, event);
|
|
2018
|
+
const parameters = await getParameters(context, event, config);
|
|
1908
2019
|
if (isDebugMode()) {
|
|
1909
2020
|
console.log(`[DT v2] ${event}, context e parameters: `, {
|
|
1910
2021
|
context,
|
|
@@ -1926,6 +2037,7 @@ var src_default = {
|
|
|
1926
2037
|
export {
|
|
1927
2038
|
EVENTS,
|
|
1928
2039
|
src_default as default,
|
|
2040
|
+
initTracker,
|
|
1929
2041
|
trackWebEvent
|
|
1930
2042
|
};
|
|
1931
2043
|
//# sourceMappingURL=mod.js.map
|