Skip to content

Commit 90822c6

Browse files
vraybaudv.raybaud
and
v.raybaud
authored
Criteo Bid Adapter: use igi.igs to register fledge auction configs (prebid#11218)
Co-authored-by: v.raybaud <[email protected]>
1 parent 4b4648e commit 90822c6

File tree

2 files changed

+98
-162
lines changed

2 files changed

+98
-162
lines changed

modules/criteoBidAdapter.js

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ export const ADAPTER_VERSION = 36;
2424
const BIDDER_CODE = 'criteo';
2525
const CDB_ENDPOINT = 'https://bidder.criteo.com/cdb';
2626
const PROFILE_ID_INLINE = 207;
27-
const FLEDGE_SELLER_DOMAIN = 'https://grid-mercury.criteo.com';
28-
const FLEDGE_SELLER_TIMEOUT = 500;
29-
const FLEDGE_DECISION_LOGIC_URL = 'https://grid-mercury.criteo.com/fledge/decision';
3027
export const PROFILE_ID_PUBLISHERTAG = 185;
3128
export const storage = getStorageManager({ bidderCode: BIDDER_CODE });
3229
const LOG_PREFIX = 'Criteo: ';
@@ -284,53 +281,13 @@ export const spec = {
284281
});
285282
}
286283

