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

add support for latLong in rubicon adapter #2508

Merged
merged 1 commit into from
May 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Collaborator

Choose a reason for hiding this comment

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

how does this work?

Copy link
Collaborator Author

@snapwich snapwich May 8, 2018

Choose a reason for hiding this comment

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

I got it from here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN#Polyfill

It's a polyfill for Number.isNaN(); I didn't want to use window.isNaN() because it's buggy and Number.isNaN() isn't supported in Internet Explorer.

}

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