Skip to content

Commit

Permalink
Criteo Bid Adapter : remove usage of bidRequest.auctionId
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardlabat committed Jun 9, 2023
1 parent 6293cd6 commit 03071e0
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 7 deletions.
8 changes: 4 additions & 4 deletions modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
56 changes: 53 additions & 3 deletions test/spec/modules/criteoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 03071e0

Please sign in to comment.