Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove isRecurringContributor
Browse files Browse the repository at this point in the history
rupertbates committed Dec 12, 2024
1 parent d763184 commit 4c77c6f
Showing 3 changed files with 1 addition and 41 deletions.
2 changes: 0 additions & 2 deletions dotcom-rendering/src/components/LiveBlogEpic.importable.tsx
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ import { submitComponentEvent } from '../client/ophan/ophan';
import { useArticleCounts } from '../lib/articleCount';
import {
getLastOneOffContributionTimestamp,
isRecurringContributor,
shouldHideSupportMessaging,
useHasOptedOutOfArticleCount,
} from '../lib/contributions';
@@ -125,7 +124,6 @@ const usePayload = ({
isPaidContent,
tags,
showSupportMessaging: !hideSupportMessagingForUser,
isRecurringContributor: isRecurringContributor(isSignedIn),
lastOneOffContributionDate:
getLastOneOffContributionTimestamp() ?? undefined,
mvtId,
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@ import {
hasCmpConsentForBrowserId,
hasCmpConsentForWeeklyArticleCount,
hasOptedOutOfArticleCount,
isRecurringContributor,
shouldHideSupportMessaging,
} from '../../lib/contributions';
import { lazyFetchEmailWithTimeout } from '../../lib/fetchEmail';
@@ -70,9 +69,6 @@ const buildPayload = async (
isPaidContent: data.isPaidContent,
tags: data.tags,
showSupportMessaging: !data.hideSupportMessagingForUser,
isRecurringContributor: isRecurringContributor(
data.isSignedIn ?? false,
),
lastOneOffContributionDate: getLastOneOffContributionTimestamp(),
epicViewLog: getEpicViewLog(storage.local),
weeklyArticleHistory: await data.asyncArticleCount,
36 changes: 1 addition & 35 deletions dotcom-rendering/src/lib/contributions.ts
Original file line number Diff line number Diff line change
@@ -61,36 +61,6 @@ export const hasSupporterCookie = (
}
};

// Determine if user is a recurring contributor by checking if they are signed in
// AND have at least one of the relevant cookies.
// We need to look at both User Attributes and Frontend Support cookies
// as the former might not reflect the latest contributor status, since it's set upon signing in.
// Frontend Support cookies are set when a contribution is made.
export const isRecurringContributor = (isSignedIn: boolean): boolean => {
// Attributes cookie - we want this to have a specific value
const isRecurringContributorFromAttrs =
getCookie({ name: RECURRING_CONTRIBUTOR_COOKIE }) === 'true';

// Support cookies - we only care whether these exist
const hasMonthlyContributionCookie =
getCookie({
name: SUPPORT_RECURRING_CONTRIBUTOR_MONTHLY_COOKIE,
shouldMemoize: true,
}) !== null;
const hasAnnualContributionCookie =
getCookie({
name: SUPPORT_RECURRING_CONTRIBUTOR_ANNUAL_COOKIE,
shouldMemoize: true,
}) !== null;

return (
isSignedIn &&
(isRecurringContributorFromAttrs ||
hasMonthlyContributionCookie ||
hasAnnualContributionCookie)
);
};

// looks at attribute and support cookies
// ONE_OFF_CONTRIBUTION_DATE_COOKIE (attributes cookie, when loggin in)
// SUPPORT_ONE_OFF_CONTRIBUTION_COOKIE (support cookie, when making one-off contribution)
@@ -168,11 +138,7 @@ export const shouldHideSupportMessaging = (
if (hasCookie === 'Pending') {
return 'Pending';
} else {
return (
hasCookie ||
isRecurringContributor(isSignedIn) ||
isRecentOneOffContributor()
);
return hasCookie || isRecentOneOffContributor();
}
};

0 comments on commit 4c77c6f

Please sign in to comment.