Skip to content

Commit

Permalink
[Fledge] Add support for seller signals per imp (#10948)
Browse files Browse the repository at this point in the history
Load seller signals for each impression and include them with the response level seller signals before returning the bid and fledge auction config.
  • Loading branch information
afewcc authored Jan 16, 2024
1 parent dc80cff commit 37aba0a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
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

0 comments on commit 37aba0a

Please sign in to comment.