Skip to content

Commit

Permalink
Add rubicon targeting to rubicon bid responses for bidderSettings use (
Browse files Browse the repository at this point in the history
  • Loading branch information
snapwich authored and matthewlane committed Mar 27, 2017
1 parent 41e6891 commit 7361e64
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/adapters/rubicon.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ function RubiconAdapter() {
[bid.width, bid.height] = sizeMap[ad.size_id].split('x').map(num => Number(num));
}

// add server-side targeting
bid.rubiconTargeting = (Array.isArray(ad.targeting) ? ad.targeting : [])
.reduce((memo, item) => {
memo[item.key] = item.values[0];
return memo;
}, {'rpfl_elemid': bidRequest.placementCode});

try {
bidmanager.addBidResponse(bidRequest.placementCode, bid);
Expand Down
8 changes: 6 additions & 2 deletions test/spec/adapters/rubicon_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ describe('the rubicon adapter', () => {
expect(bids[0].getStatusCode()).to.equal(CONSTANTS.STATUS.NO_BID);

});

it('should allow a floor override', () => {

var floorBidderRequest = clone(bidderRequest);
Expand Down Expand Up @@ -458,7 +458,7 @@ describe('the rubicon adapter', () => {
{
'key': 'rpfl_14062',
'values': [
'15_tier_all_test'
'43_tier_all_test'
]
}
]
Expand All @@ -482,6 +482,8 @@ describe('the rubicon adapter', () => {
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'>`);
expect(bids[0].rubiconTargeting.rpfl_elemid).to.equal('/19968336/header-bid-tag-0');
expect(bids[0].rubiconTargeting.rpfl_14062).to.equal('43_tier_all_test');

expect(bids[1].getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD);
expect(bids[1].bidderCode).to.equal('rubicon');
Expand All @@ -491,6 +493,8 @@ describe('the rubicon adapter', () => {
expect(bids[1].ad).to.contain(`alert('foo')`)
.and.to.contain(`<html>`)
.and.to.contain(`<div data-rp-impression-id='153dc240-8229-4604-b8f5-256933b9374c'>`);
expect(bids[1].rubiconTargeting.rpfl_elemid).to.equal('/19968336/header-bid-tag-0');
expect(bids[1].rubiconTargeting.rpfl_14062).to.equal('15_tier_all_test');
});

it('should be fine with a CPM of 0', () => {
Expand Down

0 comments on commit 7361e64

Please sign in to comment.