@azzas/azzas-tracker-web 1.0.60 → 1.0.62

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.
@@ -39,6 +39,19 @@ function _async_to_generator(fn) {
39
39
  });
40
40
  };
41
41
  }
42
+ function _define_property(obj, key, value) {
43
+ if (key in obj) {
44
+ Object.defineProperty(obj, key, {
45
+ value: value,
46
+ enumerable: true,
47
+ configurable: true,
48
+ writable: true
49
+ });
50
+ } else {
51
+ obj[key] = value;
52
+ }
53
+ return obj;
54
+ }
42
55
  function _iterable_to_array(iter) {
43
56
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
44
57
  }
@@ -72,6 +85,21 @@ function _non_iterable_rest() {
72
85
  function _non_iterable_spread() {
73
86
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
74
87
  }
88
+ function _object_spread(target) {
89
+ for(var i = 1; i < arguments.length; i++){
90
+ var source = arguments[i] != null ? arguments[i] : {};
91
+ var ownKeys = Object.keys(source);
92
+ if (typeof Object.getOwnPropertySymbols === "function") {
93
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
94
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
95
+ }));
96
+ }
97
+ ownKeys.forEach(function(key) {
98
+ _define_property(target, key, source[key]);
99
+ });
100
+ }
101
+ return target;
102
+ }
75
103
  function _sliced_to_array(arr, i) {
76
104
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
77
105
  }
@@ -191,40 +219,38 @@ function _ts_generator(thisArg, body) {
191
219
  }
