@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.
- package/dist/mod.cjs +102 -73
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.d.cts +26 -0
- package/dist/mod.d.ts +26 -0
- package/dist/mod.global.js +102 -73
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +102 -73
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +154 -115
- package/package.json +1 -1
package/dist/mod.js
CHANGED
|
@@ -28,6 +28,32 @@ var EVENTS = {
|
|
|
28
28
|
"items"
|
|
29
29
|
]
|
|
30
30
|
},
|
|
31
|
+
CUSTOM_ADD_TO_CART: {
|
|
32
|
+
name: "custom_add_to_cart",
|
|
33
|
+
hasEcommerce: true,
|
|
34
|
+
destinations: ["DataLayer"],
|
|
35
|
+
requiredParams: [
|
|
36
|
+
"brand",
|
|
37
|
+
"region",
|
|
38
|
+
"line_items",
|
|
39
|
+
"currency",
|
|
40
|
+
"value",
|
|
41
|
+
"items"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
CUSTOM_REMOVE_FROM_CART: {
|
|
45
|
+
name: "custom_remove_from_cart",
|
|
46
|
+
hasEcommerce: true,
|
|
47
|
+
destinations: ["DataLayer"],
|
|
48
|
+
requiredParams: [
|
|
49
|
+
"brand",
|
|
50
|
+
"region",
|
|
51
|
+
"line_items",
|
|
52
|
+
"currency",
|
|
53
|
+
"value",
|
|
54
|
+
"items"
|
|
55
|
+
]
|
|
56
|
+
},
|
|
31
57
|
ADD_TO_CART: {
|
|
32
58
|
name: "add_to_cart",
|
|
33
59
|
hasEcommerce: true,
|
|
@@ -166,7 +192,8 @@ var EVENTS = {
|
|
|
166
192
|
AUTH_ACTION: {
|
|
167
193
|
name: "auth_action",
|
|
168
194
|
hasEcommerce: false,
|
|
169
|
-
requiredParams: ["region"]
|
|
195
|
+
requiredParams: ["region", "method", "type", "brand"],
|
|
196
|
+
destinations: ["DataLayer"]
|
|
170
197
|
},
|
|
171
198
|
ADD_PERSONAL_INFO: {
|
|
172
199
|
name: "add_personal_info",
|
|
@@ -973,89 +1000,84 @@ function getPaymentType(context, eventName) {
|
|
|
973
1000
|
}
|
|
974
1001
|
|
|
975
1002
|
// src/params/userInfo.ts
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
"
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
"
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
"
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
"
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
async function getManuallyInfo(info) {
|
|
998
|
-
if (!(info == null ? void 0 : info.cpf)) return null;
|
|
999
|
-
const { cpf, birthDate, phone, firstName, lastName, email, email_optin } = info;
|
|
1000
|
-
const document2 = cpf == null ? void 0 : cpf.replace(/\D/g, "");
|
|
1001
|
-
const hashedDocument = await documentToHash(document2);
|
|
1002
|
-
let formattedBirthDate = null;
|
|
1003
|
-
if (birthDate) {
|
|
1004
|
-
const [day, month, year] = birthDate.split("/");
|
|
1005
|
-
if (day && month && year && !isNaN(Number(year))) {
|
|
1006
|
-
formattedBirthDate = `${year}-${month}-${day}T00:00:00Z`;
|
|
1007
|
-
} else {
|
|
1008
|
-
console.warn("[DT - user_info] Invalid birthDate format from manuallyInfo:", birthDate);
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
return {
|
|
1012
|
-
address: null,
|
|
1013
|
-
customer: {
|
|
1014
|
-
email,
|
|
1015
|
-
phone,
|
|
1016
|
-
document: document2,
|
|
1017
|
-
lastName,
|
|
1018
|
-
birthDate: formattedBirthDate,
|
|
1019
|
-
firstName,
|
|
1020
|
-
homePhone: phone,
|
|
1021
|
-
cpf: hashedDocument,
|
|
1022
|
-
...email_optin && { email_optin }
|
|
1003
|
+
async function getUserInfo(context, eventName) {
|
|
1004
|
+
var _a, _b, _c, _d, _e;
|
|
1005
|
+
const PROD_DOMAINS = {
|
|
1006
|
+
"animale": {
|
|
1007
|
+
"store": "https://www.animale.com.br",
|
|
1008
|
+
"checkout": "https://secure.animale.com.br"
|
|
1009
|
+
},
|
|
1010
|
+
"farm": {
|
|
1011
|
+
"store": "https://lojafarm.myvtex.com"
|
|
1012
|
+
},
|
|
1013
|
+
"mariafilo": {
|
|
1014
|
+
"store": "https://mariafilo.myvtex.com",
|
|
1015
|
+
"checkout": "https://secure.mariafilo.com.br"
|
|
1016
|
+
},
|
|
1017
|
+
"lojacrisbarros": {
|
|
1018
|
+
"store": "https://lojacrisbarros.myvtex.com",
|
|
1019
|
+
"checkout": "https://secure.crisbarros.com.br"
|
|
1020
|
+
},
|
|
1021
|
+
"lojaoffpremium": {
|
|
1022
|
+
"store": "https://lojaoffpremium.myvtex.com",
|
|
1023
|
+
"checkout": "https://secure.lojaoffpremium.com.br"
|
|
1023
1024
|
}
|
|
1024
1025
|
};
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
return {
|
|
1028
|
-
customer: { email: userEmail, id: userId },
|
|
1029
|
-
address: null
|
|
1030
|
-
};
|
|
1031
|
-
}
|
|
1032
|
-
async function getUserInfo(context, eventName) {
|
|
1033
|
-
var _a, _b, _c;
|
|
1034
|
-
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"];
|
|
1035
|
-
if (!domain) return getFallbackUserInfo(context.userEmail, context == null ? void 0 : context.userId);
|
|
1026
|
+
const domain = (_a = PROD_DOMAINS[context.account || "https://www.animale.com.br"]) == null ? void 0 : _a[context.platform || "store"];
|
|
1027
|
+
if (!domain) return { customer: { email: context.userEmail, id: context == null ? void 0 : context.userId }, address: null };
|
|
1036
1028
|
try {
|
|
1037
1029
|
const api = `${domain}/_v/user-info`;
|
|
1038
1030
|
const response = await fetch(api, {
|
|
1039
1031
|
method: "POST",
|
|
1040
1032
|
body: JSON.stringify({ email: context.userEmail })
|
|
1041
1033
|
});
|
|
1042
|
-
if (response.status
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1034
|
+
if (response.status !== 200) {
|
|
1035
|
+
if ((context == null ? void 0 : context.manuallyInfo) && ((_b = context.manuallyInfo) == null ? void 0 : _b.cpf)) {
|
|
1036
|
+
const { cpf, birthDate, phone, firstName, lastName, email, email_optin } = context.manuallyInfo;
|
|
1037
|
+
const document3 = cpf == null ? void 0 : cpf.replace(/\D/g, "");
|
|
1038
|
+
const hashedDocument2 = await documentToHash(document3);
|
|
1039
|
+
return {
|
|
1040
|
+
address: null,
|
|
1041
|
+
customer: {
|
|
1042
|
+
email,
|
|
1043
|
+
phone,
|
|
1044
|
+
document: document3,
|
|
1045
|
+
lastName,
|
|
1046
|
+
birthDate,
|
|
1047
|
+
firstName,
|
|
1048
|
+
email_optin,
|
|
1049
|
+
homePhone: phone,
|
|
1050
|
+
cpf: hashedDocument2
|
|
1051
|
+
}
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
return { customer: { email: context.userEmail, id: context == null ? void 0 : context.userId }, address: null };
|
|
1051
1055
|
}
|
|
1052
|
-
|
|
1056
|
+
const res = await response.json();
|
|
1057
|
+
const document2 = (_d = (_c = res == null ? void 0 : res.customer) == null ? void 0 : _c.document) == null ? void 0 : _d.replace(/\D/g, "");
|
|
1058
|
+
const hashedDocument = await documentToHash(document2);
|
|
1059
|
+
return { ...res, customer: { ...res.customer, cpf: hashedDocument, document: document2 } };
|
|
1053
1060
|
} catch (_) {
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1061
|
+
if ((context == null ? void 0 : context.manuallyInfo) && ((_e = context.manuallyInfo) == null ? void 0 : _e.cpf)) {
|
|
1062
|
+
const { cpf, birthDate, phone, firstName, lastName, email, email_optin } = context.manuallyInfo;
|
|
1063
|
+
const document2 = cpf == null ? void 0 : cpf.replace(/\D/g, "");
|
|
1064
|
+
const hashedDocument = await documentToHash(document2);
|
|
1065
|
+
return {
|
|
1066
|
+
address: null,
|
|
1067
|
+
customer: {
|
|
1068
|
+
email,
|
|
1069
|
+
phone,
|
|
1070
|
+
document: document2,
|
|
1071
|
+
lastName,
|
|
1072
|
+
birthDate,
|
|
1073
|
+
firstName,
|
|
1074
|
+
email_optin,
|
|
1075
|
+
homePhone: phone,
|
|
1076
|
+
cpf: hashedDocument
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1057
1079
|
}
|
|
1058
|
-
return
|
|
1080
|
+
return { customer: { email: context.userEmail, id: context == null ? void 0 : context.userId }, address: null };
|
|
1059
1081
|
}
|
|
1060
1082
|
}
|
|
1061
1083
|
|
|
@@ -1066,6 +1088,7 @@ var paramGetters = {
|
|
|
1066
1088
|
payment_type: getPaymentType,
|
|
1067
1089
|
user_info: getUserInfo,
|
|
1068
1090
|
content_type: (context, eventName) => {
|
|
1091
|
+
if (context == null ? void 0 : context.content_type) return context.content_type;
|
|
1069
1092
|
return `regiao`.concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
|
|
1070
1093
|
},
|
|
1071
1094
|
region: (context, eventName) => {
|
|
@@ -1250,6 +1273,12 @@ var paramGetters = {
|
|
|
1250
1273
|
},
|
|
1251
1274
|
available_grid: (context, eventName) => {
|
|
1252
1275
|
return context.availableGrid || null;
|
|
1276
|
+
},
|
|
1277
|
+
method: (context, eventName) => {
|
|
1278
|
+
return context.method || null;
|
|
1279
|
+
},
|
|
1280
|
+
type: (context, eventName) => {
|
|
1281
|
+
return context.type || null;
|
|
1253
1282
|
}
|
|
1254
1283
|
};
|
|
1255
1284
|
|