diff --git a/modules/criteoBidAdapter.js b/modules/criteoBidAdapter.js index cdf45d550b4..6488ccb746e 100644 --- a/modules/criteoBidAdapter.js +++ b/modules/criteoBidAdapter.js @@ -1,4 +1,4 @@ -import { deepAccess, isArray, logError, logInfo, logWarn, parseUrl } from '../src/utils.js'; +import { deepAccess, generateUUID, isArray, logError, logInfo, logWarn, parseUrl } from '../src/utils.js'; import { loadExternalScript } from '../src/adloader.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; @@ -235,7 +235,7 @@ export const spec = { bid.meta = Object.assign({}, bid.meta, { advertiserDomains: [slot.adomain].flat() }); } if (slot.ext?.meta?.networkName) { - bid.meta = Object.assign({}, bid.meta, {networkName: slot.ext.meta.networkName}) + bid.meta = Object.assign({}, bid.meta, { networkName: slot.ext.meta.networkName }) } if (slot.native) { if (bidRequest.params.nativeCallback) { @@ -420,6 +420,7 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { let schain; let userIdAsEids; const request = { + id: generateUUID(), publisher: { url: context.url, ext: bidderRequest.publisherExt, @@ -437,9 +438,7 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { schain = bidRequest.schain || schain; const slot = { impid: bidRequest.adUnitCode, - transactionid: bidRequest.ortb2Imp?.ext?.tid, - // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 - auctionId: bidRequest.auctionId, + transactionid: bidRequest.ortb2Imp?.ext?.tid }; if (bidRequest.params.zoneId) { slot.zoneid = bidRequest.params.zoneId; @@ -509,11 +508,14 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { if (networkId) { request.publisher.networkid = networkId; } + + request.source = { + tid: bidderRequest.ortb2?.source?.tid + }; + if (schain) { - request.source = { - ext: { - schain: schain - } + request.source.ext = { + schain: schain }; }; request.user = bidderRequest.ortb2?.user || {}; @@ -754,7 +756,7 @@ function createOutstreamVideoRenderer(slot) { window.CriteoOutStream[slot.ext.videoPlayerType].play(payload, outstreamConfig) }; - const renderer = Renderer.install({url: PUBLISHER_TAG_OUTSTREAM_SRC, config: config}); + const renderer = Renderer.install({ url: PUBLISHER_TAG_OUTSTREAM_SRC, config: config }); renderer.setRender(render); return renderer; } diff --git a/test/spec/modules/criteoBidAdapter_spec.js b/test/spec/modules/criteoBidAdapter_spec.js index 86ba2a4fba8..ff4e895ff2f 100755 --- a/test/spec/modules/criteoBidAdapter_spec.js +++ b/test/spec/modules/criteoBidAdapter_spec.js @@ -604,6 +604,56 @@ describe('The Criteo bidding adapter', function () { config.resetConfig(); }); + it('should properly build a request using random uuid as auction id', function () { + const generateUUIDStub = sinon.stub(utils, 'generateUUID'); + generateUUIDStub.returns('def'); + const bidderRequest = { + }; + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + params: {} + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + const ortbRequest = request.data; + expect(ortbRequest.id).to.equal('def'); + generateUUIDStub.restore(); + }); + + it('should properly transmit source.tid if available', function () { + const bidderRequest = { + ortb2: { + source: { + tid: 'abc' + } + } + }; + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + params: {} + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + const ortbRequest = request.data; + expect(ortbRequest.source.tid).to.equal('abc'); + }); + it('should properly build a request if refererInfo is not provided', function () { const bidderRequest = {}; const bidRequests = [ @@ -1083,7 +1133,7 @@ describe('The Criteo bidding adapter', function () { }); it('should properly build a request with bcat field', function () { - const bcat = [ 'IAB1', 'IAB2' ]; + const bcat = ['IAB1', 'IAB2']; const bidRequests = [ { bidder: 'criteo', @@ -1111,7 +1161,7 @@ describe('The Criteo bidding adapter', function () { }); it('should properly build a request with badv field', function () { - const badv = [ 'ford.com' ]; + const badv = ['ford.com']; const bidRequests = [ { bidder: 'criteo', @@ -1139,7 +1189,7 @@ describe('The Criteo bidding adapter', function () { }); it('should properly build a request with bapp field', function () { - const bapp = [ 'com.foo.mygame' ]; + const bapp = ['com.foo.mygame']; const bidRequests = [ { bidder: 'criteo',