192
220
  var AzzasTracker = function() {
193
221
  var pushToDataLayer = // src/adapters/datalayer.ts
194
- function pushToDataLayer(event, ecomm, dest) {
195
- var targetWindow = ecomm.window;
196
- var ecommercePayload = Object.assign({}, ecomm);
197
- delete ecommercePayload.window;
198
- if (targetWindow) {
199
- targetWindow.dataLayer = targetWindow.dataLayer || [];
222
+ function pushToDataLayer(event, context) {
223
+ var targetWindow = context.window || (typeof window !== "undefined" ? window : null);
224
+ if (!targetWindow) return;
225
+ var payload = Object.assign({}, context);
226
+ delete payload.window;
227
+ var eventName = event.toUpperCase();
228
+ var eventConfig = EVENTS[eventName];
229
+ targetWindow.dataLayer = targetWindow.dataLayer || [];
230
+ if (eventConfig === null || eventConfig === void 0 ? void 0 : eventConfig.hasEcommerce) {
200
231
  targetWindow.dataLayer.push({
201
232
  ecommerce: null
202
233
  });
203
234
  targetWindow.dataLayer.push({
204
235
  event: event,
205
- ecommerce: ecommercePayload
236
+ ecommerce: payload
206
237
  });
207
- return;
238
+ } else {
239
+ targetWindow.dataLayer.push(_object_spread({
240
+ event: event
241
+ }, payload));
208
242
  }
209
- window.dataLayer = window.dataLayer || [];
210
- window.dataLayer.push({
211
- ecommerce: null
212
- });
213
- window.dataLayer.push({
214
- event: event,
215
- ecommerce: ecommercePayload
216
- });
217
243
  };
218
244
  var dataTrackingLog = // src/core/utils.ts
219
- function dataTrackingLog(data, color, destination) {
220
- console.log("%c[DT - ".concat(destination, "] EVENTO DISPARADO:%c "), "background: ".concat(color, "; color: white; font-weight: bold; padding: 2px 4px; border-radius: 3px;"), "color: #fff;", data || "");
245
+ function dataTrackingLog(data, color) {
246
+ console.log("%c[DT] EVENTO DISPARADO:%c ", "background: ".concat(color, "; color: white; font-weight: bold; padding: 2px 4px; border-radius: 3px;"), "color: #fff;", data || "");
221
247
  };
222
248
  var pushToDito = // src/adapters/dito.ts
223
- function pushToDito(event, ecomm, dest) {
249
+ function pushToDito(event, ecomm) {
224
250
  dataTrackingLog({
225
251
  id: event,
226
252
  custom_data: ecomm
227
- }, "#00c851", dest);
253
+ }, "#00c851");
228
254
  };
229
255
  var dispatchTrackEvent = function dispatchTrackEvent(eventName, data) {
230
256
  return _async_to_generator(function() {
@@ -252,7 +278,7 @@ var AzzasTracker = function() {
252
278
  ]);
253
279
  return [
254
280
  4,
255
- adapters[dest](eventName.toLowerCase(), data, dest)
281
+ adapters[dest](eventName.toLowerCase(), data)
256
282
  ];
257
283
  case 1:
258
284
  _state.sent();
@@ -445,11 +471,13 @@ var AzzasTracker = function() {
445
471
  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";
446
472
  },
447
473
  function() {
448
- return item.item_category || item.category;
474
+ return item === null || item === void 0 ? void 0 : item.item_category;
475
+ },
476
+ function() {
477
+ return item === null || item === void 0 ? void 0 : item.category;
449
478
  },
450
- // deco select_item context
451
479
  function() {
452
- return item.categories[0];
480
+ return item === null || item === void 0 ? void 0 : item.categories[0];
453
481
  }
454
482
  ];
455
483
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -651,20 +679,20 @@ var AzzasTracker = function() {
651
679
  var itemsFromItem = // src/params/resolvers/items/fromItem.ts
652
680
  function itemsFromItem(context, event) {
653
681
  return _async_to_generator(function() {
654
- var _item_additionalProperty, _item_additionalInfo, _item_brand, _item_itemAttributes, _split_pop, _this, item, orderForm, _tmp, _tmp1;
682
+ var _item_additionalProperty, _item_additionalInfo, _item_brand, _item_itemAttributes, _split_pop, _this, item, orderForm, itemListName, _tmp, _tmp1;
655
683
  return _ts_generator(this, function(_state) {
656
684
  switch(_state.label){
657
685
  case 0:
658
- item = context.item, orderForm = context.orderForm;
686
+ item = context.item, orderForm = context.orderForm, itemListName = context.itemListName;
659
687
  _tmp = {
660
- index: 0,
688
+ index: typeof (item === null || item === void 0 ? void 0 : item.index) === "number" ? item.index : null,
661
689
  quantity: 1,
662
690
  item_id: (item === null || item === void 0 ? void 0 : item.productId) || (item === null || item === void 0 ? void 0 : item.item_group_id) || (item === null || item === void 0 ? void 0 : item.sku) || null,
663
691
  item_category2: getItemCategory2(item),
664
692
  item_category4: getItemCategory4(item),
665
693
  item_shipping_tier: event === "REMOVE_FROM_CART" ? getItemShippingTier(orderForm, item) : null,
666
694
  price: (item === null || item === void 0 ? void 0 : item.listPrice) || (item === null || item === void 0 ? void 0 : item.price) || 0,
667
- item_ref: (item === null || item === void 0 ? void 0 : item.refId) || (item === null || item === void 0 ? void 0 : item.item_ref) || (item === null || item === void 0 ? void 0 : (_item_additionalProperty = item.additionalProperty) === null || _item_additionalProperty === void 0 ? void 0 : _item_additionalProperty.find(function(i) {
695
+ item_ref: (item === null || item === void 0 ? void 0 : item.ref) || (item === null || item === void 0 ? void 0 : item.refId) || (item === null || item === void 0 ? void 0 : item.item_ref) || (item === null || item === void 0 ? void 0 : (_item_additionalProperty = item.additionalProperty) === null || _item_additionalProperty === void 0 ? void 0 : _item_additionalProperty.find(function(i) {
668
696
  return i.name === "RefId";
669
697
  }).value) || null,
670
698
  item_brand: (item === null || item === void 0 ? void 0 : (_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) || (item === null || item === void 0 ? void 0 : item.item_brand) || (item === null || item === void 0 ? void 0 : (_item_brand = item.brand) === null || _item_brand === void 0 ? void 0 : _item_brand.name) || null
@@ -685,7 +713,7 @@ var AzzasTracker = function() {
685
713
  return [
686
714
  2,
687
715
  [
688
- (_tmp.item_sku = _tmp1 || null, _tmp.item_name = (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.item_name) || 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)).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)) === 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 = getItemCategory(item) || null, _tmp.item_url = (item === null || item === void 0 ? void 0 : item.item_url) || null, _tmp)
716
+ (_tmp.item_sku = _tmp1 || null, _tmp.item_name = (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.item_name) || 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)).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)) === 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)
689
717
  ]
690
718
  ];
691
719
  }
@@ -1046,6 +1074,7 @@ var AzzasTracker = function() {
1046
1074
  var EVENTS = {
1047
1075
  CUSTOM_VIEW_CART: {
1048
1076
  name: "custom_view_cart",
1077
+ hasEcommerce: true,
1049
1078
  destinations: [
1050
1079
  "DataLayer"
1051
1080
  ],
@@ -1062,6 +1091,7 @@ var AzzasTracker = function() {
1062
1091
  },
1063
1092
  ADD_TO_WISHLIST: {
1064
1093
  name: "add_to_wishlist",
1094
+ hasEcommerce: true,
1065
1095
  destinations: [
1066
1096
  "DataLayer"
1067
1097
  ],
@@ -1076,6 +1106,7 @@ var AzzasTracker = function() {
1076
1106
  },
1077
1107
  ADD_TO_CART: {
1078
1108
  name: "add_to_cart",
1109
+ hasEcommerce: true,
1079
1110
  destinations: [
1080
1111
  "DataLayer"
1081
1112
  ],
@@ -1090,6 +1121,7 @@ var AzzasTracker = function() {
1090
1121
  },
1091
1122
  REMOVE_FROM_CART: {
1092
1123
  name: "remove_from_cart",
1124
+ hasEcommerce: true,
1093
1125
  destinations: [
1094
1126
  "DataLayer"
1095
1127
  ],
@@ -1104,6 +1136,7 @@ var AzzasTracker = function() {
1104
1136
  },
1105
1137
  ADD_COUPON: {
1106
1138
  name: "add_coupon",
1139
+ hasEcommerce: true,
1107
1140
  destinations: [
1108
1141
  "DataLayer"
1109
1142
  ],
@@ -1117,6 +1150,7 @@ var AzzasTracker = function() {
1117
1150
  },
1118
1151
  SEARCH: {
1119
1152
  name: "search",
1153
+ hasEcommerce: false,
1120
1154
  destinations: [
1121
1155
  "DataLayer"
1122
1156
  ],
@@ -1129,6 +1163,7 @@ var AzzasTracker = function() {
1129
1163
  },
1130
1164
  SEARCH_ZIPCODE: {
1131
1165
  name: "search_zipcode",
1166
+ hasEcommerce: false,
1132
1167
  destinations: [
1133
1168
  "DataLayer"
1134
1169
  ],
@@ -1157,6 +1192,7 @@ var AzzasTracker = function() {
1157
1192
  },
1158
1193
  SELECT_PROMOTION: {
1159
1194
  name: "select_promotion",
1195
+ hasEcommerce: true,
1160
1196
  destinations: [
1161
1197
  "DataLayer"
1162
1198
  ],
@@ -1172,6 +1208,7 @@ var AzzasTracker = function() {
1172
1208
  },
1173
1209
  SELECT_CONTENT: {
1174
1210
  name: "select_content",
1211
+ hasEcommerce: false,
1175
1212
  destinations: [
1176
1213
  "DataLayer"
1177
1214
  ],
@@ -1182,6 +1219,7 @@ var AzzasTracker = function() {
1182
1219
  },
1183
1220
  SELECT_ITEM: {
1184
1221
  name: "select_item",
1222
+ hasEcommerce: true,
1185
1223
  destinations: [
1186
1224
  "DataLayer"
1187
1225
  ],
@@ -1194,6 +1232,7 @@ var AzzasTracker = function() {
1194
1232
  },
1195
1233
  VIEW_ITEM: {
1196
1234
  name: "view_item",
1235
+ hasEcommerce: true,
1197
1236
  destinations: [
1198
1237
  "DataLayer"
1199
1238
  ],
@@ -1209,6 +1248,7 @@ var AzzasTracker = function() {
1209
1248
  CUSTOM_VIEW_ITEM: {
1210
1249
  // IO STORES
1211
1250
  name: "custom_view_item",
1251
+ hasEcommerce: true,
1212
1252
  destinations: [
1213
1253
  "DataLayer"
1214
1254
  ],
@@ -1223,6 +1263,7 @@ var AzzasTracker = function() {
1223
1263
  },
1224
1264
  VIEW_ITEM_LIST: {
1225
1265
  name: "view_item_list",
1266
+ hasEcommerce: true,
1226
1267
  destinations: [
1227
1268
  "DataLayer"
1228
1269
  ],
@@ -1235,6 +1276,7 @@ var AzzasTracker = function() {
1235
1276
  },
1236
1277
  BEGIN_CHECKOUT: {
1237
1278
  name: "begin_checkout",
1279
+ hasEcommerce: true,
1238
1280
  destinations: [
1239
1281
  "DataLayer"
1240
1282
  ],
@@ -1250,6 +1292,7 @@ var AzzasTracker = function() {
1250
1292
  },
1251
1293
  CUSTOM_BEGIN_CHECKOUT: {
1252
1294
  name: "custom_begin_checkout",
1295
+ hasEcommerce: true,
1253
1296
  destinations: [
1254
1297
  "DataLayer"
1255
1298
  ],
@@ -1265,12 +1308,14 @@ var AzzasTracker = function() {
1265
1308
  },
1266
1309
  AUTH_ACTION: {
1267
1310
  name: "auth_action",
1311
+ hasEcommerce: false,
1268
1312
  requiredParams: [
1269
1313
  "region"
1270
1314
  ]
1271
1315
  },
1272
1316
  ADD_PERSONAL_INFO: {
1273
1317
  name: "add_personal_info",
1318
+ hasEcommerce: true,
1274
1319
  destinations: [
1275
1320
  "DataLayer"
1276
1321
  ],
@@ -1286,6 +1331,7 @@ var AzzasTracker = function() {
1286
1331
  },
1287
1332
  CUSTOM_ADD_SHIPPING_INFO: {
1288
1333
  name: "add_shipping_info",
1334
+ hasEcommerce: true,
1289
1335
  destinations: [
1290
1336
  "DataLayer"
1291
1337
  ],
@@ -1304,6 +1350,7 @@ var AzzasTracker = function() {
1304
1350
  },
1305
1351
  CUSTOM_ADD_PAYMENT_INFO: {
1306
1352
  name: "add_payment_info",
1353
+ hasEcommerce: true,
1307
1354
  destinations: [
1308
1355
  "DataLayer"
1309
1356
  ],
@@ -1321,6 +1368,7 @@ var AzzasTracker = function() {
1321
1368
  },
1322
1369
  ORDER_REVIEWED: {
1323
1370
  name: "order_reviewed",
1371
+ hasEcommerce: true,
1324
1372
  destinations: [
1325
1373
  "DataLayer"
1326
1374
  ],
@@ -1336,6 +1384,7 @@ var AzzasTracker = function() {
1336
1384
  },
1337
1385
  PURCHASE: {
1338
1386
  name: "purchase",
1387
+ hasEcommerce: true,
1339
1388
  destinations: [
1340
1389
  "DataLayer"
1341
1390
  ],
@@ -1357,6 +1406,7 @@ var AzzasTracker = function() {
1357
1406
  },
1358
1407
  CUSTOM_PURCHASE: {
1359
1408
  name: "custom_purchase",
1409
+ hasEcommerce: true,
1360
1410
  destinations: [
1361
1411
  "DataLayer"
1362
1412
  ],
@@ -1378,6 +1428,7 @@ var AzzasTracker = function() {
1378
1428
  },
1379
1429
  CUSTOM_USER_INFO: {
1380
1430
  name: "custom_user_info",
1431
+ hasEcommerce: false,
1381
1432
  destinations: [
1382
1433
  "DataLayer"
1383
1434
  ],
@@ -1387,6 +1438,7 @@ var AzzasTracker = function() {
1387
1438
  },
1388
1439
  NOTIFY_ME: {
1389
1440
  name: "notify_me",
1441
+ hasEcommerce: false,
1390
1442
  destinations: [
1391
1443
  "DataLayer"
1392
1444
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azzas/azzas-tracker-web",
3
- "version": "1.0.60",
3
+ "version": "1.0.62",
4
4
  "type": "module",
5
5
  "main": "./dist/mod.cjs",
6
6
  "module": "./dist/mod.js",