@azzas/azzas-tracker-web 2.0.3-preview.3 → 2.0.3-preview.4

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.js CHANGED
@@ -115,7 +115,6 @@ var EVENTS = {
115
115
  "promotion_name",
116
116
  "creative_slot",
117
117
  "creative_name"
118
- // "items",
119
118
  ]
120
119
  },
121
120
  SELECT_PROMOTION: {
@@ -127,10 +126,8 @@ var EVENTS = {
127
126
  "region",
128
127
  "currency",
129
128
  "promotion_name",
130
- "promotion_url",
131
129
  "creative_slot",
132
130
  "creative_name"
133
- // "items",
134
131
  ]
135
132
  },
136
133
  SELECT_CONTENT: {
@@ -1073,8 +1070,8 @@ function getPaymentType(context, eventName) {
1073
1070
 
1074
1071
  // src/params/userInfo.ts
1075
1072
  var PROD_DOMAINS = {
1076
- "animale": {
1077
- "store": "https://www.animale.com.br",
1073
+ "lojaanimale": {
1074
+ "store": "https://lojaanimale.myvtex.com",
1078
1075
  "checkout": "https://secure.animale.com.br"
1079
1076
  },
1080
1077
  "lojafarm": {
@@ -1487,10 +1484,10 @@ var getItemCategory3 = (item) => {
1487
1484
  };
1488
1485
  var getItemCategory22 = (item) => {
1489
1486
  var _a, _b, _c, _d;
1490
- const AVOID_CATEGORIES = /^(outlet|bazar|sale)$/i;
1487
+ const AVOID_CATEGORIES2 = /^(outlet|bazar|sale)$/i;
1491
1488
  const categories = (_b = (_a = item.category) == null ? void 0 : _a.split(">")) != null ? _b : [];
1492
1489
  const last = (_c = categories[categories.length - 1]) != null ? _c : "";
1493
- const validHierarchy = last.split("/").filter((c) => c && !AVOID_CATEGORIES.test(c));
1490
+ const validHierarchy = last.split("/").filter((c) => c && !AVOID_CATEGORIES2.test(c));
1494
1491
  const deepest = (_d = validHierarchy[validHierarchy.length - 1]) != null ? _d : "";
1495
1492
  return capitalize(deepest);
1496
1493
  };
@@ -1598,9 +1595,9 @@ var getItemCategory5 = (item) => {
1598
1595
  };
1599
1596
  var getItemCategory23 = (item) => {
1600
1597
  var _a, _b, _c, _d;
1601
- const AVOID_CATEGORIES = /^(outlet|bazar|sale|coleção|promoção)$/i;
1598
+ const AVOID_CATEGORIES2 = /^(outlet|bazar|sale|coleção|promoção)$/i;
1602
1599
  const categories = (_c = (_b = (_a = item == null ? void 0 : item.similarItems) == null ? void 0 : _a[0]) == null ? void 0 : _b.categories) != null ? _c : [];
1603
- const validHierarchy = categories.filter((c) => c && !AVOID_CATEGORIES.test(c));
1600
+ const validHierarchy = categories.filter((c) => c && !AVOID_CATEGORIES2.test(c));
1604
1601
  const deepest = (_d = validHierarchy[validHierarchy.length - 1]) != null ? _d : "";
1605
1602
  return capitalize(deepest);
1606
1603
  };
@@ -1686,8 +1683,222 @@ var reservaAdapter = {
1686
1683
  }
1687
1684
  };
1688
1685
 
1689
- // src/params/adapters/headless/utils.ts
1686
+ // src/params/adapters/animale/utils.ts
1687
+ var SALE_CATEGORIES = /outlet|bazar|sale/i;
1688
+ var AVOID_CATEGORIES = /^(outlet|bazar|sale|cole(ç|c)(ã|a)o)$/i;
1689
+ var getLevels = (path) => path.split("/").filter(Boolean);
1690
+ var isProductCrumb = (path) => /\/p\/?$/.test(path != null ? path : "");
1691
+ var getCategoryPaths = (item) => {
1692
+ var _a, _b, _c;
1693
+ if (item && "categories" in item && ((_a = item.categories) == null ? void 0 : _a.length)) return item.categories;
1694
+ const names = [...(_c = (_b = item == null ? void 0 : item.breadcrumbList) == null ? void 0 : _b.itemListElement) != null ? _c : []].sort((a, b) => {
1695
+ var _a2, _b2;
1696
+ return ((_a2 = a == null ? void 0 : a.position) != null ? _a2 : 0) - ((_b2 = b == null ? void 0 : b.position) != null ? _b2 : 0);
1697
+ }).filter((crumb) => (crumb == null ? void 0 : crumb.name) && !isProductCrumb(crumb == null ? void 0 : crumb.item)).map((crumb) => crumb.name.trim());
1698
+ return names.length ? [`/${names.join("/")}/`] : [];
1699
+ };
1690
1700
  var getItemCategory6 = (item) => {
1701
+ var _a;
1702
+ const categories = getCategoryPaths(item);
1703
+ if (!categories.length) return "Cole\xE7\xE3o";
1704
+ const match = (_a = categories.join(" ").match(SALE_CATEGORIES)) == null ? void 0 : _a[0].toLowerCase();
1705
+ return match != null ? match : "Cole\xE7\xE3o";
1706
+ };
1707
+ var getItemCategory24 = (item) => {
1708
+ const categories = getCategoryPaths(item);
1709
+ for (const path of [...categories].reverse()) {
1710
+ const deepest = getLevels(path).reverse().find((level) => !AVOID_CATEGORIES.test(level.trim()));
1711
+ if (deepest) return capitalize(deepest.trim());
1712
+ }
1713
+ return "";
1714
+ };
1715
+ var isInStock = (availability) => /InStock/i.test(availability != null ? availability : "");
1716
+
1717
+ // src/params/adapters/animale/zones/PDC.ts
1718
+ var AnimalePdcZone = {
1719
+ items: (context) => {
1720
+ if (context == null ? void 0 : context.items) return context.items;
1721
+ if (context == null ? void 0 : context.products) {
1722
+ return context.products.map((item) => {
1723
+ 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;
1724
+ const listPrice = (_b = (_a = item == null ? void 0 : item.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b[0].listPrice;
1725
+ const price = (_d = (_c = item.offers) == null ? void 0 : _c.offers) == null ? void 0 : _d[0].price;
1726
+ const sellerId = (_h = (_g = (_f = (_e = item == null ? void 0 : item.isVariantOf) == null ? void 0 : _e.hasVariant) == null ? void 0 : _f.find((v) => v.offers.offers.find((o) => o.availability))) == null ? void 0 : _g.offers.offers[0]) == null ? void 0 : _h.seller.identifier;
1727
+ return {
1728
+ quantity: 1,
1729
+ index: (_i = item == null ? void 0 : item.index) != null ? _i : 0,
1730
+ item_brand: (_j = item.brand.name.toLowerCase()) != null ? _j : null,
1731
+ item_name: (_l = (_k = item == null ? void 0 : item.isVariantOf) == null ? void 0 : _k.name) != null ? _l : null,
1732
+ price: price != null ? price : null,
1733
+ item_shipping_tier: null,
1734
+ discount: Number(listPrice) - Number(price),
1735
+ item_variant: (_o = (_n = (_m = item.isVariantOf) == null ? void 0 : _m.hasVariant) == null ? void 0 : _n[0].name.split(" - ")[0]) != null ? _o : null,
1736
+ item_variant2: (_r = (_q = ((_p = item.additionalProperty) != null ? _p : []).find((p) => p.name === "Tamanho")) == null ? void 0 : _q.value) != null ? _r : null,
1737
+ item_ref: (_s = item == null ? void 0 : item.gtin) != null ? _s : null,
1738
+ item_category: getItemCategory6(item),
1739
+ item_category2: (_t = getItemCategory24(item)) != null ? _t : null,
1740
+ item_id: (_v = (_u = item == null ? void 0 : item.isVariantOf) == null ? void 0 : _u.productGroupID) != null ? _v : null,
1741
+ item_sku: (_w = item == null ? void 0 : item.sku) != null ? _w : null,
1742
+ item_url: (_x = item == null ? void 0 : item.slug) != null ? _x : null,
1743
+ // sem link/url no retorno do IS na multi-lib produtos PDC
1744
+ image_url: (_z = resizeVtexImage2((_y = item == null ? void 0 : item.image) == null ? void 0 : _y[0].url)) != null ? _z : null,
1745
+ seller_id: sellerId != null ? sellerId : null,
1746
+ item_list_name: (_A = item.item_list_name) != null ? _A : null
1747
+ };
1748
+ });
1749
+ }
1750
+ return null;
1751
+ },
1752
+ value: (context) => {
1753
+ if (context == null ? void 0 : context.value) return context.value;
1754
+ if (context == null ? void 0 : context.products) {
1755
+ return context.products.map((item) => item.offers.lowPrice).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
1756
+ }
1757
+ return null;
1758
+ },
1759
+ line_items: (context) => {
1760
+ if (context == null ? void 0 : context.line_items) return context.line_items;
1761
+ if (context == null ? void 0 : context.products) {
1762
+ return context.products.map((item) => item.id).filter((id) => Boolean(id)).join();
1763
+ }
1764
+ return null;
1765
+ },
1766
+ brand: (context, config2) => {
1767
+ if (config2 == null ? void 0 : config2.brand) return config2.brand;
1768
+ if (context == null ? void 0 : context.brand) return context.brand;
1769
+ if (context == null ? void 0 : context.products) {
1770
+ return context.products.map((p) => p.brand.name).join().trim();
1771
+ }
1772
+ return null;
1773
+ }
1774
+ };
1775
+
1776
+ // src/params/adapters/animale/zones/PDP.ts
1777
+ var AnimalePdpZone = {
1778
+ items: (context) => {
1779
+ if (context == null ? void 0 : context.items) return context.items;
1780
+ if (context == null ? void 0 : context.products) {
1781
+ return context.products.map((item) => {
1782
+ 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, _F;
1783
+ const listPrice = (_b = (_a = item == null ? void 0 : item.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b[0].listPrice;
1784
+ const price = (_d = (_c = item.offers) == null ? void 0 : _c.offers) == null ? void 0 : _d[0].price;
1785
+ const availableOffer = (_g = (_f = (_e = item == null ? void 0 : item.isVariantOf) == null ? void 0 : _e.hasVariant) == null ? void 0 : _f.flatMap((v) => {
1786
+ var _a2, _b2;
1787
+ return (_b2 = (_a2 = v == null ? void 0 : v.offers) == null ? void 0 : _a2.offers) != null ? _b2 : [];
1788
+ })) == null ? void 0 : _g.find((o) => isInStock(o == null ? void 0 : o.availability));
1789
+ const sellerId = (_m = (_h = availableOffer == null ? void 0 : availableOffer.seller) == null ? void 0 : _h.identifier) != null ? _m : (_l = (_k = (_j = (_i = item == null ? void 0 : item.offers) == null ? void 0 : _i.offers) == null ? void 0 : _j[0]) == null ? void 0 : _k.seller) == null ? void 0 : _l.identifier;
1790
+ return {
1791
+ quantity: 1,
1792
+ index: (_n = item == null ? void 0 : item.index) != null ? _n : 0,
1793
+ item_brand: (_o = item.brand.name.toLowerCase()) != null ? _o : null,
1794
+ item_name: (_q = (_p = item == null ? void 0 : item.isVariantOf) == null ? void 0 : _p.name) != null ? _q : null,
1795
+ price: price != null ? price : null,
1796
+ item_shipping_tier: null,
1797
+ discount: Number(listPrice) - Number(price),
1798
+ item_variant: (_t = (_s = (_r = item.isVariantOf) == null ? void 0 : _r.hasVariant) == null ? void 0 : _s[0].name.split(" - ")[0]) != null ? _t : null,
1799
+ item_variant2: (_w = (_v = ((_u = item.additionalProperty) != null ? _u : []).find((p) => p.name === "Tamanho")) == null ? void 0 : _v.value) != null ? _w : null,
1800
+ item_ref: (_x = item == null ? void 0 : item.gtin) != null ? _x : null,
1801
+ item_category: getItemCategory6(item),
1802
+ item_category2: (_y = getItemCategory24(item)) != null ? _y : null,
1803
+ item_id: (_A = (_z = item == null ? void 0 : item.isVariantOf) == null ? void 0 : _z.productGroupID) != null ? _A : null,
1804
+ item_sku: (_B = item == null ? void 0 : item.sku) != null ? _B : null,
1805
+ item_url: (_C = item == null ? void 0 : item.slug) != null ? _C : null,
1806
+ // sem link/url no retorno do IS na multi-lib produtos PDC
1807
+ image_url: (_E = resizeVtexImage2((_D = item == null ? void 0 : item.image) == null ? void 0 : _D[0].url)) != null ? _E : null,
1808
+ seller_id: sellerId != null ? sellerId : null,
1809
+ item_list_name: (_F = item.item_list_name) != null ? _F : null
1810
+ };
1811
+ });
1812
+ }
1813
+ return null;
1814
+ },
1815
+ value: (context) => {
1816
+ if (context == null ? void 0 : context.value) return context.value;
1817
+ if (context == null ? void 0 : context.products) {
1818
+ return context.products.map((item) => item.offers.lowPrice).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
1819
+ }
1820
+ return null;
1821
+ },
1822
+ line_items: (context) => {
1823
+ if (context == null ? void 0 : context.line_items) return context.line_items;
1824
+ if (context == null ? void 0 : context.products) {
1825
+ return context.products.map((item) => item.id).filter((id) => Boolean(id)).join();
1826
+ }
1827
+ return null;
1828
+ },
1829
+ brand: (context, config2) => {
1830
+ if (config2 == null ? void 0 : config2.brand) return config2.brand;
1831
+ if (context == null ? void 0 : context.brand) return context.brand;
1832
+ if (context == null ? void 0 : context.products) {
1833
+ return context.products.map((p) => p.brand.name).join().trim();
1834
+ }
1835
+ return null;
1836
+ }
1837
+ };
1838
+
1839
+ // src/params/adapters/animale/index.ts
1840
+ var animaleAdapter = {
1841
+ ...metaAdapter,
1842
+ // global adapters
1843
+ brand: (context, config2) => {
1844
+ if (context.zone === "PDP") {
1845
+ return AnimalePdpZone.brand(context, config2);
1846
+ }
1847
+ if (context.zone === "PDC") {
1848
+ return AnimalePdcZone.brand(context, config2);
1849
+ }
1850
+ return null;
1851
+ },
1852
+ line_items: (context) => {
1853
+ if (context.zone === "PDP") {
1854
+ return AnimalePdpZone.line_items(context);
1855
+ }
1856
+ if (context.zone === "PDC") {
1857
+ return AnimalePdcZone.line_items(context);
1858
+ }
1859
+ return null;
1860
+ },
1861
+ value: (context) => {
1862
+ if (context.zone === "PDP") {
1863
+ return AnimalePdpZone.value(context);
1864
+ }
1865
+ if (context.zone === "PDC") {
1866
+ return AnimalePdcZone.value(context);
1867
+ }
1868
+ return null;
1869
+ },
1870
+ items: (context) => {
1871
+ if (context.zone === "PDP") {
1872
+ return AnimalePdpZone.items(context);
1873
+ }
1874
+ if (context.zone === "PDC") {
1875
+ return AnimalePdcZone.items(context);
1876
+ }
1877
+ },
1878
+ // param used only in one Zone, the PDP; no need condition
1879
+ available_grid: (context) => {
1880
+ if (context == null ? void 0 : context.available_grid) return context.available_grid;
1881
+ if (context == null ? void 0 : context.products) {
1882
+ const sizes = context.products.flatMap(
1883
+ (p) => {
1884
+ var _a, _b;
1885
+ return ((_b = (_a = p == null ? void 0 : p.isVariantOf) == null ? void 0 : _a.hasVariant) != null ? _b : []).flatMap((variant) => {
1886
+ var _a2, _b2, _c, _d;
1887
+ const available = (_b2 = (_a2 = variant == null ? void 0 : variant.offers) == null ? void 0 : _a2.offers) == null ? void 0 : _b2.some((o) => isInStock(o == null ? void 0 : o.availability));
1888
+ const size = (_d = (_c = variant == null ? void 0 : variant.additionalProperty) == null ? void 0 : _c.find((prop) => (prop == null ? void 0 : prop.name) === "Tamanho")) == null ? void 0 : _d.value;
1889
+ return available && size ? [size] : [];
1890
+ });
1891
+ }
1892
+ );
1893
+ const result = sortSizes(sizes).join(",");
1894
+ return result || null;
1895
+ }
1896
+ return null;
1897
+ }
1898
+ };
1899
+
1900
+ // src/params/adapters/headless/utils.ts
1901
+ var getItemCategory7 = (item) => {
1691
1902
  const keywords = ["outlet", "bazar", "sale"];
1692
1903
  const regex = new RegExp(keywords.join("|"), "i");
1693
1904
  const value = item == null ? void 0 : item.categories;
@@ -1700,7 +1911,7 @@ var getItemCategory6 = (item) => {
1700
1911
  }
1701
1912
  return "Cole\xE7\xE3o";
1702
1913
  };
1703
- var getItemCategory24 = (item) => {
1914
+ var getItemCategory25 = (item) => {
1704
1915
  var _a, _b, _c;
1705
1916
  const avoidList = /outlet|bazar|sale/i;
1706
1917
  const lastCategory = (_b = (_a = item.categories) == null ? void 0 : _a[item.categories.length - 1]) != null ? _b : "";
@@ -1730,8 +1941,8 @@ var HeadlessPdpZone = {
1730
1941
  item_variant2: (_k = (_j = (_i = item.items[0]) == null ? void 0 : _i.name) == null ? void 0 : _j.split(" - ")[1]) != null ? _k : null,
1731
1942
  item_ref: (_l = item.productReference) != null ? _l : null,
1732
1943
  // sem ref no retorno do IS na multi-lib produtos PDC
1733
- item_category: getItemCategory6(item),
1734
- item_category2: (_m = getItemCategory24(item)) != null ? _m : null,
1944
+ item_category: getItemCategory7(item),
1945
+ item_category2: (_m = getItemCategory25(item)) != null ? _m : null,
1735
1946
  item_id: (_n = item == null ? void 0 : item.productId) != null ? _n : null,
1736
1947
  item_sku: (_p = (_o = item.items) == null ? void 0 : _o[0].itemId) != null ? _p : null,
1737
1948
  item_url: (_q = item.link) != null ? _q : null,
@@ -1792,8 +2003,8 @@ var HeadlessPdcZone = {
1792
2003
  item_variant2: (_i = (_h = ((_g = item.additionalProperty) != null ? _g : []).find((p) => p.name === "Tamanho")) == null ? void 0 : _h.value) != null ? _i : null,
1793
2004
  item_ref: null,
1794
2005
  // sem ref no retorno do IS na multi-lib produtos PDC
1795
- item_category: getItemCategory6(item),
1796
- item_category2: (_j = getItemCategory24(item)) != null ? _j : null,
2006
+ item_category: getItemCategory7(item),
2007
+ item_category2: (_j = getItemCategory25(item)) != null ? _j : null,
1797
2008
  item_id: (_k = item.isVariantOf.productGroupID) != null ? _k : null,
1798
2009
  item_sku: (_l = item.sku) != null ? _l : null,
1799
2010
  item_url: null,
@@ -1939,7 +2150,7 @@ var getOrderFormItems = (orderForm) => {
1939
2150
  return { ...i, quantity: 1 };
1940
2151
  }) : orderForm.items;
1941
2152
  };
1942
- var getItemCategory7 = (item) => {
2153
+ var getItemCategory8 = (item) => {
1943
2154
  var _a;
1944
2155
  const categories = item == null ? void 0 : item.productCategories;
1945
2156
  if (!categories) return "Cole\xE7\xE3o";
@@ -1947,11 +2158,11 @@ var getItemCategory7 = (item) => {
1947
2158
  const match = (_a = text.match(/outlet|bazar|sale/i)) == null ? void 0 : _a[0].toLowerCase();
1948
2159
  return match != null ? match : "Cole\xE7\xE3o";
1949
2160
  };
1950
- var getItemCategory25 = (item) => {
2161
+ var getItemCategory26 = (item) => {
1951
2162
  var _a, _b;
1952
- const AVOID_CATEGORIES = /outlet|bazar|sale|coleção|promoção/i;
2163
+ const AVOID_CATEGORIES2 = /outlet|bazar|sale|coleção|promoção/i;
1953
2164
  const categories = Object.values((_a = item == null ? void 0 : item.productCategories) != null ? _a : {});
1954
- const validHierarchy = categories.map((c) => c.trim()).filter((c) => c && !AVOID_CATEGORIES.test(c));
2165
+ const validHierarchy = categories.map((c) => c.trim()).filter((c) => c && !AVOID_CATEGORIES2.test(c));
1955
2166
  const deepest = (_b = validHierarchy[validHierarchy.length - 1]) != null ? _b : "";
1956
2167
  return capitalize(deepest);
1957
2168
  };
@@ -2002,8 +2213,8 @@ var orderFormAdapter = {
2002
2213
  item_variant2: (_m = size == null ? void 0 : size.toUpperCase()) != null ? _m : null,
2003
2214
  item_shipping_tier: getItemShippingTier2(context.orderForm, item),
2004
2215
  item_ref: (item == null ? void 0 : item.productRefId) || (item == null ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
2005
- item_category: (_n = getItemCategory7(item)) != null ? _n : null,
2006
- item_category2: (_o = getItemCategory25(item)) != null ? _o : null,
2216
+ item_category: (_n = getItemCategory8(item)) != null ? _n : null,
2217
+ item_category2: (_o = getItemCategory26(item)) != null ? _o : null,
2007
2218
  item_id: (_p = item == null ? void 0 : item.productId) != null ? _p : null,
2008
2219
  item_sku: (_q = item == null ? void 0 : item.id) != null ? _q : null,
2009
2220
  item_url: (_r = item.detailUrl) != null ? _r : null,
@@ -2247,7 +2458,8 @@ var adapters = {
2247
2458
  HEADLESS: headlessAdapter,
2248
2459
  PICKUP: pickupAdapter,
2249
2460
  ORDERFORM: orderFormAdapter,
2250
- META: metaAdapter
2461
+ META: metaAdapter,
2462
+ ANIMALE: animaleAdapter
2251
2463
  };
2252
2464
  async function getParameters(context, eventName, config2) {
2253
2465
  var _a;
@@ -2291,7 +2503,7 @@ async function trackWebEvent(event, context) {
2291
2503
  }
2292
2504
  if (isDebugMode()) {
2293
2505
  console.log(
2294
- `%c [DT v2] %c ${event} `,
2506
+ `%c [DT v2 - Animale Preview] %c ${event} `,
2295
2507
  "background: #6366f1; color: #fff; font-weight: bold; padding: 2px 6px; border-radius: 4px 0 0 4px;",
2296
2508
  "background: #1e1e2e; color: #a5b4fc; font-weight: bold; padding: 2px 6px; border-radius: 0 4px 4px 0;",
2297
2509
  { context, parameters }