abmp-npm 2.0.15 → 2.0.16
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/backend/daily-pull/utils.js +14 -1
- package/backend/members-data-methods.js +47 -1
- package/package.json +1 -1
- package/pages/LearnMore.js +27 -0
- package/pages/index.js +1 -0
- package/public/consts.js +1 -0
|
@@ -35,7 +35,17 @@ const extractBaseUrl = url => {
|
|
|
35
35
|
return url;
|
|
36
36
|
};
|
|
37
37
|
const incrementUrlCounter = (existingUrl, baseUrl) => {
|
|
38
|
-
if (existingUrl
|
|
38
|
+
if (!existingUrl || !baseUrl) {
|
|
39
|
+
return baseUrl;
|
|
40
|
+
}
|
|
41
|
+
// Normalize for comparison (case-insensitive)
|
|
42
|
+
const normalizedExisting = existingUrl.toLowerCase();
|
|
43
|
+
const normalizedBase = baseUrl.toLowerCase();
|
|
44
|
+
|
|
45
|
+
if (
|
|
46
|
+
normalizedExisting === normalizedBase ||
|
|
47
|
+
normalizedExisting.startsWith(`${normalizedBase}-`)
|
|
48
|
+
) {
|
|
39
49
|
console.log(
|
|
40
50
|
`Found member with same url ${existingUrl} for baseUrl ${baseUrl}, increasing counter by 1`
|
|
41
51
|
);
|
|
@@ -44,6 +54,9 @@ const incrementUrlCounter = (existingUrl, baseUrl) => {
|
|
|
44
54
|
const lastCounter = isNumeric ? parseInt(lastSegment, 10) : 0;
|
|
45
55
|
return `${baseUrl}-${lastCounter + 1}`;
|
|
46
56
|
}
|
|
57
|
+
|
|
58
|
+
// No conflict, return baseUrl with counter 1 to be safe
|
|
59
|
+
return `${baseUrl}-1`;
|
|
47
60
|
};
|
|
48
61
|
/**
|
|
49
62
|
* Validates core member data requirements
|
|
@@ -4,7 +4,7 @@ const { MEMBERSHIPS_TYPES } = require('./consts');
|
|
|
4
4
|
const { updateMemberContactInfo } = require('./contacts-methods');
|
|
5
5
|
const { MEMBER_ACTIONS } = require('./daily-pull/consts');
|
|
6
6
|
const { wixData } = require('./elevated-modules');
|
|
7
|
-
const { createSiteMember } = require('./members-area-methods');
|
|
7
|
+
const { createSiteMember, getCurrentMember } = require('./members-area-methods');
|
|
8
8
|
const {
|
|
9
9
|
chunkArray,
|
|
10
10
|
normalizeUrlForComparison,
|
|
@@ -477,6 +477,51 @@ async function getSiteMemberId(data) {
|
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
479
|
|
|
480
|
+
/**
|
|
481
|
+
* Tracks a button click with member and location info.
|
|
482
|
+
* @param {Object} params - Parameters
|
|
483
|
+
* @param {string} params.pageName - Name of the page/popup where button was clicked
|
|
484
|
+
* @param {string} params.buttonName - Name/ID of the button that was clicked
|
|
485
|
+
* @returns {Promise<Object>} - Saved record or null if member not found
|
|
486
|
+
*/
|
|
487
|
+
async function trackButtonClick({ pageName, buttonName }) {
|
|
488
|
+
const wixMember = await getCurrentMember();
|
|
489
|
+
|
|
490
|
+
if (!wixMember) {
|
|
491
|
+
console.warn('[trackButtonClick]: No logged in member found');
|
|
492
|
+
return null;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
const dbMember = await getMemberByContactId(wixMember._id);
|
|
496
|
+
|
|
497
|
+
if (!dbMember) {
|
|
498
|
+
console.warn(
|
|
499
|
+
`[trackButtonClick]: Member not found in MembersDataLatest for contactId: ${wixMember._id}`
|
|
500
|
+
);
|
|
501
|
+
return null;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
const memberName = dbMember.fullName || 'Unknown';
|
|
505
|
+
const memberId = dbMember.memberId;
|
|
506
|
+
|
|
507
|
+
const clickData = {
|
|
508
|
+
memberName,
|
|
509
|
+
memberId,
|
|
510
|
+
pageName,
|
|
511
|
+
buttonName,
|
|
512
|
+
clickedAt: new Date(),
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
try {
|
|
516
|
+
const result = await wixData.insert(COLLECTIONS.BUTTON_CLICKS, clickData);
|
|
517
|
+
console.log(`Tracked ${buttonName} click on ${pageName} for member ${memberId}`);
|
|
518
|
+
return result;
|
|
519
|
+
} catch (error) {
|
|
520
|
+
console.error(`Error tracking ${buttonName} click:`, error);
|
|
521
|
+
throw error;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
480
525
|
module.exports = {
|
|
481
526
|
findMemberByWixDataId,
|
|
482
527
|
createContactAndMemberIfNew,
|
|
@@ -496,4 +541,5 @@ module.exports = {
|
|
|
496
541
|
getQAUsers,
|
|
497
542
|
getSiteMemberId,
|
|
498
543
|
checkUrlUniqueness,
|
|
544
|
+
trackButtonClick,
|
|
499
545
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const PAGE_NAME = 'Learn More';
|
|
2
|
+
const BUTTON_NAME = 'Upgrade Now';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates the Learn More popup handler
|
|
6
|
+
* @param {Object} params - Parameters
|
|
7
|
+
* @param {Function} params.$w - Wix $w selector
|
|
8
|
+
* @param {Function} params.trackClick - Backend function to track the click (handles member lookup internally)
|
|
9
|
+
*/
|
|
10
|
+
function learnMoreOnReady({ $w: _$w, trackClick }) {
|
|
11
|
+
_$w('#learnMoreBtn').onClick(async () => {
|
|
12
|
+
try {
|
|
13
|
+
await trackClick({
|
|
14
|
+
pageName: PAGE_NAME,
|
|
15
|
+
buttonName: BUTTON_NAME,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
console.log(`Tracked ${BUTTON_NAME} click on ${PAGE_NAME}`);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error('Error tracking button click:', error);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = {
|
|
26
|
+
learnMoreOnReady,
|
|
27
|
+
};
|
package/pages/index.js
CHANGED