Skip to content

Commit 458e931

Browse files
author
Juarez Mota
committed
Drop redundant gandalfPageViewCount in favour of dailyArticleCount
gandalfPageViewCount duplicated dailyArticleCount (same gu.history.dailyArticleCount source, sent 0-based instead of 1-based). SDC now applies the Gandalf free-allowance rule to the existing dailyArticleCount field the client already sends.
1 parent f3ad760 commit 458e931

5 files changed

Lines changed: 12 additions & 93 deletions

File tree

dotcom-rendering/playwright/tests/banner.e2e.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ test.describe('Sign-in gate portal', function () {
167167
const auxiaRequest = await auxiaRequestPromise;
168168
const body = auxiaRequest.postDataJSON() as Record<string, unknown>;
169169
expect(body.countryCode).toBe('NZ');
170-
// Two article loads today (each increments gu.history.dailyArticleCount),
171-
// sent 0-based, so the second load sends 1.
172-
expect(body.gandalfPageViewCount).toBe(1);
170+
// Two article loads today, each increments gu.history.dailyArticleCount
171+
// including the current pageview, so the second load sends 2.
172+
expect(body.dailyArticleCount).toBe(2);
173173
});
174174
});
175175

dotcom-rendering/src/components/SignInGate/types.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ export interface AuxiaProxyGetTreatmentsPayload {
137137
showDefaultGate: ShowGateValues; // [3]
138138
gateDisplayCount: number;
139139
hideSupportMessagingTimestamp: number | undefined; // [4]
140-
gandalfPageViewCount?: number; // [5] gandalfPageViewCount
141140
}
142141

