Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the initPermutive call #1782

Merged
merged 7 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/experiments/tests/move-permutive-segmentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { ABTest } from '@guardian/ab-core';

export const movePermutiveSegmentation: ABTest = {
id: 'MovePermutiveSegmentation',
author: '@commercial-dev',
start: '2025-01-14',
expiry: '2025-02-28',
audience: 0 / 100,
audienceOffset: 20 / 100,
Copy link
Contributor

@dskamiotis dskamiotis Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know its a 0% test, Wondered what this does audienceOffset: 20 / 100

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The offset is to make sure that if we set it live (eg not 0%) that the test audience wouldn't overlap with that of your test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see great, Ill keep mine to 0/100 👍

audienceCriteria: '',
successMeasure: '',
description:
'Measure the performance impact of moving the initialisation of Permutive segmentation.',
variants: [
{
id: 'control',
test: (): void => {
/* no-op */
},
},
{
id: 'variant',
test: (): void => {
/* no-op */
},
},
],
canRun: () => true,
};
8 changes: 7 additions & 1 deletion src/init/consented-advertising.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { isUserInVariant } from '../experiments/ab';
import { movePermutiveSegmentation } from '../experiments/tests/move-permutive-segmentation';
import { init as prepareAdVerification } from '../lib/ad-verification/prepare-ad-verification';
import { bootCommercial } from '../lib/commercial-boot-utils';
import { adFreeSlotRemove } from './consented/ad-free-slot-remove';
Expand All @@ -9,6 +11,7 @@ import { init as initIpsosMori } from './consented/ipsos-mori';
import { init as initMessenger } from './consented/messenger';
import { init as prepareA9 } from './consented/prepare-a9';
import { init as prepareGoogletag } from './consented/prepare-googletag';
import { initPermutive } from './consented/prepare-permutive';
import { init as preparePrebid } from './consented/prepare-prebid';
import { removeDisabledSlots as closeDisabledSlots } from './consented/remove-slots';
import { initTeadsCookieless } from './consented/teads-cookieless';
Expand All @@ -34,7 +37,10 @@ const commercialModules = [
reloadPageOnConsentChange,
preparePrebid,
initDfpListeners,
prepareGoogletag,
// add test to determine impact of moving initPermutive
isUserInVariant(movePermutiveSegmentation, 'variant')
? prepareGoogletag
: () => initPermutive().then(prepareGoogletag),
initDynamicAdSlots,
prepareA9,
initFillSlotListener,
Expand Down
11 changes: 7 additions & 4 deletions src/init/consented/static-ad-slots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createAdvert } from '../../define/create-advert';
import { displayAds } from '../../display/display-ads';
import { displayLazyAds } from '../../display/display-lazy-ads';
import { isUserInVariant } from '../../experiments/ab';
import { movePermutiveSegmentation } from '../../experiments/tests/move-permutive-segmentation';
import { mpuWhenNoEpic } from '../../experiments/tests/mpu-when-no-epic';
import type { SizeMapping } from '../../lib/ad-sizes';
import { adSizes, createAdSize } from '../../lib/ad-sizes';
Expand Down Expand Up @@ -62,12 +63,14 @@ const fillStaticAdvertSlots = async (): Promise<void> => {
// This module has the following strict dependencies. These dependencies must be
// fulfilled before this function can execute reliably. The bootstrap
// initiates these dependencies, to speed up the init process. Bootstrap also captures the module performance.
const dependencies: Array<Promise<void>> = [
removeDisabledSlots(),
const dependencies: Array<Promise<void>> = [removeDisabledSlots()];

// add test to determine impact of moving initPermutive
if (isUserInVariant(movePermutiveSegmentation, 'variant')) {
// Permutive segmentation init code must run before googletag.enableServices() is called
/** @see https://support.permutive.com/hc/en-us/articles/360011779239-Deploying-the-Permutive-JavaScript-Tag */
initPermutive(),
];
dependencies.push(initPermutive());
}

await Promise.all(dependencies);

Expand Down
Loading