@azzas/azzas-tracker-web 2.0.0-preview.3 → 2.0.0-preview.5
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 +66 -27
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.global.js +66 -27
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +66 -27
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +76 -27
- package/package.json +1 -1
package/dist/mod.global.js
CHANGED
|
@@ -1357,9 +1357,9 @@ var AzzasTracker = (() => {
|
|
|
1357
1357
|
// src/params/adapters/meta/index.ts
|
|
1358
1358
|
var metaAdapters = {
|
|
1359
1359
|
user_info: getUserInfo,
|
|
1360
|
-
brand: (context) => {
|
|
1361
|
-
|
|
1362
|
-
},
|
|
1360
|
+
// brand: (context: MetaBrandContext) => {
|
|
1361
|
+
// return context.meta.brand || null;
|
|
1362
|
+
// },
|
|
1363
1363
|
content_type: (context) => {
|
|
1364
1364
|
return context.meta.content_type || null;
|
|
1365
1365
|
},
|
|
@@ -1439,8 +1439,36 @@ var AzzasTracker = (() => {
|
|
|
1439
1439
|
const deepest = (_d = validHierarchy[validHierarchy.length - 1]) != null ? _d : "";
|
|
1440
1440
|
return capitalize(deepest);
|
|
1441
1441
|
};
|
|
1442
|
-
|
|
1443
|
-
|
|
1442
|
+
var BRAND_CODES2 = {
|
|
1443
|
+
farm: "farmrio",
|
|
1444
|
+
"farm etc": "farmetc",
|
|
1445
|
+
"farm rio": "farmrio"
|
|
1446
|
+
};
|
|
1447
|
+
function getBrandCode2(brand) {
|
|
1448
|
+
if (!brand) return null;
|
|
1449
|
+
const standardized = brand.toLowerCase().trim();
|
|
1450
|
+
return BRAND_CODES2[standardized] || null;
|
|
1451
|
+
}
|
|
1452
|
+
function normalizeBrand2(input) {
|
|
1453
|
+
var _a;
|
|
1454
|
+
let brandStrings = [];
|
|
1455
|
+
if (Array.isArray(input) && input.every((item) => typeof item === "string")) {
|
|
1456
|
+
brandStrings = input;
|
|
1457
|
+
} else if (Array.isArray(input)) {
|
|
1458
|
+
brandStrings = input.map((item) => {
|
|
1459
|
+
var _a2;
|
|
1460
|
+
return ((_a2 = item.additionalInfo) == null ? void 0 : _a2.brandName) || item.brand;
|
|
1461
|
+
});
|
|
1462
|
+
} else if (typeof input === "object" && input !== null && "brand" in input) {
|
|
1463
|
+
brandStrings = [((_a = input.additionalInfo) == null ? void 0 : _a.brandName) || input.brand];
|
|
1464
|
+
} else if (typeof input === "string") {
|
|
1465
|
+
return getBrandCode2(input);
|
|
1466
|
+
} else {
|
|
1467
|
+
return null;
|
|
1468
|
+
}
|
|
1469
|
+
const brandCodes = brandStrings.map(getBrandCode2).filter((code) => code !== null);
|
|
1470
|
+
const uniqueSortedCodes = [...new Set(brandCodes)].sort();
|
|
1471
|
+
return uniqueSortedCodes.length > 0 ? uniqueSortedCodes.join("_") : null;
|
|
1444
1472
|
}
|
|
1445
1473
|
|
|
1446
1474
|
// src/params/adapters/deco/index.ts
|
|
@@ -1469,7 +1497,7 @@ var AzzasTracker = (() => {
|
|
|
1469
1497
|
// cor
|
|
1470
1498
|
item_variant2: (_o = (_n = item == null ? void 0 : item.name) == null ? void 0 : _n.split(" - ")[1]) != null ? _o : null,
|
|
1471
1499
|
// tamanho
|
|
1472
|
-
item_shipping_tier:
|
|
1500
|
+
item_shipping_tier: "",
|
|
1473
1501
|
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,
|
|
1474
1502
|
item_category: (_t = getItemCategory3(item)) != null ? _t : null,
|
|
1475
1503
|
item_category2: (_u = getItemCategory22(item)) != null ? _u : null,
|
|
@@ -1484,13 +1512,16 @@ var AzzasTracker = (() => {
|
|
|
1484
1512
|
}
|
|
1485
1513
|
return null;
|
|
1486
1514
|
},
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1515
|
+
brand: (context) => {
|
|
1516
|
+
if (context == null ? void 0 : context.brand) return context.brand;
|
|
1517
|
+
if (context == null ? void 0 : context.products) {
|
|
1518
|
+
return normalizeBrand2(context.products.map((p) => {
|
|
1519
|
+
var _a;
|
|
1520
|
+
return (_a = p == null ? void 0 : p.brand) == null ? void 0 : _a.name;
|
|
1521
|
+
}));
|
|
1522
|
+
}
|
|
1523
|
+
return null;
|
|
1524
|
+
},
|
|
1494
1525
|
line_items: (context) => {
|
|
1495
1526
|
if (context == null ? void 0 : context.line_items) return context.line_items;
|
|
1496
1527
|
if (context == null ? void 0 : context.products) {
|
|
@@ -1549,6 +1580,14 @@ var AzzasTracker = (() => {
|
|
|
1549
1580
|
const deepest = (_b = validHierarchy[validHierarchy.length - 1]) != null ? _b : "";
|
|
1550
1581
|
return capitalize(deepest);
|
|
1551
1582
|
};
|
|
1583
|
+
function getItemShippingTier2(orderForm, item) {
|
|
1584
|
+
var _a, _b, _c, _d;
|
|
1585
|
+
const info = (_b = (_a = orderForm == null ? void 0 : orderForm.shippingData) == null ? void 0 : _a.logisticsInfo) == null ? void 0 : _b.find(
|
|
1586
|
+
(li) => li.itemId === item.id
|
|
1587
|
+
);
|
|
1588
|
+
const selectedSla = (_c = info == null ? void 0 : info.slas) == null ? void 0 : _c.find((sla) => sla.id === info.selectedSla);
|
|
1589
|
+
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;
|
|
1590
|
+
}
|
|
1552
1591
|
var getOrderFormItems = (orderForm) => {
|
|
1553
1592
|
const idSelected = orderForm == null ? void 0 : orderForm.selected;
|
|
1554
1593
|
return idSelected ? orderForm.items.filter((item) => item.id === idSelected) : orderForm.items;
|
|
@@ -1571,7 +1610,7 @@ var AzzasTracker = (() => {
|
|
|
1571
1610
|
discount: ((item == null ? void 0 : item.listPrice) - (item == null ? void 0 : item.sellingPrice)) / 100,
|
|
1572
1611
|
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,
|
|
1573
1612
|
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,
|
|
1574
|
-
item_shipping_tier:
|
|
1613
|
+
item_shipping_tier: getItemShippingTier2(context.orderForm, item),
|
|
1575
1614
|
item_ref: (item == null ? void 0 : item.productRefId) || (item == null ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
|
|
1576
1615
|
item_category: (_o = getItemCategory5(item)) != null ? _o : null,
|
|
1577
1616
|
item_category2: (_p = getItemCategory23(item)) != null ? _p : null,
|
|
@@ -1586,13 +1625,13 @@ var AzzasTracker = (() => {
|
|
|
1586
1625
|
}
|
|
1587
1626
|
return null;
|
|
1588
1627
|
},
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1628
|
+
brand: (context) => {
|
|
1629
|
+
var _a;
|
|
1630
|
+
if (context == null ? void 0 : context.brand) return context.brand;
|
|
1631
|
+
if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
|
|
1632
|
+
const brands = getOrderFormItems(context.orderForm).map((item) => item.additionalInfo.brandName);
|
|
1633
|
+
return normalizeBrand2(brands);
|
|
1634
|
+
},
|
|
1596
1635
|
line_items: (context) => {
|
|
1597
1636
|
var _a;
|
|
1598
1637
|
if (context == null ? void 0 : context.line_items) return context.line_items;
|
|
@@ -1608,10 +1647,10 @@ var AzzasTracker = (() => {
|
|
|
1608
1647
|
payment_type: getPaymentType,
|
|
1609
1648
|
total_discount: (context) => {
|
|
1610
1649
|
var _a, _b;
|
|
1611
|
-
if (context == null ? void 0 : context.
|
|
1612
|
-
|
|
1613
|
-
const
|
|
1614
|
-
const totalDiscount =
|
|
1650
|
+
if (context == null ? void 0 : context.total_discount) return context.total_discount;
|
|
1651
|
+
if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
|
|
1652
|
+
const totalsList = ((_b = context.orderForm) == null ? void 0 : _b.totalizers) || [];
|
|
1653
|
+
const totalDiscount = getOrderFormItems(context.orderForm).reduce((acc, item) => {
|
|
1615
1654
|
const unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
|
|
1616
1655
|
return acc + unitDiscount * item.quantity;
|
|
1617
1656
|
}, 0);
|
|
@@ -1948,10 +1987,10 @@ var AzzasTracker = (() => {
|
|
|
1948
1987
|
shippings: (context) => {
|
|
1949
1988
|
if (context.shippings) {
|
|
1950
1989
|
return context.shippings.map((s) => {
|
|
1951
|
-
var _a
|
|
1990
|
+
var _a;
|
|
1952
1991
|
return {
|
|
1953
1992
|
line_items: (_a = s.line_items) != null ? _a : "",
|
|
1954
|
-
shipping:
|
|
1993
|
+
shipping: s.price / 100,
|
|
1955
1994
|
shipping_tier: getShippingTier(s),
|
|
1956
1995
|
delivery_time: getDeliveryTime(s)
|
|
1957
1996
|
};
|