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-P1: discard emptyVAST and invalidVAST bids detected by VAST unwrap module #933

Merged
merged 8 commits into from
Oct 9, 2024
32 changes: 32 additions & 0 deletions analytics/pubmatic/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ 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)
bid.Price = price
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 +567,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
Loading