Skip to content

Commit 71e13c0

Browse files
authored
Merge branch 'master' into AGT-890-tcf-race-condition-for-prebid
2 parents 92d5d57 + 1980b0a commit 71e13c0

9 files changed

Lines changed: 401 additions & 176 deletions

File tree

libraries/consentManagement/cmUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { timedAuctionHook } from '../../src/utils/perfMetrics.js';
22
import { isNumber, isPlainObject, isStr, logError, logInfo, logWarn } from '../../src/utils.js';
3-
import { ConsentHandler } from '../../src/consentHandler.js';
43
import { PbPromise } from '../../src/utils/promise.js';
54
import { buildActivityParams } from '../../src/activities/params.js';
65
import { getHook } from '../../src/hook.js';
6+
import { type ConsentHandler } from "../../src/consentHandler.ts";
77

88
export function consentManagementHook(name, loadConsentData) {
99
const SEEN = new WeakSet();
@@ -95,7 +95,7 @@ export function lookupConsentData(
9595
}).finally(() => {
9696
timeoutHandle && clearTimeout(timeoutHandle);
9797
}).catch((e) => {
98-
consentDataHandler.setConsentData(null);
98+
consentDataHandler.error(e);
9999
throw e;
100100
});
101101
}

libraries/mspa/activityControls.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { registerActivityControl } from '../../src/activities/rules.js';
22
import {
33
ACTIVITY_ENRICH_EIDS,
44
ACTIVITY_ENRICH_UFPD,
5-
ACTIVITY_SYNC_USER,
5+
ACTIVITY_SYNC_USER, ACTIVITY_TRANSMIT_EIDS,
66
ACTIVITY_TRANSMIT_PRECISE_GEO,
77
ACTIVITY_TRANSMIT_UFPD
88
} from '../../src/activities/activities.js';
@@ -122,6 +122,7 @@ export function isTransmitGeoConsentDenied(cd) {
122122
const CONSENT_RULES = {
123123
[ACTIVITY_SYNC_USER]: isConsentDenied,
124124
[ACTIVITY_ENRICH_EIDS]: isConsentDenied,
125+
[ACTIVITY_TRANSMIT_EIDS]: isConsentDenied,
125126
[ACTIVITY_ENRICH_UFPD]: isConsentDenied,
126127
[ACTIVITY_TRANSMIT_UFPD]: isTransmitUfpdConsentDenied,
127128
[ACTIVITY_TRANSMIT_PRECISE_GEO]: isTransmitGeoConsentDenied

modules/userId/index.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ function idSystemInitializer({ mkDelay = delay } = {}) {
495495
const startInit = defer<void>();
496496
const startCallbacks = defer<void>();
497497
let cancel;
498+
let initStarted = false;
498499
let initialized = false;
499500
let initMetrics;
500501

@@ -531,6 +532,7 @@ function idSystemInitializer({ mkDelay = delay } = {}) {
531532
PbPromise.all([hooksReady, startInit.promise])
532533
.then(timeConsent)
533534
.then(checkRefs(() => {
535+
initialized = true;
534536
initSubmodules(initModules, allModules);
535537
}))
536538
.then(() => startCallbacks.promise.finally(initMetrics.startTiming('userId.callbacks.pending')))
@@ -547,8 +549,8 @@ function idSystemInitializer({ mkDelay = delay } = {}) {
547549
* filtered by `submoduleNames`).
548550
*/
549551
return function ({ refresh = false, submoduleNames = null, ready = false } = {}) {
550-
if (ready && !initialized) {
551-
initialized = true;
552+
if (ready && !initStarted) {
553+
initStarted = true;
552554
startInit.resolve();
553555
// submodule callbacks should run immediately if `auctionDelay` > 0, or `syncDelay` ms after the
554556
// auction ends otherwise
@@ -765,8 +767,13 @@ function registerSignalSources() {
765767
}
766768

767769
function retryOnCancel(initParams?) {
768-
return initIdSystem(initParams).then(
769-
() => getUserIds(),
770+
const ready = initIdSystem(initParams);
771+
return ready.then(
772+
() => {
773+
// if something has changed, try again
774+
const updated = initIdSystem();
775+
return updated === ready ? getUserIds() : retryOnCancel();
776+
},
770777
(e) => {
771778
if (e === INIT_CANCELED) {
772779
// there's a pending refresh - because GreedyPromise runs this synchronously, we are now in the middle
@@ -1254,6 +1261,9 @@ export function init(config, { mkDelay = delay } = {}) {
12541261
configRegistry = [];
12551262
initializedSubmodules = mkPriorityMaps();
12561263
initIdSystem = idSystemInitializer({ mkDelay });
1264+
allConsent.onChange(() => {
1265+
initIdSystem({ refresh: true });
1266+
})
12571267
if (configListener != null) {
12581268
configListener();
12591269
}

0 commit comments

Comments
 (0)