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 : support Fledge seller signals per imp #10948

Merged
merged 1 commit into from
Jan 16, 2024
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
10 changes: 8 additions & 2 deletions modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,20 +276,26 @@ export const spec = {
if (isArray(body.ext?.igbid)) {
const seller = body.ext.seller || FLEDGE_SELLER_DOMAIN;
const sellerTimeout = body.ext.sellerTimeout || FLEDGE_SELLER_TIMEOUT;
const sellerSignals = body.ext.sellerSignals || {};
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;
}
if (!sellerSignals.sellerCurrency && bidRequest.params.bidFloorCur) {
sellerSignals.sellerCurrency = bidRequest.params.bidFloorCur;
}
const bidId = bidRequest.bidId;
if (body?.ext?.sellerSignalsPerImp !== undefined) {
const sellerSignalsPerImp = body.ext.sellerSignalsPerImp[bidId];
if (sellerSignalsPerImp !== undefined) {
sellerSignals = {...sellerSignals, ...sellerSignalsPerImp};
}
}
fledgeAuctionConfigs.push({
bidId,
config: {
Expand Down
59 changes: 58 additions & 1 deletion test/spec/modules/criteoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2470,12 +2470,30 @@ describe('The Criteo bidding adapter', function () {
foo: 'baz',
},
}]
}, {
impid: 'test-bidId-2',
igbuyer: [{
origin: 'https://first-buyer-domain.com',
buyerdata: {
foo: 'bar',
},
}, {
origin: 'https://second-buyer-domain.com',
buyerdata: {
foo: 'baz',
},
}]
}],
seller: 'https://seller-domain.com',
sellerTimeout: 500,
sellerSignals: {
foo: 'bar',
},
sellerSignalsPerImp: {
'test-bidId': {
foo2: 'bar2',
}
},
},
},
};
Expand All @@ -2502,15 +2520,54 @@ describe('The Criteo bidding adapter', function () {
bidFloorCur: 'EUR'
}
},
{
bidId: 'test-bidId-2',
bidder: 'criteo',
adUnitCode: 'bid-123',
transactionId: 'transaction-123',
mediaTypes: {
banner: {
sizes: [[728, 90]]
}
},
params: {
bidFloor: 1,
bidFloorCur: 'EUR'
}
},
];
const request = spec.buildRequests(bidRequests, bidderRequest);
const interpretedResponse = spec.interpretResponse(response, request);
expect(interpretedResponse).to.have.property('bids');
expect(interpretedResponse).to.have.property('fledgeAuctionConfigs');
expect(interpretedResponse.bids).to.have.lengthOf(0);
expect(interpretedResponse.fledgeAuctionConfigs).to.have.lengthOf(1);
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'
},
},
seller: 'https://seller-domain.com',
sellerTimeout: 500,
sellerSignals: {
foo: 'bar',
foo2: 'bar2',
floor: 1,
sellerCurrency: 'EUR',
},
},
});
expect(interpretedResponse.fledgeAuctionConfigs[1]).to.deep.equal({
bidId: 'test-bidId-2',
config: {
auctionSignals: {},
decisionLogicUrl: 'https://grid-mercury.criteo.com/fledge/decision',
Expand Down