Skip to content

Commit

Permalink
Merge pull request #24 from themaven-net/ADS-4131-send-ad-auction-bid…
Browse files Browse the repository at this point in the history
…s-to-liftigniter

ADS-4131 Enable MavenDistributionAnalyticsAdapter (LiftIgniter) for Salish and HubPages
  • Loading branch information
yonran authored Jun 24, 2020
2 parents a8a492d + 18bbf71 commit 67b19d9
Show file tree
Hide file tree
Showing 4 changed files with 1,403 additions and 9 deletions.
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

0 comments on commit 67b19d9

Please sign in to comment.