@azzas/azzas-tracker-web 1.0.89 → 1.0.90

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,6 +1198,147 @@ var AzzasTracker = function() {
1198
1198
  return null;
1199
1199
  }
1200
1200
  };
1201
+ var getUserInfo = // src/params/userInfo.ts
1202
+ function getUserInfo(context, eventName) {
1203
+ return _async_to_generator(function() {
1204
+ var _context_manuallyInfo, _PROD_DOMAINS_, _context_manuallyInfo1, cpf, birthDate, phone, firstName, lastName, email, document2, hashedDocument, PROD_DOMAINS, domain, _res_customer_document, _res_customer, api, response, res, document21, hashedDocument1, _;
1205
+ return _ts_generator(this, function(_state) {
1206
+ switch(_state.label){
1207
+ case 0:
1208
+ 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 [
1209
+ 3,
1210
+ 2
1211
+ ];
1212
+ _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;
1213
+ document2 = cpf === null || cpf === void 0 ? void 0 : cpf.replace(/\D/g, "");
1214
+ return [
1215
+ 4,
1216
+ documentToHash(document2)
1217
+ ];
1218
+ case 1:
1219
+ hashedDocument = _state.sent();
1220
+ return [
1221
+ 2,
1222
+ {
1223
+ address: null,
1224
+ customer: {
1225
+ email: email,
1226
+ phone: phone,
1227
+ lastName: lastName,
1228
+ birthDate: birthDate,
1229
+ firstName: firstName,
1230
+ homePhone: phone,
1231
+ document: hashedDocument
1232
+ }
1233
+ }
1234
+ ];
1235
+ case 2:
1236
+ PROD_DOMAINS = {
1237
+ "animale": {
1238
+ "store": "https://www.animale.com.br",
1239
+ "checkout": "https://secure.animale.com.br"
1240
+ },
1241
+ "farm": {
1242
+ "store": "https://lojafarm.myvtex.com"
1243
+ },
1244
+ "mariafilo": {
1245
+ "store": "https://mariafilo.myvtex.com",
1246
+ "checkout": "https://secure.mariafilo.com.br"
1247
+ },
1248
+ "lojacrisbarros": {
1249
+ "store": "https://lojacrisbarros.myvtex.com",
1250
+ "checkout": "https://secure.crisbarros.com.br"
1251
+ },
1252
+ "lojaoffpremium": {
1253
+ "store": "https://lojaoffpremium.myvtex.com",
1254
+ "checkout": "https://secure.lojaoffpremium.com.br"
1255
+ }
1256
+ };
1257
+ domain = (_PROD_DOMAINS_ = PROD_DOMAINS[context.account || "https://www.animale.com.br"]) === null || _PROD_DOMAINS_ === void 0 ? void 0 : _PROD_DOMAINS_[context.platform || "store"];
1258
+ if (!domain) return [
1259
+ 2,
1260
+ {
1261
+ customer: {
1262
+ email: context.userEmail,
1263
+ id: context === null || context === void 0 ? void 0 : context.userId
1264
+ },
1265
+ address: null
1266
+ }
1267
+ ];
1268
+ _state.label = 3;
1269
+ case 3:
1270
+ _state.trys.push([
1271
+ 3,
1272
+ 7,
1273
+ ,
1274
+ 8
1275
+ ]);
1276
+ api = "".concat(domain, "/_v/user-info");
1277
+ return [
1278
+ 4,
1279
+ fetch(api, {
1280
+ method: "POST",
1281
+ body: JSON.stringify({
1282
+ email: context.userEmail
1283
+ })
1284
+ })
1285
+ ];
1286
+ case 4:
1287
+ response = _state.sent();
1288
+ if (response.status !== 200) {
1289
+ return [
1290
+ 2,
1291
+ {
1292
+ customer: {
1293
+ email: context.userEmail,
1294
+ id: context === null || context === void 0 ? void 0 : context.userId
1295
+ },
1296
+ address: null
1297
+ }
1298
+ ];
1299
+ }
1300
+ return [
1301
+ 4,
1302
+ response.json()
1303
+ ];
1304
+ case 5:
1305
+ res = _state.sent();
1306
+ document21 = 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, "");
1307
+ return [
1308
+ 4,
1309
+ documentToHash(document21)
1310
+ ];
1311
+ case 6:
1312
+ hashedDocument1 = _state.sent();
1313
+ return [
1314
+ 2,
1315
+ _object_spread_props(_object_spread({}, res), {
1316
+ customer: _object_spread_props(_object_spread({}, res.customer), {
1317
+ cpf: hashedDocument1,
1318
+ document: document21
1319
+ })
1320
+ })
1321
+ ];
1322
+ case 7:
1323
+ _ = _state.sent();
1324
+ return [
1325
+ 2,
1326
+ {
1327
+ customer: {
1328
+ email: context.userEmail,
1329
+ id: context === null || context === void 0 ? void 0 : context.userId
1330
+ },
1331
+ address: null
1332
+ }
1333
+ ];
1334
+ case 8:
1335
+ return [
1336
+ 2
1337
+ ];
1338
+ }
1339
+ });
1340
+ })();
1341
+ };
1201
1342
  var getParameters = // src/formatter/index.ts
