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 3 commits
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
5 changes: 5 additions & 0 deletions .changeset/unlucky-lizards-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@guardian/commercial': minor
---

Move the initPermutive call so that the googletag script can be loaded a little earlier
5 changes: 1 addition & 4 deletions src/init/consented-advertising.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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 @@ -35,9 +34,7 @@ const commercialModules = [
reloadPageOnConsentChange,
preparePrebid,
initDfpListeners,
// Permutive init code must run before google tag enableServices()
// The permutive lib however is loaded async with the third party tags
() => initPermutive().then(prepareGoogletag),
prepareGoogletag,
initDynamicAdSlots,
prepareA9,
initFillSlotListener,
Expand Down
8 changes: 7 additions & 1 deletion src/init/consented/static-ad-slots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { getCurrentBreakpoint } from '../../lib/detect/detect-breakpoint';
import { dfpEnv } from '../../lib/dfp/dfp-env';
import { queueAdvert } from '../../lib/dfp/queue-advert';
import { isInUk, isInUsa } from '../../lib/geo/geo-utils';
import { initPermutive } from './prepare-permutive';
import { setupPrebidOnce } from './prepare-prebid';
import { removeDisabledSlots } from './remove-slots';

Expand Down Expand Up @@ -61,7 +62,12 @@ 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(),
// 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(),
];

await Promise.all(dependencies);

Expand Down
Loading