@azzas/azzas-tracker-web 1.0.80 → 1.0.82

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,178 @@ 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.item_id === "string" && typeof candidate.item_list_name === "string" && typeof candidate.timestamp === "number";
787
+ };
788
+ var normalizeStoredItemMemory = function normalizeStoredItemMemory(value) {
789
+ if (!value || (typeof value === "undefined" ? "undefined" : _type_of(value)) !== "object") return null;
790
+ var candidate = value;
791
+ var itemId = candidate.item_id;
792
+ var itemListName = candidate.item_list_name;
793
+ var timestamp = candidate.timestamp;
794
+ if (typeof itemId !== "string" || typeof itemListName !== "string" || typeof timestamp !== "number") {
795
+ return null;
796
+ }
797
+ return {
798
+ item_id: itemId,
799
+ item_list_name: itemListName,
800
+ timestamp: timestamp
801
+ };
802
+ };
803
+ var resolveIdFromUnknownItem = function resolveIdFromUnknownItem(item) {
804
+ var _ref, _ref1, _ref2, _ref3, _ref4;
805
+ 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;
806
+ return id == null ? null : String(id);
807
+ };
808
+ var resolveItemId = function resolveItemId(item) {
809
+ return resolveIdFromUnknownItem(item);
810
+ };
811
+ var readStoredItem = function readStoredItem(key) {
812
+ var storage = getStorage();
813
+ if (!storage) return null;
814
+ try {
815
+ var parsed = parseJSON(storage.getItem(key));
816
+ var normalized = normalizeStoredItemMemory(parsed);
817
+ return normalized && isStoredItemMemory(normalized) ? normalized : null;
818
+ } catch (unused) {
819
+ return null;
820
+ }
821
+ };
822
+ var writeStoredItem = function writeStoredItem(key, value) {
823
+ var storage = getStorage();
824
+ if (!storage) return;
825
+ try {
826
+ storage.setItem(key, JSON.stringify(value));
827
+ } catch (unused) {}
828
+ };
829
+ var readCartHistory = function readCartHistory() {
830
+ var storage = getStorage();
831
+ if (!storage) return [];
832
+ try {
833
+ var parsed = parseJSON(storage.getItem(CART_LIST_HISTORY_KEY));
834
+ if (!Array.isArray(parsed)) return [];
835
+ return parsed.filter(function(entry) {
836
+ return !!entry && (typeof entry === "undefined" ? "undefined" : _type_of(entry)) === "object" && typeof entry.item_id === "string" && typeof entry.item_list_name === "string";
837
+ });
838
+ } catch (unused) {
839
+ return [];
840
+ }
841
+ };
842
+ var writeCartHistory = function writeCartHistory(history) {
843
+ var storage = getStorage();
844
+ if (!storage) return;
845
+ try {
846
+ storage.setItem(CART_LIST_HISTORY_KEY, JSON.stringify(history));
847
+ } catch (unused) {}
848
+ };
849
+ var saveSelectedItem = function saveSelectedItem(productId, listName) {
850
+ if (productId == null || !listName) return;
851
+ var payload = {
852
+ item_id: String(productId),
853
+ item_list_name: String(listName),
854
+ timestamp: Date.now()
855
+ };
856
+ writeStoredItem(LAST_SELECTED_ITEM_KEY, payload);
857
+ };
858
+ var saveViewedItem = function saveViewedItem(productId, listName) {
859
+ if (productId == null) return;
860
+ var payload = {
861
+ item_id: String(productId),
862
+ item_list_name: String(listName !== null && listName !== void 0 ? listName : "PDP"),
863
+ timestamp: Date.now()
864
+ };
865
+ writeStoredItem(STORAGE_VIEWED, payload);
866
+ };
867
+ var resolveItemListName = function resolveItemListName(params) {
868
+ var event = params.event, item = params.item, itemListName = params.itemListName;
869
+ var currentListName = itemListName !== null && itemListName !== void 0 ? itemListName : null;
870
+ var isResolvableEvent = event === "VIEW_ITEM" || event === "ADD_TO_CART";
871
+ if (!isResolvableEvent) return currentListName;
872
+ var currentItemId = resolveIdFromUnknownItem(item);
873
+ if (event === "VIEW_ITEM") {
874
+ if (!currentItemId) return "PDP";
875
+ var selectedItem = readStoredItem(LAST_SELECTED_ITEM_KEY);
876
+ if (!selectedItem) return "PDP";
877
+ if (selectedItem.item_id === currentItemId && isFreshTimestamp(selectedItem.timestamp)) {
878
+ return selectedItem.item_list_name;
879
+ }
880
+ return "PDP";
881
+ }
882
+ if (currentListName !== "PDP" && currentListName !== null) return currentListName;
883
+ if (!currentItemId) return currentListName;
884
+ var viewedItem = readStoredItem(STORAGE_VIEWED);
885
+ if (viewedItem && viewedItem.item_id === currentItemId && isFreshTimestamp(viewedItem.timestamp)) {
886
+ return viewedItem.item_list_name;
887
+ }
888
+ return currentListName === "PDP" ? "PDP" : null;
889
+ };
890
+ var appendCartHistory = function appendCartHistory(productId, listName) {
891
+ if (productId == null) return;
892
+ var history = readCartHistory();
893
+ history.push({
894
+ item_id: String(productId),
895
+ item_list_name: listName ? String(listName) : "PDP"
896
+ });
897
+ writeCartHistory(history);
898
+ };
899
+ var pickSelectedItemFromResolvedItems = function pickSelectedItemFromResolvedItems(items, source) {
900
+ if (!Array.isArray(items) || items.length === 0) return null;
901
+ if (typeof (source === null || source === void 0 ? void 0 : source.index) === "number") {
902
+ var _items_find;
903
+ var indexed = (_items_find = items.find(function(item) {
904
+ return (item === null || item === void 0 ? void 0 : item.index) === source.index;
905
+ })) !== null && _items_find !== void 0 ? _items_find : items[source.index];
906
+ if (indexed && (typeof indexed === "undefined" ? "undefined" : _type_of(indexed)) === "object") return indexed;
907
+ }
908
+ return items[0];
909
+ };
910
+ var persistSelectItemOriginFromResolvedItems = function persistSelectItemOriginFromResolvedItems(items, source) {
911
+ var _ref, _ref1, _ref2;
912
+ var selectedItem = pickSelectedItemFromResolvedItems(items, source);
913
+ if (!selectedItem) return;
914
+ var productId = resolveIdFromUnknownItem(selectedItem);
915
+ 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;
916
+ saveSelectedItem(productId, listName);
917
+ };
763
918
  var itemsFromItem = // src/params/resolvers/items/fromItem.ts
