@azzas/azzas-tracker-web 1.0.80 → 1.0.81

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.
@@ -760,14 +760,162 @@ var AzzasTracker = function() {
760
760
  });
761
761
  })();
762
762
  };
763
+ var getStorage = function getStorage() {
764
+ try {
765
+ if (typeof window === "undefined" || !window.localStorage) return null;
766
+ return window.localStorage;
767
+ } catch (unused) {
768
+ return null;
769
+ }
770
+ };
771
+ var parseJSON = function parseJSON(value) {
772
+ if (!value) return null;
773
+ try {
774
+ return JSON.parse(value);
775
+ } catch (unused) {
776
+ return null;
777
+ }
778
+ };
779
+ var isFreshTimestamp = function isFreshTimestamp(timestamp) {
780
+ var elapsed = Date.now() - timestamp;
781
+ return elapsed >= 0 && elapsed < DAY_IN_MS;
782
+ };
783
+ var isStoredItemMemory = function isStoredItemMemory(value) {
784
+ if (!value || (typeof value === "undefined" ? "undefined" : _type_of(value)) !== "object") return false;
785
+ var candidate = value;
786
+ return typeof candidate.id === "string" && typeof candidate.list === "string" && typeof candidate.timestamp === "number";
787
+ };
788
+ var resolveIdFromUnknownItem = function resolveIdFromUnknownItem(item) {
789
+ var _ref, _ref1, _ref2, _ref3, _ref4;
790
+ var id = (_ref = (_ref1 = (_ref2 = (_ref3 = (_ref4 = item === null || item === void 0 ? void 0 : item.productID) !== null && _ref4 !== void 0 ? _ref4 : item === null || item === void 0 ? void 0 : item.productId) !== null && _ref3 !== void 0 ? _ref3 : item === null || item === void 0 ? void 0 : item.item_group_id) !== null && _ref2 !== void 0 ? _ref2 : item === null || item === void 0 ? void 0 : item.item_id) !== null && _ref1 !== void 0 ? _ref1 : item === null || item === void 0 ? void 0 : item.id) !== null && _ref !== void 0 ? _ref : null;
791
+ return id == null ? null : String(id);
792
+ };
793
+ var resolveItemId = function resolveItemId(item) {
794
+ return resolveIdFromUnknownItem(item);
795
+ };
796
+ var readStoredItem = function readStoredItem(key) {
797
+ var storage = getStorage();
798
+ if (!storage) return null;
799
+ try {
800
+ var parsed = parseJSON(storage.getItem(key));
801
+ return isStoredItemMemory(parsed) ? parsed : null;
802
+ } catch (unused) {
803
+ return null;
804
+ }
805
+ };
806
+ var writeStoredItem = function writeStoredItem(key, value) {
807
+ var storage = getStorage();
808
+ if (!storage) return;
809
+ try {
810
+ storage.setItem(key, JSON.stringify(value));
811
+ } catch (unused) {}
812
+ };
813
+ var readCartHistory = function readCartHistory() {
814
+ var storage = getStorage();
815
+ if (!storage) return [];
816
+ try {
817
+ var parsed = parseJSON(storage.getItem(CART_LIST_HISTORY_KEY));
818
+ if (!Array.isArray(parsed)) return [];
819
+ return parsed.filter(function(entry) {
820
+ return !!entry && (typeof entry === "undefined" ? "undefined" : _type_of(entry)) === "object" && typeof entry.id === "string" && typeof entry.list === "string";
821
+ });
822
+ } catch (unused) {
823
+ return [];
824
+ }
825
+ };
826
+ var writeCartHistory = function writeCartHistory(history) {
827
+ var storage = getStorage();
828
+ if (!storage) return;
829
+ try {
830
+ storage.setItem(CART_LIST_HISTORY_KEY, JSON.stringify(history));
831
+ } catch (unused) {}
832
+ };
833
+ var saveSelectedItem = function saveSelectedItem(productId, listName) {
834
+ if (productId == null || !listName) return;
835
+ var payload = {
836
+ id: String(productId),
837
+ list: String(listName),
838
+ timestamp: Date.now()
839
+ };
840
+ writeStoredItem(LAST_SELECTED_ITEM_KEY, payload);
841
+ };
842
+ var saveViewedItem = function saveViewedItem(productId, listName) {
843
+ if (productId == null) return;
844
+ var payload = {
845
+ id: String(productId),
846
+ list: String(listName !== null && listName !== void 0 ? listName : "PDP"),
847
+ timestamp: Date.now()
848
+ };
849
+ writeStoredItem(STORAGE_VIEWED, payload);
850
+ };
851
+ var resolveItemListName = function resolveItemListName(params) {
852
+ var event = params.event, item = params.item, itemListName = params.itemListName;
853
+ var currentListName = itemListName !== null && itemListName !== void 0 ? itemListName : null;
854
+ var isResolvableEvent = event === "VIEW_ITEM" || event === "ADD_TO_CART";
855
+ if (!isResolvableEvent) return currentListName;
856
+ var currentItemId = resolveIdFromUnknownItem(item);
857
+ if (event === "VIEW_ITEM") {
858
+ if (!currentItemId) return "PDP";
859
+ var selectedItem = readStoredItem(LAST_SELECTED_ITEM_KEY);
860
+ if (!selectedItem) return "PDP";
861
+ if (selectedItem.id === currentItemId && isFreshTimestamp(selectedItem.timestamp)) {
862
+ return selectedItem.list;
863
+ }
864
+ return "PDP";
865
+ }
866
+ if (currentListName !== "PDP" && currentListName !== null) return currentListName;
867
+ if (!currentItemId) return currentListName;
868
+ var viewedItem = readStoredItem(STORAGE_VIEWED);
869
+ if (viewedItem && viewedItem.id === currentItemId && isFreshTimestamp(viewedItem.timestamp)) {
870
+ return viewedItem.list;
871
+ }
872
+ return currentListName === "PDP" ? "PDP" : null;
873
+ };
874
+ var appendCartHistory = function appendCartHistory(productId, listName) {
875
+ if (productId == null) return;
876
+ var history = readCartHistory();
877
+ history.push({
878
+ id: String(productId),
879
+ list: listName ? String(listName) : "PDP"
880
+ });
881
+ writeCartHistory(history);
882
+ };
883
+ var pickSelectedItemFromResolvedItems = function pickSelectedItemFromResolvedItems(items, source) {
884
+ if (!Array.isArray(items) || items.length === 0) return null;
885
+ if (typeof (source === null || source === void 0 ? void 0 : source.index) === "number") {
886
+ var _items_find;
887
+ var indexed = (_items_find = items.find(function(item) {
888
+ return (item === null || item === void 0 ? void 0 : item.index) === source.index;
889
+ })) !== null && _items_find !== void 0 ? _items_find : items[source.index];
890
+ if (indexed && (typeof indexed === "undefined" ? "undefined" : _type_of(indexed)) === "object") return indexed;
891
+ }
892
+ return items[0];
893
+ };
894
+ var persistSelectItemOriginFromResolvedItems = function persistSelectItemOriginFromResolvedItems(items, source) {
895
+ var _ref, _ref1, _ref2;
896
+ var selectedItem = pickSelectedItemFromResolvedItems(items, source);
897
+ if (!selectedItem) return;
898
+ var productId = resolveIdFromUnknownItem(selectedItem);
899
+ var listName = (_ref = (_ref1 = (_ref2 = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.item_list_name) !== null && _ref2 !== void 0 ? _ref2 : source === null || source === void 0 ? void 0 : source.itemListName) !== null && _ref1 !== void 0 ? _ref1 : source === null || source === void 0 ? void 0 : source.item_list_name) !== null && _ref !== void 0 ? _ref : null;
900
+ saveSelectedItem(productId, listName);
901
+ };
763
902
  var itemsFromItem = // src/params/resolvers/items/fromItem.ts
