Skip to content

Commit

Permalink
Rubicon Bid Adapter: PAAPI/Fledge support (#10671)
Browse files Browse the repository at this point in the history
* Rubicon adapter support for PAAPI/Fledge

* fix lint

* add unit tests

* Fix linting

* incorporate review feedback

* revert return change

* fix test

---------

Co-authored-by: Chris Huie <[email protected]>
  • Loading branch information
spotxslagle and ChrisHuie authored Nov 8, 2023
1 parent 5b82e3b commit 680f924
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 3 deletions.
20 changes: 17 additions & 3 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ export const spec = {
'x_source.tid',
'l_pb_bid_id',
'p_screen_res',
'o_ae',
'rp_floor',
'rp_secure',
'tk_user_key'
Expand Down Expand Up @@ -520,6 +521,10 @@ export const spec = {
if (configUserId) {
data['ppuid'] = configUserId;
}

if (bidRequest?.ortb2Imp?.ext?.ae) {
data['o_ae'] = 1;
}
// loop through userIds and add to request
if (bidRequest.userIdAsEids) {
bidRequest.userIdAsEids.forEach(eid => {
Expand Down Expand Up @@ -619,7 +624,7 @@ export const spec = {
* @param {*} responseObj
* @param {BidRequest|Object.<string, BidRequest[]>} request - if request was SRA the bidRequest argument will be a keyed BidRequest array object,
* non-SRA responses return a plain BidRequest object
* @return {Bid[]} An array of bids which
* @return {{fledgeAuctionConfigs: *, bids: *}} An array of bids which
*/
interpretResponse: function (responseObj, request) {
responseObj = responseObj.body;
Expand All @@ -629,7 +634,6 @@ export const spec = {
if (!responseObj || typeof responseObj !== 'object') {
return [];
}

// Response from PBS Java openRTB
if (responseObj.seatbid) {
const responseErrors = deepAccess(responseObj, 'ext.errors.rubicon');
Expand All @@ -655,7 +659,7 @@ export const spec = {
return [];
}

return ads.reduce((bids, ad, i) => {
let bids = ads.reduce((bids, ad, i) => {
(ad.impression_id && lastImpId === ad.impression_id) ? multibid++ : lastImpId = ad.impression_id;

if (ad.status !== 'ok') {
Expand Down Expand Up @@ -716,6 +720,16 @@ export const spec = {
}, []).sort((adA, adB) => {
return (adB.cpm || 0.0) - (adA.cpm || 0.0);
});

let fledgeAuctionConfigs = responseObj.component_auction_config?.map(config => {
return { config, bidId: config.bidId }
});

if (fledgeAuctionConfigs) {
return { bids, fledgeAuctionConfigs };
} else {
return bids;
}
},
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) {
if (!hasSynced && syncOptions.iframeEnabled) {
Expand Down
46 changes: 46 additions & 0 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2589,6 +2589,15 @@ describe('the rubicon adapter', function () {
const slotParams = spec.createSlotParams(bidderRequest.bids[0], bidderRequest);
expect(slotParams.kw).to.equal('a,b,c');
});

it('should pass along o_ae param when fledge is enabled', () => {
const localBidRequest = Object.assign({}, bidderRequest.bids[0]);
localBidRequest.ortb2Imp.ext.ae = true;

const slotParams = spec.createSlotParams(localBidRequest, bidderRequest);

expect(slotParams['o_ae']).to.equal(1)
});
});

describe('classifiedAsVideo', function () {
Expand Down Expand Up @@ -3309,6 +3318,43 @@ describe('the rubicon adapter', function () {
expect(bids).to.be.lengthOf(0);
});

it('Should support recieving an auctionConfig and pass it along to Prebid', function () {
let response = {
'status': 'ok',
'account_id': 14062,
'site_id': 70608,
'zone_id': 530022,
'size_id': 15,
'alt_size_ids': [
43
],
'tracking': '',
'inventory': {},
'ads': [{
'status': 'ok',
'cpm': 0,
'size_id': 15
}],
'component_auction_config': [{
'random': 'value',
'bidId': '5432'
},
{
'random': 'string',
'bidId': '6789'
}]
};

let {bids, fledgeAuctionConfigs} = spec.interpretResponse({body: response}, {
bidRequest: bidderRequest.bids[0]
});

expect(bids).to.be.lengthOf(1);
expect(fledgeAuctionConfigs[0].bidId).to.equal('5432');
expect(fledgeAuctionConfigs[0].config.random).to.equal('value');
expect(fledgeAuctionConfigs[1].bidId).to.equal('6789');
});

it('should handle an error', function () {
let response = {
'status': 'ok',
Expand Down

0 comments on commit 680f924

Please sign in to comment.