143142
// [1]
@@ -184,21 +183,17 @@ export interface AuxiaProxyGetTreatmentsPayload {
184183
// It is either undefined or return the timestamp carried by cookie `gu_hide_support_messaging`
185184
// See: https://github.com/guardian/support-frontend/blob/7a5c0f9209054c24934b876771392531c261f51c/support-frontend/assets/helpers/storage/contributionsCookies.ts#L11
186185

187-
// [5] gandalfPageViewCount
186+
// [5] (comment group: gandalf)
188187
//
189188
// date: 2nd September 2026
190-
// comment group: gandalf
191189
//
192190
// "Gandalf" is the marketing name for the Guardian-managed sign-in gate
193191
// journey: a 100% rollout run entirely by Guardian rules with no Auxia
194192
// involvement, currently live for New Zealand and extendable to further
195-
// countries via the gandalfSignInGateCountries channel switch.
196-
//
197-
// `gandalfPageViewCount` is the 0-based number of views the reader has
198-
// already completed today (gu.history.dailyArticleCount, see
199-
// src/lib/dailyArticleCount.ts). It is optional so older payloads and traffic
200-
// outside the Gandalf countries are unaffected; SDC treats a missing value
201-
// as 0.
193+
// countries via the gandalfSignInGateCountries channel switch. SDC drives
194+
// the journey from the standard dailyArticleCount field (the reader's
195+
// pageview count for the current day, including this pageview) — see
196+
// gandalfSignInGate on AuxiaProxyGetTreatmentsProxyResponseData below.
202197

203198
export interface AuxiaProxyGetTreatmentsResponse {
204199
status: boolean;
@@ -209,10 +204,10 @@ export interface AuxiaProxyGetTreatmentsProxyResponseData {
209204
responseId: string;
210205
userTreatment?: AuxiaAPIResponseDataUserTreatment;
211206
// Set to true on responses produced by the active Gandalf rules, both
212-
// when no gate should display (the pageview still counts towards the free
213-
// allowance) and when the Guardian-managed non-dismissible popup is
214-
// returned. When present, the client must not make any Auxia interaction
215-
// call and reports to Ophan under the stable Gandalf identity.
207+
// when no gate should display and when the Guardian-managed
208+
// non-dismissible popup is returned. When present, the client must not
209+
// make any Auxia interaction call and reports to Ophan under the stable
210+
// Gandalf identity.
216211
gandalfSignInGate?: boolean;
217212
}
218213

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

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Mock the auxia module before imports so the mock is applied when the module
22
// under test is evaluated.
33
import { buildAuxiaGateDisplayData } from '../../lib/auxia';
4-
import { getDailyArticleCount, getToday } from '../../lib/dailyArticleCount';
54
import type { AuxiaAPIResponseDataUserTreatment } from '../SignInGate/types';
65
import type { AuxiaGateDisplayData } from '../SignInGate/types';
76
import type { CanShowSignInGateProps } from './SignInGatePortal';
@@ -12,20 +11,12 @@ jest.mock('../../lib/auxia', () => ({
1211
buildAuxiaGateDisplayData: jest.fn(),
1312
}));
1413

15-
jest.mock('../../lib/dailyArticleCount', () => ({
16-
getDailyArticleCount: jest.fn().mockReturnValue(undefined),
17-
getToday: jest.fn().mockReturnValue(200),
18-
}));
19-
2014
// Mock document.getElementById
2115
const mockGetElementById = jest.fn();
2216
Object.defineProperty(document, 'getElementById', {
2317
value: mockGetElementById,
2418
});
2519

26-
const mockGetDailyArticleCount = jest.mocked(getDailyArticleCount);
27-
const mockGetToday = jest.mocked(getToday);
28-
2920
const canShowProps: CanShowSignInGateProps = {
3021
isSignedIn: false,
3122
isPaidContent: false,
@@ -222,56 +213,6 @@ describe('SignInGatePortal', () => {
222213
});
223214

224215
describe('Gandalf (Guardian-managed sign-in gate journey)', () => {
225-
it('sends today’s view count (0-based) to SDC', async () => {
226-
mockGetElementById.mockReturnValue(document.createElement('div'));
227-
// 4 views today: the current pageview is included, so the portal
228-
// sends 3 (0-based).
229-
mockGetDailyArticleCount.mockReturnValue([{ day: 200, count: 4 }]);
230-
mockGetToday.mockReturnValue(200);
231-
(
232-
buildAuxiaGateDisplayData as jest.MockedFunction<
233-
typeof buildAuxiaGateDisplayData
234-
>
235-
).mockResolvedValue(makeAuxiaReturn(undefined, true));
236-
237-
await canShowSignInGatePortal(canShowProps);
238-
239-
expect(buildAuxiaGateDisplayData).toHaveBeenCalledWith(
240-
'https://contributions.local',
241-
'page-id',
242-
'UK',
243-
'Article',
244-
'section',
245-
[],
246-
0,
247-
3,
248-
);
249-
});
250-
251-
it('sends 0 when the latest daily count is not from today', async () => {
252-
mockGetElementById.mockReturnValue(document.createElement('div'));
253-
mockGetDailyArticleCount.mockReturnValue([{ day: 199, count: 9 }]);
254-
mockGetToday.mockReturnValue(200);
255-
(
256-
buildAuxiaGateDisplayData as jest.MockedFunction<
257-
typeof buildAuxiaGateDisplayData
258-
>
259-
).mockResolvedValue(makeAuxiaReturn(undefined, true));
260-
261-
await canShowSignInGatePortal(canShowProps);
262-
263-
expect(buildAuxiaGateDisplayData).toHaveBeenCalledWith(
264-
'https://contributions.local',
265-
'page-id',
266-
'UK',
267-
'Article',
268-
'section',
269-
[],
270-
0,
271-
0,
272-
);
273-
});
274-
275216
it('returns no gate but carries the marker metadata on a free Gandalf pageview', async () => {
276217
mockGetElementById.mockReturnValue(document.createElement('div'));
277218
(

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { CountryCode } from '@guardian/libs';
22
import { useCallback, useEffect, useMemo, useState } from 'react';
33
import { createPortal } from 'react-dom';
44
import { buildAuxiaGateDisplayData } from '../../lib/auxia';
5-
import { getDailyArticleCount, getToday } from '../../lib/dailyArticleCount';
65
import type { EditionId } from '../../lib/edition';
76
import type { CanShowResult } from '../../lib/messagePicker';
87
import { useAuthStatus } from '../../lib/useAuthStatus';
@@ -197,17 +196,6 @@ export const canShowSignInGatePortal = async ({
197196
}
198197

199198
try {
200-
// Today's view count (gu.history.dailyArticleCount). The count is
201-
// incremented for the current pageview before the banner flow runs,
202-
// so it is 1-based: the 4th view of the day sends 3. SDC only
203-
// consumes this for active Gandalf traffic.
204-
const dailyHistory = getDailyArticleCount();
205-
const latestDay = dailyHistory?.[0];
206-
const viewCountToday =
207-
latestDay?.day === getToday()
208-
? Math.max(latestDay.count - 1, 0)
209-
: 0;
210-
211199
const auxiaData = await buildAuxiaGateDisplayData(
212200
contributionsServiceUrl,
213201
pageId,
@@ -216,7 +204,6 @@ export const canShowSignInGatePortal = async ({
216204
sectionId,
217205
tags,
218206
retrieveLastGateDismissedCount('AuxiaSignInGate'),
219-
viewCountToday,
220207
);
221208

222209
const meta = (

dotcom-rendering/src/lib/auxia.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ const fetchProxyGetTreatments = async (
125125
showDefaultGate: ShowGateValues,
126126
gateDisplayCount: number,
127127
hideSupportMessagingTimestamp: number | undefined,
128-
gandalfPageViewCount?: number,
129128
): Promise<AuxiaProxyGetTreatmentsResponse> => {
130129
const articleIdentifier = `www.theguardian.com/${pageId}`;
131130
const url = `${contributionsServiceUrl}/auxia/get-treatments`;
@@ -148,7 +147,6 @@ const fetchProxyGetTreatments = async (
148147
showDefaultGate,
149148
gateDisplayCount,
150149
hideSupportMessagingTimestamp,
151-
gandalfPageViewCount,
152150
};
153151

154152
const params = { method: 'POST', headers, body: JSON.stringify(payload) };
@@ -217,7 +215,6 @@ export const buildAuxiaGateDisplayData = async (
217215
sectionId: string,
218216
tags: TagType[],
219217
gateDismissCount: number,
220-
gandalfPageViewCount?: number,
221218
): Promise<AuxiaGateDisplayData | undefined> => {
222219
const readerPersonalData = await decideAuxiaProxyReaderPersonalData();
223220
const tagIds = tags.map((tag) => tag.id);
@@ -245,7 +242,6 @@ export const buildAuxiaGateDisplayData = async (
245242
showDefaultGate,
246243
gateDisplayCount,
247244
hideSupportMessagingTimestamp,
248-
gandalfPageViewCount,
249245
);
250246

251247
if (response.status && response.data) {

0 commit comments

Comments
 (0)