-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Appnexus adaptor - Added App parameters for hybrid apps. #2973
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
Changes from 4 commits
9a2ec5f
879d079
8571aae
9a20e4b
d9f0681
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ const URL = '//ib.adnxs.com/ut/v3/prebid'; | |
const VIDEO_TARGETING = ['id', 'mimes', 'minduration', 'maxduration', | ||
'startdelay', 'skippable', 'playback_method', 'frameworks']; | ||
const USER_PARAMS = ['age', 'external_uid', 'segments', 'gender', 'dnt', 'language']; | ||
const APP_DEVICE_PARAMS = ['geo', 'device_id']; // appid is collected separately | ||
const NATIVE_MAPPING = { | ||
body: 'description', | ||
cta: 'ctatext', | ||
|
@@ -59,6 +60,23 @@ export const spec = { | |
.forEach(param => userObj[param] = userObjBid.params.user[param]); | ||
} | ||
|
||
const appDeviceObjBid = find(bidRequests, hasAppDeviceInfo); | ||
let appDeviceObj; | ||
if (appDeviceObjBid && appDeviceObjBid.params && appDeviceObjBid.params.app) { | ||
appDeviceObj = {}; | ||
Object.keys(appDeviceObjBid.params.app) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will throw error if |
||
.filter(param => includes(APP_DEVICE_PARAMS, param)) | ||
.forEach(param => appDeviceObj[param] = appDeviceObjBid.params.app[param]); | ||
} | ||
|
||
const appIdObjBid = find(bidRequests, hasAppId); | ||
let appIdObj; | ||
if (appIdObjBid && appIdObjBid.params && appDeviceObjBid.params.app && appDeviceObjBid.params.app.id) { | ||
appIdObj = { | ||
appid: appIdObjBid.params.app.id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will throw error if params and app are undefined. To access nested property you need to add check that it exist. |
||
}; | ||
} | ||
|
||
const memberIdBid = find(bidRequests, hasMemberId); | ||
const member = memberIdBid ? parseInt(memberIdBid.params.member, 10) : 0; | ||
|
||
|
@@ -74,6 +92,13 @@ export const spec = { | |
payload.member_id = member; | ||
} | ||
|
||
if (appDeviceObjBid) { | ||
payload.device = appDeviceObj | ||
} | ||
if (appIdObjBid) { | ||
payload.app = appIdObj; | ||
} | ||
|
||
if (bidderRequest && bidderRequest.gdprConsent) { | ||
// note - objects for impbus use underscore instead of camelCase | ||
payload.gdpr_consent = { | ||
|
@@ -381,6 +406,19 @@ function hasMemberId(bid) { | |
return !!parseInt(bid.params.member, 10); | ||
} | ||
|
||
function hasAppDeviceInfo(bid) { | ||
if (!!bid.params) { | ||
return !!bid.params.app | ||
} | ||
} | ||
|
||
function hasAppId(bid) { | ||
if (!!bid.params.app) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add check for nested access |
||
return !!bid.params.app.id | ||
} | ||
return !!bid.params.app | ||
} | ||
|
||
function getRtbBid(tag) { | ||
return tag && tag.ads && tag.ads.length && find(tag.ads, ad => ad.rtb); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aneuway2 Just to confirm a use-case - do you foresee the chance that multiple adUnits for
appnexus
would ever have differing values for thisdevice
/geo
fields?This
find
grabs the first matching result and uses that for the value. If you had multiple adUnits with differing sets of values, only the first set of those values would be used - potentially skewing the request that gets generated.I'm not sure this would happen, but I wanted to clarify just in case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsnellbaker device and geo are both related to the current user, so these should remain the same between adUnits