@azzas/azzas-tracker-web 1.0.85 → 1.0.87

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.
@@ -537,11 +537,13 @@ var AzzasTracker = function() {
537
537
  return 0;
538
538
  };
539
539
  var getItemCategory = function getItemCategory(item) {
540
+ var keywords = [
541
+ "outlet",
542
+ "bazar",
543
+ "sale"
544
+ ];
545
+ var regex = new RegExp(keywords.join("|"), "i");
540
546
  var strategies = [
541
- function() {
542
- var _item_productCategories;
543
- return (item === null || item === void 0 ? void 0 : (_item_productCategories = item.productCategories) === null || _item_productCategories === void 0 ? void 0 : _item_productCategories["39"]) === "BAZAR" ? "Sale" : "Cole\xE7\xE3o";
544
- },
545
547
  function() {
546
548
  return item === null || item === void 0 ? void 0 : item.item_category;
547
549
  },
@@ -549,7 +551,11 @@ var AzzasTracker = function() {
549
551
  return item === null || item === void 0 ? void 0 : item.category;
550
552
  },
551
553
  function() {
552
- return item === null || item === void 0 ? void 0 : item.categories[0];
554
+ return item === null || item === void 0 ? void 0 : item.categories;
555
+ },
556
+ function() {
557
+ var _item_productCategories;
558
+ return item === null || item === void 0 ? void 0 : (_item_productCategories = item.productCategories) === null || _item_productCategories === void 0 ? void 0 : _item_productCategories["39"];
553
559
  },
554
560
  function() {
555
561
  var _item_itemOffered_breadcrumbList, _item_itemOffered;
@@ -568,9 +574,13 @@ var AzzasTracker = function() {
568
574
  try {
569
575
  for(var _iterator = strategies[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
570
576
  var getValue = _step.value;
571
- var value = getValue();
572
- if (value !== null && value !== void 0) {
573
- return value;
577
+ var rawValue = getValue();
578
+ if (rawValue) {
579
+ var textToTest = Array.isArray(rawValue) ? rawValue.join(" ") : String(rawValue);
580
+ var match = textToTest.match(regex);
581
+ if (match) {
582
+ return match[0].toLowerCase();
583
+ }
574
584
  }
575
585
  }
576
586
  } catch (err) {
@@ -587,7 +597,7 @@ var AzzasTracker = function() {
587
597
  }
588
598
  }
589
599
  }
590
- return null;
600
+ return "Cole\xE7\xE3o";
591
601
  };
592
602
  var getItemCategory2 = function getItemCategory2(item) {
593
603
  var strategies = [
@@ -1305,20 +1315,20 @@ var AzzasTracker = function() {
1305
1315
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1306
1316
  var __getOwnPropNames = Object.getOwnPropertyNames;
1307
1317
  var __hasOwnProp = Object.prototype.hasOwnProperty;
1308
- var __export = function __export(target, all) {
1318
+ var __export = function(target, all) {
1309
1319
  for(var name in all)__defProp(target, name, {
1310
1320
  get: all[name],
1311
1321
  enumerable: true
1312
1322
  });
1313
1323
  };
1314
- var __copyProps = function __copyProps(to, from, except, desc) {
1324
+ var __copyProps = function(to, from, except, desc) {
1315
1325
  if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
1316
1326
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1317
1327
  try {
1318
1328
  var _loop = function() {
1319
1329
  var key = _step.value;
1320
1330
  if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
1321
- get: function get() {
1331
+ get: function() {
1322
1332
  return from[key];
1323
1333
  },
1324
1334
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
@@ -1342,7 +1352,7 @@ var AzzasTracker = function() {
1342
1352
  }
1343
1353
  return to;
1344
1354
  };
1345
- var __toCommonJS = function __toCommonJS(mod) {
1355
+ var __toCommonJS = function(mod) {
1346
1356
  return __copyProps(__defProp({}, "__esModule", {
1347
1357
  value: true
1348
1358
  }), mod);
@@ -1350,13 +1360,13 @@ var AzzasTracker = function() {
1350
1360
  // src/index.ts
1351
1361
  var src_exports = {};
1352
1362
  __export(src_exports, {
1353
- EVENTS: function EVENTS1() {
1363
+ EVENTS: function() {
1354
1364
  return EVENTS;
1355
1365
  },
1356
- default: function _default() {
1366
+ default: function() {
1357
1367
  return src_default;
1358
1368
  },
1359
- trackWebEvent: function trackWebEvent1() {
1369
+ trackWebEvent: function() {
1360
1370
  return trackWebEvent;
1361
1371
  }
1362
1372
  });
@@ -1807,16 +1817,16 @@ var AzzasTracker = function() {
1807
1817
  "cart\xE3o"
1808
1818
  ]
1809
1819
  ];
1810
- var toNum = function toNum(val) {
1820
+ var toNum = function(val) {
1811
1821
  return typeof val === "string" ? Number(val.replace(/[^\d,]/g, "").replace(",", ".")) : val;
1812
1822
  };
1813
- var setLocalStorage = function setLocalStorage(key, value) {
1823
+ var setLocalStorage = function(key, value) {
1814
1824
  localStorage.setItem(key, value);
1815
1825
  };
1816
- var getLocalStorage = function getLocalStorage(key) {
1826
+ var getLocalStorage = function(key) {
1817
1827
  return localStorage.getItem(key);
1818
1828
  };
1819
- var documentToHash = function documentToHash(document2) {
1829
+ var documentToHash = function(document2) {
1820
1830
  return _async_to_generator(function() {
1821
1831
  var encoder, data, hashBuffer, hashArray;
1822
1832
  return _ts_generator(this, function(_state) {
@@ -1861,7 +1871,7 @@ var AzzasTracker = function() {
1861
1871
  brand: getBrand,
1862
1872
  items: getItems,
1863
1873
  payment_type: getPaymentType,
1864
- user_info: function user_info(context, eventName) {
1874
+ user_info: function(context, eventName) {
1865
1875
  return _async_to_generator(function() {
1866
1876
  var _PROD_DOMAINS_, PROD_DOMAINS, domain, api, response, res, cpfFromStorage, hashedDocument, _;
1867
1877
  return _ts_generator(this, function(_state) {
@@ -1992,13 +2002,13 @@ var AzzasTracker = function() {
1992
2002
  });
1993
2003
  })();
1994
2004
  },
1995
- content_type: function content_type(context, eventName) {
2005
+ content_type: function(context, eventName) {
1996
2006
  return "regiao".concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
1997
2007
  },
1998
- region: function region(context, eventName) {
2008
+ region: function(context, eventName) {
1999
2009
  return context.region || null;
2000
2010
  },
2001
- line_items: function line_items(context, eventName) {
2011
+ line_items: function(context, eventName) {
2002
2012
  if (context === null || context === void 0 ? void 0 : context.lineItems) return context.lineItems;
2003
2013
  if (context === null || context === void 0 ? void 0 : context.item) {
2004
2014
  return [
@@ -2014,7 +2024,7 @@ var AzzasTracker = function() {
2014
2024
  return item.productId;
2015
2025
  }).join(",");
2016
2026
  },
2017
- currency: function currency(context, eventName) {
2027
+ currency: function(context, eventName) {
2018
2028
  var _context_orderForm_storePreferencesData, _context_orderForm;
2019
2029
  if (context === null || context === void 0 ? void 0 : context.currency) return context.currency;
2020
2030
  if (context === null || context === void 0 ? void 0 : context.bannerUrl) return "BRL";
@@ -2024,12 +2034,12 @@ var AzzasTracker = function() {
2024
2034
  }
2025
2035
  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;
2026
2036
  },
2027
- value: function value(context, eventName) {
2037
+ value: function(context, eventName) {
2028
2038
  var _context_item, _context_orderForm;
2029
2039
  if (context === null || context === void 0 ? void 0 : context.value) return toNum(context.value);
2030
2040
  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;
2031
2041
  },
2032
- total_discount: function total_discount(context, eventName) {
2042
+ total_discount: function(context, eventName) {
2033
2043
  var _context_orderForm, _context_orderForm1;
2034
2044
  if (context === null || context === void 0 ? void 0 : context.totalDiscount) return context.totalDiscount;
2035
2045
  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) || [];
@@ -2043,7 +2053,7 @@ var AzzasTracker = function() {
2043
2053
  });
2044
2054
  return Math.abs(((discounts === null || discounts === void 0 ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
2045
2055
  },
2046
- subtotal: function subtotal(context, eventName) {
2056
+ subtotal: function(context, eventName) {
2047
2057
  var _context_orderForm, _context_orderForm1;
2048
2058
  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) || [];
2049
2059
  var subtotal = totalsList.filter(function(t) {
@@ -2053,7 +2063,7 @@ var AzzasTracker = function() {
2053
2063
  }, 0) / 100 || 0;
2054
2064
  return subtotal;
2055
2065
  },
2056
- coupon_message: function coupon_message(context, eventName) {
2066
+ coupon_message: function(context, eventName) {
2057
2067
  var _context_orderForm;
2058
2068
  if (context.couponMessage) return context.couponMessage;
2059
2069
  var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
@@ -2066,44 +2076,44 @@ var AzzasTracker = function() {
2066
2076
  return msg.text;
2067
2077
  }).join(" | ");
2068
2078
  },
2069
- seller_cod_name: function seller_cod_name(context, eventName) {
2079
+ seller_cod_name: function(context, eventName) {
2070
2080
  return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
2071
2081
  },
2072
- coupon: function coupon(context, eventName) {
2082
+ coupon: function(context, eventName) {
2073
2083
  var _context_orderForm_marketingData, _context_orderForm;
2074
2084
  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;
2075
2085
  },
2076
- pre_filled: function pre_filled(context, eventName) {
2086
+ pre_filled: function(context, eventName) {
2077
2087
  return !!context.preFilled;
2078
2088
  },
2079
- search_term: function search_term(context, eventName) {
2089
+ search_term: function(context, eventName) {
2080
2090
  return context.searchTerm || null;
2081
2091
  },
2082
- search_found: function search_found(context, eventName) {
2092
+ search_found: function(context, eventName) {
2083
2093
  return !!context.searchFound;
2084
2094
  },
2085
- search_quantity: function search_quantity(context, eventName) {
2095
+ search_quantity: function(context, eventName) {
2086
2096
  return context.searchQuantity || 0;
2087
2097
  },
2088
- promotion_name: function promotion_name(context, eventName) {
2098
+ promotion_name: function(context, eventName) {
2089
2099
  return context.promotionName || null;
2090
2100
  },
2091
- creative_name: function creative_name(context, eventName) {
2101
+ creative_name: function(context, eventName) {
2092
2102
  return context.creativeName || null;
2093
2103
  },
2094
- creative_slot: function creative_slot(context, eventName) {
2104
+ creative_slot: function(context, eventName) {
2095
2105
  return context.creativeSlot || null;
2096
2106
  },
2097
- zipcode: function zipcode(context, eventName) {
2107
+ zipcode: function(context, eventName) {
2098
2108
  return context.zipCode || null;
2099
2109
  },
2100
- size: function size(context, eventName) {
2110
+ size: function(context, eventName) {
2101
2111
  return context.size || null;
2102
2112
  },
2103
- item_ref: function item_ref(context, eventName) {
2113
+ item_ref: function(context, eventName) {
2104
2114
  return context.itemRef || null;
2105
2115
  },
2106
- flag_pickup: function flag_pickup(context, eventName) {
2116
+ flag_pickup: function(context, eventName) {
2107
2117
  var _orderForm_shippingData;
2108
2118
  var orderForm = context.orderForm;
2109
2119
  if (!orderForm) return null;
@@ -2116,7 +2126,7 @@ var AzzasTracker = function() {
2116
2126
  });
2117
2127
  return hasPickup;
2118
2128
  },
2119
- shippings: function shippings(context, eventName) {
2129
+ shippings: function(context, eventName) {
2120
2130
  var orderForm = context.orderForm;
2121
2131
  if (!orderForm) return null;
2122
2132
  var groupShipping = {};
@@ -2180,7 +2190,7 @@ var AzzasTracker = function() {
2180
2190
  });
2181
2191
  return shippings || null;
2182
2192
  },
2183
- shipping: function shipping(context, eventName) {
2193
+ shipping: function(context, eventName) {
2184
2194
  var _ref;
2185
2195
  var _context_orderForm_shippingData, _context_orderForm;
2186
2196
  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 : [];
@@ -2193,7 +2203,7 @@ var AzzasTracker = function() {
2193
2203
  return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
2194
2204
  }, 0);
2195
2205
  },
2196
- shipping_tier: function shipping_tier(context, eventName) {
2206
+ shipping_tier: function(context, eventName) {
2197
2207
  var _ref;
2198
2208
  var _context_orderForm_shippingData, _context_orderForm;
2199
2209
  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 : [];
@@ -2228,11 +2238,11 @@ var AzzasTracker = function() {
2228
2238
  }).filter(Boolean).join(", ");
2229
2239
  return shippingTier || null;
2230
2240
  },
2231
- transaction_id: function transaction_id(context, eventName) {
2241
+ transaction_id: function(context, eventName) {
2232
2242
  var _context_orderForm_orderGroup, _context_orderForm;
2233
2243
  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;
2234
2244
  },
2235
- available_grid: function available_grid(context, eventName) {
2245
+ available_grid: function(context, eventName) {
2236
2246
  return context.availableGrid || null;
2237
2247
  }
2238
2248
  };
package/package.json CHANGED
@@ -1,38 +1,38 @@
1
- {
2
- "name": "@azzas/azzas-tracker-web",
3
- "version": "1.0.85",
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
- }
1
+ {
2
+ "name": "@azzas/azzas-tracker-web",
3
+ "version": "1.0.87",
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
+ }