Skip to content

Commit

Permalink
No more regional prebid (#1765)
Browse files Browse the repository at this point in the history
* Use single version of prebid

* Changeset
  • Loading branch information
emma-imber authored Jan 29, 2025
1 parent c3bb849 commit 9bc278c
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 66 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-carpets-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@guardian/commercial': minor
---

Use a single version of prebid instead of splitting by region
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"webpack-merge": "^6.0.1"
},
"dependencies": {
"@guardian/prebid.js": "8.52.0-11",
"@guardian/prebid.js": "8.52.0-12",
"fastdom": "^1.0.12",
"lodash-es": "^4.17.21",
"process": "^0.11.10",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

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

2 changes: 0 additions & 2 deletions src/experiments/ab-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { gpidPrebidAdUnits } from './tests/gpid-prebid';
import { mpuWhenNoEpic } from './tests/mpu-when-no-epic';
import { optOutFrequencyCap } from './tests/opt-out-frequency-cap';
import { prebidKeywords } from './tests/prebid-keywords';
import { regionSpecificPrebid } from './tests/region-specific-prebid';

/**
* You only need to add tests to this file if the code you are testing is here in
Expand All @@ -15,6 +14,5 @@ export const concurrentTests: ABTest[] = [
mpuWhenNoEpic,
optOutFrequencyCap,
gpidPrebidAdUnits,
regionSpecificPrebid,
prebidKeywords,
];
29 changes: 0 additions & 29 deletions src/experiments/tests/region-specific-prebid.ts

This file was deleted.

27 changes: 3 additions & 24 deletions src/init/consented/prepare-prebid.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import type { ConsentFramework } from '@guardian/libs';
import { getConsentFor, log, onConsent } from '@guardian/libs';
import { once } from 'lodash-es';
import { isUserInVariant } from '../../experiments/ab';
import { regionSpecificPrebid } from '../../experiments/tests/region-specific-prebid';
import { commercialFeatures } from '../../lib/commercial-features';
import { isGoogleProxy } from '../../lib/detect/detect-google-proxy';
import {
isInAuOrNz,
isInCanada,
isInUk,
isInUsa,
} from '../../lib/geo/geo-utils';
import { isInCanada } from '../../lib/geo/geo-utils';
import { prebid } from '../../lib/header-bidding/prebid/prebid';
import { shouldIncludeOnlyA9 } from '../../lib/header-bidding/utils';

Expand All @@ -23,25 +16,11 @@ const shouldLoadPrebid = () =>
!shouldIncludeOnlyA9 &&
!isInCanada();

const prebidVersion = () => {
if (isUserInVariant(regionSpecificPrebid, 'variant')) {
if (isInUk()) {
return 'uk';
} else if (isInAuOrNz()) {
return 'aus-nz';
} else if (isInUsa()) {
return 'us';
}
return 'row';
}
return 'all';
};

const loadPrebid = async (framework: ConsentFramework): Promise<void> => {
if (shouldLoadPrebid()) {
await import(
/* webpackChunkName: "Prebid.js" */
`@guardian/prebid.js/build/dist/${prebidVersion()}/prebid`
// @ts-expect-error -- there’s no types for Prebid.js
/* webpackChunkName: "Prebid.js" */ '@guardian/prebid.js/build/dist/prebid'
);
prebid.initialise(window, framework);
}
Expand Down
6 changes: 1 addition & 5 deletions src/lib/header-bidding/prebid/prebid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@ jest.mock('lib/dfp/get-advert-by-id', () => ({
getAdvertById: jest.fn(),
}));

jest.mock('experiments/ab', () => ({
isUserInVariant: jest.fn(),
}));

const resetPrebid = () => {
delete window.pbjs;
// @ts-expect-error -- there’s no types for this
delete window.pbjsChunk;
jest.resetModules();
jest.requireActual('@guardian/prebid.js/build/dist/all/prebid');
jest.requireActual('@guardian/prebid.js/build/dist/prebid');
};

describe('initialise', () => {
Expand Down

0 comments on commit 9bc278c

Please sign in to comment.