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

OTT-1807: discard emptyVAST and invalidVAST bids detected by VAST unwrap module #874

Merged
merged 12 commits into from
Sep 2, 2024
Merged
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,
pm-jaydeep-mohite marked this conversation as resolved.
Show resolved Hide resolved
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
Loading