mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 20:34:02 +03:00
Fixed FirstPromoter integration to ignore old referrals
closes https://github.com/TryGhost/Team/issues/2888 Due to lack of member's created at date, we previously called the FirstPromoter tracking function for all logged-in members irrespective of when they signed up. This caused issues in few cases where members who were already signed up were getting falsely attributed as referrals if they had clicked on a referral link previously. This change uses the member's created at date which is now available on frontend for logged-in members, and ignored the FirstPromoter tracking script if member had signed up more than 24 hours ago.
This commit is contained in:
parent
e95c531e8b
commit
56eb7a822f
@ -20,6 +20,7 @@ module.exports.formattedMemberResponse = function formattedMemberResponse(member
|
||||
subscribed: !!member.subscribed,
|
||||
subscriptions: member.subscriptions || [],
|
||||
paid: member.status !== 'free',
|
||||
created_at: member.created_at,
|
||||
enable_comment_notifications: member.enable_comment_notifications
|
||||
};
|
||||
if (member.newsletters) {
|
||||
|
@ -11,7 +11,7 @@ import {getActivePage, isAccountPage, isOfferPage} from './pages';
|
||||
import ActionHandler from './actions';
|
||||
import './App.css';
|
||||
import NotificationParser from './utils/notifications';
|
||||
import {allowCompMemberUpgrade, createPopupNotification, getCurrencySymbol, getFirstpromoterId, getPriceIdFromPageQuery, getProductCadenceFromPrice, getProductFromId, getQueryPrice, getSiteDomain, isActiveOffer, isComplimentaryMember, isInviteOnlySite, isPaidMember, isSentryEventAllowed, removePortalLinkFromUrl} from './utils/helpers';
|
||||
import {allowCompMemberUpgrade, createPopupNotification, getCurrencySymbol, getFirstpromoterId, getPriceIdFromPageQuery, getProductCadenceFromPrice, getProductFromId, getQueryPrice, getSiteDomain, isActiveOffer, isComplimentaryMember, isInviteOnlySite, isPaidMember, isRecentMember, isSentryEventAllowed, removePortalLinkFromUrl} from './utils/helpers';
|
||||
import {handleDataAttributes} from './data-attributes';
|
||||
|
||||
import i18nLib from '@tryghost/i18n';
|
||||
@ -558,7 +558,7 @@ export default class App extends React.Component {
|
||||
if (!_t || 'complete' === _t || 'loaded' === _t) {
|
||||
try {
|
||||
window.$FPROM.init(firstPromoterId, siteDomain);
|
||||
if (member) {
|
||||
if (isRecentMember({member})) {
|
||||
const email = member.email;
|
||||
const uid = member.uuid;
|
||||
if (window.$FPROM) {
|
||||
|
@ -891,3 +891,17 @@ export function getUrlHistory() {
|
||||
console.warn(`[Portal] Failed to load member URL history:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if member is a recent member, i.e. created in last 24 hours
|
||||
export function isRecentMember({member}) {
|
||||
if (!member?.created_at) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
const created = new Date(member.created_at);
|
||||
const diff = now.getTime() - created.getTime();
|
||||
const diffHours = Math.round(diff / (1000 * 60 * 60));
|
||||
|
||||
return diffHours < 24;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user