@azzas/azzas-tracker-web 1.0.95 → 1.0.97

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.
@@ -56,6 +56,32 @@ var AzzasTracker = (() => {
56
56
  "items"
57
57
  ]
58
58
  },
59
+ CUSTOM_ADD_TO_CART: {
60
+ name: "custom_add_to_cart",
61
+ hasEcommerce: true,
62
+ destinations: ["DataLayer"],
63
+ requiredParams: [
64
+ "brand",
65
+ "region",
66
+ "line_items",
67
+ "currency",
68
+ "value",
69
+ "items"
70
+ ]
71
+ },
72
+ CUSTOM_REMOVE_FROM_CART: {
73
+ name: "custom_remove_from_cart",
74
+ hasEcommerce: true,
75
+ destinations: ["DataLayer"],
76
+ requiredParams: [
77
+ "brand",
78
+ "region",
79
+ "line_items",
80
+ "currency",
81
+ "value",
82
+ "items"
83
+ ]
84
+ },
59
85
  ADD_TO_CART: {
60
86
  name: "add_to_cart",
61
87
  hasEcommerce: true,
@@ -194,7 +220,8 @@ var AzzasTracker = (() => {
194
220
  AUTH_ACTION: {
195
221
  name: "auth_action",
196
222
  hasEcommerce: false,
197
- requiredParams: ["region"]
223
+ requiredParams: ["region", "method", "type", "brand"],
224
+ destinations: ["DataLayer"]
198
225
  },
199
226
  ADD_PERSONAL_INFO: {
200
227
  name: "add_personal_info",
@@ -1001,89 +1028,84 @@ var AzzasTracker = (() => {
1001
1028
  }
1002
1029
 
1003
1030
  // src/params/userInfo.ts
1004
- var PROD_DOMAINS = {
1005
- "animale": {
1006
- "store": "https://www.animale.com.br",
1007
- "checkout": "https://secure.animale.com.br"
1008
- },
1009
- "farm": {
1010
- "store": "https://lojafarm.myvtex.com"
1011
- },
1012
- "mariafilo": {
1013
- "store": "https://mariafilo.myvtex.com",
1014
- "checkout": "https://secure.mariafilo.com.br"
1015
- },
1016
- "lojacrisbarros": {
1017
- "store": "https://lojacrisbarros.myvtex.com",
1018
- "checkout": "https://secure.crisbarros.com.br"
1019
- },
1020
- "lojaoffpremium": {
1021
- "store": "https://lojaoffpremium.myvtex.com",
1022
- "checkout": "https://secure.lojaoffpremium.com.br"
1023
- }
1024
- };
1025
- async function getManuallyInfo(info) {
1026
- if (!(info == null ? void 0 : info.cpf)) return null;
1027
- const { cpf, birthDate, phone, firstName, lastName, email, email_optin } = info;
1028
- const document2 = cpf == null ? void 0 : cpf.replace(/\D/g, "");
1029
- const hashedDocument = await documentToHash(document2);
1030
- let formattedBirthDate = null;
1031
- if (birthDate) {
1032
- const [day, month, year] = birthDate.split("/");
1033
- if (day && month && year && !isNaN(Number(year))) {
1034
- formattedBirthDate = `${year}-${month}-${day}T00:00:00Z`;
1035
- } else {
1036
- console.warn("[DT - user_info] Invalid birthDate format from manuallyInfo:", birthDate);
1037
- }
1038
- }
1039
- return {
1040
- address: null,
1041
- customer: {
1042
- email,
1043
- phone,
1044
- document: document2,
1045
- lastName,
1046
- birthDate: formattedBirthDate,
1047
- firstName,
1048
- homePhone: phone,
1049
- cpf: hashedDocument,
1050
- ...email_optin && { email_optin }
1031
+ async function getUserInfo(context, eventName) {
1032
+ var _a, _b, _c, _d, _e;
1033
+ const PROD_DOMAINS = {
1034
+ "animale": {
1035
+ "store": "https://www.animale.com.br",
1036
+ "checkout": "https://secure.animale.com.br"
1037
+ },
1038
+ "farm": {
1039
+ "store": "https://lojafarm.myvtex.com"
1040
+ },
1041
+ "mariafilo": {
1042
+ "store": "https://mariafilo.myvtex.com",
1043
+ "checkout": "https://secure.mariafilo.com.br"
1044
+ },
1045
+ "lojacrisbarros": {
1046
+ "store": "https://lojacrisbarros.myvtex.com",
1047
+ "checkout": "https://secure.crisbarros.com.br"
1048
+ },
1049
+ "lojaoffpremium": {
1050
+ "store": "https://lojaoffpremium.myvtex.com",
1051
+ "checkout": "https://secure.lojaoffpremium.com.br"
1051
1052
  }
1052
1053
  };
1053
- }
1054
- function getFallbackUserInfo(userEmail, userId) {
1055
- return {
1056
- customer: { email: userEmail, id: userId },
1057
- address: null
1058
- };
1059
- }
1060
- async function getUserInfo(context, eventName) {
1061
- var _a, _b, _c;
1062
- const domain = (_a = PROD_DOMAINS[(context == null ? void 0 : context.account) || "https://www.animale.com.br"]) == null ? void 0 : _a[(context == null ? void 0 : context.platform) || "store"];
1063
- if (!domain) return getFallbackUserInfo(context.userEmail, context == null ? void 0 : context.userId);
1054
+ const domain = (_a = PROD_DOMAINS[context.account || "https://www.animale.com.br"]) == null ? void 0 : _a[context.platform || "store"];
1055
+ if (!domain) return { customer: { email: context.userEmail, id: context == null ? void 0 : context.userId }, address: null };
1064
1056
  try {
1065
1057
  const api = `${domain}/_v/user-info`;
1066
1058
  const response = await fetch(api, {
1067
1059
  method: "POST",
1068
1060
  body: JSON.stringify({ email: context.userEmail })
1069
1061
  });
1070
- if (response.status === 200) {
1071
- const res = await response.json();
1072
- const document2 = (_c = (_b = res == null ? void 0 : res.customer) == null ? void 0 : _b.document) == null ? void 0 : _c.replace(/\D/g, "");
1073
- const hashedDocument = await documentToHash(document2);
1074
- return { ...res, customer: { ...res.customer, cpf: hashedDocument, document: document2 } };
1075
- }
1076
- const manuallyInfoResult = await getManuallyInfo(context == null ? void 0 : context.manuallyInfo);
1077
- if (manuallyInfoResult) {
1078
- return manuallyInfoResult;
1062
+ if (response.status !== 200) {
1063
+ if ((context == null ? void 0 : context.manuallyInfo) && ((_b = context.manuallyInfo) == null ? void 0 : _b.cpf)) {
1064
+ const { cpf, birthDate, phone, firstName, lastName, email, email_optin } = context.manuallyInfo;
1065
+ const document3 = cpf == null ? void 0 : cpf.replace(/\D/g, "");
1066
+ const hashedDocument2 = await documentToHash(document3);
1067
+ return {
1068
+ address: null,
1069
+ customer: {
1070
+ email,
1071
+ phone,
1072
+ document: document3,
1073
+ lastName,
1074
+ birthDate,
1075
+ firstName,
1076
+ email_optin,
1077
+ homePhone: phone,
1078
+ cpf: hashedDocument2
1079
+ }
1080
+ };
1081
+ }
1082
+ return { customer: { email: context.userEmail, id: context == null ? void 0 : context.userId }, address: null };
1079
1083
  }
1080
- return getFallbackUserInfo(context.userEmail, context == null ? void 0 : context.userId);
1084
+ const res = await response.json();
1085
+ const document2 = (_d = (_c = res == null ? void 0 : res.customer) == null ? void 0 : _c.document) == null ? void 0 : _d.replace(/\D/g, "");
1086
+ const hashedDocument = await documentToHash(document2);
1087
+ return { ...res, customer: { ...res.customer, cpf: hashedDocument, document: document2 } };
1081
1088
  } catch (_) {
1082
- const manuallyInfoResult = await getManuallyInfo(context == null ? void 0 : context.manuallyInfo);
1083
- if (manuallyInfoResult) {
1084
- return manuallyInfoResult;
1089
+ if ((context == null ? void 0 : context.manuallyInfo) && ((_e = context.manuallyInfo) == null ? void 0 : _e.cpf)) {
1090
+ const { cpf, birthDate, phone, firstName, lastName, email, email_optin } = context.manuallyInfo;
1091
+ const document2 = cpf == null ? void 0 : cpf.replace(/\D/g, "");
1092
+ const hashedDocument = await documentToHash(document2);
1093
+ return {
1094
+ address: null,
1095
+ customer: {
1096
+ email,
1097
+ phone,
1098
+ document: document2,
1099
+ lastName,
1100
+ birthDate,
1101
+ firstName,
1102
+ email_optin,
1103
+ homePhone: phone,
1104
+ cpf: hashedDocument
1105
+ }
1106
+ };
1085
1107
  }
1086
- return getFallbackUserInfo(context.userEmail, context == null ? void 0 : context.userId);
1108
+ return { customer: { email: context.userEmail, id: context == null ? void 0 : context.userId }, address: null };
1087
1109
  }
1088
1110
  }
1089
1111
 
@@ -1094,6 +1116,7 @@ var AzzasTracker = (() => {
1094
1116
  payment_type: getPaymentType,
1095
1117
  user_info: getUserInfo,
1096
1118
  content_type: (context, eventName) => {
1119
+ if (context == null ? void 0 : context.content_type) return context.content_type;
1097
1120
  return `regiao`.concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
1098
1121
  },
1099
1122
  region: (context, eventName) => {
@@ -1278,6 +1301,12 @@ var AzzasTracker = (() => {
1278
1301
  },
1279
1302
  available_grid: (context, eventName) => {
1280
1303
  return context.availableGrid || null;
1304
+ },
1305
+ method: (context, eventName) => {
1306
+ return context.method || null;
1307
+ },
1308
+ type: (context, eventName) => {
1309
+ return context.type || null;
1281
1310
  }
1282
1311
  };
1283
1312