@azzas/azzas-tracker-web 1.0.79 → 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.
@@ -100,6 +100,30 @@ function _object_spread(target) {
100
100
  }
101
101
  return target;
102
102
  }
103
+ function ownKeys(object, enumerableOnly) {
104
+ var keys = Object.keys(object);
105
+ if (Object.getOwnPropertySymbols) {
106
+ var symbols = Object.getOwnPropertySymbols(object);
107
+ if (enumerableOnly) {
108
+ symbols = symbols.filter(function(sym) {
109
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
110
+ });
111
+ }
112
+ keys.push.apply(keys, symbols);
113
+ }
114
+ return keys;
115
+ }
116
+ function _object_spread_props(target, source) {
117
+ source = source != null ? source : {};
118
+ if (Object.getOwnPropertyDescriptors) {
119
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
120
+ } else {
121
+ ownKeys(Object(source)).forEach(function(key) {
122
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
123
+ });
124
+ }
125
+ return target;
126
+ }
103
127
  function _sliced_to_array(arr, i) {
104
128
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
105
129
  }
@@ -736,14 +760,162 @@ var AzzasTracker = function() {
736
760
  });
737
761
  })();
738
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
+ };
739
902
  var itemsFromItem = // src/params/resolvers/items/fromItem.ts
740
903
  function itemsFromItem(context, event) {
741
904
  return _async_to_generator(function() {
742
- 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;
743
906
  return _ts_generator(this, function(_state) {
744
907
  switch(_state.label){
745
908
  case 0:
746
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
+ }
747
919
  _tmp = {
748
920
  index: typeof (item === null || item === void 0 ? void 0 : item.index) === "number" ? item.index : null,
749
921
  quantity: 1,
@@ -773,7 +945,7 @@ var AzzasTracker = function() {
773
945
  return [
774
946
  2,
775
947
  [
776
- (_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
777
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)
778
950
  ]
779
951
  ];
@@ -811,11 +983,20 @@ var AzzasTracker = function() {
811
983
  })();
812
984
  };
813
985
  var itemsFromPDP = // src/params/resolvers/items/fromPdp.ts
814
- function itemsFromPDP(context) {
986
+ function itemsFromPDP(context, event) {
815
987
  return _async_to_generator(function() {
816
- 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;
817
989
  return _ts_generator(this, function(_state) {
818
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
+ }
819
1000
  return [
820
1001
  2,
821
1002
  [
@@ -836,7 +1017,8 @@ var AzzasTracker = function() {
836
1017
  item_sku: (item === null || item === void 0 ? void 0 : item.sku) || (item === null || item === void 0 ? void 0 : item.productId) || null,
837
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,
838
1019
  image_url: resizeVtexImage(item === null || item === void 0 ? void 0 : item.image) || resizeVtexImage(item === null || item === void 0 ? void 0 : item.imageUrl) || null,
839
- 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
840
1022
  }
841
1023
  ]
842
1024
  ];
@@ -898,11 +1080,15 @@ var AzzasTracker = function() {
898
1080
  case "REMOVE_FROM_CART":
899
1081
  return itemsFromItem(context, eventName);
900
1082
  case "SELECT_ITEM":
1083
+ return itemsFromList(context).then(function(items) {
1084
+ persistSelectItemOriginFromResolvedItems(items, context);
1085
+ return items;
1086
+ });
901
1087
  case "VIEW_ITEM_LIST":
902
1088
  return itemsFromList(context);
903
1089
  case "VIEW_ITEM":
904
1090
  case "CUSTOM_VIEW_ITEM":
905
- return itemsFromPDP(context);
1091
+ return itemsFromPDP(context, eventName);
906
1092
  case "VIEW_PROMOTION":
907
1093
  case "SELECT_PROMOTION":
908
1094
  return itemsFromBanner(context);
@@ -1077,20 +1263,20 @@ var AzzasTracker = function() {
1077
1263
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1078
1264
  var __getOwnPropNames = Object.getOwnPropertyNames;
1079
1265
  var __hasOwnProp = Object.prototype.hasOwnProperty;
1080
- var __export = function(target, all) {
1266
+ var __export = function __export(target, all) {
1081
1267
  for(var name in all)__defProp(target, name, {
1082
1268
  get: all[name],
1083
1269
  enumerable: true
1084
1270
  });
1085
1271
  };
1086
- var __copyProps = function(to, from, except, desc) {
1272
+ var __copyProps = function __copyProps(to, from, except, desc) {
1087
1273
  if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
1088
1274
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1089
1275
  try {
1090
1276
  var _loop = function() {
1091
1277
  var key = _step.value;
1092
1278
  if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
1093
- get: function() {
1279
+ get: function get() {
1094
1280
  return from[key];
1095
1281
  },
1096
1282
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
@@ -1114,7 +1300,7 @@ var AzzasTracker = function() {
1114
1300
  }
1115
1301
  return to;
1116
1302
  };
1117
- var __toCommonJS = function(mod) {
1303
+ var __toCommonJS = function __toCommonJS(mod) {
1118
1304
  return __copyProps(__defProp({}, "__esModule", {
1119
1305
  value: true
1120
1306
  }), mod);
@@ -1122,13 +1308,13 @@ var AzzasTracker = function() {
1122
1308
  // src/index.ts
1123
1309
  var src_exports = {};
1124
1310
  __export(src_exports, {
1125
- EVENTS: function() {
1311
+ EVENTS: function EVENTS1() {
1126
1312
  return EVENTS;
1127
1313
  },
1128
- default: function() {
1314
+ default: function _default() {
1129
1315
  return src_default;
1130
1316
  },
1131
- trackWebEvent: function() {
1317
+ trackWebEvent: function trackWebEvent1() {
1132
1318
  return trackWebEvent;
1133
1319
  }
1134
1320
  });
@@ -1579,9 +1765,40 @@ var AzzasTracker = function() {
1579
1765
  "cart\xE3o"
1580
1766
  ]
1581
1767
  ];
1582
- var toNum = function(val) {
1768
+ var toNum = function toNum(val) {
1583
1769
  return typeof val === "string" ? Number(val.replace(/[^\d,]/g, "").replace(",", ".")) : val;
1584
1770
  };
1771
+ var setLocalStorage = function setLocalStorage(key, value) {
1772
+ localStorage.setItem(key, value);
1773
+ };
1774
+ var getLocalStorage = function getLocalStorage(key) {
1775
+ return localStorage.getItem(key);
1776
+ };
1777
+ var documentToHash = function documentToHash(document2) {
1778
+ return _async_to_generator(function() {
1779
+ var encoder, data, hashBuffer, hashArray;
1780
+ return _ts_generator(this, function(_state) {
1781
+ switch(_state.label){
1782
+ case 0:
1783
+ encoder = new TextEncoder();
1784
+ data = encoder.encode(document2);
1785
+ return [
1786
+ 4,
1787
+ crypto.subtle.digest("SHA-256", data)
1788
+ ];
1789
+ case 1:
1790
+ hashBuffer = _state.sent();
1791
+ hashArray = Array.from(new Uint8Array(hashBuffer));
1792
+ return [
1793
+ 2,
1794
+ hashArray.map(function(b) {
1795
+ return b.toString(16).padStart(2, "0");
1796
+ }).join("")
1797
+ ];
1798
+ }
1799
+ });
1800
+ })();
1801
+ };
1585
1802
  // src/adapters/index.ts
1586
1803
  var adapters = {
1587
1804
  DataLayer: pushToDataLayer,
@@ -1592,14 +1809,19 @@ var AzzasTracker = function() {
1592
1809
  "farm etc": "farmetc",
1593
1810
  "farm rio": "farmrio"
1594
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;
1595
1817
  // src/params/index.ts
1596
1818
  var paramGetters = {
1597
1819
  brand: getBrand,
1598
1820
  items: getItems,
1599
1821
  payment_type: getPaymentType,
1600
- user_info: function(context, eventName) {
1822
+ user_info: function user_info(context, eventName) {
1601
1823
  return _async_to_generator(function() {
1602
- var _PROD_DOMAINS_, PROD_DOMAINS, domain, api, response, _;
1824
+ var _PROD_DOMAINS_, PROD_DOMAINS, domain, api, response, res, cpfFromStorage, hashedDocument, _;
1603
1825
  return _ts_generator(this, function(_state) {
1604
1826
  switch(_state.label){
1605
1827
  case 0:
@@ -1639,9 +1861,9 @@ var AzzasTracker = function() {
1639
1861
  case 1:
1640
1862
  _state.trys.push([
1641
1863
  1,
1642
- 4,
1864
+ 7,
1643
1865
  ,
1644
- 5
1866
+ 8
1645
1867
  ]);
1646
1868
  api = "".concat(domain, "/_v/user-info");
1647
1869
  return [
@@ -1672,11 +1894,43 @@ var AzzasTracker = function() {
1672
1894
  response.json()
1673
1895
  ];
1674
1896
  case 3:
1897
+ res = _state.sent();
1898
+ cpfFromStorage = getLocalStorage("user_doc_dt");
1899
+ if (!cpfFromStorage) return [
1900
+ 3,
1901
+ 4
1902
+ ];
1675
1903
  return [
1676
1904
  2,
1677
- _state.sent()
1905
+ _object_spread_props(_object_spread({}, res), {
1906
+ customer: _object_spread_props(_object_spread({}, res.customer), {
1907
+ cpf: cpfFromStorage
1908
+ })
1909
+ })
1678
1910
  ];
1679
1911
  case 4:
1912
+ return [
1913
+ 4,
1914
+ documentToHash(res.customer.document)
1915
+ ];
1916
+ case 5:
1917
+ hashedDocument = _state.sent();
1918
+ console.log("[DT] set localstorage");
1919
+ setLocalStorage("user_doc_dt", hashedDocument);
1920
+ return [
1921
+ 2,
1922
+ _object_spread_props(_object_spread({}, res), {
1923
+ customer: _object_spread_props(_object_spread({}, res.customer), {
1924
+ cpf: hashedDocument
1925
+ })
1926
+ })
1927
+ ];
1928
+ case 6:
1929
+ return [
1930
+ 3,
1931
+ 8
1932
+ ];
1933
+ case 7:
1680
1934
  _ = _state.sent();
1681
1935
  return [
1682
1936
  2,
@@ -1688,7 +1942,7 @@ var AzzasTracker = function() {
1688
1942
  address: null
1689
1943
  }
1690
1944
  ];
1691
- case 5:
1945
+ case 8:
1692
1946
  return [
1693
1947
  2
1694
1948
  ];
@@ -1696,13 +1950,13 @@ var AzzasTracker = function() {
1696
1950
  });
1697
1951
  })();
1698
1952
  },
1699
- content_type: function(context, eventName) {
1953
+ content_type: function content_type(context, eventName) {
1700
1954
  return "regiao".concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
1701
1955
  },
1702
- region: function(context, eventName) {
1956
+ region: function region(context, eventName) {
1703
1957
  return context.region || null;
1704
1958
  },
1705
- line_items: function(context, eventName) {
1959
+ line_items: function line_items(context, eventName) {
1706
1960
  if (context === null || context === void 0 ? void 0 : context.lineItems) return context.lineItems;
1707
1961
  if (context === null || context === void 0 ? void 0 : context.item) {
1708
1962
  return [
@@ -1718,7 +1972,7 @@ var AzzasTracker = function() {
1718
1972
  return item.productId;
1719
1973
  }).join(",");
1720
1974
  },
1721
- currency: function(context, eventName) {
1975
+ currency: function currency(context, eventName) {
1722
1976
  var _context_orderForm_storePreferencesData, _context_orderForm;
1723
1977
  if (context === null || context === void 0 ? void 0 : context.currency) return context.currency;
1724
1978
  if (context === null || context === void 0 ? void 0 : context.bannerUrl) return "BRL";
@@ -1728,12 +1982,12 @@ var AzzasTracker = function() {
1728
1982
  }
1729
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;
1730
1984
  },
1731
- value: function(context, eventName) {
1985
+ value: function value(context, eventName) {
1732
1986
  var _context_item, _context_orderForm;
1733
1987
  if (context === null || context === void 0 ? void 0 : context.value) return toNum(context.value);
1734
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;
1735
1989
  },
1736
- total_discount: function(context, eventName) {
1990
+ total_discount: function total_discount(context, eventName) {
1737
1991
  var _context_orderForm, _context_orderForm1;
1738
1992
  if (context === null || context === void 0 ? void 0 : context.totalDiscount) return context.totalDiscount;
1739
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) || [];
@@ -1747,7 +2001,7 @@ var AzzasTracker = function() {
1747
2001
  });
1748
2002
  return Math.abs(((discounts === null || discounts === void 0 ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
1749
2003
  },
1750
- subtotal: function(context, eventName) {
2004
+ subtotal: function subtotal(context, eventName) {
1751
2005
  var _context_orderForm, _context_orderForm1;
1752
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) || [];
1753
2007
  var subtotal = totalsList.filter(function(t) {
@@ -1757,7 +2011,7 @@ var AzzasTracker = function() {
1757
2011
  }, 0) / 100 || 0;
1758
2012
  return subtotal;
1759
2013
  },
1760
- coupon_message: function(context, eventName) {
2014
+ coupon_message: function coupon_message(context, eventName) {
1761
2015
  var _context_orderForm;
1762
2016
  if (context.couponMessage) return context.couponMessage;
1763
2017
  var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
@@ -1770,44 +2024,44 @@ var AzzasTracker = function() {
1770
2024
  return msg.text;
1771
2025
  }).join(" | ");
1772
2026
  },
1773
- seller_cod_name: function(context, eventName) {
2027
+ seller_cod_name: function seller_cod_name(context, eventName) {
1774
2028
  return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
1775
2029
  },
1776
- coupon: function(context, eventName) {
2030
+ coupon: function coupon(context, eventName) {
1777
2031
  var _context_orderForm_marketingData, _context_orderForm;
1778
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;
1779
2033
  },
1780
- pre_filled: function(context, eventName) {
2034
+ pre_filled: function pre_filled(context, eventName) {
1781
2035
  return !!context.preFilled;
1782
2036
  },
1783
- search_term: function(context, eventName) {
2037
+ search_term: function search_term(context, eventName) {
1784
2038
  return context.searchTerm || null;
1785
2039
  },
1786
- search_found: function(context, eventName) {
2040
+ search_found: function search_found(context, eventName) {
1787
2041
  return !!context.searchFound;
1788
2042
  },
1789
- search_quantity: function(context, eventName) {
2043
+ search_quantity: function search_quantity(context, eventName) {
1790
2044
  return context.searchQuantity || 0;
1791
2045
  },
1792
- promotion_name: function(context, eventName) {
2046
+ promotion_name: function promotion_name(context, eventName) {
1793
2047
  return context.promotionName || null;
1794
2048
  },
1795
- creative_name: function(context, eventName) {
2049
+ creative_name: function creative_name(context, eventName) {
1796
2050
  return context.creativeName || null;
1797
2051
  },
1798
- creative_slot: function(context, eventName) {
2052
+ creative_slot: function creative_slot(context, eventName) {
1799
2053
  return context.creativeSlot || null;
1800
2054
  },
1801
- zipcode: function(context, eventName) {
2055
+ zipcode: function zipcode(context, eventName) {
1802
2056
  return context.zipCode || null;
1803
2057
  },
1804
- size: function(context, eventName) {
2058
+ size: function size(context, eventName) {
1805
2059
  return context.size || null;
1806
2060
  },
1807
- item_ref: function(context, eventName) {
2061
+ item_ref: function item_ref(context, eventName) {
1808
2062
  return context.itemRef || null;
1809
2063
  },
1810
- flag_pickup: function(context, eventName) {
2064
+ flag_pickup: function flag_pickup(context, eventName) {
1811
2065
  var _orderForm_shippingData;
1812
2066
  var orderForm = context.orderForm;
1813
2067
  if (!orderForm) return null;
@@ -1820,7 +2074,7 @@ var AzzasTracker = function() {
1820
2074
  });
1821
2075
  return hasPickup;
1822
2076
  },
1823
- shippings: function(context, eventName) {
2077
+ shippings: function shippings(context, eventName) {
1824
2078
  var orderForm = context.orderForm;
1825
2079
  if (!orderForm) return null;
1826
2080
  var groupShipping = {};
@@ -1884,7 +2138,7 @@ var AzzasTracker = function() {
1884
2138
  });
1885
2139
  return shippings || null;
1886
2140
  },
1887
- shipping: function(context, eventName) {
2141
+ shipping: function shipping(context, eventName) {
1888
2142
  var _ref;
1889
2143
  var _context_orderForm_shippingData, _context_orderForm;
1890
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 : [];
@@ -1897,7 +2151,7 @@ var AzzasTracker = function() {
1897
2151
  return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
1898
2152
  }, 0);
1899
2153
  },
1900
- shipping_tier: function(context, eventName) {
2154
+ shipping_tier: function shipping_tier(context, eventName) {
1901
2155
  var _ref;
1902
2156
  var _context_orderForm_shippingData, _context_orderForm;
1903
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 : [];
@@ -1932,11 +2186,11 @@ var AzzasTracker = function() {
1932
2186
  }).filter(Boolean).join(", ");
1933
2187
  return shippingTier || null;
1934
2188
  },
1935
- transaction_id: function(context, eventName) {
2189
+ transaction_id: function transaction_id(context, eventName) {
1936
2190
  var _context_orderForm_orderGroup, _context_orderForm;
1937
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;
1938
2192
  },
1939
- available_grid: function(context, eventName) {
2193
+ available_grid: function available_grid(context, eventName) {
1940
2194
  return context.availableGrid || null;
1941
2195
  }
1942
2196
  };