Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 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
feebac2
Parser Implementation for AdRule
Pubmatic-Dhruv-Sonone Sep 12, 2024
d7921bf
Adding UTs
Pubmatic-Dhruv-Sonone Sep 12, 2024
85bbca8
Addressing review comments
Pubmatic-Dhruv-Sonone Sep 12, 2024
4b5cbb4
Fixing UT
Pubmatic-Dhruv-Sonone Sep 12, 2024
cb47761
Addressing review comments
Pubmatic-Dhruv-Sonone Sep 13, 2024
2acbbb6
OTT-1987: Adpod requests for not getting created for ORTB endpoint wi…
Pubmatic-Dhruv-Sonone Sep 13, 2024
eea2dd8
Set creative duration matching policy only if video durations are pre…
Pubmatic-Dhruv-Sonone Sep 16, 2024
6493ba9
Removed support for Adpod in request.Ext
Pubmatic-Dhruv-Sonone Sep 16, 2024
acfa62e
UOE-11205: Auto detect Ow values from GAM URL
Pubmatic-Dhruv-Sonone Sep 24, 2024
80c4088
Setting impression video details using GAM params
Pubmatic-Dhruv-Sonone Sep 24, 2024
290b85e
UOE-11231: Fixing Vast XML parsing error in case of debug=1
Pubmatic-Dhruv-Sonone Sep 30, 2024
7f78223
Set adpod to nil in bid.ext for video/vast endpoint
Pubmatic-Dhruv-Sonone Oct 1, 2024
07fe11b
Merging latest ci
Pubmatic-Dhruv-Sonone Oct 2, 2024
e2906e2
Adding validation for Adpod v25
Pubmatic-Dhruv-Sonone Oct 3, 2024
b588992
Merging latest ci
Pubmatic-Dhruv-Sonone Oct 3, 2024
56ab0f4
Merging latest ci
Pubmatic-Dhruv-Sonone Oct 3, 2024
70244fa
UOE-11252: Validation for v25 adpod
Pubmatic-Dhruv-Sonone Oct 4, 2024
e5436c5
Parser fix for device.dnt
Pubmatic-Dhruv-Sonone Oct 4, 2024
5db9ceb
Fixing parser implementation for dev.dnt
Pubmatic-Dhruv-Sonone Oct 4, 2024
ae03707
Merging latest ci
Pubmatic-Dhruv-Sonone Oct 25, 2024
4cf661f
Merge branch 'ci' into Adpod-Bug-Fix
Pubmatic-Dhruv-Sonone Nov 8, 2024
c330e58
Support for Dynamic Adpod in modules
Pubmatic-Dhruv-Sonone Nov 11, 2024
0887593
Fixing import issue.
Pubmatic-Dhruv-Sonone Nov 11, 2024
0025548
Adding adpod auction changes to modules
Pubmatic-Dhruv-Sonone Nov 11, 2024
1160623
Fixing import
Pubmatic-Dhruv-Sonone Nov 13, 2024
5835956
Fixing import
Pubmatic-Dhruv-Sonone Nov 13, 2024
26a3eb7
Dynamic adpod combination generation support
Pubmatic-Dhruv-Sonone Nov 13, 2024
6a91cc5
Merge branch 'ci' into OTT-1969-adpod
Pubmatic-Dhruv-Sonone Nov 13, 2024
ac7077f
Fixing dynamic pod auction
Pubmatic-Dhruv-Sonone Nov 15, 2024
784fc82
Fixing ReqDur usage
Pubmatic-Dhruv-Sonone Nov 18, 2024
5bbb9b4
Fix for UOE-11320: Vast Version is incorrect in response in modules code
Pubmatic-Dhruv-Sonone Nov 19, 2024
84ebee5
Fixing panic
Pubmatic-Dhruv-Sonone Nov 21, 2024
5af2c70
Fixing Dynamic pod
Pubmatic-Dhruv-Sonone Nov 21, 2024
72befc9
Fixing value of pwt_dur in case of test = 1
Pubmatic-Dhruv-Sonone Nov 21, 2024
f043650
Fixing adpod config validation
Pubmatic-Dhruv-Sonone Nov 25, 2024
4e8d4aa
Fix for adpod validation
Pubmatic-Dhruv-Sonone Nov 28, 2024
a9274d1
Fixing validation
Pubmatic-Dhruv-Sonone Nov 28, 2024
dd606e5
Adding panic handler
Pubmatic-Dhruv-Sonone Nov 28, 2024
376857c
Panic handler for impression generator
Pubmatic-Dhruv-Sonone Nov 28, 2024
bab92fa
Removing adpod validation
Pubmatic-Dhruv-Sonone Nov 28, 2024
d983740
Removing panic handler
Pubmatic-Dhruv-Sonone Nov 29, 2024
b8fd11b
Adding validations for adpod
Pubmatic-Dhruv-Sonone Dec 2, 2024
8c61f96
Fixing nil pointer issue
Pubmatic-Dhruv-Sonone Dec 2, 2024
89fda0a
Fixing validation
Pubmatic-Dhruv-Sonone Dec 2, 2024
8ceff95
Changed adpod config model
Pubmatic-Dhruv-Sonone Dec 4, 2024
fc1638e
Fixing logger changes
Pubmatic-Dhruv-Sonone Dec 4, 2024
f7ed5ea
Adding support for adpod using request.Ext
Pubmatic-Dhruv-Sonone Dec 5, 2024
5ad4d65
Adding request level adpod validations
Pubmatic-Dhruv-Sonone Dec 7, 2024
a8c3453
Adding support for structured adpod
Pubmatic-Dhruv-Sonone Dec 17, 2024
22ce75c
Fix for structured adpod
Pubmatic-Dhruv-Sonone Dec 17, 2024
541bae1
Merge branch 'ci' into OTT-1969-adpod
Pubmatic-Dhruv-Sonone Dec 17, 2024
6ffc494
ExitPoint Stage implementation
Pubmatic-Dhruv-Sonone Dec 23, 2024
1f47989
Merge branch 'ci' into OTT-1969-adpod
Pubmatic-Dhruv-Sonone Dec 23, 2024
2e216a2
Remove rejection for exitpoint hook
Pubmatic-Dhruv-Sonone Dec 26, 2024
d07e48a
Adding support for exitpoint hook in openwrap module
Pubmatic-Dhruv-Sonone Dec 26, 2024
a451007
Updating the auction.go to use response.
Pubmatic-Dhruv-Sonone Dec 26, 2024
33699cd
Merge branch 'ExitPointHook' into OTT-1969-adpod
Pubmatic-Dhruv-Sonone Dec 27, 2024
3081e3f
Adding interface for exitpoint hook implementation
Pubmatic-Dhruv-Sonone Dec 27, 2024
1892eb5
Fixing Typeo
Pubmatic-Dhruv-Sonone Dec 27, 2024
b5ae3d1
Changes for vast and ortb endpoint in exitpoint hooks
Pubmatic-Dhruv-Sonone Dec 27, 2024
29b9053
Removed redundant comments.
Pubmatic-Dhruv-Sonone Dec 27, 2024
dad7cba
Merge branch 'ci' into OTT-1969-adpod
pm-viral-vala Jan 20, 2025
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
8 changes: 4 additions & 4 deletions analytics/pubmatic/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,10 @@ func getAdPodSlot(adPodConfig *models.AdPod) *AdPodSlot {
}

