Skip to content

Commit

Permalink
Rubicon bid adapter: fix netRev (#4552)
Browse files Browse the repository at this point in the history
* fix netRev

* adding comments and more tests
  • Loading branch information
robertrmartinez authored and Isaac A. Dettman committed Dec 9, 2019
1 parent b640d0b commit 42d856b
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 4 deletions.
4 changes: 2 additions & 2 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ export const spec = {
cpm: bid.price || 0,
bidderCode: seatbid.seat,
ttl: 300,
netRevenue: config.getConfig('rubicon.netRevenue') || true,
netRevenue: config.getConfig('rubicon.netRevenue') !== false, // If anything other than false, netRev is true
width: bid.w || utils.deepAccess(bidRequest, 'mediaTypes.video.w') || utils.deepAccess(bidRequest, 'params.video.playerWidth'),
height: bid.h || utils.deepAccess(bidRequest, 'mediaTypes.video.h') || utils.deepAccess(bidRequest, 'params.video.playerHeight'),
};
Expand Down Expand Up @@ -639,7 +639,7 @@ export const spec = {
cpm: ad.cpm || 0,
dealId: ad.deal,
ttl: 300, // 5 minutes
netRevenue: config.getConfig('rubicon.netRevenue') || false,
netRevenue: config.getConfig('rubicon.netRevenue') !== false, // If anything other than false, netRev is true
rubicon: {
advertiserId: ad.advertiser, networkId: ad.network
},
Expand Down
116 changes: 114 additions & 2 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,7 @@ describe('the rubicon adapter', function () {
expect(bids[0].height).to.equal(50);
expect(bids[0].cpm).to.equal(0.911);
expect(bids[0].ttl).to.equal(300);
expect(bids[0].netRevenue).to.equal(false);
expect(bids[0].netRevenue).to.equal(true);
expect(bids[0].rubicon.advertiserId).to.equal(7);
expect(bids[0].rubicon.networkId).to.equal(8);
expect(bids[0].creativeId).to.equal('crid-9');
Expand All @@ -1775,7 +1775,7 @@ describe('the rubicon adapter', function () {
expect(bids[1].height).to.equal(250);
expect(bids[1].cpm).to.equal(0.811);
expect(bids[1].ttl).to.equal(300);
expect(bids[1].netRevenue).to.equal(false);
expect(bids[1].netRevenue).to.equal(true);
expect(bids[1].rubicon.advertiserId).to.equal(7);
expect(bids[1].rubicon.networkId).to.equal(8);
expect(bids[1].creativeId).to.equal('crid-9');
Expand All @@ -1787,6 +1787,118 @@ describe('the rubicon adapter', function () {
expect(bids[1].rubiconTargeting.rpfl_14062).to.equal('15_tier_all_test');
});

it('should pass netRevenue correctly if set in setConfig', 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',
'impression_id': '153dc240-8229-4604-b8f5-256933b9374c',
'size_id': '15',
'ad_id': '6',
'advertiser': 7,
'network': 8,
'creative_id': 'crid-9',
'type': 'script',
'script': 'alert(\'foo\')',
'campaign_id': 10,
'cpm': 0.811,
'targeting': [
{
'key': 'rpfl_14062',
'values': [
'15_tier_all_test'
]
}
]
},
{
'status': 'ok',
'impression_id': '153dc240-8229-4604-b8f5-256933b9374d',
'size_id': '43',
'ad_id': '7',
'advertiser': 7,
'network': 8,
'creative_id': 'crid-9',
'type': 'script',
'script': 'alert(\'foo\')',
'campaign_id': 10,
'cpm': 0.911,
'targeting': [
{
'key': 'rpfl_14062',
'values': [
'43_tier_all_test'
]
}
]
}
]
};

// Set to false => false
config.setConfig({
rubicon: {
netRevenue: false
}
});
let bids = spec.interpretResponse({body: response}, {
bidRequest: bidderRequest.bids[0]
});
expect(bids).to.be.lengthOf(2);
expect(bids[0].netRevenue).to.equal(false);
expect(bids[1].netRevenue).to.equal(false);

// Set to true => true
config.setConfig({
rubicon: {
netRevenue: true
}
});
bids = spec.interpretResponse({body: response}, {
bidRequest: bidderRequest.bids[0]
});
expect(bids).to.be.lengthOf(2);
expect(bids[0].netRevenue).to.equal(true);
expect(bids[1].netRevenue).to.equal(true);

// Set to undefined => true
config.setConfig({
rubicon: {
netRevenue: undefined
}
});
bids = spec.interpretResponse({body: response}, {
bidRequest: bidderRequest.bids[0]
});
expect(bids).to.be.lengthOf(2);
expect(bids[0].netRevenue).to.equal(true);
expect(bids[1].netRevenue).to.equal(true);

// Set to string => true
config.setConfig({
rubicon: {
netRevenue: 'someString'
}
});
bids = spec.interpretResponse({body: response}, {
bidRequest: bidderRequest.bids[0]
});
expect(bids).to.be.lengthOf(2);
expect(bids[0].netRevenue).to.equal(true);
expect(bids[1].netRevenue).to.equal(true);

config.resetConfig();
});
it('should use "network-advertiser" if no creative_id', function () {
let response = {
'status': 'ok',
Expand Down

0 comments on commit 42d856b

Please sign in to comment.