764
903
  function itemsFromItem(context, event) {
765
904
  return _async_to_generator(function() {
766
- var _item_additionalProperty, _item_itemOffered, _item_itemOffered1, _item_additionalInfo, _item_brand, _item_itemOffered_brand, _item_itemOffered2, _item_itemOffered3, _item_name, _item_item_name, _item_itemOffered_isVariantOf_name, _item_itemOffered_isVariantOf, _item_itemOffered4, _item_itemAttributes, _split_pop, _this, item, orderForm, itemListName, _tmp, _tmp1;
905
+ var _item_additionalProperty, _item_itemOffered, _item_itemOffered1, _item_additionalInfo, _item_brand, _item_itemOffered_brand, _item_itemOffered2, _item_itemOffered3, _item_name, _item_item_name, _item_itemOffered_isVariantOf_name, _item_itemOffered_isVariantOf, _item_itemOffered4, _item_itemAttributes, _split_pop, _this, item, orderForm, itemListName, resolvedListName, resolvedItemId, _tmp, _tmp1;
767
906
  return _ts_generator(this, function(_state) {
768
907
  switch(_state.label){
769
908
  case 0:
770
909
  item = context.item, orderForm = context.orderForm, itemListName = context.itemListName;
910
+ resolvedListName = resolveItemListName({
911
+ event: event,
912
+ item: item,
913
+ itemListName: itemListName
914
+ });
915
+ resolvedItemId = resolveItemId(item);
916
+ if (event === "ADD_TO_CART") {
917
+ appendCartHistory(resolvedItemId, resolvedListName);
918
+ }
771
919
  _tmp = {
772
920
  index: typeof (item === null || item === void 0 ? void 0 : item.index) === "number" ? item.index : null,
773
921
  quantity: 1,
@@ -797,7 +945,7 @@ var AzzasTracker = function() {
797
945
  return [
798
946
  2,
799
947
  [
800
- (_tmp.item_sku = _tmp1 || null, _tmp.item_name = (item === null || item === void 0 ? void 0 : (_item_name = item.name) === null || _item_name === void 0 ? void 0 : _item_name.split(" - ").shift()) || (item === null || item === void 0 ? void 0 : (_item_item_name = item.item_name) === null || _item_item_name === void 0 ? void 0 : _item_item_name.split(" - ").shift()) || (item === null || item === void 0 ? void 0 : (_item_itemOffered4 = item.itemOffered) === null || _item_itemOffered4 === void 0 ? void 0 : (_item_itemOffered_isVariantOf = _item_itemOffered4.isVariantOf) === null || _item_itemOffered_isVariantOf === void 0 ? void 0 : (_item_itemOffered_isVariantOf_name = _item_itemOffered_isVariantOf.name) === null || _item_itemOffered_isVariantOf_name === void 0 ? void 0 : _item_itemOffered_isVariantOf_name.split(" - ").shift()) || null, _tmp.item_category = getItemCategory(item) || null, _tmp.item_variant = ((item === null || item === void 0 ? void 0 : item.skuName) || (item === null || item === void 0 ? void 0 : item.item_variant) || (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.itemOffered.name)).split(/[-/]/)[0].trim() || null, _tmp.item_variant2 = (item === null || item === void 0 ? void 0 : item.size) || (item === null || item === void 0 ? void 0 : (_item_itemAttributes = item.itemAttributes) === null || _item_itemAttributes === void 0 ? void 0 : _item_itemAttributes.size) || ((_this = (item === null || item === void 0 ? void 0 : item.skuName) || (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.itemOffered.name)) === null || _this === void 0 ? void 0 : (_split_pop = _this.split(/[-/]/).pop()) === null || _split_pop === void 0 ? void 0 : _split_pop.trim()) || null, _tmp.discount = getDiscount(item), _tmp.item_list_name = itemListName || null, _tmp.item_url = (item === null || item === void 0 ? void 0 : item.item_url) || null, _tmp.// add_to_cart dito
948
+ (_tmp.item_sku = _tmp1 || null, _tmp.item_name = (item === null || item === void 0 ? void 0 : (_item_name = item.name) === null || _item_name === void 0 ? void 0 : _item_name.split(" - ").shift()) || (item === null || item === void 0 ? void 0 : (_item_item_name = item.item_name) === null || _item_item_name === void 0 ? void 0 : _item_item_name.split(" - ").shift()) || (item === null || item === void 0 ? void 0 : (_item_itemOffered4 = item.itemOffered) === null || _item_itemOffered4 === void 0 ? void 0 : (_item_itemOffered_isVariantOf = _item_itemOffered4.isVariantOf) === null || _item_itemOffered_isVariantOf === void 0 ? void 0 : (_item_itemOffered_isVariantOf_name = _item_itemOffered_isVariantOf.name) === null || _item_itemOffered_isVariantOf_name === void 0 ? void 0 : _item_itemOffered_isVariantOf_name.split(" - ").shift()) || null, _tmp.item_category = getItemCategory(item) || null, _tmp.item_variant = ((item === null || item === void 0 ? void 0 : item.skuName) || (item === null || item === void 0 ? void 0 : item.item_variant) || (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.itemOffered.name)).split(/[-/]/)[0].trim() || null, _tmp.item_variant2 = (item === null || item === void 0 ? void 0 : item.size) || (item === null || item === void 0 ? void 0 : (_item_itemAttributes = item.itemAttributes) === null || _item_itemAttributes === void 0 ? void 0 : _item_itemAttributes.size) || ((_this = (item === null || item === void 0 ? void 0 : item.skuName) || (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.itemOffered.name)) === null || _this === void 0 ? void 0 : (_split_pop = _this.split(/[-/]/).pop()) === null || _split_pop === void 0 ? void 0 : _split_pop.trim()) || null, _tmp.discount = getDiscount(item), _tmp.item_list_name = resolvedListName, _tmp.item_url = (item === null || item === void 0 ? void 0 : item.item_url) || null, _tmp.// add_to_cart dito
801
949
  image_url = resizeVtexImage(item === null || item === void 0 ? void 0 : item.image) || resizeVtexImage(item === null || item === void 0 ? void 0 : item.imageUrl) || null, _tmp)
802
950
  ]
803
951
  ];
@@ -835,11 +983,20 @@ var AzzasTracker = function() {
835
983
  })();
836
984
  };
837
985
  var itemsFromPDP = // src/params/resolvers/items/fromPdp.ts
838
- function itemsFromPDP(context) {
986
+ function itemsFromPDP(context, event) {
839
987
  return _async_to_generator(function() {
840
- var _item_additionalProperty, _item_name, _item_category_split_, _item_category, item, value, brand;
988
+ var _item_additionalProperty, _item_name, _item_category_split_, _item_category, item, value, brand, resolvedListName, resolvedItemId;
841
989
  return _ts_generator(this, function(_state) {
842
990
  item = context.item, value = context.value, brand = context.brand;
991
+ resolvedListName = resolveItemListName({
992
+ event: event,
993
+ item: item,
994
+ itemListName: null
995
+ });
996
+ resolvedItemId = resolveItemId(item);
997
+ if (event === "VIEW_ITEM") {
998
+ saveViewedItem(resolvedItemId, resolvedListName);
999
+ }
843
1000
  return [
844
1001
  2,
845
1002
  [
@@ -860,7 +1017,8 @@ var AzzasTracker = function() {
860
1017
  item_sku: (item === null || item === void 0 ? void 0 : item.sku) || (item === null || item === void 0 ? void 0 : item.productId) || null,
861
1018
  item_url: (item === null || item === void 0 ? void 0 : item.url) || (item === null || item === void 0 ? void 0 : item.item_url) || (item === null || item === void 0 ? void 0 : item.link) || null,
862
1019
  image_url: resizeVtexImage(item === null || item === void 0 ? void 0 : item.image) || resizeVtexImage(item === null || item === void 0 ? void 0 : item.imageUrl) || null,
863
- seller_id: (item === null || item === void 0 ? void 0 : item.seller) || null
1020
+ seller_id: (item === null || item === void 0 ? void 0 : item.seller) || null,
1021
+ item_list_name: resolvedListName
864
1022
  }
865
1023
  ]
866
1024
  ];
@@ -922,11 +1080,15 @@ var AzzasTracker = function() {
922
1080
  case "REMOVE_FROM_CART":
923
1081
  return itemsFromItem(context, eventName);
924
1082
  case "SELECT_ITEM":
1083
+ return itemsFromList(context).then(function(items) {
1084
+ persistSelectItemOriginFromResolvedItems(items, context);
1085
+ return items;
1086
+ });
925
1087
  case "VIEW_ITEM_LIST":
926
1088
  return itemsFromList(context);
927
1089
  case "VIEW_ITEM":
928
1090
  case "CUSTOM_VIEW_ITEM":
929
- return itemsFromPDP(context);
1091
+ return itemsFromPDP(context, eventName);
930
1092
  case "VIEW_PROMOTION":
931
1093
  case "SELECT_PROMOTION":
932
1094
  return itemsFromBanner(context);
@@ -1101,20 +1263,20 @@ var AzzasTracker = function() {
1101
1263
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1102
1264
  var __getOwnPropNames = Object.getOwnPropertyNames;
1103
1265
  var __hasOwnProp = Object.prototype.hasOwnProperty;
1104
- var __export = function(target, all) {
1266
+ var __export = function __export(target, all) {
1105
1267
  for(var name in all)__defProp(target, name, {
1106
1268
  get: all[name],
1107
1269
  enumerable: true
1108
1270
  });
1109
1271
  };
1110
- var __copyProps = function(to, from, except, desc) {
1272
+ var __copyProps = function __copyProps(to, from, except, desc) {
1111
1273
  if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
1112
1274
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1113
1275
  try {
1114
1276
  var _loop = function() {
1115
1277
  var key = _step.value;
1116
1278
  if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
1117
- get: function() {
1279
+ get: function get() {
1118
1280
  return from[key];
1119
1281
  },
1120
1282
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
@@ -1138,7 +1300,7 @@ var AzzasTracker = function() {
1138
1300
  }
1139
1301
  return to;
1140
1302
  };
1141
- var __toCommonJS = function(mod) {
1303
+ var __toCommonJS = function __toCommonJS(mod) {
1142
1304
  return __copyProps(__defProp({}, "__esModule", {
1143
1305
  value: true
1144
1306
  }), mod);
@@ -1146,13 +1308,13 @@ var AzzasTracker = function() {
1146
1308
  // src/index.ts
1147
1309
  var src_exports = {};
1148
1310
  __export(src_exports, {
1149
- EVENTS: function() {
1311
+ EVENTS: function EVENTS1() {
1150
1312
  return EVENTS;
1151
1313
  },
1152
- default: function() {
1314
+ default: function _default() {
1153
1315
  return src_default;
1154
1316
  },
1155
- trackWebEvent: function() {
1317
+ trackWebEvent: function trackWebEvent1() {
1156
1318
  return trackWebEvent;
1157
1319
  }
1158
1320
  });
@@ -1603,16 +1765,16 @@ var AzzasTracker = function() {
1603
1765
  "cart\xE3o"
1604
1766
  ]
1605
1767
  ];
1606
- var toNum = function(val) {
1768
+ var toNum = function toNum(val) {
1607
1769
  return typeof val === "string" ? Number(val.replace(/[^\d,]/g, "").replace(",", ".")) : val;
1608
1770
  };
1609
- var setLocalStorage = function(key, value) {
1771
+ var setLocalStorage = function setLocalStorage(key, value) {
1610
1772
  localStorage.setItem(key, value);
1611
1773
  };
1612
- var getLocalStorage = function(key) {
1774
+ var getLocalStorage = function getLocalStorage(key) {
1613
1775
  return localStorage.getItem(key);
1614
1776
  };
1615
- var documentToHash = function(document2) {
1777
+ var documentToHash = function documentToHash(document2) {
1616
1778
  return _async_to_generator(function() {
1617
1779
  var encoder, data, hashBuffer, hashArray;
1618
1780
  return _ts_generator(this, function(_state) {
@@ -1647,12 +1809,17 @@ var AzzasTracker = function() {
1647
1809
  "farm etc": "farmetc",
1648
1810
  "farm rio": "farmrio"
1649
1811
  };
1812
+ // src/params/utils/itemListAttribution.ts
1813
+ var LAST_SELECTED_ITEM_KEY = "last_selected_item";
1814
+ var STORAGE_VIEWED = "last_viewed_item";
1815
+ var CART_LIST_HISTORY_KEY = "cart_list_history";
1816
+ var DAY_IN_MS = 24 * 60 * 60 * 1e3;
1650
1817
  // src/params/index.ts
1651
1818
  var paramGetters = {
1652
1819
  brand: getBrand,
1653
1820
  items: getItems,
1654
1821
  payment_type: getPaymentType,
1655
- user_info: function(context, eventName) {
1822
+ user_info: function user_info(context, eventName) {
1656
1823
  return _async_to_generator(function() {
1657
1824
  var _PROD_DOMAINS_, PROD_DOMAINS, domain, api, response, res, cpfFromStorage, hashedDocument, _;
1658
1825
  return _ts_generator(this, function(_state) {
@@ -1783,13 +1950,13 @@ var AzzasTracker = function() {
1783
1950
  });
1784
1951
  })();
1785
1952
  },
1786
- content_type: function(context, eventName) {
1953
+ content_type: function content_type(context, eventName) {
1787
1954
  return "regiao".concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
1788
1955
  },
1789
- region: function(context, eventName) {
1956
+ region: function region(context, eventName) {
1790
1957
  return context.region || null;
1791
1958
  },
1792
- line_items: function(context, eventName) {
1959
+ line_items: function line_items(context, eventName) {
1793
1960
  if (context === null || context === void 0 ? void 0 : context.lineItems) return context.lineItems;
1794
1961
  if (context === null || context === void 0 ? void 0 : context.item) {
1795
1962
  return [
@@ -1805,7 +1972,7 @@ var AzzasTracker = function() {
1805
1972
  return item.productId;
1806
1973
  }).join(",");
1807
1974
  },
1808
- currency: function(context, eventName) {
1975
+ currency: function currency(context, eventName) {
1809
1976
  var _context_orderForm_storePreferencesData, _context_orderForm;
1810
1977
  if (context === null || context === void 0 ? void 0 : context.currency) return context.currency;
1811
1978
  if (context === null || context === void 0 ? void 0 : context.bannerUrl) return "BRL";
@@ -1815,12 +1982,12 @@ var AzzasTracker = function() {
1815
1982
  }
1816
1983
  return ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_storePreferencesData = _context_orderForm.storePreferencesData) === null || _context_orderForm_storePreferencesData === void 0 ? void 0 : _context_orderForm_storePreferencesData.currencyCode) || null;
1817
1984
  },
1818
- value: function(context, eventName) {
1985
+ value: function value(context, eventName) {
1819
1986
  var _context_item, _context_orderForm;
1820
1987
  if (context === null || context === void 0 ? void 0 : context.value) return toNum(context.value);
1821
1988
  return context.item ? toNum((_context_item = context.item) === null || _context_item === void 0 ? void 0 : _context_item.price) : ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.value) != null ? context.orderForm.value / 100 : null;
1822
1989
  },
1823
- total_discount: function(context, eventName) {
1990
+ total_discount: function total_discount(context, eventName) {
1824
1991
  var _context_orderForm, _context_orderForm1;
1825
1992
  if (context === null || context === void 0 ? void 0 : context.totalDiscount) return context.totalDiscount;
1826
1993
  var totalsList = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.totalizers) || ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totals) || [];
@@ -1834,7 +2001,7 @@ var AzzasTracker = function() {
1834
2001
  });
1835
2002
  return Math.abs(((discounts === null || discounts === void 0 ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
1836
2003
  },
1837
- subtotal: function(context, eventName) {
2004
+ subtotal: function subtotal(context, eventName) {
1838
2005
  var _context_orderForm, _context_orderForm1;
1839
2006
  var totalsList = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.totalizers) || ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totals) || [];
1840
2007
  var subtotal = totalsList.filter(function(t) {
@@ -1844,7 +2011,7 @@ var AzzasTracker = function() {
1844
2011
  }, 0) / 100 || 0;
1845
2012
  return subtotal;
1846
2013
  },
1847
- coupon_message: function(context, eventName) {
2014
+ coupon_message: function coupon_message(context, eventName) {
1848
2015
  var _context_orderForm;
1849
2016
  if (context.couponMessage) return context.couponMessage;
1850
2017
  var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
@@ -1857,44 +2024,44 @@ var AzzasTracker = function() {
1857
2024
  return msg.text;
1858
2025
  }).join(" | ");
1859
2026
  },
1860
- seller_cod_name: function(context, eventName) {
2027
+ seller_cod_name: function seller_cod_name(context, eventName) {
1861
2028
  return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
1862
2029
  },
1863
- coupon: function(context, eventName) {
2030
+ coupon: function coupon(context, eventName) {
1864
2031
  var _context_orderForm_marketingData, _context_orderForm;
1865
2032
  return context.appliedCoupon || (context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_marketingData = _context_orderForm.marketingData) === null || _context_orderForm_marketingData === void 0 ? void 0 : _context_orderForm_marketingData.coupon) || null;
1866
2033
  },
1867
- pre_filled: function(context, eventName) {
2034
+ pre_filled: function pre_filled(context, eventName) {
1868
2035
  return !!context.preFilled;
1869
2036
  },
1870
- search_term: function(context, eventName) {
2037
+ search_term: function search_term(context, eventName) {
1871
2038
  return context.searchTerm || null;
1872
2039
  },
1873
- search_found: function(context, eventName) {
2040
+ search_found: function search_found(context, eventName) {
1874
2041
  return !!context.searchFound;
1875
2042
  },
1876
- search_quantity: function(context, eventName) {
2043
+ search_quantity: function search_quantity(context, eventName) {
1877
2044
  return context.searchQuantity || 0;
1878
2045
  },
1879
- promotion_name: function(context, eventName) {
2046
+ promotion_name: function promotion_name(context, eventName) {
1880
2047
  return context.promotionName || null;
1881
2048
  },
1882
- creative_name: function(context, eventName) {
2049
+ creative_name: function creative_name(context, eventName) {
1883
2050
  return context.creativeName || null;
1884
2051
  },
1885
- creative_slot: function(context, eventName) {
2052
+ creative_slot: function creative_slot(context, eventName) {
1886
2053
  return context.creativeSlot || null;
1887
2054
  },
1888
- zipcode: function(context, eventName) {
2055
+ zipcode: function zipcode(context, eventName) {
1889
2056
  return context.zipCode || null;
1890
2057
  },
1891
- size: function(context, eventName) {
2058
+ size: function size(context, eventName) {
1892
2059
  return context.size || null;
1893
2060
  },
1894
- item_ref: function(context, eventName) {
2061
+ item_ref: function item_ref(context, eventName) {
1895
2062
  return context.itemRef || null;
1896
2063
  },
1897
- flag_pickup: function(context, eventName) {
2064
+ flag_pickup: function flag_pickup(context, eventName) {
1898
2065
  var _orderForm_shippingData;
1899
2066
  var orderForm = context.orderForm;
1900
2067
  if (!orderForm) return null;
@@ -1907,7 +2074,7 @@ var AzzasTracker = function() {
1907
2074
  });
1908
2075
  return hasPickup;
1909
2076
  },
1910
- shippings: function(context, eventName) {
2077
+ shippings: function shippings(context, eventName) {
1911
2078
  var orderForm = context.orderForm;
1912
2079
  if (!orderForm) return null;
1913
2080
  var groupShipping = {};
@@ -1971,7 +2138,7 @@ var AzzasTracker = function() {
1971
2138
  });
1972
2139
  return shippings || null;
1973
2140
  },
1974
- shipping: function(context, eventName) {
2141
+ shipping: function shipping(context, eventName) {
1975
2142
  var _ref;
1976
2143
  var _context_orderForm_shippingData, _context_orderForm;
1977
2144
  var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
@@ -1984,7 +2151,7 @@ var AzzasTracker = function() {
1984
2151
  return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
1985
2152
  }, 0);
1986
2153
  },
1987
- shipping_tier: function(context, eventName) {
2154
+ shipping_tier: function shipping_tier(context, eventName) {
1988
2155
  var _ref;
1989
2156
  var _context_orderForm_shippingData, _context_orderForm;
1990
2157
  var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
@@ -2019,11 +2186,11 @@ var AzzasTracker = function() {
2019
2186
  }).filter(Boolean).join(", ");
2020
2187
  return shippingTier || null;
2021
2188
  },
2022
- transaction_id: function(context, eventName) {
2189
+ transaction_id: function transaction_id(context, eventName) {
2023
2190
  var _context_orderForm_orderGroup, _context_orderForm;
2024
2191
  return ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_orderGroup = _context_orderForm.orderGroup) === null || _context_orderForm_orderGroup === void 0 ? void 0 : _context_orderForm_orderGroup.toString()) || null;
2025
2192
  },
2026
- available_grid: function(context, eventName) {
2193
+ available_grid: function available_grid(context, eventName) {
2027
2194
  return context.availableGrid || null;
2028
2195
  }
2029
2196
  };
package/package.json CHANGED
@@ -1,38 +1,38 @@
1
- {
2
- "name": "@azzas/azzas-tracker-web",
3
- "version": "1.0.80",
4
- "type": "module",
5
- "main": "./dist/mod.cjs",
6
- "module": "./dist/mod.js",
7
- "types": "./dist/mod.d.ts",
8
- "unpkg": "./dist/mod.global.js",
9
- "jsdelivr": "./dist/mod.global.js",
10
- "exports": {
11
- ".": {
12
- "import": "./dist/mod.js",
13
- "require": "./dist/mod.cjs",
14
- "default": "./dist/legacy/mod.cjs"
15
- }
16
- },
17
- "files": [
18
- "dist"
19
- ],
20
- "scripts": {
21
- "build": "tsup",
22
- "prepublishOnly": "npm run build",
23
- "release:homolog": "npm run build && npm version prepatch --preid=beta && npm publish --tag beta --access public",
24
- "release:prod": "npm run build && npm version patch && npm publish --access public",
25
- "pack:copy": "VERSION=$(npm pkg get version | tr -d '\"') && npm pack && tar -xzf azzas-azzas-tracker-web-$VERSION.tgz",
26
- "start:deno": "deno run --allow-net --allow-read https://deno.land/std@0.207.0/http/file_server.ts ./package",
27
- "dev:deno": "npm run build && npm run pack:copy && npm run start:deno",
28
- "dev:npm": "npm run build -- --watch"
29
- },
30
- "publishConfig": {
31
- "access": "public"
32
- },
33
- "devDependencies": {
34
- "@swc/core": "^1.15.7",
35
- "tsup": "^8.5.0",
36
- "typescript": "^5.9.2"
37
- }
38
- }
1
+ {
2
+ "name": "@azzas/azzas-tracker-web",
3
+ "version": "1.0.81",
4
+ "type": "module",
5
+ "main": "./dist/mod.cjs",
6
+ "module": "./dist/mod.js",
7
+ "types": "./dist/mod.d.ts",
8
+ "unpkg": "./dist/mod.global.js",
9
+ "jsdelivr": "./dist/mod.global.js",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/mod.js",
13
+ "require": "./dist/mod.cjs",
14
+ "default": "./dist/legacy/mod.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsup",
22
+ "prepublishOnly": "npm run build",
23
+ "release:homolog": "npm run build && npm version prepatch --preid=beta && npm publish --tag beta --access public",
24
+ "release:prod": "npm run build && npm version patch && npm publish --access public",
25
+ "pack:copy": "node -e \"const v=require('./package.json').version,e=require('child_process').execSync;e('npm pack',{stdio:'inherit'});e('tar -xzf azzas-azzas-tracker-web-'+v+'.tgz',{stdio:'inherit'})\"",
26
+ "start:deno": "deno run --allow-net --allow-read https://deno.land/std@0.207.0/http/file_server.ts ./package",
27
+ "dev:deno": "npm run build && npm run pack:copy && npm run start:deno",
28
+ "dev:npm": "npm run build -- --watch"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "devDependencies": {
34
+ "@swc/core": "^1.15.7",
35
+ "tsup": "^8.5.0",
36
+ "typescript": "^5.9.2"
37
+ }
38
+ }