diff --git a/dotcom-rendering/src/client/userFeatures/user-features.test.ts b/dotcom-rendering/src/client/userFeatures/user-features.test.ts index e96a1fc0eec..a720abd3697 100644 --- a/dotcom-rendering/src/client/userFeatures/user-features.test.ts +++ b/dotcom-rendering/src/client/userFeatures/user-features.test.ts @@ -35,18 +35,11 @@ const getAuthStatus = getAuthStatus_ as jest.MockedFunction< const PERSISTENCE_KEYS = { USER_FEATURES_EXPIRY_COOKIE: 'gu_user_features_expiry', - PAYING_MEMBER_COOKIE: 'gu_paying_member', - RECURRING_CONTRIBUTOR_COOKIE: 'gu_recurring_contributor', AD_FREE_USER_COOKIE: 'GU_AF1', ACTION_REQUIRED_FOR_COOKIE: 'gu_action_required_for', DIGITAL_SUBSCRIBER_COOKIE: 'gu_digital_subscriber', SUPPORT_ONE_OFF_CONTRIBUTION_COOKIE: 'gu.contributions.contrib-timestamp', - ONE_OFF_CONTRIBUTION_DATE_COOKIE: 'gu_one_off_contribution_date', HIDE_SUPPORT_MESSAGING_COOKIE: 'gu_hide_support_messaging', - SUPPORT_MONTHLY_CONTRIBUTION_COOKIE: - 'gu.contributions.recurring.contrib-timestamp.Monthly', - SUPPORT_ANNUAL_CONTRIBUTION_COOKIE: - 'gu.contributions.recurring.contrib-timestamp.Annual', }; const setAllFeaturesData = (opts: { isExpired: boolean }) => { @@ -58,11 +51,6 @@ const setAllFeaturesData = (opts: { isExpired: boolean }) => { const adFreeExpiryDate = opts.isExpired ? new Date(currentTime - msInOneDay * 2) : new Date(currentTime + msInOneDay * 2); - setCookie({ name: PERSISTENCE_KEYS.PAYING_MEMBER_COOKIE, value: 'true' }); - setCookie({ - name: PERSISTENCE_KEYS.RECURRING_CONTRIBUTOR_COOKIE, - value: 'true', - }); setCookie({ name: PERSISTENCE_KEYS.DIGITAL_SUBSCRIBER_COOKIE, value: 'true', @@ -86,8 +74,6 @@ const setAllFeaturesData = (opts: { isExpired: boolean }) => { }; const deleteAllFeaturesData = () => { - removeCookie({ name: PERSISTENCE_KEYS.PAYING_MEMBER_COOKIE }); - removeCookie({ name: PERSISTENCE_KEYS.RECURRING_CONTRIBUTOR_COOKIE }); removeCookie({ name: PERSISTENCE_KEYS.DIGITAL_SUBSCRIBER_COOKIE }); removeCookie({ name: PERSISTENCE_KEYS.USER_FEATURES_EXPIRY_COOKIE }); removeCookie({ name: PERSISTENCE_KEYS.AD_FREE_USER_COOKIE }); @@ -125,14 +111,6 @@ describe('Refreshing the features data', () => { it('Does not delete the data just because it has expired', async () => { setAllFeaturesData({ isExpired: true }); await refresh(); - expect( - getCookie({ name: PERSISTENCE_KEYS.PAYING_MEMBER_COOKIE }), - ).toBe('true'); - expect( - getCookie({ - name: PERSISTENCE_KEYS.RECURRING_CONTRIBUTOR_COOKIE, - }), - ).toBe('true'); expect( getCookie({ name: PERSISTENCE_KEYS.USER_FEATURES_EXPIRY_COOKIE, @@ -148,15 +126,6 @@ describe('Refreshing the features data', () => { await refresh(); expect(fetchJsonSpy).not.toHaveBeenCalled(); }); - - it('Performs an update if membership-frontend wipes just the paying-member cookie', async () => { - // Set everything except paying-member cookie - setAllFeaturesData({ isExpired: true }); - removeCookie({ name: PERSISTENCE_KEYS.PAYING_MEMBER_COOKIE }); - - await refresh(); - expect(fetchJsonSpy).toHaveBeenCalledTimes(1); - }); }); }); describe('If user signed out', () => { @@ -178,14 +147,6 @@ describe('If user signed out', () => { expect( getCookie({ name: PERSISTENCE_KEYS.AD_FREE_USER_COOKIE }), ).toBeNull(); - expect( - getCookie({ name: PERSISTENCE_KEYS.PAYING_MEMBER_COOKIE }), - ).toBeNull(); - expect( - getCookie({ - name: PERSISTENCE_KEYS.RECURRING_CONTRIBUTOR_COOKIE, - }), - ).toBeNull(); expect( getCookie({ name: PERSISTENCE_KEYS.DIGITAL_SUBSCRIBER_COOKIE }), ).toBeNull(); @@ -270,14 +231,6 @@ describe('Storing new feature data', () => { }), ); return refresh().then(() => { - expect( - getCookie({ name: PERSISTENCE_KEYS.PAYING_MEMBER_COOKIE }), - ).toBe('false'); - expect( - getCookie({ - name: PERSISTENCE_KEYS.RECURRING_CONTRIBUTOR_COOKIE, - }), - ).toBe('false'); expect( getCookie({ name: PERSISTENCE_KEYS.DIGITAL_SUBSCRIBER_COOKIE }), ).toBe('false'); @@ -300,14 +253,6 @@ describe('Storing new feature data', () => { }), ); return refresh().then(() => { - expect( - getCookie({ name: PERSISTENCE_KEYS.PAYING_MEMBER_COOKIE }), - ).toBe('true'); - expect( - getCookie({ - name: PERSISTENCE_KEYS.RECURRING_CONTRIBUTOR_COOKIE, - }), - ).toBe('true'); expect( getCookie({ name: PERSISTENCE_KEYS.DIGITAL_SUBSCRIBER_COOKIE }), ).toBe('true'); diff --git a/dotcom-rendering/src/client/userFeatures/user-features.ts b/dotcom-rendering/src/client/userFeatures/user-features.ts index 6229e1ef83f..333c9a2424f 100644 --- a/dotcom-rendering/src/client/userFeatures/user-features.ts +++ b/dotcom-rendering/src/client/userFeatures/user-features.ts @@ -27,15 +27,11 @@ import { import type { UserFeaturesResponse } from './user-features-lib'; const USER_FEATURES_EXPIRY_COOKIE = 'gu_user_features_expiry'; -const PAYING_MEMBER_COOKIE = 'gu_paying_member'; const ACTION_REQUIRED_FOR_COOKIE = 'gu_action_required_for'; const DIGITAL_SUBSCRIBER_COOKIE = 'gu_digital_subscriber'; const HIDE_SUPPORT_MESSAGING_COOKIE = 'gu_hide_support_messaging'; const AD_FREE_USER_COOKIE = 'GU_AF1'; -const RECURRING_CONTRIBUTOR_COOKIE = 'gu_recurring_contributor'; -const ONE_OFF_CONTRIBUTION_DATE_COOKIE = 'gu_one_off_contribution_date'; - const forcedAdFreeMode = !!/[#&]noadsaf(&.*)?$/.exec(window.location.hash); const userHasData = () => { @@ -43,9 +39,6 @@ const userHasData = () => { getAdFreeCookie() ?? getCookie({ name: ACTION_REQUIRED_FOR_COOKIE }) ?? getCookie({ name: USER_FEATURES_EXPIRY_COOKIE }) ?? - getCookie({ name: PAYING_MEMBER_COOKIE }) ?? - getCookie({ name: RECURRING_CONTRIBUTOR_COOKIE }) ?? - getCookie({ name: ONE_OFF_CONTRIBUTION_DATE_COOKIE }) ?? getCookie({ name: DIGITAL_SUBSCRIBER_COOKIE }) ?? getCookie({ name: HIDE_SUPPORT_MESSAGING_COOKIE }); return !!cookie; @@ -69,14 +62,6 @@ const persistResponse = (JsonResponse: UserFeaturesResponse) => { name: USER_FEATURES_EXPIRY_COOKIE, value: timeInDaysFromNow(1), }); - setCookie({ - name: PAYING_MEMBER_COOKIE, - value: String(JsonResponse.contentAccess.paidMember), - }); - setCookie({ - name: RECURRING_CONTRIBUTOR_COOKIE, - value: String(JsonResponse.contentAccess.recurringContributor), - }); setCookie({ name: DIGITAL_SUBSCRIBER_COOKIE, value: String(JsonResponse.contentAccess.digitalPack), @@ -85,12 +70,6 @@ const persistResponse = (JsonResponse: UserFeaturesResponse) => { name: HIDE_SUPPORT_MESSAGING_COOKIE, value: String(!JsonResponse.showSupportMessaging), }); - if (JsonResponse.oneOffContributionDate) { - setCookie({ - name: ONE_OFF_CONTRIBUTION_DATE_COOKIE, - value: JsonResponse.oneOffContributionDate, - }); - } removeCookie({ name: ACTION_REQUIRED_FOR_COOKIE }); if (JsonResponse.alertAvailableFor) { @@ -110,12 +89,9 @@ const persistResponse = (JsonResponse: UserFeaturesResponse) => { const deleteOldData = (): void => { removeCookie({ name: AD_FREE_USER_COOKIE }); removeCookie({ name: USER_FEATURES_EXPIRY_COOKIE }); - removeCookie({ name: PAYING_MEMBER_COOKIE }); - removeCookie({ name: RECURRING_CONTRIBUTOR_COOKIE }); removeCookie({ name: ACTION_REQUIRED_FOR_COOKIE }); removeCookie({ name: DIGITAL_SUBSCRIBER_COOKIE }); removeCookie({ name: HIDE_SUPPORT_MESSAGING_COOKIE }); - removeCookie({ name: ONE_OFF_CONTRIBUTION_DATE_COOKIE }); }; const requestNewData = () => { diff --git a/dotcom-rendering/src/lib/contributions.ts b/dotcom-rendering/src/lib/contributions.ts index 9729ce31fde..59c03659964 100644 --- a/dotcom-rendering/src/lib/contributions.ts +++ b/dotcom-rendering/src/lib/contributions.ts @@ -16,11 +16,7 @@ export const HIDE_SUPPORT_MESSAGING_COOKIE = 'gu_hide_support_messaging'; export const RECURRING_CONTRIBUTOR_COOKIE = 'gu_recurring_contributor'; export const OPT_OUT_OF_ARTICLE_COUNT_COOKIE = 'gu_article_count_opt_out'; -// Support Frontend cookies (created when a contribution is made) -export const SUPPORT_RECURRING_CONTRIBUTOR_MONTHLY_COOKIE = - 'gu.contributions.recurring.contrib-timestamp.Monthly'; // TODO: delete this, no longer needed -export const SUPPORT_RECURRING_CONTRIBUTOR_ANNUAL_COOKIE = - 'gu.contributions.recurring.contrib-timestamp.Annual'; // TODO: delete this, no longer needed +// Support Frontend cookie (created when a contribution is made) export const SUPPORT_ONE_OFF_CONTRIBUTION_COOKIE = 'gu.contributions.contrib-timestamp'; diff --git a/dotcom-rendering/src/lib/readerRevenueDevUtils.ts b/dotcom-rendering/src/lib/readerRevenueDevUtils.ts index 082407e1177..53f2975ab72 100644 --- a/dotcom-rendering/src/lib/readerRevenueDevUtils.ts +++ b/dotcom-rendering/src/lib/readerRevenueDevUtils.ts @@ -3,16 +3,12 @@ import { HIDE_SUPPORT_MESSAGING_COOKIE, RECURRING_CONTRIBUTOR_COOKIE, SUPPORT_ONE_OFF_CONTRIBUTION_COOKIE, - SUPPORT_RECURRING_CONTRIBUTOR_ANNUAL_COOKIE, - SUPPORT_RECURRING_CONTRIBUTOR_MONTHLY_COOKIE, } from './contributions'; import { getLocaleCode } from './getCountryCode'; const readerRevenueCookies = [ HIDE_SUPPORT_MESSAGING_COOKIE, RECURRING_CONTRIBUTOR_COOKIE, - SUPPORT_RECURRING_CONTRIBUTOR_MONTHLY_COOKIE, - SUPPORT_RECURRING_CONTRIBUTOR_ANNUAL_COOKIE, SUPPORT_ONE_OFF_CONTRIBUTION_COOKIE, ];