diff --git a/modules/adagioBidAdapter.js b/modules/adagioBidAdapter.js index fe086afbf43..57dd80aa9b1 100644 --- a/modules/adagioBidAdapter.js +++ b/modules/adagioBidAdapter.js @@ -860,8 +860,7 @@ function storeRequestInAdagioNS(bidRequest) { bidder: bidRequest.bidder, params: bidRequest.params // use the updated bid.params object with auto-detected params }], - // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 - auctionId: bidRequest.auctionId, + auctionId: bidRequest.auctionId, // this auctionId has been generated by adagioBidAdapter pageviewId: internal.getPageviewId(), printNumber, localPbjs: '$$PREBID_GLOBAL$$', @@ -870,7 +869,7 @@ function storeRequestInAdagioNS(bidRequest) { // (legacy) Store internal adUnit information w.ADAGIO.adUnits[bidRequest.adUnitCode] = { - auctionId: bidRequest.auctionId, + auctionId: bidRequest.auctionId, // this auctionId has been generated by adagioBidAdapter pageviewId: internal.getPageviewId(), printNumber, }; @@ -982,7 +981,14 @@ export const spec = { const syncEnabled = deepAccess(config.getConfig('userSync'), 'syncEnabled') const usIfr = syncEnabled && userSync.canBidderRegisterSync('iframe', 'adagio') - const adUnits = _map(validBidRequests, (bidRequest) => { + const aucId = generateUUID() + + const adUnits = _map(validBidRequests, (rawBidRequest) => { + const bidRequest = {...rawBidRequest} + + // Fix https://github.com/prebid/Prebid.js/issues/9781 + bidRequest.auctionId = aucId + const globalFeatures = GlobalExchange.getOrSetGlobalFeatures(); const features = { ...globalFeatures, @@ -1095,6 +1101,12 @@ export const spec = { storeRequestInAdagioNS(bidRequest); + // Remove these fields at the very end, so we can still use them before. + delete bidRequest.transactionId; + delete bidRequest.ortb2Imp; + delete bidRequest.ortb2; + delete bidRequest.sizes; + return bidRequest; }); @@ -1233,33 +1245,8 @@ export const spec = { * @returns {object} updated params */ transformBidParams(params, isOrtb, adUnit, bidRequests) { - const adagioBidderRequest = find(bidRequests, bidRequest => bidRequest.bidderCode === 'adagio'); - const adagioBid = find(adagioBidderRequest.bids, bid => bid.adUnitCode === adUnit.code); - - if (isOrtb) { - autoFillParams(adagioBid); - - adagioBid.params.auctionId = deepAccess(adagioBidderRequest, 'auctionId'); - - const globalFeatures = GlobalExchange.getOrSetGlobalFeatures(); - adagioBid.params.features = { - ...globalFeatures, - print_number: getPrintNumber(adagioBid.adUnitCode, adagioBidderRequest).toString(), - adunit_position: getSlotPosition(adagioBid.params.adUnitElementId) // adUnitElementId à déplacer ??? - }; - - adagioBid.params.pageviewId = internal.getPageviewId(); - adagioBid.params.prebidVersion = '$prebid.version$'; - adagioBid.params.data = GlobalExchange.getExchangeData(); - - if (deepAccess(adagioBid, 'mediaTypes.video.context') === OUTSTREAM) { - adagioBid.params.playerName = setPlayerName(adagioBid); - } - - storeRequestInAdagioNS(adagioBid); - } - - return adagioBid.params; + // We do not have a prebid server adapter. So let's return unchanged params. + return params; } }; diff --git a/test/spec/modules/adagioBidAdapter_spec.js b/test/spec/modules/adagioBidAdapter_spec.js index 7476482721b..2fb40070184 100644 --- a/test/spec/modules/adagioBidAdapter_spec.js +++ b/test/spec/modules/adagioBidAdapter_spec.js @@ -296,6 +296,7 @@ describe('Adagio bid adapter', () => { sandbox.stub(adagio, 'getDevice').returns({ a: 'a' }); sandbox.stub(adagio, 'getSite').returns({ domain: 'adagio.io', 'page': 'https://adagio.io/hb' }); sandbox.stub(adagio, 'getPageviewId').returns('1234-567'); + sandbox.stub(utils, 'generateUUID').returns('blabla'); const bid01 = new BidRequestBuilder().withParams().build(); const bidderRequest = new BidderRequestBuilder().build(); @@ -309,6 +310,18 @@ describe('Adagio bid adapter', () => { expect(requests[0].data).to.have.all.keys(expectedDataKeys); }); + it('should use a custom generated auctionId and remove transactionId', function() { + const expectedAuctionId = '373bcda7-9794-4f1c-be2c-0d223d11d579' + sandbox.stub(utils, 'generateUUID').returns(expectedAuctionId); + + const bid01 = new BidRequestBuilder().withParams().build(); + const bidderRequest = new BidderRequestBuilder().build(); + + const requests = spec.buildRequests([bid01], bidderRequest); + expect(requests[0].data.adUnits[0].auctionId).eq(expectedAuctionId); + expect(requests[0].data.adUnits[0].transactionId).to.not.exist; + }); + it('should enqueue computed features for collect usage', function() { sandbox.stub(Date, 'now').returns(12345); @@ -1280,14 +1293,6 @@ describe('Adagio bid adapter', () => { describe('transformBidParams', function() { it('Compute additional params in s2s mode', function() { - GlobalExchange.prepareExchangeData('{}'); - - sandbox.stub(window.top.document, 'getElementById').returns( - fixtures.getElementById() - ); - sandbox.stub(window.top, 'getComputedStyle').returns({ display: 'block' }); - sandbox.stub(utils, 'inIframe').returns(false); - const adUnit = { code: 'adunit-code', params: { @@ -1308,22 +1313,8 @@ describe('Adagio bid adapter', () => { } }).withParams().build(); - const params = spec.transformBidParams({ organizationId: '1000' }, true, adUnit, [{ bidderCode: 'adagio', auctionId: bid01.auctionId, bids: [bid01] }]); - - expect(params.organizationId).to.exist; - expect(params.auctionId).to.exist; - expect(params.playerName).to.exist; - expect(params.playerName).to.equal('other'); - expect(params.features).to.exist; - expect(params.features.page_dimensions).to.exist; - expect(params.features.adunit_position).to.exist; - expect(params.features.dom_loading).to.exist; - expect(params.features.print_number).to.exist; - expect(params.features.user_timestamp).to.exist; - expect(params.placement).to.exist; - expect(params.adUnitElementId).to.exist; - expect(params.site).to.exist; - expect(params.data.session).to.exist; + const params = spec.transformBidParams({ param01: 'test' }, true, adUnit, [{ bidderCode: 'adagio', auctionId: bid01.auctionId, bids: [bid01] }]); + expect(params.param01).eq('test'); }); });