diff --git a/modules/criteoBidAdapter.js b/modules/criteoBidAdapter.js index 6892c9f692f7..b05b85eb58ba 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'; @@ -242,7 +242,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) { @@ -445,7 +445,7 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { const slot = { impid: bidRequest.adUnitCode, transactionid: bidRequest.transactionId, - auctionId: bidRequest.auctionId, + auctionId: bidderRequest.ortb2?.source?.tid || generateUUID(), }; if (bidRequest.params.zoneId) { slot.zoneid = bidRequest.params.zoneId; @@ -760,7 +760,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 1d246e4cd2a4..296797bc61f3 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 source tid as auction id 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.slots[0].auctionId).to.equal('abc'); + }); + + it('should properly build a request using random uuid as auction id if source tid is not available', 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.slots[0].auctionId).to.equal('def'); + generateUUIDStub.restore(); + }); + it('should properly build a request if refererInfo is not provided', function () { const bidderRequest = {}; const bidRequests = [ @@ -1063,7 +1113,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', @@ -1091,7 +1141,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', @@ -1119,7 +1169,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',