Skip to content

Commit 8ddc724

Browse files
committed
add logs for supporter revenue banner decisions and include decision on window object
1 parent c9cabe5 commit 8ddc724

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

dotcom-rendering/src/components/ReaderRevenueDev.importable.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export const ReaderRevenueDev = ({ shouldHideReaderRevenue }: Props) => {
99
useEffect(() => {
1010
// Used internally only, so only import each function on demand
1111
const loadAndRun =
12-
<K extends keyof ReaderRevenueDevUtils>(key: K) =>
12+
<K extends keyof Omit<ReaderRevenueDevUtils, 'bannerToShow'>>(
13+
key: K,
14+
) =>
1315
(asExistingSupporter: boolean) =>
1416
import(
1517
/* webpackChunkName: "readerRevenueDevUtils" */ '../lib/readerRevenueDevUtils'
@@ -36,6 +38,7 @@ export const ReaderRevenueDev = ({ shouldHideReaderRevenue }: Props) => {
3638
showMeTheBanner: loadAndRun('showMeTheBanner'),
3739
showNextVariant: loadAndRun('showNextVariant'),
3840
showPreviousVariant: loadAndRun('showPreviousVariant'),
41+
bannerToShow: null,
3942
};
4043
}
4144
}, [shouldHideReaderRevenue]);

dotcom-rendering/src/components/StickyBottomBanner.importable.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {
33
BrazeMessagesInterface,
44
} from '@guardian/braze-components/logic';
55
import type { CountryCode } from '@guardian/libs';
6-
import { cmp, isString, isUndefined, storage } from '@guardian/libs';
6+
import { cmp, isString, isUndefined, log, storage } from '@guardian/libs';
77
import type { ModuleData } from '@guardian/support-dotcom-components/dist/dotcom/types';
88
import type { BannerProps } from '@guardian/support-dotcom-components/dist/shared/types';
99
import { useEffect, useState } from 'react';
@@ -72,6 +72,8 @@ const buildCmpBannerConfig = (): CandidateConfig<void> => ({
7272
result ? { show: true, meta: undefined } : { show: false },
7373
),
7474
show: () => {
75+
log('supporterRevenue', `Showing CMP UI`);
76+
window.guardian.readerRevenue.bannerToShow = 'cmpUi';
7577
// New CMP is not a react component and is shown outside of react's world
7678
// so render nothing if it will show
7779
return null;
@@ -160,9 +162,11 @@ const buildRRBannerConfigWith = ({
160162
ophanPageViewId,
161163
pageId,
162164
}),
163-
show:
164-
({ name, props }: ModuleData<BannerProps>) =>
165-
() => <BannerComponent name={name} props={props} />,
165+
show: ({ name, props }: ModuleData<BannerProps>) => {
166+
log('supporterRevenue', `Showing banner: ${name}`);
167+
window.guardian.readerRevenue.bannerToShow = name;
168+
return () => <BannerComponent name={name} props={props} />;
169+
},
166170
},
167171
timeoutMillis: DEFAULT_BANNER_TIMEOUT_MILLIS,
168172
};
@@ -193,9 +197,11 @@ const buildBrazeBanner = (
193197
tags,
194198
shouldHideReaderRevenue,
195199
),
196-
show: (meta: any) => () => (
197-
<BrazeBanner meta={meta} idApiUrl={idApiUrl} />
198-
),
200+
show: (meta: any) => () => {
201+
log('supporterRevenue', `Showing banner: braze-banner`);
202+
window.guardian.readerRevenue.bannerToShow = 'braze-banner';
203+
return <BrazeBanner meta={meta} idApiUrl={idApiUrl} />;
204+
},
199205
},
200206
timeoutMillis: DEFAULT_BANNER_TIMEOUT_MILLIS,
201207
});

dotcom-rendering/src/lib/messagePicker.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isUndefined, startPerformanceMeasure } from '@guardian/libs';
1+
import { isUndefined, log, startPerformanceMeasure } from '@guardian/libs';
22
import { getOphan } from '../client/ophan/ophan';
33
import type { RenderingTarget } from '../types/renderingTarget';
44

@@ -165,9 +165,17 @@ export const pickMessage = (
165165
clearAllTimeouts(candidateConfigsWithTimeout);
166166

167167
if (winner === null) {
168+
log(
169+
'supporterRevenue',
170+
`pickMessage for ${name}: no winner, returning default value`,
171+
);
168172
resolve(defaultShow);
169173
} else {
170174
const { candidate, meta } = winner;
175+
log(
176+
'supporterRevenue',
177+
`pickMessage for ${name}: winner is ${candidate.id}`,
178+
);
171179
resolve(() => candidate.show(meta));
172180
}
173181
})

dotcom-rendering/src/lib/readerRevenueDevUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export interface ReaderRevenueDevUtils {
161161
showMeTheBanner: ReaderRevenueDevUtil;
162162
showNextVariant: ReaderRevenueDevUtil;
163163
showPreviousVariant: ReaderRevenueDevUtil;
164+
bannerToShow: string | null;
164165
}
165166

166167
const getForcedVariant = (type: 'epic' | 'banner'): string | null => {

0 commit comments

Comments
 (0)