Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Criteo Bid Adapter : remove usage of bidRequest.auctionId #10084

Merged
merged 1 commit into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 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 @@ -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) {
Expand Down Expand Up @@ -420,6 +420,7 @@ function buildCdbRequest(context, bidRequests, bidderRequest) {
let schain;
let userIdAsEids;
const request = {
id: generateUUID(),
publisher: {
url: context.url,
ext: bidderRequest.publisherExt,
Expand All @@ -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;
Expand Down Expand Up @@ -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 || {};
Expand Down Expand Up @@ -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;
}
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 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 = [
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down