Skip to content

Commit

Permalink
Prebid 9: change auctionDelay default to 500 (prebid#11498)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi authored and zkosanovic committed May 29, 2024
1 parent 92a1090 commit 1ae9ee7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 34 deletions.
7 changes: 3 additions & 4 deletions modules/userId/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,11 @@ import {MODULE_TYPE_UID} from '../../src/activities/modules.js';
import {isActivityAllowed} from '../../src/activities/rules.js';
import {ACTIVITY_ENRICH_EIDS} from '../../src/activities/activities.js';
import {activityParams} from '../../src/activities/activityParams.js';
import {USERSYNC_DEFAULT_CONFIG} from '../../src/userSync.js';

const MODULE_NAME = 'User ID';
const COOKIE = STORAGE_TYPE_COOKIES;
const LOCAL_STORAGE = STORAGE_TYPE_LOCALSTORAGE;
const DEFAULT_SYNC_DELAY = 500;
const NO_AUCTION_DELAY = 0;
export const PBJS_USER_ID_OPTOUT_NAME = '_pbjs_id_optout';
export const coreStorage = getCoreStorageManager('userId');
export const dep = {
Expand Down Expand Up @@ -1160,8 +1159,8 @@ export function init(config, {delay = GreedyPromise.timeout} = {}) {
ppidSource = userSync.ppid;
if (userSync.userIds) {
configRegistry = userSync.userIds;
syncDelay = isNumber(userSync.syncDelay) ? userSync.syncDelay : DEFAULT_SYNC_DELAY;
auctionDelay = isNumber(userSync.auctionDelay) ? userSync.auctionDelay : NO_AUCTION_DELAY;
syncDelay = isNumber(userSync.syncDelay) ? userSync.syncDelay : USERSYNC_DEFAULT_CONFIG.syncDelay
auctionDelay = isNumber(userSync.auctionDelay) ? userSync.auctionDelay : USERSYNC_DEFAULT_CONFIG.auctionDelay;
updateSubmodules();
updateIdPriority(userSync.idPriority, submodules);
initIdSystem({ready: true});
Expand Down
2 changes: 1 addition & 1 deletion src/userSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const USERSYNC_DEFAULT_CONFIG = {
},
syncsPerBidder: 5,
syncDelay: 3000,
auctionDelay: 0
auctionDelay: 500
};

// Set userSync default values
Expand Down
1 change: 1 addition & 0 deletions test/spec/modules/id5IdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@ describe('ID5 ID System', function () {
id5System.storeNbInCache(ID5_TEST_PARTNER_ID, 1);
let id5Config = getFetchLocalStorageConfig();
id5Config.userSync.userIds[0].storage.refreshInSeconds = 2;
id5Config.userSync.auctionDelay = 0; // do not trigger callback before auction
init(config);
setSubmoduleRegistry([id5System.id5IdSubmodule]);
config.setConfig(id5Config);
Expand Down
47 changes: 18 additions & 29 deletions test/spec/modules/userId_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ describe('User ID', function () {

afterEach(() => {
sandbox.restore();
config.resetConfig();
});

describe('GVL IDs', () => {
Expand Down Expand Up @@ -1361,7 +1362,6 @@ describe('User ID', function () {
coreStorage.setCookie(PBJS_USER_ID_OPTOUT_NAME, '', EXPIRED_COOKIE_DATE);
$$PREBID_GLOBAL$$.requestBids.removeAll();
utils.logInfo.restore();
config.resetConfig();
});

it('does not fetch ids if opt out cookie exists', function () {
Expand Down Expand Up @@ -1391,7 +1391,6 @@ describe('User ID', function () {
afterEach(function () {
$$PREBID_GLOBAL$$.requestBids.removeAll();
utils.logInfo.restore();
config.resetConfig();
});

it('handles config with no usersync object', function () {
Expand Down Expand Up @@ -1559,7 +1558,7 @@ describe('User ID', function () {
expect(auctionDelay).to.equal(100);
});

it('config auctionDelay defaults to 0 if not a number', function () {
it('config auctionDelay defaults to 500 if not a number', function () {
init(config);
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, hadronIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, euidIdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]);
config.setConfig({
Expand All @@ -1571,7 +1570,7 @@ describe('User ID', function () {
}]
}
});
expect(auctionDelay).to.equal(0);
expect(auctionDelay).to.equal(500);
});

describe('auction and user sync delays', function () {
Expand Down Expand Up @@ -1689,20 +1688,17 @@ describe('User ID', function () {
});
});

it('does not delay auction if not set, delays id fetch after auction ends with syncDelay', function () {
it('does not delay auction if set to 0, delays id fetch after auction ends with syncDelay', function () {
config.setConfig({
userSync: {
auctionDelay: 0,
syncDelay: 77,
userIds: [{
name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'}
}]
}
});

// check config has been set correctly
expect(auctionDelay).to.equal(0);
expect(syncDelay).to.equal(77);

return expectImmediateBidHook(auctionSpy, {adUnits})
.then(() => {
// should not delay auction
Expand All @@ -1728,15 +1724,14 @@ describe('User ID', function () {
it('does not delay user id sync after auction ends if set to 0', function () {
config.setConfig({
userSync: {
auctionDelay: 0,
syncDelay: 0,
userIds: [{
name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'}
}]
}
});

expect(syncDelay).to.equal(0);

return expectImmediateBidHook(auctionSpy, {adUnits})
.then(() => {
// auction should not be delayed
Expand Down Expand Up @@ -3128,6 +3123,12 @@ describe('User ID', function () {

describe('callbacks at the end of auction', function () {
beforeEach(function () {
config.setConfig({
// callbacks run after auction end only when auctionDelay is 0
userSync: {
auctionDelay: 0,
}
})
sinon.stub(events, 'getEvents').returns([]);
sinon.stub(utils, 'triggerPixel');
coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE);
Expand All @@ -3151,17 +3152,13 @@ describe('User ID', function () {
}

it('pubcid callback with url', function () {
let adUnits = [getAdUnitMock()];
let innerAdUnits;
let customCfg = getConfigMock(['pubCommonId', 'pubcid', 'cookie']);
customCfg = addConfig(customCfg, 'params', {pixelUrl: '/any/pubcid/url'});

init(config);
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule]);
config.setConfig(customCfg);
return runBidsHook((config) => {
innerAdUnits = config.adUnits
}, {adUnits}).then(() => {
config.mergeConfig(customCfg);
return runBidsHook({}).then(() => {
expect(utils.triggerPixel.called).to.be.false;
return endAuction();
}).then(() => {
Expand All @@ -3170,17 +3167,13 @@ describe('User ID', function () {
});

it('unifiedid callback with url', function () {
let adUnits = [getAdUnitMock()];
let innerAdUnits;
let customCfg = getConfigMock(['unifiedId', 'unifiedid', 'cookie']);
addConfig(customCfg, 'params', {url: '/any/unifiedid/url'});

init(config);
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule]);
config.setConfig(customCfg);
return runBidsHook((config) => {
innerAdUnits = config.adUnits
}, {adUnits}).then(() => {
config.mergeConfig(customCfg);
return runBidsHook({}).then(() => {
expect(server.requests).to.be.empty;
return endAuction();
}).then(() => {
Expand All @@ -3189,17 +3182,13 @@ describe('User ID', function () {
});

it('unifiedid callback with partner', function () {
let adUnits = [getAdUnitMock()];
let innerAdUnits;
let customCfg = getConfigMock(['unifiedId', 'unifiedid', 'cookie']);
addConfig(customCfg, 'params', {partner: 'rubicon'});

init(config);
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule]);
config.setConfig(customCfg);
return runBidsHook((config) => {
innerAdUnits = config.adUnits
}, {adUnits}).then(() => {
config.mergeConfig(customCfg);
return runBidsHook({}).then(() => {
expect(server.requests).to.be.empty;
return endAuction();
}).then(() => {
Expand Down

0 comments on commit 1ae9ee7

Please sign in to comment.