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

ADS-4131 Enable MavenDistributionAnalyticsAdapter (LiftIgniter) for Salish and HubPages #24

Merged
merged 2 commits into from
Jun 24, 2020
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
1 change: 1 addition & 0 deletions hpmodules.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"justpremiumBidAdapter",
"mantisBidAdapter",
"mavenAnalyticsAdapter",
"mavenDistributionAnalyticsAdapter",
"openxBidAdapter",
"rubiconBidAdapter",
"sovrnBidAdapter",
Expand Down
1 change: 1 addition & 0 deletions modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"justpremiumBidAdapter",
"lockerdomeBidAdapter",
"mantisBidAdapter",
"mavenDistributionAnalyticsAdapter",
"medianetBidAdapter",
"openxBidAdapter",
"pubmaticBidAdapter",
Expand Down
31 changes: 22 additions & 9 deletions modules/mavenDistributionAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const MAVEN_DISTRIBUTION_GLOBAL = '$p'
* provider: typeof PROVIDER_CODE
* options: {
* sampling?: number
* zoneMap: {[adUnitCode: string]: {index?: number, zone?: string}}
* zoneMap?: {[adUnitCode: string]: {index?: number, zone?: string}}
* }
* }} MavenDistributionAdapterConfig
*/
Expand Down Expand Up @@ -64,13 +64,25 @@ export function summarizeAuctionEnd(args, adapterConfig) {
const cpmsMap = {}
const zoneNames = []
const zoneIndexes = []
const adUnitCodes = []
const zoneMap = adapterConfig.options.zoneMap || {}
let someZoneIndexNonNull = false
let someZoneNameNonNull = false
let allZoneNamesNonNull = true
args.adUnits.forEach(adUnit => {
cpmsMap[adUnit.code] = 0
const zoneConfig = adapterConfig.options.zoneMap[adUnit.code] || {}
let zoneIndex = zoneConfig.index != null && isFinite(zoneConfig.index)
? +zoneConfig.index : null
adUnitCodes.push(adUnit.code)

const zoneConfig = zoneMap[adUnit.code] || {}
const zoneIndexNonNull = zoneConfig.index != null && isFinite(zoneConfig.index)
someZoneIndexNonNull = someZoneIndexNonNull || zoneIndexNonNull

let zoneIndex = zoneIndexNonNull ? +zoneConfig.index : null
const zoneNameNonNull = zoneConfig.zone != null
zoneIndexes.push(zoneIndex)
zoneNames.push(zoneConfig.zone != null ? zoneConfig.zone : null)
zoneNames.push(zoneNameNonNull ? zoneConfig.zone : null)
someZoneNameNonNull = someZoneNameNonNull || zoneNameNonNull
allZoneNamesNonNull = allZoneNamesNonNull && zoneNameNonNull
})
args.bidsReceived.forEach(bid => {
cpmsMap[bid.adUnitCode] = Math.max(cpmsMap[bid.adUnitCode], bid.cpm || 0)
Expand All @@ -81,9 +93,10 @@ export function summarizeAuctionEnd(args, adapterConfig) {
const eventToSend = {
auc: args.auctionId,
cpms: cpms,
zoneIndexes: zoneIndexes,
zoneNames: zoneNames,
}
if (!allZoneNamesNonNull) eventToSend.codes = adUnitCodes
if (someZoneNameNonNull) eventToSend.zoneNames = zoneNames
if (someZoneIndexNonNull) eventToSend.zoneIndexes = zoneIndexes
return eventToSend
}

Expand Down Expand Up @@ -153,8 +166,8 @@ MavenDistributionAnalyticsAdapter.prototype = {
// call base implementation which prints a warning
return this.base.enableAnalytics(adapterConfig)
}
if (adapterConfig.options.zoneMap == null) {
return logError(`Adapter ${PROVIDER_CODE}: zoneMap null; disabling`)
if (adapterConfig.options == null) {
return logError(`Adapter ${PROVIDER_CODE}: options null; disabling`)
}
const inner = new MavenDistributionAnalyticsAdapterInner(adapterConfig)
const base = adapter({global: MAVEN_DISTRIBUTION_GLOBAL})
Expand Down
Loading