764
919
  function itemsFromItem(context, event) {
765
920
  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;
921
+ 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
922
  return _ts_generator(this, function(_state) {
768
923
  switch(_state.label){
769
924
  case 0:
770
925
  item = context.item, orderForm = context.orderForm, itemListName = context.itemListName;
926
+ resolvedListName = resolveItemListName({
927
+ event: event,
928
+ item: item,
929
+ itemListName: itemListName
930
+ });
931
+ resolvedItemId = resolveItemId(item);
932
+ if (event === "ADD_TO_CART") {
933
+ appendCartHistory(resolvedItemId, resolvedListName);
934
+ }
771
935
  _tmp = {
772
936
  index: typeof (item === null || item === void 0 ? void 0 : item.index) === "number" ? item.index : null,
773
937
  quantity: 1,
@@ -797,7 +961,7 @@ var AzzasTracker = function() {
797
961
  return [
798
962
  2,
799
963
  [
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
964
+ (_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
965
  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
966
  ]
803
967
  ];
@@ -835,11 +999,20 @@ var AzzasTracker = function() {
835
999
  })();
836
1000
  };
837
1001
  var itemsFromPDP = // src/params/resolvers/items/fromPdp.ts
838
- function itemsFromPDP(context) {
1002
+ function itemsFromPDP(context, event) {
839
1003
  return _async_to_generator(function() {
840
- var _item_additionalProperty, _item_name, _item_category_split_, _item_category, item, value, brand;
1004
+ var _item_additionalProperty, _item_name, _item_category_split_, _item_category, item, value, brand, resolvedListName, resolvedItemId;
841
1005
  return _ts_generator(this, function(_state) {
842
1006
  item = context.item, value = context.value, brand = context.brand;
1007
+ resolvedListName = resolveItemListName({
1008
+ event: event,
1009
+ item: item,
1010
+ itemListName: null
1011
+ });
1012
+ resolvedItemId = resolveItemId(item);
1013
+ if (event === "VIEW_ITEM") {
1014
+ saveViewedItem(resolvedItemId, resolvedListName);
1015
+ }
843
1016
  return [
844
1017
  2,
845
1018
  [
@@ -860,7 +1033,8 @@ var AzzasTracker = function() {
860
1033
  item_sku: (item === null || item === void 0 ? void 0 : item.sku) || (item === null || item === void 0 ? void 0 : item.productId) || null,
861
1034
  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
1035
  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
1036
+ seller_id: (item === null || item === void 0 ? void 0 : item.seller) || null,
1037
+ item_list_name: resolvedListName
864
1038
  }
865
1039
  ]
866
1040
  ];
@@ -922,11 +1096,15 @@ var AzzasTracker = function() {
922
1096
  case "REMOVE_FROM_CART":
923
1097
  return itemsFromItem(context, eventName);
924
1098
  case "SELECT_ITEM":
1099
+ return itemsFromList(context).then(function(items) {
1100
+ persistSelectItemOriginFromResolvedItems(items, context);
1101
+ return items;
1102
+ });
925
1103
  case "VIEW_ITEM_LIST":
926
1104
  return itemsFromList(context);
927
1105
  case "VIEW_ITEM":
928
1106
  case "CUSTOM_VIEW_ITEM":
929
- return itemsFromPDP(context);
1107
+ return itemsFromPDP(context, eventName);
930
1108
  case "VIEW_PROMOTION":
931
1109
  case "SELECT_PROMOTION":
932
1110
  return itemsFromBanner(context);
@@ -1101,20 +1279,20 @@ var AzzasTracker = function() {
1101
1279
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1102
1280
  var __getOwnPropNames = Object.getOwnPropertyNames;
1103
1281
  var __hasOwnProp = Object.prototype.hasOwnProperty;
1104
- var __export = function(target, all) {
1282
+ var __export = function __export(target, all) {
1105
1283
  for(var name in all)__defProp(target, name, {
1106
1284
  get: all[name],
1107
1285
  enumerable: true
1108
1286
  });
1109
1287
  };
1110
- var __copyProps = function(to, from, except, desc) {
1288
+ var __copyProps = function __copyProps(to, from, except, desc) {
1111
1289
  if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
1112
1290
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1113
1291
  try {
1114
1292
  var _loop = function() {
1115
1293
  var key = _step.value;
1116
1294
  if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
1117
- get: function() {
1295
+ get: function get() {
1118
1296
  return from[key];
1119
1297
  },
1120
1298
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
@@ -1138,7 +1316,7 @@ var AzzasTracker = function() {
1138
1316
  }
1139
1317
  return to;
1140
1318
  };
1141
- var __toCommonJS = function(mod) {
1319
+ var __toCommonJS = function __toCommonJS(mod) {
1142
1320
  return __copyProps(__defProp({}, "__esModule", {
1143
1321
  value: true
1144
1322
  }), mod);
@@ -1146,13 +1324,13 @@ var AzzasTracker = function() {
1146
1324
  // src/index.ts
1147
1325
  var src_exports = {};
1148
1326
  __export(src_exports, {
1149
- EVENTS: function() {
1327
+ EVENTS: function EVENTS1() {
1150
1328
  return EVENTS;
1151
1329
  },
1152
- default: function() {
1330
+ default: function _default() {
1153
1331
  return src_default;
1154
1332
  },
1155
- trackWebEvent: function() {
1333
+ trackWebEvent: function trackWebEvent1() {
1156
1334
  return trackWebEvent;
1157
1335
  }
1158
1336
  });
@@ -1603,16 +1781,16 @@ var AzzasTracker = function() {
1603
1781
  "cart\xE3o"
1604
1782
  ]
1605
1783
  ];
1606
- var toNum = function(val) {
1784
+ var toNum = function toNum(val) {
1607
1785
  return typeof val === "string" ? Number(val.replace(/[^\d,]/g, "").replace(",", ".")) : val;
1608
1786
  };
1609
- var setLocalStorage = function(key, value) {
1787
+ var setLocalStorage = function setLocalStorage(key, value) {
1610
1788
  localStorage.setItem(key, value);
1611
1789
  };
1612
- var getLocalStorage = function(key) {
1790
+ var getLocalStorage = function getLocalStorage(key) {
1613
1791
  return localStorage.getItem(key);
1614
1792
  };
1615
- var documentToHash = function(document2) {
1793
+ var documentToHash = function documentToHash(document2) {
1616
1794
  return _async_to_generator(function() {
1617
1795
  var encoder, data, hashBuffer, hashArray;
1618
1796
  return _ts_generator(this, function(_state) {
@@ -1647,12 +1825,17 @@ var AzzasTracker = function() {
1647
1825
  "farm etc": "farmetc",
1648
1826
  "farm rio": "farmrio"
1649
1827
  };
1828
+ // src/params/utils/itemListAttribution.ts
1829
+ var LAST_SELECTED_ITEM_KEY = "last_selected_item";
1830
+ var STORAGE_VIEWED = "last_viewed_item";
1831
+ var CART_LIST_HISTORY_KEY = "cart_list_history";
1832
+ var DAY_IN_MS = 24 * 60 * 60 * 1e3;
1650
1833
  // src/params/index.ts
1651
1834
  var paramGetters = {
1652
1835
  brand: getBrand,
1653
1836
  items: getItems,
1654
1837
  payment_type: getPaymentType,
1655
- user_info: function(context, eventName) {
1838
+ user_info: function user_info(context, eventName) {
1656
1839
  return _async_to_generator(function() {
1657
1840
  var _PROD_DOMAINS_, PROD_DOMAINS, domain, api, response, res, cpfFromStorage, hashedDocument, _;
1658
1841
  return _ts_generator(this, function(_state) {
@@ -1783,13 +1966,13 @@ var AzzasTracker = function() {
1783
1966
  });
1784
1967
  })();
1785
1968
  },
1786
- content_type: function(context, eventName) {
1969
+ content_type: function content_type(context, eventName) {
1787
1970
  return "regiao".concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
1788
1971
  },
1789
- region: function(context, eventName) {
1972
+ region: function region(context, eventName) {
1790
1973
  return context.region || null;
1791
1974
  },
1792
- line_items: function(context, eventName) {
1975
+ line_items: function line_items(context, eventName) {
1793
1976
  if (context === null || context === void 0 ? void 0 : context.lineItems) return context.lineItems;
1794
1977
  if (context === null || context === void 0 ? void 0 : context.item) {
1795
1978
  return [
@@ -1805,7 +1988,7 @@ var AzzasTracker = function() {
1805
1988
  return item.productId;
1806
1989
  }).join(",");
1807
1990
  },
1808
- currency: function(context, eventName) {
1991
+ currency: function currency(context, eventName) {
1809
1992
  var _context_orderForm_storePreferencesData, _context_orderForm;
1810
1993
  if (context === null || context === void 0 ? void 0 : context.currency) return context.currency;
1811
1994
  if (context === null || context === void 0 ? void 0 : context.bannerUrl) return "BRL";
@@ -1815,12 +1998,12 @@ var AzzasTracker = function() {
1815
1998
  }
1816
1999
  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
2000
  },
1818
- value: function(context, eventName) {
2001
+ value: function value(context, eventName) {
1819
2002
  var _context_item, _context_orderForm;
1820
2003
  if (context === null || context === void 0 ? void 0 : context.value) return toNum(context.value);
1821
2004
  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
2005
  },
1823
- total_discount: function(context, eventName) {
2006
+ total_discount: function total_discount(context, eventName) {
1824
2007
  var _context_orderForm, _context_orderForm1;
1825
2008
  if (context === null || context === void 0 ? void 0 : context.totalDiscount) return context.totalDiscount;
1826
2009
  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 +2017,7 @@ var AzzasTracker = function() {
1834
2017
  });
1835
2018
  return Math.abs(((discounts === null || discounts === void 0 ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
1836
2019
  },
1837
- subtotal: function(context, eventName) {
2020
+ subtotal: function subtotal(context, eventName) {
1838
2021
  var _context_orderForm, _context_orderForm1;
1839
2022
  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
2023
  var subtotal = totalsList.filter(function(t) {
@@ -1844,7 +2027,7 @@ var AzzasTracker = function() {
1844
2027
  }, 0) / 100 || 0;
1845
2028
  return subtotal;
1846
2029
  },
1847
- coupon_message: function(context, eventName) {
2030
+ coupon_message: function coupon_message(context, eventName) {
1848
2031
  var _context_orderForm;
1849
2032
  if (context.couponMessage) return context.couponMessage;
1850
2033
  var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
@@ -1857,44 +2040,44 @@ var AzzasTracker = function() {
1857
2040
  return msg.text;
1858
2041
  }).join(" | ");
1859
2042
  },
1860
- seller_cod_name: function(context, eventName) {
2043
+ seller_cod_name: function seller_cod_name(context, eventName) {
1861
2044
  return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
1862
2045
  },
1863
- coupon: function(context, eventName) {
2046
+ coupon: function coupon(context, eventName) {
1864
2047
  var _context_orderForm_marketingData, _context_orderForm;
1865
2048
  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
2049
  },
1867
- pre_filled: function(context, eventName) {
2050
+ pre_filled: function pre_filled(context, eventName) {
1868
2051
  return !!context.preFilled;
1869
2052
  },
1870
- search_term: function(context, eventName) {
2053
+ search_term: function search_term(context, eventName) {
1871
2054
  return context.searchTerm || null;
1872
2055
  },
1873
- search_found: function(context, eventName) {
2056
+ search_found: function search_found(context, eventName) {
1874
2057
  return !!context.searchFound;
1875
2058
  },
1876
- search_quantity: function(context, eventName) {
2059
+ search_quantity: function search_quantity(context, eventName) {
1877
2060
  return context.searchQuantity || 0;
1878
2061
  },
1879
- promotion_name: function(context, eventName) {
2062
+ promotion_name: function promotion_name(context, eventName) {
1880
2063
  return context.promotionName || null;
1881
2064
  },
1882
- creative_name: function(context, eventName) {
2065
+ creative_name: function creative_name(context, eventName) {
1883
2066
  return context.creativeName || null;
1884
2067
  },
1885
- creative_slot: function(context, eventName) {
2068
+ creative_slot: function creative_slot(context, eventName) {
1886
2069
  return context.creativeSlot || null;
1887
2070
  },
1888
- zipcode: function(context, eventName) {
2071
+ zipcode: function zipcode(context, eventName) {
1889
2072
  return context.zipCode || null;
1890
2073
  },
1891
- size: function(context, eventName) {
2074
+ size: function size(context, eventName) {
1892
2075
  return context.size || null;
1893
2076
  },
1894
- item_ref: function(context, eventName) {
2077
+ item_ref: function item_ref(context, eventName) {
1895
2078
  return context.itemRef || null;
1896
2079
  },
1897
- flag_pickup: function(context, eventName) {
2080
+ flag_pickup: function flag_pickup(context, eventName) {
1898
2081
  var _orderForm_shippingData;
1899
2082
  var orderForm = context.orderForm;
1900
2083
  if (!orderForm) return null;
@@ -1907,7 +2090,7 @@ var AzzasTracker = function() {
1907
2090
  });
1908
2091
  return hasPickup;
1909
2092
  },
1910
- shippings: function(context, eventName) {
2093
+ shippings: function shippings(context, eventName) {
1911
2094
  var orderForm = context.orderForm;
1912
2095
  if (!orderForm) return null;
1913
2096
  var groupShipping = {};
@@ -1971,7 +2154,7 @@ var AzzasTracker = function() {
1971
2154
  });
1972
2155
  return shippings || null;
1973
2156
  },
1974
- shipping: function(context, eventName) {
2157
+ shipping: function shipping(context, eventName) {
1975
2158
  var _ref;
1976
2159
  var _context_orderForm_shippingData, _context_orderForm;
1977
2160
  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 +2167,7 @@ var AzzasTracker = function() {
1984
2167
  return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
1985
2168
  }, 0);
1986
2169
  },
1987
- shipping_tier: function(context, eventName) {
2170
+ shipping_tier: function shipping_tier(context, eventName) {
1988
2171
  var _ref;
1989
2172
  var _context_orderForm_shippingData, _context_orderForm;
1990
2173
  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 +2202,11 @@ var AzzasTracker = function() {
2019
2202
  }).filter(Boolean).join(", ");
2020
2203
  return shippingTier || null;
2021
2204
  },
2022
- transaction_id: function(context, eventName) {
2205
+ transaction_id: function transaction_id(context, eventName) {
2023
2206
  var _context_orderForm_orderGroup, _context_orderForm;
2024
2207
  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
2208
  },
2026
- available_grid: function(context, eventName) {
2209
+ available_grid: function available_grid(context, eventName) {
2027
2210
  return context.availableGrid || null;
2028
2211
  }
2029
2212
  };
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.82",
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
+ }