Skip to content

Commit

Permalink
add support for latLong in rubicon adapter (#2508)
Browse files Browse the repository at this point in the history
  • Loading branch information
snapwich authored and harpere committed May 11, 2018
1 parent 3d96d9e commit 877a58c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
16 changes: 12 additions & 4 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ export const spec = {
keywords,
visitor,
inventory,
userId
userId,
latLong: [latitude, longitude] = [],
} = bidRequest.params;

// defaults
Expand All @@ -230,7 +231,9 @@ export const spec = {
'x_source.tid', bidRequest.transactionId,
'p_screen_res', _getScreenResolution(),
'kw', keywords,
'tk_user_key', userId
'tk_user_key', userId,
'p_geo.latitude', parseFloat(latitude).toFixed(4),
'p_geo.longitude', parseFloat(longitude).toFixed(4)
];

if (gdprConsent) {
Expand Down Expand Up @@ -258,7 +261,7 @@ export const spec = {

data = data.reduce(
(memo, curr, index) =>
index % 2 === 0 && data[index + 1] !== undefined
index % 2 === 0 && data[index + 1] !== undefined && !isNaN(data[index + 1])
? memo + curr + '=' + encodeURIComponent(data[index + 1]) + '&' : memo,
''
).slice(0, -1); // remove trailing &
Expand Down Expand Up @@ -287,7 +290,7 @@ export const spec = {
* @return {Bid[]} An array of bids which
*/
interpretResponse: function (responseObj, {bidRequest}) {
responseObj = responseObj.body
responseObj = responseObj.body;
let ads = responseObj.ads;

// check overall response
Expand Down Expand Up @@ -472,4 +475,9 @@ export function resetUserSync() {
hasSynced = false;
}

function isNaN(value) {
// eslint-disable-next-line no-self-compare
return value !== value;
}

registerBidder(spec);
7 changes: 5 additions & 2 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ describe('the rubicon adapter', () => {
lastsearch: 'iphone'
},
position: 'atf',
referrer: 'localhost'
referrer: 'localhost',
latLong: [40.7608, '111.8910']
},
adUnitCode: '/19968336/header-bid-tag-0',
code: 'div-1',
Expand Down Expand Up @@ -239,7 +240,9 @@ describe('the rubicon adapter', () => {
'tg_v.lastsearch': 'iphone',
'tg_i.rating': '5-star',
'tg_i.prodtype': 'tech',
'rf': 'localhost'
'rf': 'localhost',
'p_geo.latitude': '40.7608',
'p_geo.longitude': '111.8910'
};

// test that all values above are both present and correct
Expand Down

0 comments on commit 877a58c

Please sign in to comment.