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

Rubicon Bid Adapter: PAAPI/Fledge support #10671

Merged
merged 10 commits into from
Nov 8, 2023
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 }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this bidId returned by AE have to match the bidId prebid has for the bidRequest?

Where is DV+ getting this bidId?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. They're getting it from the fastlane param we pass in the adapter

});

if (fledgeAuctionConfigs) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return {bids, fledgeAuctionConfigs} should work, core will ignore the second property if it's not an array and still pick up the bids

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While that would be better, it breaks some unit tests it's not worth fixing right now. I'll plan to deal with this when we aren't trying to get this out so quickly

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