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-9681,UOE-9670: Add OWS hosted PBS vanilla endpoint, for prebid.js DIY client #583

Merged
merged 25 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ccaa7ac
OWS hosted PBS vanilla endpoint
AvinashKapre Oct 13, 2023
9233011
Reading profile deatils from request ext
AvinashKapre Oct 15, 2023
9505578
Merge branch 'ci' into UOE-9681
AvinashKapre Oct 16, 2023
a6eadc5
test cases
AvinashKapre Oct 16, 2023
3955d0c
Merge branch 'ci' into UOE-9681
AvinashKapre Oct 19, 2023
ee6ca06
read adunit for prebid.js diy client req
pm-saurabh-narkhede Oct 12, 2023
0476286
separate adunit by delimeter '#'
pm-saurabh-narkhede Oct 12, 2023
8c9e96d
modify and add tests
pm-saurabh-narkhede Oct 16, 2023
310dc6e
address comment
pm-saurabh-narkhede Oct 16, 2023
1f98796
Merge remote-tracking branch 'origin/UOE-9670-ci' into UOE-9681
AvinashKapre Oct 19, 2023
e6a3b75
Fix unit test case
AvinashKapre Oct 23, 2023
f6b3b10
debug flag set from request.ext.prebid.debug
AvinashKapre Nov 3, 2023
07c1bbf
Merge branch 'ci' into UOE-9681
AvinashKapre Nov 3, 2023
cbb41c5
temp
AvinashKapre Nov 3, 2023
d0d71a0
entrypoint hook refactor
AvinashKapre Nov 3, 2023
4b67612
Nitpick
AvinashKapre Nov 6, 2023
bcff633
Set sshb key in rctx to identify request
AvinashKapre Nov 6, 2023
61217fa
sshb handling in auctionResponse hook
AvinashKapre Nov 6, 2023
728479e
sshb hybrid case
AvinashKapre Nov 6, 2023
9e555b9
test cases
AvinashKapre Nov 6, 2023
92f9ea1
address review comment
pm-saurabh-narkhede Nov 6, 2023
3ed88df
name refactor
AvinashKapre Nov 7, 2023
1146e26
Merge branch 'UOE-9681' of https://github.com/PubMatic-OpenWrap/prebi…
AvinashKapre Nov 7, 2023
471d84b
Merge branch 'ci' into UOE-9681
AvinashKapre Nov 7, 2023
47f8ace
Merge branch 'ci' into UOE-9681
AvinashKapre Nov 7, 2023
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: 9 additions & 0 deletions modules/pubmatic/openwrap/auctionresponsehook.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ func (m OpenWrap) handleAuctionResponseHook(
result.DebugMessages = append(result.DebugMessages, "error: request-ctx not found in handleBeforeValidationHook()")
return result, nil
}

//SSHB request should not execute module
if rctx.Sshb == "1" || rctx.Endpoint == models.EndpointHybrid {
return result, nil
}
if rctx.Endpoint == models.EndpointOWS2S {
return result, nil
AvinashKapre marked this conversation as resolved.
Show resolved Hide resolved
}

defer func() {
moduleCtx.ModuleContext["rctx"] = rctx
m.metricEngine.RecordPublisherResponseTimeStats(rctx.PubIDStr, int(time.Since(time.Unix(rctx.StartTime, 0)).Milliseconds()))
Expand Down
53 changes: 40 additions & 13 deletions modules/pubmatic/openwrap/beforevalidationhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"net/url"
"strconv"
"strings"

"github.com/buger/jsonparser"
"github.com/prebid/openrtb/v19/openrtb2"
Expand Down Expand Up @@ -46,6 +47,18 @@ func (m OpenWrap) handleBeforeValidationHook(
}
}()

//Do not execute the module for requests processed in SSHB(8001)
if rCtx.Sshb == "1" {
result.Reject = false
return result, nil
}

if rCtx.Endpoint == models.EndpointHybrid {
//TODO: Add bidder params fix
result.Reject = false
return result, nil
}

pubID, err := getPubID(*payload.BidRequest)
if err != nil {
result.NbrCode = nbr.InvalidPublisherID
Expand Down Expand Up @@ -154,6 +167,19 @@ func (m OpenWrap) handleBeforeValidationHook(
var isAdPodImpression bool
imp := payload.BidRequest.Imp[i]

impExt := &models.ImpExtension{}
if len(imp.Ext) != 0 {
err := json.Unmarshal(imp.Ext, impExt)
if err != nil {
result.NbrCode = nbr.InternalError
err = errors.New("failed to parse imp.ext: " + imp.ID)
result.Errors = append(result.Errors, err.Error())
return result, err
}
}
if rCtx.Endpoint == models.EndpointOWS2S {
imp.TagID = getTagID(imp, impExt)
}
if imp.TagID == "" {
result.NbrCode = nbr.InvalidImpressionTagID
err = errors.New("tagid missing for imp: " + imp.ID)
Expand Down Expand Up @@ -184,17 +210,6 @@ func (m OpenWrap) handleBeforeValidationHook(
}
}

impExt := &models.ImpExtension{}
if len(imp.Ext) != 0 {
err := json.Unmarshal(imp.Ext, impExt)
if err != nil {
result.NbrCode = nbr.InternalError
err = errors.New("failed to parse imp.ext: " + imp.ID)
result.Errors = append(result.Errors, err.Error())
return result, err
}
}

div := ""
if impExt.Wrapper != nil {
div = impExt.Wrapper.Div
Expand Down Expand Up @@ -439,7 +454,7 @@ func (m *OpenWrap) applyProfileChanges(rctx models.RequestCtx, bidRequest *openr
}

if cur, ok := rctx.PartnerConfigMap[models.VersionLevelConfigID][models.AdServerCurrency]; ok {
bidRequest.Cur = []string{cur}
bidRequest.Cur = append(bidRequest.Cur, cur)
}
if bidRequest.TMax == 0 {
bidRequest.TMax = rctx.TMax
Expand Down Expand Up @@ -797,7 +812,6 @@ func (m OpenWrap) setTimeout(rCtx models.RequestCtx) int64 {
// if ssauction flag is not set and platform is dislay, then by default send all bids
// if ssauction flag is not set and platform is in-app, then check if profile setting sendAllBids is set to 1
func isSendAllBids(rctx models.RequestCtx) bool {

//if ssauction is set to 0 in the request
if rctx.SSAuction == 0 {
return true
Expand Down Expand Up @@ -844,3 +858,16 @@ func getPubID(bidRequest openrtb2.BidRequest) (pubID int, err error) {
}
return pubID, err
}

func getTagID(imp openrtb2.Imp, impExt *models.ImpExtension) string {
//priority for tagId is imp.ext.gpid > imp.TagID > imp.ext.data.pbadslot
if impExt.Gpid != "" {
if idx := strings.Index(impExt.Gpid, "#"); idx != -1 {
return impExt.Gpid[:idx]
}
return impExt.Gpid
} else if imp.TagID != "" {
return imp.TagID
}
return impExt.Data.PbAdslot
}
Loading
Loading