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

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