abmp-npm 2.0.28 → 2.0.30
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.
|
@@ -12,6 +12,7 @@ const elevatedCreateContact = auth.elevate(contacts.createContact);
|
|
|
12
12
|
* @returns {Promise<Object>} - Contact data
|
|
13
13
|
*/
|
|
14
14
|
async function createSiteContact(contactData, allowDuplicates = false) {
|
|
15
|
+
console.log('[createSiteContact]contactData', JSON.stringify(contactData, null, 2));
|
|
15
16
|
if (!contactData || !(contactData.contactFormEmail || contactData.email)) {
|
|
16
17
|
throw new Error('Contact data is required');
|
|
17
18
|
}
|
|
@@ -27,7 +28,12 @@ async function createSiteContact(contactData, allowDuplicates = false) {
|
|
|
27
28
|
},
|
|
28
29
|
phones: { items: phones.map(phone => ({ phone })) },
|
|
29
30
|
};
|
|
31
|
+
console.log('[createSiteContact]contactInfo', JSON.stringify(contactInfo, null, 2));
|
|
30
32
|
const createContactResponse = await elevatedCreateContact(contactInfo, { allowDuplicates });
|
|
33
|
+
console.log(
|
|
34
|
+
'[createSiteContact]createContactResponse',
|
|
35
|
+
JSON.stringify(createContactResponse, null, 2)
|
|
36
|
+
);
|
|
31
37
|
return createContactResponse.contact._id;
|
|
32
38
|
}
|
|
33
39
|
/**
|
|
@@ -9,6 +9,22 @@ const { bulkProcessAndSaveMemberData } = require('./bulk-process-methods');
|
|
|
9
9
|
const { MEMBER_ACTIONS } = require('./consts');
|
|
10
10
|
const { isUpdatedMember, isSiteAssociatedMember } = require('./utils');
|
|
11
11
|
|
|
12
|
+
const filterLicensesByAssociation = (member, siteAssociation) => {
|
|
13
|
+
if (!member?.licenses || !Array.isArray(member.licenses)) {
|
|
14
|
+
return member;
|
|
15
|
+
}
|
|
16
|
+
const filteredLicenses = member.licenses.filter(license => {
|
|
17
|
+
if (!license || !license.association) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return license.association === siteAssociation;
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
...member,
|
|
24
|
+
licenses: filteredLicenses,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
12
28
|
async function syncMembersDataPerAction(taskData) {
|
|
13
29
|
const { action, backupDate, isTestEnvironment, includeNone } = taskData;
|
|
14
30
|
try {
|
|
@@ -110,6 +126,9 @@ async function synchronizeSinglePage(taskObject) {
|
|
|
110
126
|
}
|
|
111
127
|
return isUpdatedMember(member);
|
|
112
128
|
});
|
|
129
|
+
const toSyncMembersWithFilteredLicenses = toSyncMembers.map(member =>
|
|
130
|
+
filterLicensesByAssociation(member, siteAssociation)
|
|
131
|
+
);
|
|
113
132
|
if (toSyncMembers.length === 0) {
|
|
114
133
|
return {
|
|
115
134
|
success: true,
|
|
@@ -120,7 +139,7 @@ async function synchronizeSinglePage(taskObject) {
|
|
|
120
139
|
};
|
|
121
140
|
}
|
|
122
141
|
const result = await bulkProcessAndSaveMemberData({
|
|
123
|
-
memberDataList:
|
|
142
|
+
memberDataList: toSyncMembersWithFilteredLicenses,
|
|
124
143
|
currentPageNumber: pageNumber,
|
|
125
144
|
});
|
|
126
145
|
|
|
@@ -13,9 +13,11 @@ function prepareMemberData(partner) {
|
|
|
13
13
|
}
|
|
14
14
|
async function createMemberFunction(member) {
|
|
15
15
|
const newMember = await elevatedCreateMember(member);
|
|
16
|
+
console.log('[createMemberFunction]newMember', JSON.stringify(newMember, null, 2));
|
|
16
17
|
return newMember._id;
|
|
17
18
|
}
|
|
18
19
|
const createSiteMember = async memberDetails => {
|
|
20
|
+
console.log('createSiteMember memberDetails', memberDetails);
|
|
19
21
|
try {
|
|
20
22
|
const options = prepareMemberData(memberDetails);
|
|
21
23
|
return await createMemberFunction(options);
|
|
@@ -45,17 +45,23 @@ async function createContactAndMemberIfNew(memberData, allowDuplicates = false)
|
|
|
45
45
|
};
|
|
46
46
|
const needsWixMember = !memberData.wixMemberId;
|
|
47
47
|
const needsWixContact = !memberData.wixContactId;
|
|
48
|
+
console.log('needsWixMember', needsWixMember);
|
|
49
|
+
console.log('needsWixContact', needsWixContact);
|
|
48
50
|
const [newWixMemberId, newWixContactId] = await Promise.all([
|
|
49
51
|
needsWixMember ? createSiteMember(toCreateMemberData) : Promise.resolve(null),
|
|
50
52
|
needsWixContact
|
|
51
53
|
? createSiteContact(toCreateMemberData, allowDuplicates)
|
|
52
54
|
: Promise.resolve(null),
|
|
53
55
|
]);
|
|
56
|
+
console.log('newWixMemberId', newWixMemberId);
|
|
57
|
+
console.log('newWixContactId', newWixContactId);
|
|
54
58
|
let memberDataWithContactId = {
|
|
55
59
|
...memberData,
|
|
56
60
|
wixMemberId: newWixMemberId || memberData.wixMemberId,
|
|
57
61
|
wixContactId: newWixContactId || memberData.wixContactId,
|
|
58
62
|
};
|
|
63
|
+
console.log('latest WixMemberId', memberDataWithContactId.wixMemberId);
|
|
64
|
+
console.log('latest WixContactId', memberDataWithContactId.wixContactId);
|
|
59
65
|
const updatedResult = await updateMember(memberDataWithContactId);
|
|
60
66
|
memberDataWithContactId = {
|
|
61
67
|
...memberDataWithContactId,
|
|
@@ -550,12 +556,14 @@ async function trackButtonClick({ pageName, buttonName, data }) {
|
|
|
550
556
|
|
|
551
557
|
const memberName = dbMember.fullName || 'Unknown';
|
|
552
558
|
const memberId = dbMember.memberId;
|
|
559
|
+
const memberEmail = dbMember.email;
|
|
553
560
|
|
|
554
561
|
const clickData = {
|
|
555
562
|
memberName,
|
|
556
563
|
memberId,
|
|
557
564
|
pageName,
|
|
558
565
|
buttonName,
|
|
566
|
+
memberEmail,
|
|
559
567
|
clickedAt: new Date(),
|
|
560
568
|
...(data && { data }),
|
|
561
569
|
};
|