adPodSlot := AdPodSlot{
MinAds: adPodConfig.MinAds,
MaxAds: adPodConfig.MaxAds,
MinDuration: adPodConfig.MinDuration,
MaxDuration: adPodConfig.MaxDuration,
MinAds: *adPodConfig.MinAds,
MaxAds: *adPodConfig.MaxAds,
MinDuration: *adPodConfig.MinDuration,
MaxDuration: *adPodConfig.MaxDuration,
AdvertiserExclusionPercent: *adPodConfig.AdvertiserExclusionPercent,
IABCategoryExclusionPercent: *adPodConfig.IABCategoryExclusionPercent,
}
Expand Down
25 changes: 20 additions & 5 deletions endpoints/openrtb2/auction.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package openrtb2

import (
"bytes"
"compress/gzip"
"context"
"encoding/json"
Expand Down Expand Up @@ -411,19 +412,33 @@ func sendAuctionResponse(
}

// Fixes #231
enc := json.NewEncoder(w)
w.Header().Set("Content-Type", "application/json")

// Create a buffer to hold the JSON response
var respBuf bytes.Buffer

// Create a new JSON encoder and set the SetEscapeHTML option to false
enc := json.NewEncoder(&respBuf)
enc.SetEscapeHTML(false)

w.Header().Set("Content-Type", "application/json")
// Encode the response
if err := enc.Encode(response); err != nil {
ao.Errors = append(ao.Errors, fmt.Errorf("/openrtb2/auction Failed to encode response: %v", err))
return labels, ao
}

rawResponse, headers := hookExecutor.ExecuteExitPointStage(respBuf.Bytes(), w.Header())
for key, values := range headers {
w.Header()[key] = values
}

// If an error happens when encoding the response, there isn't much we can do.
// If an error happens when writing the response, there isn't much we can do.
// If we've sent _any_ bytes, then Go would have sent the 200 status code first.
// That status code can't be un-sent... so the best we can do is log the error.
if err := enc.Encode(response); err != nil {
if _, err := w.Write(rawResponse); err != nil {
labels.RequestStatus = metrics.RequestStatusNetworkErr
ao.Errors = append(ao.Errors, fmt.Errorf("/openrtb2/auction Failed to send response: %v", err))
}

return labels, ao
}

Expand Down
5 changes: 5 additions & 0 deletions endpoints/openrtb2/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,7 @@ type mockPlanBuilder struct {
rawBidderResponsePlan hooks.Plan[hookstage.RawBidderResponse]
allProcessedBidResponsesPlan hooks.Plan[hookstage.AllProcessedBidResponses]
auctionResponsePlan hooks.Plan[hookstage.AuctionResponse]
exitPointPlan hooks.Plan[hookstage.ExitPoint]
}

func (m mockPlanBuilder) PlanForEntrypointStage(_ string) hooks.Plan[hookstage.Entrypoint] {
Expand Down Expand Up @@ -1486,6 +1487,10 @@ func (m mockPlanBuilder) PlanForAuctionResponseStage(_ string, _ *config.Account
return m.auctionResponsePlan
}

func (m mockPlanBuilder) PlanForExitPointStage(_ string, _ *config.Account) hooks.Plan[hookstage.ExitPoint] {
return m.exitPointPlan
}

func makePlan[H any](hook H) hooks.Plan[H] {
return hooks.Plan[H]{
{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ replace github.com/prebid/openrtb/v20 => github.com/PubMatic-OpenWrap/prebid-ope

replace github.com/beevik/etree v1.0.2 => github.com/PubMatic-OpenWrap/etree v1.0.2-0.20241125102329-0b5c47d99ad5

replace github.com/beevik/etree/110 => github.com/beevik/etree v1.1.0
replace github.com/beevik/etree/110 => github.com/beevik/etree v1.1.0
2 changes: 1 addition & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1042,4 +1042,4 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
4 changes: 4 additions & 0 deletions hooks/empty_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ func (e EmptyPlanBuilder) PlanForAllProcessedBidResponsesStage(endpoint string,
func (e EmptyPlanBuilder) PlanForAuctionResponseStage(endpoint string, account *config.Account) Plan[hookstage.AuctionResponse] {
return nil
}

func (e EmptyPlanBuilder) PlanForExitPointStage(endpoint string, account *config.Account) Plan[hookstage.ExitPoint] {
return nil
}
33 changes: 33 additions & 0 deletions hooks/hookexecution/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type StageExecutor interface {
ExecuteAllProcessedBidResponsesStage(adapterBids map[openrtb_ext.BidderName]*entities.PbsOrtbSeatBid)
ExecuteAuctionResponseStage(response *openrtb2.BidResponse)
ExecuteBeforeRequestValidationStage(req *openrtb2.BidRequest) *RejectError
ExecuteExitPointStage(response []byte, headers http.Header) ([]byte, http.Header)
}

type HookStageExecutor interface {
Expand Down Expand Up @@ -326,6 +327,34 @@ func (e *hookExecutor) ExecuteAuctionResponseStage(response *openrtb2.BidRespons
e.pushStageOutcome(outcome)
}

func (e *hookExecutor) ExecuteExitPointStage(response []byte, headers http.Header) ([]byte, http.Header) {
plan := e.planBuilder.PlanForExitPointStage(e.endpoint, e.account)
if len(plan) == 0 {
return response, headers
}

handler := func(
ctx context.Context,
moduleCtx hookstage.ModuleInvocationContext,
hook hookstage.ExitPoint,
payload hookstage.ExitPointPayload,
) (hookstage.HookResult[hookstage.ExitPointPayload], error) {
return hook.HandleExitPointHook(ctx, moduleCtx, payload)
}

stageName := hooks.StageAuctionResponse.String()
executionCtx := e.newContext(stageName)
payload := hookstage.ExitPointPayload{RawResponse: response}

outcome, _, contexts, _ := executeStage(executionCtx, plan, payload, handler, e.metricEngine)
outcome.Entity = entityAuctionResponse
outcome.Stage = stageName

e.saveModuleContexts(contexts)
e.pushStageOutcome(outcome)
return payload.RawResponse, payload.Headers
}

func (e *hookExecutor) newContext(stage string) executionContext {
return executionContext{
account: e.account,
Expand Down Expand Up @@ -389,3 +418,7 @@ func (executor EmptyHookExecutor) ExecuteAuctionResponseStage(_ *openrtb2.BidRes
func (executor EmptyHookExecutor) ExecuteBeforeRequestValidationStage(_ *openrtb2.BidRequest) *RejectError {
return nil
}

func (executor EmptyHookExecutor) ExecuteExitPointStage(response []byte, headers http.Header) ([]byte, http.Header) {
return nil, nil
}
22 changes: 22 additions & 0 deletions hooks/hookstage/exitpoint.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package hookstage

import (
"context"
"net/http"
)

type ExitPoint interface {
HandleExitPointHook(
context.Context,
ModuleInvocationContext,
ExitPointPayload,
) (HookResult[ExitPointPayload], error)
}

// ExitPointPayload represents the payload data for the exit point hook stage.
// It contains the raw response body and the associated HTTP headers.
// Hooks are allowed to modify response using mutations.
type ExitPointPayload struct {
RawResponse []byte
Headers http.Header
}
12 changes: 12 additions & 0 deletions hooks/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
StageRawBidderResponse Stage = "raw_bidder_response"
StageAllProcessedBidResponses Stage = "all_processed_bid_responses"
StageAuctionResponse Stage = "auction_response"
StageExitPoint Stage = "exitpoint"
)

func (s Stage) String() string {
Expand All @@ -42,6 +43,7 @@ type ExecutionPlanBuilder interface {
PlanForRawBidderResponseStage(endpoint string, account *config.Account) Plan[hookstage.RawBidderResponse]
PlanForAllProcessedBidResponsesStage(endpoint string, account *config.Account) Plan[hookstage.AllProcessedBidResponses]
PlanForAuctionResponseStage(endpoint string, account *config.Account) Plan[hookstage.AuctionResponse]
PlanForExitPointStage(endpoint string, account *config.Account) Plan[hookstage.ExitPoint]
}

// Plan represents a slice of groups of hooks of a specific type grouped in the established order.
Expand Down Expand Up @@ -167,6 +169,16 @@ func (p PlanBuilder) PlanForAuctionResponseStage(endpoint string, account *confi
)
}

func (p PlanBuilder) PlanForExitPointStage(endpoint string, account *config.Account) Plan[hookstage.ExitPoint] {
return getMergedPlan(
p.hooks,
account,
endpoint,
StageExitPoint,
p.repo.GetExitPointHook,
)
}

type hookFn[T any] func(moduleName string) (T, bool)

func getMergedPlan[T any](
Expand Down
13 changes: 13 additions & 0 deletions hooks/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type HookRepository interface {
GetRawBidderResponseHook(id string) (hookstage.RawBidderResponse, bool)
GetAllProcessedBidResponsesHook(id string) (hookstage.AllProcessedBidResponses, bool)
GetAuctionResponseHook(id string) (hookstage.AuctionResponse, bool)
GetExitPointHook(id string) (hookstage.ExitPoint, bool)
}

// NewHookRepository returns a new instance of the HookRepository interface.
Expand Down Expand Up @@ -51,6 +52,7 @@ type hookRepository struct {
rawBidderResponseHooks map[string]hookstage.RawBidderResponse
allProcessedBidResponseHooks map[string]hookstage.AllProcessedBidResponses
auctionResponseHooks map[string]hookstage.AuctionResponse
exitPointHooks map[string]hookstage.ExitPoint
}

func (r *hookRepository) GetEntrypointHook(id string) (hookstage.Entrypoint, bool) {
Expand Down Expand Up @@ -85,6 +87,10 @@ func (r *hookRepository) GetAuctionResponseHook(id string) (hookstage.AuctionRes
return getHook(r.auctionResponseHooks, id)
}

func (r *hookRepository) GetExitPointHook(id string) (hookstage.ExitPoint, bool) {
return getHook(r.exitPointHooks, id)
}

func (r *hookRepository) add(id string, hook interface{}) error {
var hasAnyHooks bool
var err error
Expand Down Expand Up @@ -145,6 +151,13 @@ func (r *hookRepository) add(id string, hook interface{}) error {
}
}

if h, ok := hook.(hookstage.ExitPoint); ok {
hasAnyHooks = true
if r.exitPointHooks, err = addHook(r.exitPointHooks, h, id); err != nil {
return err
}
}

if !hasAnyHooks {
return fmt.Errorf(`hook "%s" does not implement any supported hook interface`, id)
}
Expand Down
Loading