Skip to content

Commit

Permalink
Setup test for new prebid analytics endpoint (#1654)
Browse files Browse the repository at this point in the history
Co-authored-by: Emma Imber <[email protected]>
  • Loading branch information
Jakeii and emma-imber authored Nov 11, 2024
1 parent 87891ab commit 877f516
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-pants-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@guardian/commercial': minor
---

Setup test for new prebid analytics endpoint
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
},
"dependencies": {
"@changesets/cli": "^2.26.2",
"@guardian/prebid.js": "8.52.0-7",
"@guardian/prebid.js": "8.52.0-8",
"@octokit/core": "^6.1.2",
"fastdom": "^1.0.11",
"lodash-es": "^4.17.21",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/experiments/ab-tests.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ABTest } from '@guardian/ab-core';
import { mpuWhenNoEpic } from './tests/mpu-when-no-epic';
import { newHeaderBiddingEndpoint } from './tests/new-header-bidding-endpoint';
import { optOutFrequencyCap } from './tests/opt-out-frequency-cap';

/**
Expand All @@ -11,4 +12,5 @@ export const concurrentTests: ABTest[] = [
// one test per line
mpuWhenNoEpic,
optOutFrequencyCap,
newHeaderBiddingEndpoint,
];
28 changes: 28 additions & 0 deletions src/experiments/tests/new-header-bidding-endpoint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { ABTest } from '@guardian/ab-core';

export const newHeaderBiddingEndpoint: ABTest = {
id: 'newHeaderBiddingEndpoint',
author: '@commercial-dev',
start: '2024-11-11',
expiry: '2024-11-30',
audience: 0 / 100,
audienceOffset: 0 / 100,
audienceCriteria: '',
successMeasure: '',
description: 'Test new header bidding (prebid) analytics endpoint.',
variants: [
{
id: 'control',
test: (): void => {
/* no-op */
},
},
{
id: 'variant',
test: (): void => {
/* no-op */
},
},
],
canRun: () => true,
};
9 changes: 9 additions & 0 deletions src/lib/header-bidding/prebid/prebid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { PREBID_TIMEOUT } from '../../../core/constants/prebid-timeout';
import { EventTimer } from '../../../core/event-timer';
import type { PageTargeting } from '../../../core/targeting/build-page-targeting';
import type { Advert } from '../../../define/Advert';
import { isUserInVariant } from '../../../experiments/ab';
import { newHeaderBiddingEndpoint } from '../../../experiments/tests/new-header-bidding-endpoint';
import { getPageTargeting } from '../../build-page-targeting';
import { getAdvertById } from '../../dfp/get-advert-by-id';
import { isUserLoggedInOktaRefactor } from '../../identity/api';
Expand Down Expand Up @@ -124,6 +126,8 @@ type EnableAnalyticsConfig = {
options: {
ajaxUrl: string;
pv: string;
enableV2Endpoint: boolean;
ajaxUrlV2: string;
};
};

Expand Down Expand Up @@ -423,6 +427,11 @@ const initialise = (
options: {
ajaxUrl: window.guardian.config.page.ajaxUrl ?? '',
pv: window.guardian.ophan.pageViewId,
enableV2Endpoint: isUserInVariant(
newHeaderBiddingEndpoint,
'variant',
),
ajaxUrlV2: `//performance-events.code.dev-guardianapis.com/header-bidding`,
},
},
]);
Expand Down

0 comments on commit 877f516

Please sign in to comment.