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

UOE-11098: Pass user.ext.sessionduration and user.ext.impdepth ORTB request to OW partners #918

Open
wants to merge 26 commits into
base: ci
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
dc9041a
UOE-10974: Bug-fix- PubMatic-Secondary and pubmatic alias partners ar…
AvinashKapre Aug 30, 2024
8a1de80
UOE-10950 : kgpv and kgpsv getting empty in logger for flag test=1 (#…
pm-priyanka-bagade Aug 30, 2024
3334b0f
OTT-1807: discard emptyVAST and invalidVAST bids detected by VAST unw…
ashishshinde-pubm Sep 2, 2024
cce5d99
OTT-1863 :: Support to read adpod configs from UI in openwrap module …
pm-nikhil-vaidya Sep 3, 2024
cea0fed
Fixed import issue (#892)
pm-nikhil-vaidya Sep 3, 2024
edfbc45
UOE-8632: refactoring macro replacement in video event injection (#858)
pm-viral-vala Sep 3, 2024
5e667cf
UOE-10993: Support for apppLovinMax endpoint- Read and forwrad DSA ob…
AvinashKapre Sep 4, 2024
fbd2a2c
OTT-1824-P1: enabling fastxml for vcr (#894)
pm-viral-vala Sep 4, 2024
dceb025
Merge pull request #897 from PubMatic-OpenWrap/master
PubMatic-OpenWrap Sep 9, 2024
b5d950c
OTT-1824-P2 removing bidder key and updating logs for fastxml (#896)
pm-viral-vala Sep 9, 2024
212b43a
OTT-1982: honor IFA over session_id if when ifa_type is absent (#895)
Pubmatic-Supriya-Patil Sep 9, 2024
82e4730
OTT-1824-Fix-Imports (#898)
pm-viral-vala Sep 9, 2024
cd6c38d
OTT-1807: Fix incorrect pb value for seatNonBid (#899)
ashishshinde-pubm Sep 10, 2024
cfc54e4
OTT-1824-P31 Adding fastxml_enabled_percentage (#900)
pm-viral-vala Sep 10, 2024
9e2497f
Fixed panic when connectionType is not available in request (#901)
pm-nikhil-vaidya Sep 10, 2024
0affd2c
Merge pull request #902 from PubMatic-OpenWrap/ci
PubMatic-OpenWrap Sep 10, 2024
adcba22
Merge pull request #905 from PubMatic-OpenWrap/master
PubMatic-OpenWrap Sep 14, 2024
cb7dca4
OTT-1824-P4: updated etree library to return trimmed text (#906)
pm-viral-vala Sep 14, 2024
5d3b3de
UOE-10822: Prometheus Stat for Bid Recovery (#851)
pm-saurabh-narkhede Sep 16, 2024
c10317d
UOE-11149: Send Encoded SSPBurl in bid.Burl (#908)
pm-saurabh-narkhede Sep 16, 2024
69030ce
UOE-11149: Fix Tests-Send Encoded SSPBurl in bid.Burl (#909)
pm-saurabh-narkhede Sep 16, 2024
432f47b
OTT-11098: Pass user.ext.sessionduration and user.ext.impdepth ORTB r…
Pubmatic-Supriya-Patil Sep 23, 2024
f0c4ed3
UOE-11098: Added validation on session duration and imp depth to cons…
Pubmatic-Supriya-Patil Sep 24, 2024
c55846a
UOE-11098:Fix session duration and imp depth validation in CTV parser…
Pubmatic-Supriya-Patil Sep 26, 2024
b8ceeb6
UOE-11098:Fix session duration and imp depth validation in CTV parser…
Pubmatic-Supriya-Patil Sep 26, 2024
f545c40
UOE-11098: Addressed Review Comment
Pubmatic-Supriya-Patil Sep 27, 2024
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
9 changes: 4 additions & 5 deletions adapters/vastbidder/etree_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package vastbidder

import (
"strconv"
"strings"

"github.com/beevik/etree"
"github.com/prebid/prebid-server/v2/openrtb_ext"
Expand Down Expand Up @@ -70,7 +69,7 @@ func (p *etreeXMLParser) GetPricingDetails() (price float64, currency string) {
return 0.0, ""
}

priceValue, err := strconv.ParseFloat(strings.TrimSpace(node.Text()), 64)
priceValue, err := strconv.ParseFloat(node.TrimmedText(), 64)
if nil != err {
return 0.0, ""
}
Expand All @@ -89,7 +88,7 @@ func (p *etreeXMLParser) GetAdvertiser() (advertisers []string) {
if ext.SelectAttrValue("type", "") == "advertiser" {
ele := ext.SelectElement("Advertiser")
if ele != nil {
if value := strings.TrimSpace(ele.Text()); len(value) > 0 {
if value := ele.TrimmedText(); len(value) > 0 {
advertisers = append(advertisers, value)
}
}
Expand All @@ -98,7 +97,7 @@ func (p *etreeXMLParser) GetAdvertiser() (advertisers []string) {

case vastVersion4x:
if ele := p.adElement.SelectElement("Advertiser"); ele != nil {
if value := strings.TrimSpace(ele.Text()); len(value) > 0 {
if value := ele.TrimmedText(); len(value) > 0 {
advertisers = append(advertisers, value)
}
}
Expand Down Expand Up @@ -126,7 +125,7 @@ func (p *etreeXMLParser) GetDuration() (int, error) {
if node == nil {
return 0, errEmptyVideoDuration
}
return parseDuration(strings.TrimSpace(node.Text()))
return parseDuration(node.TrimmedText())
}

func (p *etreeXMLParser) getAdElement(vast *etree.Element) *etree.Element {
Expand Down
6 changes: 6 additions & 0 deletions adapters/vastbidder/etree_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ func getPricingDetailsTestCases() []struct {
wantPrice: 0,
wantCurrency: "",
},
{
name: "bug",
vastXML: "<VAST\n\txmlns:xs=\"https://www.w3.org/2001/XMLSchema\"\n\txmlns=\"https://www.iab.com/VAST\" version=\"4.1\">\n\t<Ad id=\"scenario_9_adid\" sequence=\"1\">\n\t\t<InLine>\n\t\t\t<AdSystem version=\"4.1\">PubMatic</AdSystem>\n\t\t\t<AdServingId>scenario_9</AdServingId>\n\t\t\t<AdTitle>Test Ad scenario_9</AdTitle>\n\t\t\t<Pricing model=\"cpm\" currency=\"USD\">\n\t\t\t\t<![CDATA[ 5.00 ]]>\n\t\t\t</Pricing>\n\t\t\t<Impression>\n\t\t\t\t<![CDATA[ https://example.com/impression/ ]]>\n\t\t\t</Impression>\n\t\t\t<Advertiser>Test Advertiser</Advertiser>\n\t\t\t<Category authority=\"https://www.iabtechlab.com/categoryauthority\">IAB1-1\t</Category>\n\t\t\t<Creatives>\n\t\t\t\t<Creative id=\"5481\" sequence=\"1\" adId=\"2447226_scenario_9\">\n\t\t\t\t\t<UniversalAdId idRegistry=\"Ad-ID\">8465_scenario_9</UniversalAdId>\n\t\t\t\t\t<Linear>\n\t\t\t\t\t\t<Duration>00:00:10</Duration>\n\t\t\t\t\t\t<MediaFiles>\n\t\t\t\t\t\t\t<MediaFile delivery=\"progressive\" type=\"video/mp4\" bitrate=\"500\" width=\"400\" height=\"300\" scalable=\"true\" maintainAspectRatio=\"true\">\n\t\t\t\t\t\t\t\t<![CDATA[ https://ads.pubmatic.com/AdServer/js/ott/sampleads/10_seconds_ad.mp4 ]]>\n\t\t\t\t\t\t\t</MediaFile>\n\t\t\t\t\t\t</MediaFiles>\n\t\t\t\t\t</Linear>\n\t\t\t\t</Creative>\n\t\t\t</Creatives>\n\t\t</InLine>\n\t</Ad>\n</VAST> ",
wantPrice: 5,
wantCurrency: "USD",
},
// TODO: Add test cases.
}
}
Expand Down
8 changes: 4 additions & 4 deletions adapters/vastbidder/fastxml_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (p *fastXMLParser) GetPricingDetails() (price float64, currency string) {
return 0.0, ""
}

priceValue, err := strconv.ParseFloat(strings.TrimSpace(p.reader.Text(node, true)), 64)
priceValue, err := strconv.ParseFloat(strings.TrimSpace(p.reader.RawText(node)), 64)
if nil != err {
return 0.0, ""
}
Expand All @@ -89,7 +89,7 @@ func (p *fastXMLParser) GetAdvertiser() (advertisers []string) {
if p.reader.SelectAttrValue(ext, "type") == "advertiser" {
ele := p.reader.SelectElement(ext, "Advertiser")
if ele != nil {
if value := strings.TrimSpace(p.reader.Text(ele, true)); len(value) > 0 {
if value := strings.TrimSpace(p.reader.Text(ele)); len(value) > 0 {
advertisers = append(advertisers, value)
}
}
Expand All @@ -98,7 +98,7 @@ func (p *fastXMLParser) GetAdvertiser() (advertisers []string) {

case vastVersion4x:
if ele := p.reader.SelectElement(p.adElement, "Advertiser"); ele != nil {
if value := strings.TrimSpace(p.reader.Text(ele, true)); len(value) > 0 {
if value := strings.TrimSpace(p.reader.Text(ele)); len(value) > 0 {
advertisers = append(advertisers, value)
}
}
Expand Down Expand Up @@ -126,7 +126,7 @@ func (p *fastXMLParser) GetDuration() (int, error) {
if node == nil {
return 0, errEmptyVideoDuration
}
return parseDuration(strings.TrimSpace(p.reader.Text(node, true)))
return parseDuration(strings.TrimSpace(p.reader.RawText(node)))
}

func (p *fastXMLParser) getAdElement(vast *fastxml.Element) *fastxml.Element {
Expand Down
22 changes: 11 additions & 11 deletions adapters/vastbidder/vastbidder.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
// VASTBidder is default implementation of ITagBidder
type VASTBidder struct {
adapters.Bidder
bidderName openrtb_ext.BidderName
adapterConfig *config.Adapter
fastXMLExperiment bool
bidderName openrtb_ext.BidderName
adapterConfig *config.Adapter
fastXMLEnabledPercentage int
}

// MakeRequests will contains default definition for processing queries
Expand Down Expand Up @@ -76,7 +76,7 @@ func (a *VASTBidder) MakeBids(internalRequest *openrtb2.BidRequest, externalRequ

responseData, errs := handler.MakeBids()

if a.fastXMLExperiment && len(errs) == 0 {
if openrtb_ext.IsFastXMLEnabled(a.fastXMLEnabledPercentage) && len(errs) == 0 {
a.fastXMLTesting(
newResponseHandler(internalRequest, externalRequest, response, getXMLParser(fastXMLParserType)),
responseData,
Expand All @@ -101,26 +101,26 @@ func (a *VASTBidder) fastXMLTesting(handler *responseHandler, responseData *adap
}
}

vastBidderInfo := &openrtb_ext.FastXMLMetrics{
xmlParsingMetrics := &openrtb_ext.FastXMLMetrics{
XMLParserTime: handlerTime,
EtreeParserTime: etreeParserTime,
IsRespMismatch: isVASTMismatch,
}

responseData.FastXMLMetrics = vastBidderInfo
responseData.FastXMLMetrics = xmlParsingMetrics
}

// NewTagBidder is an constructor for TagBidder
func NewTagBidder(bidderName openrtb_ext.BidderName, config config.Adapter, enableFastXML bool) *VASTBidder {
func NewTagBidder(bidderName openrtb_ext.BidderName, config config.Adapter, enableFastXML int) *VASTBidder {
obj := &VASTBidder{
bidderName: bidderName,
adapterConfig: &config,
fastXMLExperiment: enableFastXML,
bidderName: bidderName,
adapterConfig: &config,
fastXMLEnabledPercentage: enableFastXML,
}
return obj
}

// Builder builds a new instance of the 33Across adapter for the given bidder with the given config.
func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, serverConfig config.Server) (adapters.Bidder, error) {
return NewTagBidder(bidderName, config, serverConfig.EnableFastXML), nil
return NewTagBidder(bidderName, config, serverConfig.FastXMLEnabledPercentage), nil
}
2 changes: 1 addition & 1 deletion adapters/vastbidder/vastbidder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func TestMakeRequests(t *testing.T) {
RegisterNewBidderMacro(bidderName, func() IBidderMacro {
return newMyVastBidderMacro(tt.args.customHeaders)
})
bidder := NewTagBidder(bidderName, config.Adapter{}, false)
bidder := NewTagBidder(bidderName, config.Adapter{}, 0)
reqData, err := bidder.MakeRequests(tt.args.req, nil)
assert.Nil(t, err)
for _, req := range reqData {
Expand Down
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