@azzas/azzas-tracker-web 1.0.93 → 1.0.95

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,52 +1198,82 @@ var AzzasTracker = function() {
1198
1198
  return null;
1199
1199
  }
1200
1200
  };
1201
- var getUserInfo = // src/params/userInfo.ts
1202
- function getUserInfo(context, eventName) {
1201
+ var getManuallyInfo = function getManuallyInfo(info) {
1203
1202
  return _async_to_generator(function() {
1204
- var _PROD_DOMAINS_, PROD_DOMAINS, domain, _res_customer_document, _res_customer, api, response, _context_manuallyInfo, _context_manuallyInfo1, cpf, birthDate, phone, firstName, lastName, email, document3, hashedDocument2, res, document2, hashedDocument, _, _context_manuallyInfo2, _context_manuallyInfo3, cpf1, birthDate1, phone1, firstName1, lastName1, email1, document21, hashedDocument1;
1203
+ var cpf, birthDate, phone, firstName, lastName, email, email_optin, document2, hashedDocument, formattedBirthDate, _birthDate_split, day, month, year;
1205
1204
  return _ts_generator(this, function(_state) {
1206
1205
  switch(_state.label){
1207
1206
  case 0:
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"
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);
1227
1226
  }
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 [
1227
+ }
1228
+ return [
1231
1229
  2,
1232
1230
  {
1233
- customer: {
1234
- email: context.userEmail,
1235
- id: context === null || context === void 0 ? void 0 : context.userId
1236
- },
1237
- address: null
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
+ })
1238
1244
  }
1239
1245
  ];
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
+ ];
1240
1270
  _state.label = 1;
1241
1271
  case 1:
1242
1272
  _state.trys.push([
1243
1273
  1,
1244
- 8,
1274
+ 7,
1245
1275
  ,
1246
- 11
1276
+ 9
1247
1277
  ]);
1248
1278
  api = "".concat(domain, "/_v/user-info");
1249
1279
  return [
@@ -1257,62 +1287,22 @@ var AzzasTracker = function() {
1257
1287
  ];
1258
1288
  case 2:
1259
1289
  response = _state.sent();
1260
- if (!(response.status !== 200)) return [
1290
+ if (!(response.status === 200)) return [
1261
1291
  3,
1262
1292
  5
1263
1293
  ];
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;
1269
- document3 = cpf === null || cpf === void 0 ? void 0 : cpf.replace(/\D/g, "");
1270
- return [
1271
- 4,
1272
- documentToHash(document3)
1273
- ];
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
- homePhone: phone,
1288
- cpf: hashedDocument2
1289
- }
1290
- }
1291
- ];
1292
- case 4:
1293
- return [
1294
- 2,
1295
- {
1296
- customer: {
1297
- email: context.userEmail,
1298
- id: context === null || context === void 0 ? void 0 : context.userId
1299
- },
1300
- address: null
1301
- }
1302
- ];
1303
- case 5:
1304
1294
  return [
1305
1295
  4,
1306
1296
  response.json()
1307
1297
  ];
1308
- case 6:
1298
+ case 3:
1309
1299
  res = _state.sent();
1310
1300
  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, "");
1311
1301
  return [
1312
1302
  4,
1313
1303
  documentToHash(document2)
1314
1304
  ];
1315
- case 7:
1305
+ case 4:
1316
1306
  hashedDocument = _state.sent();
1317
1307
  return [
1318
1308
  2,
@@ -1323,48 +1313,42 @@ var AzzasTracker = function() {
1323
1313
  })
1324
1314
  })
1325
1315
  ];
1326
- case 8:
1327
- _ = _state.sent();
1328
- 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 [
1329
- 3,
1330
- 10
1331
- ];
1332
- _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;
1333
- document21 = cpf1 === null || cpf1 === void 0 ? void 0 : cpf1.replace(/\D/g, "");
1316
+ case 5:
1334
1317
  return [
1335
1318
  4,
1336
- documentToHash(document21)
1319
+ getManuallyInfo(context === null || context === void 0 ? void 0 : context.manuallyInfo)
1337
1320
  ];
1338
- case 9:
1339
- hashedDocument1 = _state.sent();
1321
+ case 6:
1322
+ manuallyInfoResult = _state.sent();
1323
+ if (manuallyInfoResult) {
1324
+ return [
1325
+ 2,
1326
+ manuallyInfoResult
1327
+ ];
1328
+ }
1340
1329
  return [
1341
1330
  2,
1342
- {
1343
- address: null,
1344
- customer: {
1345
- email: email1,
1346
- phone: phone1,
1347
- document: document21,
1348
- lastName: lastName1,
1349
- birthDate: birthDate1,
1350
- firstName: firstName1,
1351
- homePhone: phone1,
1352
- cpf: hashedDocument1
1353
- }
1354
- }
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)
1355
1338
  ];
1356
- case 10:
1339
+ case 8:
1340
+ manuallyInfoResult1 = _state.sent();
1341
+ if (manuallyInfoResult1) {
1342
+ return [
1343
+ 2,
1344
+ manuallyInfoResult1
1345
+ ];
1346
+ }
1357
1347
  return [
1358
1348
  2,
1359
- {
1360
- customer: {
1361
- email: context.userEmail,
1362
- id: context === null || context === void 0 ? void 0 : context.userId
1363
- },
1364
- address: null
1365
- }
1349
+ getFallbackUserInfo(context.userEmail, context === null || context === void 0 ? void 0 : context.userId)
1366
1350
  ];
1367
- case 11:
1351
+ case 9:
1368
1352
  return [
1369
1353
  2
1370
1354
  ];
@@ -2037,6 +2021,28 @@ var AzzasTracker = function() {
2037
2021
  var STORAGE_VIEWED = "last_viewed_item";
2038
2022
  var CART_LIST_HISTORY_KEY = "cart_list_history";
2039
2023
  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
+ };
2040
2046
  // src/params/index.ts
2041
2047
  var paramGetters = {
2042
2048
  brand: getBrand,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azzas/azzas-tracker-web",
3
- "version": "1.0.93",
3
+ "version": "1.0.95",
4
4
  "type": "module",
5
5
  "main": "./dist/mod.cjs",
6
6
  "module": "./dist/mod.js",