Skip to content

Commit 9bf21cb

Browse files
author
Juarez Mota
committed
Skip SDC request for surfaces that can never show sign-in gate
Non-article surfaces outside NZ are filtered out early to avoid unnecessary SDC requests, since Gandalf gates only appear on articles (except in NZ where fronts are also eligible).
1 parent 458e931 commit 9bf21cb

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

dotcom-rendering/src/components/StickyBottomBanner/SignInGatePortal.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,26 @@ describe('SignInGatePortal', () => {
213213
});
214214

215215
describe('Gandalf (Guardian-managed sign-in gate journey)', () => {
216+
it('makes no request to SDC for surfaces that can never display the gate', async () => {
217+
mockGetElementById.mockReturnValue(document.createElement('div'));
218+
(
219+
buildAuxiaGateDisplayData as jest.MockedFunction<
220+
typeof buildAuxiaGateDisplayData
221+
>
222+
).mockResolvedValue(makeAuxiaReturn(undefined, true));
223+
224+
// A front in GB: not an article, not a Gandalf country. The gate
225+
// decision is predetermined, so SDC is not contacted at all.
226+
const result = await canShowSignInGatePortal({
227+
...canShowProps,
228+
contentType: 'Network Front',
229+
countryCode: 'GB',
230+
});
231+
232+
expect(result).toEqual({ show: false });
233+
expect(buildAuxiaGateDisplayData).not.toHaveBeenCalled();
234+
});
235+
216236
it('returns no gate but carries the marker metadata on a free Gandalf pageview', async () => {
217237
mockGetElementById.mockReturnValue(document.createElement('div'));
218238
(

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ export const canShowSignInGatePortal = async ({
195195
return Promise.resolve({ show: false });
196196
}
197197

198+
// Gandalf (comment group: gandalf) — the Guardian-managed sign-in gate
199+
// journey is currently New Zealand only, and every other country gates on
200+
// articles only. Surfaces that can never display the gate (e.g. a front in
201+
// GB) are filtered out here so they make no request to SDC at all.
202+
if (contentType !== 'Article' && countryCode !== 'NZ') {
203+
return Promise.resolve({ show: false });
204+
}
205+
198206
try {
199207
const auxiaData = await buildAuxiaGateDisplayData(
200208
contributionsServiceUrl,

0 commit comments

Comments
 (0)