1202
1343
  function getParameters(_0) {
1203
1344
  return _async_to_generator(function() {
@@ -1868,118 +2009,7 @@ var AzzasTracker = function() {
1868
2009
  brand: getBrand,
1869
2010
  items: getItems,
1870
2011
  payment_type: getPaymentType,
1871
- user_info: function(context, eventName) {
1872
- return _async_to_generator(function() {
1873
- var _PROD_DOMAINS_, PROD_DOMAINS, domain, _res_customer_document, _res_customer, api, response, res, document2, hashedDocument, _;
1874
- return _ts_generator(this, function(_state) {
1875
- switch(_state.label){
1876
- case 0:
1877
- PROD_DOMAINS = {
1878
- "animale": {
1879
- "store": "https://www.animale.com.br",
1880
- "checkout": "https://secure.animale.com.br"
1881
- },
1882
- "farm": {
1883
- "store": "https://lojafarm.myvtex.com"
1884
- },
1885
- "mariafilo": {
1886
- "store": "https://mariafilo.myvtex.com",
1887
- "checkout": "https://secure.mariafilo.com.br"
1888
- },
1889
- "lojacrisbarros": {
1890
- "store": "https://lojacrisbarros.myvtex.com",
1891
- "checkout": "https://secure.crisbarros.com.br"
1892
- },
1893
- "lojaoffpremium": {
1894
- "store": "https://lojaoffpremium.myvtex.com",
1895
- "checkout": "https://secure.lojaoffpremium.com.br"
1896
- }
1897
- };
1898
- domain = (_PROD_DOMAINS_ = PROD_DOMAINS[context.account || "https://www.animale.com.br"]) === null || _PROD_DOMAINS_ === void 0 ? void 0 : _PROD_DOMAINS_[context.platform || "store"];
1899
- if (!domain) return [
1900
- 2,
1901
- {
1902
- customer: {
1903
- email: context.userEmail,
1904
- id: context === null || context === void 0 ? void 0 : context.userId
1905
- },
1906
- address: null
1907
- }
1908
- ];
1909
- _state.label = 1;
1910
- case 1:
1911
- _state.trys.push([
1912
- 1,
1913
- 5,
1914
- ,
1915
- 6
1916
- ]);
1917
- api = "".concat(domain, "/_v/user-info");
1918
- return [
1919
- 4,
1920
- fetch(api, {
1921
- method: "POST",
1922
- body: JSON.stringify({
1923
- email: context.userEmail
1924
- })
1925
- })
1926
- ];
1927
- case 2:
1928
- response = _state.sent();
1929
- if (response.status !== 200) {
1930
- return [
1931
- 2,
1932
- {
1933
- customer: {
1934
- email: context.userEmail,
1935
- id: context === null || context === void 0 ? void 0 : context.userId
1936
- },
1937
- address: null
1938
- }
1939
- ];
1940
- }
1941
- return [
1942
- 4,
1943
- response.json()
1944
- ];
1945
- case 3:
1946
- res = _state.sent();
1947
- 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, "");
1948
- return [
1949
- 4,
1950
- documentToHash(document2)
1951
- ];
1952
- case 4:
1953
- hashedDocument = _state.sent();
1954
- return [
1955
- 2,
1956
- _object_spread_props(_object_spread({}, res), {
1957
- customer: _object_spread_props(_object_spread({}, res.customer), {
1958
- cpf: hashedDocument,
1959
- document: document2
1960
- })
1961
- })
1962
- ];
1963
- case 5:
1964
- _ = _state.sent();
1965
- return [
1966
- 2,
1967
- {
1968
- customer: {
1969
- email: context.userEmail,
1970
- id: context === null || context === void 0 ? void 0 : context.userId
1971
- },
1972
- address: null
1973
- }
1974
- ];
1975
- case 6:
1976
- return [
1977
- 2
1978
- ];
1979
- }
1980
- });
1981
- })();
1982
- },
2012
+ user_info: getUserInfo,
1983
2013
  content_type: function(context, eventName) {
1984
2014
  return "regiao".concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
1985
2015
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azzas/azzas-tracker-web",
3
- "version": "1.0.89",
3
+ "version": "1.0.90",
4
4
  "type": "module",
5
5
  "main": "./dist/mod.cjs",
6
6
  "module": "./dist/mod.js",