@azzas/azzas-tracker-web 1.0.95 → 1.0.96

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.
@@ -1198,82 +1198,52 @@ var AzzasTracker = function() {
1198
1198
  return null;
1199
1199
  }
1200
1200
  };
1201
- var getManuallyInfo = function getManuallyInfo(info) {
1201
+ var getUserInfo = // src/params/userInfo.ts
1202
+ function getUserInfo(context, eventName) {
1202
1203
  return _async_to_generator(function() {
1203
- var cpf, birthDate, phone, firstName, lastName, email, email_optin, document2, hashedDocument, formattedBirthDate, _birthDate_split, day, month, year;
1204
+ var _PROD_DOMAINS_, PROD_DOMAINS, domain, _res_customer_document, _res_customer, api, response, _context_manuallyInfo, _context_manuallyInfo1, cpf, birthDate, phone, firstName, lastName, email, email_optin, document3, hashedDocument2, res, document2, hashedDocument, _, _context_manuallyInfo2, _context_manuallyInfo3, cpf1, birthDate1, phone1, firstName1, lastName1, email1, email_optin1, document21, hashedDocument1;
1204
1205
  return _ts_generator(this, function(_state) {
1205
1206
  switch(_state.label){
1206
1207
  case 0:
1207
- if (!(info === null || info === void 0 ? void 0 : info.cpf)) return [
1208
- 2,
1209
- null
1210
- ];
1211
- cpf = info.cpf, birthDate = info.birthDate, phone = info.phone, firstName = info.firstName, lastName = info.lastName, email = info.email, email_optin = info.email_optin;
1212
- document2 = cpf === null || cpf === void 0 ? void 0 : cpf.replace(/\D/g, "");
1213
- return [
1214
- 4,
1215
- documentToHash(document2)
1216
- ];
1217
- case 1:
1218
- hashedDocument = _state.sent();
1219
- formattedBirthDate = null;
1220
- if (birthDate) {
1221
- _birthDate_split = _sliced_to_array(birthDate.split("/"), 3), day = _birthDate_split[0], month = _birthDate_split[1], year = _birthDate_split[2];
1222
- if (day && month && year && !isNaN(Number(year))) {
1223
- formattedBirthDate = "".concat(year, "-").concat(month, "-").concat(day, "T00:00:00Z");
1224
- } else {
1225
- console.warn("[DT - user_info] Invalid birthDate format from manuallyInfo:", birthDate);
1208
+ PROD_DOMAINS = {
1209
+ "animale": {
1210
+ "store": "https://www.animale.com.br",
1211
+ "checkout": "https://secure.animale.com.br"
1212
+ },
1213
+ "farm": {
1214
+ "store": "https://lojafarm.myvtex.com"
1215
+ },
1216
+ "mariafilo": {
1217
+ "store": "https://mariafilo.myvtex.com",
1218
+ "checkout": "https://secure.mariafilo.com.br"
1219
+ },
1220
+ "lojacrisbarros": {
1221
+ "store": "https://lojacrisbarros.myvtex.com",
1222
+ "checkout": "https://secure.crisbarros.com.br"
1223
+ },
1224
+ "lojaoffpremium": {
1225
+ "store": "https://lojaoffpremium.myvtex.com",
1226
+ "checkout": "https://secure.lojaoffpremium.com.br"
1226
1227
  }
1227
- }
1228
- return [
1228
+ };
1229
+ domain = (_PROD_DOMAINS_ = PROD_DOMAINS[context.account || "https://www.animale.com.br"]) === null || _PROD_DOMAINS_ === void 0 ? void 0 : _PROD_DOMAINS_[context.platform || "store"];
1230
+ if (!domain) return [
1229
1231
  2,
1230
1232
  {
1231
- address: null,
1232
- customer: _object_spread({
1233
- email: email,
1234
- phone: phone,
1235
- document: document2,
1236
- lastName: lastName,
1237
- birthDate: formattedBirthDate,
1238
- firstName: firstName,
1239
- homePhone: phone,
1240
- cpf: hashedDocument
1241
- }, email_optin && {
1242
- email_optin: email_optin
1243
- })
1233
+ customer: {
1234
+ email: context.userEmail,
1235
+ id: context === null || context === void 0 ? void 0 : context.userId
1236
+ },
1237
+ address: null
1244
1238
  }
1245
1239
  ];
1246
- }
1247
- });
1248
- })();
1249
- };
1250
- var getFallbackUserInfo = function getFallbackUserInfo(userEmail, userId) {
1251
- return {
1252
- customer: {
1253
- email: userEmail,
1254
- id: userId
1255
- },
1256
- address: null
1257
- };
1258
- };
1259
- var getUserInfo = function getUserInfo(context, eventName) {
1260
- return _async_to_generator(function() {
1261
- var _PROD_DOMAINS_, domain, api, response, _res_customer_document, _res_customer, res, document2, hashedDocument, manuallyInfoResult, _, manuallyInfoResult1;
1262
- return _ts_generator(this, function(_state) {
1263
- switch(_state.label){
1264
- case 0:
1265
- domain = (_PROD_DOMAINS_ = PROD_DOMAINS[(context === null || context === void 0 ? void 0 : context.account) || "https://www.animale.com.br"]) === null || _PROD_DOMAINS_ === void 0 ? void 0 : _PROD_DOMAINS_[(context === null || context === void 0 ? void 0 : context.platform) || "store"];
1266
- if (!domain) return [
1267
- 2,
1268
- getFallbackUserInfo(context.userEmail, context === null || context === void 0 ? void 0 : context.userId)
1269
- ];
1270
1240
  _state.label = 1;
1271
1241
  case 1:
1272
1242
  _state.trys.push([
1273
1243
  1,
1274
- 7,
1244
+ 8,
1275
1245
  ,
1276
- 9
1246
+ 11
1277
1247
  ]);
1278
1248
  api = "".concat(domain, "/_v/user-info");
1279
1249
  return [
@@ -1287,22 +1257,63 @@ var AzzasTracker = function() {
1287
1257
  ];
1288
1258
  case 2:
1289
1259
  response = _state.sent();
1290
- if (!(response.status === 200)) return [
1260
+ if (!(response.status !== 200)) return [
1291
1261
  3,
1292
1262
  5
1293
1263
  ];
1264
+ if (!((context === null || context === void 0 ? void 0 : context.manuallyInfo) && ((_context_manuallyInfo = context.manuallyInfo) === null || _context_manuallyInfo === void 0 ? void 0 : _context_manuallyInfo.cpf))) return [
1265
+ 3,
1266
+ 4
1267
+ ];
1268
+ _context_manuallyInfo1 = context.manuallyInfo, cpf = _context_manuallyInfo1.cpf, birthDate = _context_manuallyInfo1.birthDate, phone = _context_manuallyInfo1.phone, firstName = _context_manuallyInfo1.firstName, lastName = _context_manuallyInfo1.lastName, email = _context_manuallyInfo1.email, email_optin = _context_manuallyInfo1.email_optin;
1269
+ document3 = cpf === null || cpf === void 0 ? void 0 : cpf.replace(/\D/g, "");
1294
1270
  return [
1295
1271
  4,
1296
- response.json()
1272
+ documentToHash(document3)
1297
1273
  ];
1298
1274
  case 3:
1275
+ hashedDocument2 = _state.sent();
1276
+ return [
1277
+ 2,
1278
+ {
1279
+ address: null,
1280
+ customer: {
1281
+ email: email,
1282
+ phone: phone,
1283
+ document: document3,
1284
+ lastName: lastName,
1285
+ birthDate: birthDate,
1286
+ firstName: firstName,
1287
+ email_optin: email_optin,
1288
+ homePhone: phone,
1289
+ cpf: hashedDocument2
1290
+ }
1291
+ }
1292
+ ];
1293
+ case 4:
1294
+ return [
1295
+ 2,
1296
+ {
1297
+ customer: {
1298
+ email: context.userEmail,
1299
+ id: context === null || context === void 0 ? void 0 : context.userId
1300
+ },
1301
+ address: null
1302
+ }
1303
+ ];
1304
+ case 5:
1305
+ return [
1306
+ 4,
1307
+ response.json()
1308
+ ];
1309
+ case 6:
1299
1310
  res = _state.sent();
1300
1311
  document2 = res === null || res === void 0 ? void 0 : (_res_customer = res.customer) === null || _res_customer === void 0 ? void 0 : (_res_customer_document = _res_customer.document) === null || _res_customer_document === void 0 ? void 0 : _res_customer_document.replace(/\D/g, "");
1301
1312
  return [
1302
1313
  4,
1303
1314
  documentToHash(document2)
1304
1315
  ];
1305
- case 4:
1316
+ case 7:
1306
1317
  hashedDocument = _state.sent();
1307
1318
  return [
1308
1319
  2,
@@ -1313,42 +1324,49 @@ var AzzasTracker = function() {
1313
1324
  })
1314
1325
  })
1315
1326
  ];
1316
- case 5:
1327
+ case 8:
1328
+ _ = _state.sent();
1329
+ if (!((context === null || context === void 0 ? void 0 : context.manuallyInfo) && ((_context_manuallyInfo2 = context.manuallyInfo) === null || _context_manuallyInfo2 === void 0 ? void 0 : _context_manuallyInfo2.cpf))) return [
1330
+ 3,
1331
+ 10
1332
+ ];
1333
+ _context_manuallyInfo3 = context.manuallyInfo, cpf1 = _context_manuallyInfo3.cpf, birthDate1 = _context_manuallyInfo3.birthDate, phone1 = _context_manuallyInfo3.phone, firstName1 = _context_manuallyInfo3.firstName, lastName1 = _context_manuallyInfo3.lastName, email1 = _context_manuallyInfo3.email, email_optin1 = _context_manuallyInfo3.email_optin;
1334
+ document21 = cpf1 === null || cpf1 === void 0 ? void 0 : cpf1.replace(/\D/g, "");
1317
1335
  return [
1318
1336
  4,
1319
- getManuallyInfo(context === null || context === void 0 ? void 0 : context.manuallyInfo)
1337
+ documentToHash(document21)
1320
1338
  ];
1321
- case 6:
1322
- manuallyInfoResult = _state.sent();
1323
- if (manuallyInfoResult) {
1324
- return [
1325
- 2,
1326
- manuallyInfoResult
1327
- ];
1328
- }
1339
+ case 9:
1340
+ hashedDocument1 = _state.sent();
1329
1341
  return [
1330
1342
  2,
1331
- getFallbackUserInfo(context.userEmail, context === null || context === void 0 ? void 0 : context.userId)
1332
- ];
1333
- case 7:
1334
- _ = _state.sent();
1335
- return [
1336
- 4,
1337
- getManuallyInfo(context === null || context === void 0 ? void 0 : context.manuallyInfo)
1343
+ {
1344
+ address: null,
1345
+ customer: {
1346
+ email: email1,
1347
+ phone: phone1,
1348
+ document: document21,
1349
+ lastName: lastName1,
1350
+ birthDate: birthDate1,
1351
+ firstName: firstName1,
1352
+ email_optin: email_optin1,
1353
+ homePhone: phone1,
1354
+ cpf: hashedDocument1
1355
+ }
1356
+ }
1338
1357
  ];
1339
- case 8:
1340
- manuallyInfoResult1 = _state.sent();
1341
- if (manuallyInfoResult1) {
1342
- return [
1343
- 2,
1344
- manuallyInfoResult1
1345
- ];
1346
- }
1358
+ case 10:
1347
1359
  return [
1348
1360
  2,
1349
- getFallbackUserInfo(context.userEmail, context === null || context === void 0 ? void 0 : context.userId)
1361
+ {
1362
+ customer: {
1363
+ email: context.userEmail,
1364
+ id: context === null || context === void 0 ? void 0 : context.userId
1365
+ },
1366
+ address: null
1367
+ }
1350
1368
  ];
1351
- case 9:
1369
+ case 11:
1352
1370
  return [
1353
1371
  2
1354
1372
  ];
@@ -1769,6 +1787,9 @@ var AzzasTracker = function() {
1769
1787
  hasEcommerce: false,
1770
1788
  requiredParams: [
1771
1789
  "region"
1790
+ ],
1791
+ destinations: [
1792
+ "DataLayer"
1772
1793
  ]
1773
1794
  },
1774
1795
  ADD_PERSONAL_INFO: {
@@ -2021,28 +2042,6 @@ var AzzasTracker = function() {
2021
2042
  var STORAGE_VIEWED = "last_viewed_item";
2022
2043
  var CART_LIST_HISTORY_KEY = "cart_list_history";
2023
2044
  var DAY_IN_MS = 24 * 60 * 60 * 1e3;
2024
- // src/params/userInfo.ts
2025
- var PROD_DOMAINS = {
2026
- "animale": {
2027
- "store": "https://www.animale.com.br",
2028
- "checkout": "https://secure.animale.com.br"
2029
- },
2030
- "farm": {
2031
- "store": "https://lojafarm.myvtex.com"
2032
- },
2033
- "mariafilo": {
2034
- "store": "https://mariafilo.myvtex.com",
2035
- "checkout": "https://secure.mariafilo.com.br"
2036
- },
2037
- "lojacrisbarros": {
2038
- "store": "https://lojacrisbarros.myvtex.com",
2039
- "checkout": "https://secure.crisbarros.com.br"
2040
- },
2041
- "lojaoffpremium": {
2042
- "store": "https://lojaoffpremium.myvtex.com",
2043
- "checkout": "https://secure.lojaoffpremium.com.br"
2044
- }
2045
- };
2046
2045
  // src/params/index.ts
2047
2046
  var paramGetters = {
2048
2047
  brand: getBrand,
@@ -2050,6 +2049,7 @@ var AzzasTracker = function() {
2050
2049
  payment_type: getPaymentType,
2051
2050
  user_info: getUserInfo,
2052
2051
  content_type: function(context, eventName) {
2052
+ if (context === null || context === void 0 ? void 0 : context.content_type) return context.content_type;
2053
2053
  return "regiao".concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
2054
2054
  },
2055
2055
  region: function(context, eventName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azzas/azzas-tracker-web",
3
- "version": "1.0.95",
3
+ "version": "1.0.96",
4
4
  "type": "module",
5
5
  "main": "./dist/mod.cjs",
6
6
  "module": "./dist/mod.js",