From 91587a19096dc09f9391c3cc5b34879c2d2f8475 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Wed, 23 Oct 2024 10:36:01 -0700 Subject: [PATCH] Revert "gptPreAuction: fix missing gpid when using mcmEnabled (#12356)" (#12360) This reverts commit 2fb16e22a6432fed0e04f1dcf00282aaaacbb939. --- modules/gptPreAuction.js | 16 ++++------- test/spec/modules/gptPreAuction_spec.js | 38 ------------------------- 2 files changed, 6 insertions(+), 48 deletions(-) diff --git a/modules/gptPreAuction.js b/modules/gptPreAuction.js index 7052e6f97ea..29b9257d325 100644 --- a/modules/gptPreAuction.js +++ b/modules/gptPreAuction.js @@ -76,25 +76,21 @@ export const appendGptSlots = adUnits => { return acc; }, {}); - const adUnitPaths = {}; - window.googletag.pubads().getSlots().forEach(slot => { const matchingAdUnitCode = find(Object.keys(adUnitMap), customGptSlotMatching ? customGptSlotMatching(slot) : isAdUnitCodeMatchingSlot(slot)); if (matchingAdUnitCode) { - const path = adUnitPaths[matchingAdUnitCode] = slot.getAdUnitPath(); const adserver = { name: 'gam', - adslot: sanitizeSlotPath(path) + adslot: sanitizeSlotPath(slot.getAdUnitPath()) }; adUnitMap[matchingAdUnitCode].forEach((adUnit) => { deepSetValue(adUnit, 'ortb2Imp.ext.data.adserver', Object.assign({}, adUnit.ortb2Imp?.ext?.data?.adserver, adserver)); }); } }); - return adUnitPaths; }; const sanitizeSlotPath = (path) => { @@ -107,7 +103,7 @@ const sanitizeSlotPath = (path) => { return path; } -const defaultPreAuction = (adUnit, adServerAdSlot, adUnitPath) => { +const defaultPreAuction = (adUnit, adServerAdSlot) => { const context = adUnit.ortb2Imp.ext.data; // use pbadslot if supplied @@ -121,7 +117,7 @@ const defaultPreAuction = (adUnit, adServerAdSlot, adUnitPath) => { } // find all GPT slots with this name - var gptSlots = window.googletag.pubads().getSlots().filter(slot => slot.getAdUnitPath() === adUnitPath); + var gptSlots = window.googletag.pubads().getSlots().filter(slot => slot.getAdUnitPath() === adServerAdSlot); if (gptSlots.length === 0) { return; // should never happen @@ -171,7 +167,7 @@ function warnDeprecation(adUnit) { } export const makeBidRequestsHook = (fn, adUnits, ...args) => { - const adUnitPaths = appendGptSlots(adUnits); + appendGptSlots(adUnits); const { useDefaultPreAuction, customPreAuction } = _currentConfig; adUnits.forEach(adUnit => { // init the ortb2Imp if not done yet @@ -194,9 +190,9 @@ export const makeBidRequestsHook = (fn, adUnits, ...args) => { let adserverSlot = deepAccess(context, 'data.adserver.adslot'); let result; if (customPreAuction) { - result = customPreAuction(adUnit, adserverSlot, adUnitPaths[adUnit.code]); + result = customPreAuction(adUnit, adserverSlot); } else if (useDefaultPreAuction) { - result = defaultPreAuction(adUnit, adserverSlot, adUnitPaths[adUnit.code]); + result = defaultPreAuction(adUnit, adserverSlot); } if (result) { context.gpid = context.data.pbadslot = result; diff --git a/test/spec/modules/gptPreAuction_spec.js b/test/spec/modules/gptPreAuction_spec.js index bc41c811e7d..88062f2b785 100644 --- a/test/spec/modules/gptPreAuction_spec.js +++ b/test/spec/modules/gptPreAuction_spec.js @@ -209,17 +209,6 @@ describe('GPT pre-auction module', () => { expect(adUnit.ortb2Imp.ext.data.adserver).to.deep.equal({ name: 'gam', adslot: '/12345/slotCode2' }); }); - it('returns full ad unit path even if mcmEnabled is true', () => { - config.setConfig({ gptPreAuction: { enabled: true, mcmEnabled: true } }); - window.googletag.pubads().setSlots([ - makeSlot({ code: '/12345,21212/slot', divId: 'div1' }), - ]); - const adUnit = {code: '/12345,21212/slot'}; - expect(appendGptSlots([adUnit])).to.eql({ - '/12345,21212/slot': '/12345,21212/slot' - }) - }) - it('will not trim child id if mcmEnabled is not set to true', () => { window.googletag.pubads().setSlots([ makeSlot({ code: '/12345,21212/slotCode1', divId: 'div1' }), @@ -470,23 +459,6 @@ describe('GPT pre-auction module', () => { expect(returnedAdUnits).to.deep.equal(expectedAdUnits); }); - it('should pass full slot path to customPreAuction when mcmEnabled is true', () => { - const customPreAuction = sinon.stub(); - config.setConfig({ - gptPreAuction: { - enabled: true, - mcmEnabled: true, - customPreAuction - } - }); - window.googletag.pubads().setSlots([ - makeSlot({ code: '/12345,21212/slot', divId: 'div1' }), - ]); - const adUnit = {code: '/12345,21212/slot'}; - makeBidRequestsHook(sinon.stub(), [adUnit]); - sinon.assert.calledWith(customPreAuction, adUnit, '/12345/slot', adUnit.code); - }); - it('should use useDefaultPreAuction logic', () => { config.setConfig({ gptPreAuction: { @@ -568,16 +540,6 @@ describe('GPT pre-auction module', () => { runMakeBidRequests(testAdUnits); expect(returnedAdUnits).to.deep.equal(expectedAdUnits); }); - - it('sets gpid when mcmEnabled: true', () => { - config.setConfig({ gptPreAuction: { enabled: true, mcmEnabled: true } }); - window.googletag.pubads().setSlots([ - makeSlot({ code: '/12345,21212/slot', divId: 'div1' }), - ]); - const adUnit = {code: '/12345,21212/slot'}; - makeBidRequestsHook(sinon.stub(), [adUnit]); - expect(adUnit.ortb2Imp.ext.gpid).to.eql('/12345/slot'); - }); }); describe('pps gpt config', () => {