Skip to content

Commit

Permalink
OTT-1807: discard emptyVAST and invalidVAST bids detected by VAST unw…
Browse files Browse the repository at this point in the history
…rap module (#874)

* OTT-1807: discard emptyVAST and invalidVAST bids
  • Loading branch information
ashishshinde-pubm authored and pm-viral-vala committed Sep 26, 2024
1 parent bcc32d1 commit e28236f
Show file tree
Hide file tree
Showing 17 changed files with 1,245 additions and 570 deletions.
31 changes: 31 additions & 0 deletions analytics/pubmatic/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ func getPartnerRecordsByImp(ao analytics.AuctionObject, rCtx *models.RequestCtx)
}

price := bid.Price
// If bids are rejected before setting bidExt.OriginalBidCPM, calculate the price and ocpm values based on the currency and revshare.
price = computeBidPriceForBidsRejectedBeforeSettingOCPM(rCtx, &bidExt, price, revShare, ao)
if ao.Response.Cur != models.USD {
if bidCtx.EN != 0 { // valid-bids + dropped-bids+ default-bids
price = bidCtx.EN
Expand Down Expand Up @@ -564,3 +566,32 @@ func getAdPodSlot(adPodConfig *models.AdPod) *AdPodSlot {

return &adPodSlot
}

func GetBidPriceAfterCurrencyConversion(price float64, requestCurrencies []string, responseCurrency string,
currencyConverter func(fromCurrency string, toCurrency string, value float64) (float64, error)) float64 {
if len(requestCurrencies) == 0 {
requestCurrencies = []string{models.USD}
}
for _, requestCurrency := range requestCurrencies {
if value, err := currencyConverter(responseCurrency, requestCurrency, price); err == nil {
return value
}
}
return 0 // in case of error, send 0 value to make it consistent with prebid
}

func computeBidPriceForBidsRejectedBeforeSettingOCPM(rCtx *models.RequestCtx, bidExt *models.BidExt,
price, revshare float64, ao analytics.AuctionObject) float64 {
if price != 0 && bidExt.OriginalBidCPM == 0 {
if len(bidExt.OriginalBidCur) == 0 {
bidExt.OriginalBidCur = models.USD
}
bidExt.OriginalBidCPM = price
price = price * models.GetBidAdjustmentValue(revshare)
if cpmUSD, err := rCtx.CurrencyConversion(bidExt.OriginalBidCur, models.USD, price); err == nil {
bidExt.OriginalBidCPMUSD = cpmUSD
}
price = GetBidPriceAfterCurrencyConversion(price, ao.RequestWrapper.Cur, bidExt.OriginalBidCur, rCtx.CurrencyConversion)
}
return price
}
Loading

0 comments on commit e28236f

Please sign in to comment.