Skip to content

Commit 4b4648e

Browse files
authored
Taboola Bid Adapter : add for support fledge (prebid#11192)
* Support fledge in taboola adapter * Append corner cases handling for the empty or partial response * Swap json parse to safeJsonParse * Rename test param
1 parent 40dd3b6 commit 4b4648e

File tree

2 files changed

+401
-4
lines changed

2 files changed

+401
-4
lines changed

modules/taboolaBidAdapter.js

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import {registerBidder} from '../src/adapters/bidderFactory.js';
44
import {BANNER} from '../src/mediaTypes.js';
55
import {config} from '../src/config.js';
6-
import {deepAccess, deepSetValue, getWindowSelf, replaceAuctionPrice} from '../src/utils.js';
6+
import {deepAccess, deepSetValue, getWindowSelf, replaceAuctionPrice, isArray, safeJSONParse} from '../src/utils.js';
77
import {getStorageManager} from '../src/storageManager.js';
88
import {ajax} from '../src/ajax.js';
99
import {ortbConverter} from '../libraries/ortbConverter/converter.js';
@@ -151,12 +151,59 @@ export const spec = {
151151
if (!serverResponse || !serverResponse.body) {
152152
return [];
153153
}
154-
154+
const bids = [];
155+
const fledgeAuctionConfigs = [];
155156
if (!serverResponse.body.seatbid || !serverResponse.body.seatbid.length || !serverResponse.body.seatbid[0].bid || !serverResponse.body.seatbid[0].bid.length) {
156-
return [];
157+
if (!serverResponse.body.ext || !serverResponse.body.ext.igbid || !serverResponse.body.ext.igbid.length) {
158+
return [];
159+
}
160+
} else {
161+
bids.push(...converter.fromORTB({response: serverResponse.body, request: request.data}).bids);
162+
}
163+
if (isArray(serverResponse.body.ext?.igbid)) {
164+
serverResponse.body.ext.igbid.forEach((igbid) => {
165+
if (!igbid || !igbid.igbuyer || !igbid.igbuyer.length || !igbid.igbuyer[0].buyerdata) {
166+
return;
167+
}
168+
let buyerdata = safeJSONParse(igbid.igbuyer[0]?.buyerdata)
169+
if (!buyerdata) {
170+
return;
171+
}
172+
const perBuyerSignals = {};
173+
igbid.igbuyer.forEach(buyerItem => {
174+
if (!buyerItem || !buyerItem.buyerdata || !buyerItem.origin) {
175+
return;
176+
}
177+
let parsedData = safeJSONParse(buyerItem.buyerdata)
178+
if (!parsedData || !parsedData.perBuyerSignals || !(buyerItem.origin in parsedData.perBuyerSignals)) {
179+
return;
180+
}
181+
perBuyerSignals[buyerItem.origin] = parsedData.perBuyerSignals[buyerItem.origin];
182+
});
183+
const impId = igbid?.impid;
184+
fledgeAuctionConfigs.push({
185+
impId,
186+
config: {
187+
seller: buyerdata?.seller,
188+
resolveToConfig: buyerdata?.resolveToConfig,
189+
sellerSignals: {},
190+
sellerTimeout: buyerdata?.sellerTimeout,
191+
perBuyerSignals,
192+
auctionSignals: {},
193+
decisionLogicUrl: buyerdata?.decisionLogicUrl,
194+
interestGroupBuyers: buyerdata?.interestGroupBuyers,
195+
perBuyerTimeouts: buyerdata?.perBuyerTimeouts,
196+
},
197+
});
198+
});
157199
}
158200

159-
const bids = converter.fromORTB({response: serverResponse.body, request: request.data}).bids;
201+
if (fledgeAuctionConfigs.length) {
202+
return {
203+
bids,
204+
fledgeAuctionConfigs,
205+
};
206+
}
160207
return bids;
161208
},
162209
onBidWon: (bid) => {

0 commit comments

Comments
 (0)