Skip to content

Commit

Permalink
Criteo Bid Adapter: use igi.igs to register fledge auction configs (#…
Browse files Browse the repository at this point in the history
…11218)

Co-authored-by: v.raybaud <[email protected]>
  • Loading branch information
vraybaud and v.raybaud authored Mar 19, 2024
1 parent 4b4648e commit 90822c6
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 162 deletions.
55 changes: 6 additions & 49 deletions modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ export const ADAPTER_VERSION = 36;
const BIDDER_CODE = 'criteo';
const CDB_ENDPOINT = 'https://bidder.criteo.com/cdb';
const PROFILE_ID_INLINE = 207;
const FLEDGE_SELLER_DOMAIN = 'https://grid-mercury.criteo.com';
const FLEDGE_SELLER_TIMEOUT = 500;
const FLEDGE_DECISION_LOGIC_URL = 'https://grid-mercury.criteo.com/fledge/decision';
export const PROFILE_ID_PUBLISHERTAG = 185;
export const storage = getStorageManager({ bidderCode: BIDDER_CODE });
const LOG_PREFIX = 'Criteo: ';
Expand Down Expand Up @@ -284,53 +281,13 @@ export const spec = {
});
}

if (isArray(body.ext?.igbid)) {
const seller = body.ext.seller || FLEDGE_SELLER_DOMAIN;
const sellerTimeout = body.ext.sellerTimeout || FLEDGE_SELLER_TIMEOUT;
body.ext.igbid.forEach((igbid) => {
const perBuyerSignals = {};
igbid.igbuyer.forEach(buyerItem => {
perBuyerSignals[buyerItem.origin] = buyerItem.buyerdata;
});
const bidRequest = request.bidRequests.find(b => b.bidId === igbid.impid);
const bidId = bidRequest.bidId;
let sellerSignals = body.ext.sellerSignals || {};
if (!sellerSignals.floor && bidRequest.params.bidFloor) {
sellerSignals.floor = bidRequest.params.bidFloor;
}
let perBuyerTimeout = { '*': 500 };
if (sellerSignals.perBuyerTimeout) {
for (const buyer in sellerSignals.perBuyerTimeout) {
perBuyerTimeout[buyer] = sellerSignals.perBuyerTimeout[buyer];
}
}
let perBuyerGroupLimits = { '*': 60 };
if (sellerSignals.perBuyerGroupLimits) {
for (const buyer in sellerSignals.perBuyerGroupLimits) {
perBuyerGroupLimits[buyer] = sellerSignals.perBuyerGroupLimits[buyer];
}
}
if (body?.ext?.sellerSignalsPerImp !== undefined) {
const sellerSignalsPerImp = body.ext.sellerSignalsPerImp[bidId];
if (sellerSignalsPerImp !== undefined) {
sellerSignals = {...sellerSignals, ...sellerSignalsPerImp};
}
if (isArray(body.ext?.igi)) {
body.ext.igi.forEach((igi) => {
if (isArray(igi?.igs)) {
igi.igs.forEach((igs) => {
fledgeAuctionConfigs.push(igs);
});
}
fledgeAuctionConfigs.push({
bidId,
config: {
seller,
sellerSignals,
sellerTimeout,
perBuyerSignals,
perBuyerTimeout,
perBuyerGroupLimits,
auctionSignals: {},
decisionLogicUrl: FLEDGE_DECISION_LOGIC_URL,
interestGroupBuyers: Object.keys(perBuyerSignals),
sellerCurrency: sellerSignals.currency || '???',
},
});
});
}

Expand Down
205 changes: 92 additions & 113 deletions test/spec/modules/criteoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2538,49 +2538,102 @@ describe('The Criteo bidding adapter', function () {
});

it('should properly parse a bid response with FLEDGE auction configs', function () {
let auctionConfig1 = {
auctionSignals: {},
decisionLogicUrl: 'https://grid-mercury.criteo.com/fledge/decision',
interestGroupBuyers: ['https://first-buyer-domain.com', 'https://second-buyer-domain.com'],
perBuyerSignals: {
'https://first-buyer-domain.com': {
foo: 'bar',
},
'https://second-buyer-domain.com': {
foo: 'baz'
},
},
perBuyerTimeout: {
'*': 500,
'buyer1': 100,
'buyer2': 200
},
perBuyerGroupLimits: {
'*': 60,
'buyer1': 300,
'buyer2': 400
},
seller: 'https://seller-domain.com',
sellerTimeout: 500,
sellerSignals: {
foo: 'bar',
foo2: 'bar2',
floor: 1,
currency: 'USD',
perBuyerTimeout: {
'buyer1': 100,
'buyer2': 200
},
perBuyerGroupLimits: {
'buyer1': 300,
'buyer2': 400
},
},
sellerCurrency: 'USD',
};
let auctionConfig2 = {
auctionSignals: {},
decisionLogicUrl: 'https://grid-mercury.criteo.com/fledge/decision',
interestGroupBuyers: ['https://first-buyer-domain.com', 'https://second-buyer-domain.com'],
perBuyerSignals: {
'https://first-buyer-domain.com': {
foo: 'bar',
},
'https://second-buyer-domain.com': {
foo: 'baz'
},
},
perBuyerTimeout: {
'*': 500,
'buyer1': 100,
'buyer2': 200
},
perBuyerGroupLimits: {
'*': 60,
'buyer1': 300,
'buyer2': 400
},
seller: 'https://seller-domain.com',
sellerTimeout: 500,
sellerSignals: {
foo: 'bar',
floor: 1,
perBuyerTimeout: {
'buyer1': 100,
'buyer2': 200
},
perBuyerGroupLimits: {
'buyer1': 300,
'buyer2': 400
},
},
sellerCurrency: '???'
};
const response = {
body: {
ext: {
igbid: [{
igi: [{
impid: 'test-bidId',
igbuyer: [{
origin: 'https://first-buyer-domain.com',
buyerdata: {
foo: 'bar',
},
}, {
origin: 'https://second-buyer-domain.com',
buyerdata: {
foo: 'baz',
},
igs: [{
impid: 'test-bidId',
bidId: 'test-bidId',
config: auctionConfig1
}]
}, {
impid: 'test-bidId-2',
igbuyer: [{
origin: 'https://first-buyer-domain.com',
buyerdata: {
foo: 'bar',
},
}, {
origin: 'https://second-buyer-domain.com',
buyerdata: {
foo: 'baz',
},
igs: [{
impid: 'test-bidId-2',
bidId: 'test-bidId-2',
config: auctionConfig2
}]
}],
seller: 'https://seller-domain.com',
sellerTimeout: 500,
sellerSignals: {
foo: 'bar',
perBuyerTimeout: { 'buyer1': 100, 'buyer2': 200 },
perBuyerGroupLimits: { 'buyer1': 300, 'buyer2': 400 },
},
sellerSignalsPerImp: {
'test-bidId': {
foo2: 'bar2',
currency: 'USD'
},
},
}]
},
},
};
Expand Down Expand Up @@ -2631,87 +2684,13 @@ describe('The Criteo bidding adapter', function () {
expect(interpretedResponse.fledgeAuctionConfigs).to.have.lengthOf(2);
expect(interpretedResponse.fledgeAuctionConfigs[0]).to.deep.equal({
bidId: 'test-bidId',
config: {
auctionSignals: {},
decisionLogicUrl: 'https://grid-mercury.criteo.com/fledge/decision',
interestGroupBuyers: ['https://first-buyer-domain.com', 'https://second-buyer-domain.com'],
perBuyerSignals: {
'https://first-buyer-domain.com': {
foo: 'bar',
},
'https://second-buyer-domain.com': {
foo: 'baz'
},
},
perBuyerTimeout: {
'*': 500,
'buyer1': 100,
'buyer2': 200
},
perBuyerGroupLimits: {
'*': 60,
'buyer1': 300,
'buyer2': 400
},
seller: 'https://seller-domain.com',
sellerTimeout: 500,
sellerSignals: {
foo: 'bar',
foo2: 'bar2',
floor: 1,
currency: 'USD',
perBuyerTimeout: {
'buyer1': 100,
'buyer2': 200
},
perBuyerGroupLimits: {
'buyer1': 300,
'buyer2': 400
},
},
sellerCurrency: 'USD',
},
impid: 'test-bidId',
config: auctionConfig1,
});
expect(interpretedResponse.fledgeAuctionConfigs[1]).to.deep.equal({
bidId: 'test-bidId-2',
config: {
auctionSignals: {},
decisionLogicUrl: 'https://grid-mercury.criteo.com/fledge/decision',
interestGroupBuyers: ['https://first-buyer-domain.com', 'https://second-buyer-domain.com'],
perBuyerSignals: {
'https://first-buyer-domain.com': {
foo: 'bar',
},
'https://second-buyer-domain.com': {
foo: 'baz'
},
},
perBuyerTimeout: {
'*': 500,
'buyer1': 100,
'buyer2': 200
},
perBuyerGroupLimits: {
'*': 60,
'buyer1': 300,
'buyer2': 400
},
seller: 'https://seller-domain.com',
sellerTimeout: 500,
sellerSignals: {
foo: 'bar',
floor: 1,
perBuyerTimeout: {
'buyer1': 100,
'buyer2': 200
},
perBuyerGroupLimits: {
'buyer1': 300,
'buyer2': 400
},
},
sellerCurrency: '???'
},
impid: 'test-bidId-2',
config: auctionConfig2,
});
});

Expand Down

0 comments on commit 90822c6

Please sign in to comment.