287-
if (isArray(body.ext?.igbid)) {
288-
const seller = body.ext.seller || FLEDGE_SELLER_DOMAIN;
289-
const sellerTimeout = body.ext.sellerTimeout || FLEDGE_SELLER_TIMEOUT;
290-
body.ext.igbid.forEach((igbid) => {
291-
const perBuyerSignals = {};
292-
igbid.igbuyer.forEach(buyerItem => {
293-
perBuyerSignals[buyerItem.origin] = buyerItem.buyerdata;
294-
});
295-
const bidRequest = request.bidRequests.find(b => b.bidId === igbid.impid);
296-
const bidId = bidRequest.bidId;
297-
let sellerSignals = body.ext.sellerSignals || {};
298-
if (!sellerSignals.floor && bidRequest.params.bidFloor) {
299-
sellerSignals.floor = bidRequest.params.bidFloor;
300-
}
301-
let perBuyerTimeout = { '*': 500 };
302-
if (sellerSignals.perBuyerTimeout) {
303-
for (const buyer in sellerSignals.perBuyerTimeout) {
304-
perBuyerTimeout[buyer] = sellerSignals.perBuyerTimeout[buyer];
305-
}
306-
}
307-
let perBuyerGroupLimits = { '*': 60 };
308-
if (sellerSignals.perBuyerGroupLimits) {
309-
for (const buyer in sellerSignals.perBuyerGroupLimits) {
310-
perBuyerGroupLimits[buyer] = sellerSignals.perBuyerGroupLimits[buyer];
311-
}
312-
}
313-
if (body?.ext?.sellerSignalsPerImp !== undefined) {
314-
const sellerSignalsPerImp = body.ext.sellerSignalsPerImp[bidId];
315-
if (sellerSignalsPerImp !== undefined) {
316-
sellerSignals = {...sellerSignals, ...sellerSignalsPerImp};
317-
}
284+
if (isArray(body.ext?.igi)) {
285+
body.ext.igi.forEach((igi) => {
286+
if (isArray(igi?.igs)) {
287+
igi.igs.forEach((igs) => {
288+
fledgeAuctionConfigs.push(igs);
289+
});
318290
}
319-
fledgeAuctionConfigs.push({
320-
bidId,
321-
config: {
322-
seller,
323-
sellerSignals,
324-
sellerTimeout,
325-
perBuyerSignals,
326-
perBuyerTimeout,
327-
perBuyerGroupLimits,
328-
auctionSignals: {},
329-
decisionLogicUrl: FLEDGE_DECISION_LOGIC_URL,
330-
interestGroupBuyers: Object.keys(perBuyerSignals),
331-
sellerCurrency: sellerSignals.currency || '???',
332-
},
333-
});
334291
});
335292
}
336293

test/spec/modules/criteoBidAdapter_spec.js

Lines changed: 92 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,49 +2538,102 @@ describe('The Criteo bidding adapter', function () {
25382538
});
25392539

25402540
it('should properly parse a bid response with FLEDGE auction configs', function () {
2541+
let auctionConfig1 = {
2542+
auctionSignals: {},
2543+
decisionLogicUrl: 'https://grid-mercury.criteo.com/fledge/decision',
2544+
interestGroupBuyers: ['https://first-buyer-domain.com', 'https://second-buyer-domain.com'],
2545+
perBuyerSignals: {
2546+
'https://first-buyer-domain.com': {
2547+
foo: 'bar',
2548+
},
2549+
'https://second-buyer-domain.com': {
2550+
foo: 'baz'
2551+
},
2552+
},
2553+
perBuyerTimeout: {
2554+
'*': 500,
2555+
'buyer1': 100,
2556+
'buyer2': 200
2557+
},
2558+
perBuyerGroupLimits: {
2559+
'*': 60,
2560+
'buyer1': 300,
2561+
'buyer2': 400
2562+
},
2563+
seller: 'https://seller-domain.com',
2564+
sellerTimeout: 500,
2565+
sellerSignals: {
2566+
foo: 'bar',
2567+
foo2: 'bar2',
2568+
floor: 1,
2569+
currency: 'USD',
2570+
perBuyerTimeout: {
2571+
'buyer1': 100,
2572+
'buyer2': 200
2573+
},
2574+
perBuyerGroupLimits: {
2575+
'buyer1': 300,
2576+
'buyer2': 400
2577+
},
2578+
},
2579+
sellerCurrency: 'USD',
2580+
};
2581+
let auctionConfig2 = {
2582+
auctionSignals: {},
2583+
decisionLogicUrl: 'https://grid-mercury.criteo.com/fledge/decision',
2584+
interestGroupBuyers: ['https://first-buyer-domain.com', 'https://second-buyer-domain.com'],
2585+
perBuyerSignals: {
2586+
'https://first-buyer-domain.com': {
2587+
foo: 'bar',
2588+
},
2589+
'https://second-buyer-domain.com': {
2590+
foo: 'baz'
2591+
},
2592+
},
2593+
perBuyerTimeout: {
2594+
'*': 500,
2595+
'buyer1': 100,
2596+
'buyer2': 200
2597+
},
2598+
perBuyerGroupLimits: {
2599+
'*': 60,
2600+
'buyer1': 300,
2601+
'buyer2': 400
2602+
},
2603+
seller: 'https://seller-domain.com',
2604+
sellerTimeout: 500,
2605+
sellerSignals: {
2606+
foo: 'bar',
2607+
floor: 1,
2608+
perBuyerTimeout: {
2609+
'buyer1': 100,
2610+
'buyer2': 200
2611+
},
2612+
perBuyerGroupLimits: {
2613+
'buyer1': 300,
2614+
'buyer2': 400
2615+
},
2616+
},
2617+
sellerCurrency: '???'
2618+
};
25412619
const response = {
25422620
body: {
25432621
ext: {
2544-
igbid: [{
2622+
igi: [{
25452623
impid: 'test-bidId',
2546-
igbuyer: [{
2547-
origin: 'https://first-buyer-domain.com',
2548-
buyerdata: {
2549-
foo: 'bar',
2550-
},
2551-
}, {
2552-
origin: 'https://second-buyer-domain.com',
2553-
buyerdata: {
2554-
foo: 'baz',
2555-
},
2624+
igs: [{
2625+
impid: 'test-bidId',
2626+
bidId: 'test-bidId',
2627+
config: auctionConfig1
25562628
}]
25572629
}, {
25582630
impid: 'test-bidId-2',
2559-
igbuyer: [{
2560-
origin: 'https://first-buyer-domain.com',
2561-
buyerdata: {
2562-
foo: 'bar',
2563-
},
2564-
}, {
2565-
origin: 'https://second-buyer-domain.com',
2566-
buyerdata: {
2567-
foo: 'baz',
2568-
},
2631+
igs: [{
2632+
impid: 'test-bidId-2',
2633+
bidId: 'test-bidId-2',
2634+
config: auctionConfig2
25692635
}]
2570-
}],
2571-
seller: 'https://seller-domain.com',
2572-
sellerTimeout: 500,
2573-
sellerSignals: {
2574-
foo: 'bar',
2575-
perBuyerTimeout: { 'buyer1': 100, 'buyer2': 200 },
2576-
perBuyerGroupLimits: { 'buyer1': 300, 'buyer2': 400 },
2577-
},
2578-
sellerSignalsPerImp: {
2579-
'test-bidId': {
2580-
foo2: 'bar2',
2581-
currency: 'USD'
2582-
},
2583-
},
2636+
}]
25842637
},
25852638
},
25862639
};
@@ -2631,87 +2684,13 @@ describe('The Criteo bidding adapter', function () {
26312684
expect(interpretedResponse.fledgeAuctionConfigs).to.have.lengthOf(2);
26322685
expect(interpretedResponse.fledgeAuctionConfigs[0]).to.deep.equal({
26332686
bidId: 'test-bidId',
2634-
config: {
2635-
auctionSignals: {},
2636-
decisionLogicUrl: 'https://grid-mercury.criteo.com/fledge/decision',
2637-
interestGroupBuyers: ['https://first-buyer-domain.com', 'https://second-buyer-domain.com'],
2638-
perBuyerSignals: {
2639-
'https://first-buyer-domain.com': {
2640-
foo: 'bar',
2641-
},
2642-
'https://second-buyer-domain.com': {
2643-
foo: 'baz'
2644-
},
2645-
},
2646-
perBuyerTimeout: {
2647-
'*': 500,
2648-
'buyer1': 100,
2649-
'buyer2': 200
2650-
},
2651-
perBuyerGroupLimits: {
2652-
'*': 60,
2653-
'buyer1': 300,
2654-
'buyer2': 400
2655-
},
2656-
seller: 'https://seller-domain.com',
2657-
sellerTimeout: 500,
2658-
sellerSignals: {
2659-
foo: 'bar',
2660-
foo2: 'bar2',
2661-
floor: 1,
2662-
currency: 'USD',
2663-
perBuyerTimeout: {
2664-
'buyer1': 100,
2665-
'buyer2': 200
2666-
},
2667-
perBuyerGroupLimits: {
2668-
'buyer1': 300,
2669-
'buyer2': 400
2670-
},
2671-
},
2672-
sellerCurrency: 'USD',
2673-
},
2687+
impid: 'test-bidId',
2688+
config: auctionConfig1,
26742689
});
26752690
expect(interpretedResponse.fledgeAuctionConfigs[1]).to.deep.equal({
26762691
bidId: 'test-bidId-2',
2677-
config: {
2678-
auctionSignals: {},
2679-
decisionLogicUrl: 'https://grid-mercury.criteo.com/fledge/decision',
2680-
interestGroupBuyers: ['https://first-buyer-domain.com', 'https://second-buyer-domain.com'],
2681-
perBuyerSignals: {
2682-
'https://first-buyer-domain.com': {
2683-
foo: 'bar',
2684-
},
2685-
'https://second-buyer-domain.com': {
2686-
foo: 'baz'
2687-
},
2688-
},
2689-
perBuyerTimeout: {
2690-
'*': 500,
2691-
'buyer1': 100,
2692-
'buyer2': 200
2693-
},
2694-
perBuyerGroupLimits: {
2695-
'*': 60,
2696-
'buyer1': 300,
2697-
'buyer2': 400
2698-
},
2699-
seller: 'https://seller-domain.com',
2700-
sellerTimeout: 500,
2701-
sellerSignals: {
2702-
foo: 'bar',
2703-
floor: 1,
2704-
perBuyerTimeout: {
2705-
'buyer1': 100,
2706-
'buyer2': 200
2707-
},
2708-
perBuyerGroupLimits: {
2709-
'buyer1': 300,
2710-
'buyer2': 400
2711-
},
2712-
},
2713-
sellerCurrency: '???'
2714-
},
2692+
impid: 'test-bidId-2',
2693+
config: auctionConfig2,
27152694
});
27162695
});
27172696

0 commit comments

Comments
 (0)