Skip to content

Commit

Permalink
Rubicon Bid Adapter - Interpret response adds new meta values (#5864)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoschovas authored Oct 22, 2020
1 parent b2ecc7e commit 081a9f2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
15 changes: 14 additions & 1 deletion modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,13 +685,22 @@ export const spec = {
bidObject.dealId = bid.dealid;
}

if (bid.adomain) {
utils.deepSetValue(bidObject, 'meta.advertiserDomains', Array.isArray(bid.adomain) ? bid.adomain : [bid.adomain]);
}

if (utils.deepAccess(bid, 'ext.bidder.rp.advid')) {
utils.deepSetValue(bidObject, 'meta.advertiserId', bid.ext.bidder.rp.advid);
}

let serverResponseTimeMs = utils.deepAccess(responseObj, 'ext.responsetimemillis.rubicon');
if (bidRequest && serverResponseTimeMs) {
bidRequest.serverResponseTimeMs = serverResponseTimeMs;
}

if (utils.deepAccess(bid, 'ext.prebid.type') === VIDEO) {
bidObject.mediaType = VIDEO;
utils.deepSetValue(bidObject, 'meta.mediaType', VIDEO);
const extPrebidTargeting = utils.deepAccess(bid, 'ext.prebid.targeting');

// If ext.prebid.targeting exists, add it as a property value named 'adserverTargeting'
Expand Down Expand Up @@ -757,14 +766,18 @@ export const spec = {
advertiserId: ad.advertiser, networkId: ad.network
},
meta: {
advertiserId: ad.advertiser, networkId: ad.network
advertiserId: ad.advertiser, networkId: ad.network, mediaType: BANNER
}
};

if (ad.creative_type) {
bid.mediaType = ad.creative_type;
}

if (ad.adomain) {
bid.meta.advertiserDomains = Array.isArray(ad.adomain) ? ad.adomain : [ad.adomain];
}

if (ad.creative_type === VIDEO) {
bid.width = associatedBidRequest.params.video.playerWidth;
bid.height = associatedBidRequest.params.video.playerHeight;
Expand Down
11 changes: 10 additions & 1 deletion test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2127,6 +2127,7 @@ describe('the rubicon adapter', function () {
'impression_id': '153dc240-8229-4604-b8f5-256933b9374c',
'size_id': '15',
'ad_id': '6',
'adomain': ['test.com'],
'advertiser': 7,
'network': 8,
'creative_id': 'crid-9',
Expand All @@ -2148,6 +2149,7 @@ describe('the rubicon adapter', function () {
'impression_id': '153dc240-8229-4604-b8f5-256933b9374d',
'size_id': '43',
'ad_id': '7',
'adomain': ['test.com'],
'advertiser': 7,
'network': 8,
'creative_id': 'crid-9',
Expand Down Expand Up @@ -2182,6 +2184,8 @@ describe('the rubicon adapter', function () {
expect(bids[0].rubicon.networkId).to.equal(8);
expect(bids[0].creativeId).to.equal('crid-9');
expect(bids[0].currency).to.equal('USD');
expect(bids[0].meta.mediaType).to.equal('banner');
expect(String(bids[0].meta.advertiserDomains)).to.equal('test.com');
expect(bids[0].ad).to.contain(`alert('foo')`)
.and.to.contain(`<html>`)
.and.to.contain(`<div data-rp-impression-id='153dc240-8229-4604-b8f5-256933b9374d'>`);
Expand Down Expand Up @@ -2715,13 +2719,15 @@ describe('the rubicon adapter', function () {
bid: [{
id: '0',
impid: 'instream_video1',
adomain: ['test.com'],
price: 2,
crid: '4259970',
ext: {
bidder: {
rp: {
mime: 'application/javascript',
size_id: 201
size_id: 201,
advid: 12345
}
},
prebid: {
Expand Down Expand Up @@ -2750,6 +2756,9 @@ describe('the rubicon adapter', function () {
expect(bids[0].netRevenue).to.equal(true);
expect(bids[0].adserverTargeting).to.deep.equal({hb_uuid: '0c498f63-5111-4bed-98e2-9be7cb932a64'});
expect(bids[0].mediaType).to.equal('video');
expect(bids[0].meta.mediaType).to.equal('video');
expect(String(bids[0].meta.advertiserDomains)).to.equal('test.com');
expect(bids[0].meta.advertiserId).to.equal(12345);
expect(bids[0].bidderCode).to.equal('rubicon');
expect(bids[0].currency).to.equal('USD');
expect(bids[0].width).to.equal(640);
Expand Down

0 comments on commit 081a9f2

Please sign in to comment.