-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Rubicon: PVID & Standardize rubicon get config calls #5780
Changes from all commits
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 |
---|---|---|
|
@@ -51,27 +51,16 @@ const cache = { | |
|
||
const BID_REJECTED_IPF = 'rejected-ipf'; | ||
|
||
let fpkvs = {}; | ||
function updateFpkvs(fpkvs, newKvs) { | ||
const isValid = typeof newKvs === 'object' && Object.keys(newKvs).every(key => typeof newKvs[key] === 'string'); | ||
if (!isValid) { | ||
utils.logError('Rubicon Analytics: fpkvs must be object with string keys and values'); | ||
return fpkvs; | ||
} else { | ||
return {...fpkvs, ...newKvs}; | ||
} | ||
} | ||
|
||
let integration, ruleId, wrapperName; | ||
// listen for any rubicon setConfig events and save them to appropriate fields! | ||
export let rubiConf = { | ||
pvid: utils.generateUUID().slice(0, 8) | ||
}; | ||
// we are saving these as global to this module so that if a pub accidentally overwrites the entire | ||
// rubicon object, then we do not lose other data | ||
config.getConfig('rubicon', config => { | ||
let rubiConf = config.rubicon; | ||
integration = rubiConf.int_type || integration || DEFAULT_INTEGRATION; | ||
ruleId = rubiConf.rule_name || ruleId; | ||
wrapperName = rubiConf.wrapperName || wrapperName; | ||
fpkvs = rubiConf.fpkvs ? updateFpkvs(fpkvs, rubiConf.fpkvs) : fpkvs | ||
utils.mergeDeep(rubiConf, config.rubicon); | ||
if (utils.deepAccess(config, 'rubicon.updatePageView') === true) { | ||
rubiConf.pvid = utils.generateUUID().slice(0, 8) | ||
} | ||
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. deep merge everything, but if this specific setConfig call wants us to regenerate the pvid, we do so. |
||
}); | ||
|
||
export function getHostNameFromReferer(referer) { | ||
|
@@ -163,13 +152,13 @@ function sendMessage(auctionId, bidWonId) { | |
let referrer = config.getConfig('pageUrl') || (auctionCache && auctionCache.referrer); | ||
let message = { | ||
eventTimeMillis: Date.now(), | ||
integration, | ||
ruleId, | ||
integration: rubiConf.int_type || DEFAULT_INTEGRATION, | ||
ruleId: rubiConf.rule_name, | ||
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. if never set, then it will be |
||
version: '$prebid.version$', | ||
referrerUri: referrer, | ||
referrerHostname: rubiconAdapter.referrerHostname || getHostNameFromReferer(referrer), | ||
channel: 'web', | ||
wrapperName | ||
wrapperName: rubiConf.wrapperName | ||
}; | ||
if (auctionCache && !auctionCache.sent) { | ||
let adUnitMap = Object.keys(auctionCache.bids).reduce((adUnits, bidId) => { | ||
|
@@ -359,10 +348,9 @@ export function parseBidResponse(bid, previousBidResponse, auctionFloorData) { | |
]); | ||
} | ||
|
||
function getPageViewId() { | ||
if (prebidGlobal.rp && typeof prebidGlobal.rp.generatePageViewId === 'function') { | ||
return prebidGlobal.rp.generatePageViewId(false); | ||
} | ||
function getFpkvs() { | ||
const isValid = rubiConf.fpkvs && typeof rubiConf.fpkvs === 'object' && Object.keys(rubiConf.fpkvs).every(key => typeof rubiConf.fpkvs[key] === 'string'); | ||
return isValid ? rubiConf.fpkvs : {}; | ||
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. makes sure any set fpkvs are valid before merging, else just empty |
||
} | ||
|
||
let samplingFactor = 1; | ||
|
@@ -420,8 +408,8 @@ function updateRpaCookie() { | |
// possible that decodedRpaCookie is undefined, and if it is, we probably are blocked by storage or some other exception | ||
if (Object.keys(decodedRpaCookie).length) { | ||
decodedRpaCookie.lastSeen = currentTime; | ||
decodedRpaCookie.fpkvs = {...decodedRpaCookie.fpkvs, ...fpkvs}; | ||
decodedRpaCookie.pvid = getPageViewId(); | ||
decodedRpaCookie.fpkvs = {...decodedRpaCookie.fpkvs, ...getFpkvs()}; | ||
decodedRpaCookie.pvid = rubiConf.pvid; | ||
setRpaCookie(decodedRpaCookie) | ||
} | ||
return decodedRpaCookie; | ||
|
@@ -495,8 +483,8 @@ let rubiconAdapter = Object.assign({}, baseAdapter, { | |
}, | ||
disableAnalytics() { | ||
this.getUrl = baseAdapter.getUrl; | ||
accountId = integration = ruleId = wrapperName = undefined; | ||
fpkvs = {}; | ||
accountId = undefined; | ||
rubiConf = {}; | ||
cache.gpt.registered = false; | ||
baseAdapter.disableAnalytics.apply(this, arguments); | ||
}, | ||
|
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.
On intial page load we set first pvid automatically