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-1726: analytics throttling based on feature and vault configuration #778

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ format:
formatcheck:
./scripts/format.sh -f false

mockgen: mockgeninstall mockgendb mockgencache mockgenmetrics
mockgen: mockgeninstall mockgendb mockgencache mockgenmetrics mockgenlogger mockgenpublisherfeature

# export GOPATH=~/go ; GOBIN=~/go/bin; export PATH=$PATH:$GOBIN
mockgeninstall:
Expand Down
2 changes: 1 addition & 1 deletion analytics/pubmatic/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var getUUID = func() string {

// GetLogAuctionObjectAsURL will form the owlogger-url and http-headers
func GetLogAuctionObjectAsURL(ao analytics.AuctionObject, rCtx *models.RequestCtx, logInfo, forRespExt bool) (string, http.Header) {
if ao.RequestWrapper == nil || ao.RequestWrapper.BidRequest == nil || rCtx == nil || rCtx.PubID == 0 {
if ao.RequestWrapper == nil || ao.RequestWrapper.BidRequest == nil || rCtx == nil || rCtx.PubID == 0 || rCtx.LoggerDisabled {
return "", nil
}

Expand Down
22 changes: 22 additions & 0 deletions analytics/pubmatic/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3368,6 +3368,28 @@ func TestGetLogAuctionObjectAsURL(t *testing.T) {
args args
want want
}{
{
name: "logger_disabled",
args: args{
ao: analytics.AuctionObject{
RequestWrapper: &openrtb_ext.RequestWrapper{
BidRequest: &openrtb2.BidRequest{},
},
Response: &openrtb2.BidResponse{},
},
rCtx: &models.RequestCtx{
Endpoint: models.EndpointV25,
LoggerDisabled: true,
PubID: 5890,
},
logInfo: true,
forRespExt: true,
},
want: want{
logger: "",
header: nil,
},
},
{
name: "do not prepare owlogger if pubid is missing",
args: args{
Expand Down
51 changes: 26 additions & 25 deletions analytics/pubmatic/mhttp/mock/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions analytics/pubmatic/pubmatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ func (ow HTTPLogger) LogAuctionObject(ao *analytics.AuctionObject) {
return
}

if rCtx.LoggerDisabled {
// logger disabled explicitly for publisher,profile request
return
}

url, headers := GetLogAuctionObjectAsURL(*ao, rCtx, false, false)
if url == "" {
glog.Errorf("Failed to prepare the owlogger for pub:[%d], profile:[%d], version:[%d].",
Expand Down
32 changes: 32 additions & 0 deletions analytics/pubmatic/pubmatic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,38 @@ func TestLogAuctionObject(t *testing.T) {
},
},
},
{
name: "logger_disabled",
ao: &analytics.AuctionObject{
HookExecutionOutcome: []hookexecution.StageOutcome{
{
Groups: []hookexecution.GroupOutcome{
{
InvocationResults: []hookexecution.HookOutcome{
{
AnalyticsTags: hookanalytics.Analytics{
Activities: []hookanalytics.Activity{
{
Results: []hookanalytics.Result{
{
Values: map[string]interface{}{
"request-ctx": &models.RequestCtx{
LoggerDisabled: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
}
for _, tt := range tests {
HTTPLogger{}.LogAuctionObject(tt.ao)
Expand Down
10 changes: 7 additions & 3 deletions exchange/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type eventTracking struct {
accountID string
enabledForAccount bool
enabledForRequest bool
enabledVideoEvents bool //TODO: OPENWRAP Video Events Flag
auctionTimestampMs int64
integrationType string
bidderInfos config.BidderInfos
Expand All @@ -31,6 +32,7 @@ func getEventTracking(requestExtPrebid *openrtb_ext.ExtRequestPrebid, ts time.Ti
accountID: account.ID,
enabledForAccount: account.Events.Enabled,
enabledForRequest: requestExtPrebid != nil && requestExtPrebid.Events != nil,
enabledVideoEvents: requestExtPrebid == nil || !requestExtPrebid.ExtOWRequestPrebid.TrackerDisabled,
auctionTimestampMs: ts.UnixNano() / 1e+6,
integrationType: getIntegrationType(requestExtPrebid),
bidderInfos: bidderInfos,
Expand Down Expand Up @@ -79,9 +81,11 @@ func (ev *eventTracking) modifyBidVAST(pbsBid *entities.PbsOrtbBid, bidderName o
}
}

// always inject event trackers without checkign isModifyingVASTXMLAllowed
if newVastXML, injected, _ := events.InjectVideoEventTrackers(trackerURL, vastXML, bid, bidID, bidderName.String(), bidderCoreName.String(), ev.accountID, ev.auctionTimestampMs, req); injected {
bid.AdM = string(newVastXML)
if ev.enabledVideoEvents {
// always inject event trackers without checkign isModifyingVASTXMLAllowed
if newVastXML, injected, _ := events.InjectVideoEventTrackers(trackerURL, vastXML, bid, bidID, bidderName.String(), bidderCoreName.String(), ev.accountID, ev.auctionTimestampMs, req); injected {
bid.AdM = string(newVastXML)
}
}
}

Expand Down
8 changes: 6 additions & 2 deletions exchange/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ func Test_isEventAllowed(t *testing.T) {

func TestModifyBidVAST(t *testing.T) {
type args struct {
bidReq *openrtb2.BidRequest
bid *openrtb2.Bid
enabledVideoEvents bool
bidReq *openrtb2.BidRequest
bid *openrtb2.Bid
}
type want struct {
tags []string
Expand All @@ -211,6 +212,7 @@ func TestModifyBidVAST(t *testing.T) {
{
name: "empty_adm", // expect adm contain vast tag with tracking events and VASTAdTagURI nurl contents
args: args{
enabledVideoEvents: true,
bidReq: &openrtb2.BidRequest{
Imp: []openrtb2.Imp{{ID: "123", Video: &openrtb2.Video{}}},
},
Expand Down Expand Up @@ -242,6 +244,7 @@ func TestModifyBidVAST(t *testing.T) {
{
name: "adm_containing_url", // expect adm contain vast tag with tracking events and VASTAdTagURI adm url (previous value) contents
args: args{
enabledVideoEvents: true,
bidReq: &openrtb2.BidRequest{
Imp: []openrtb2.Imp{{ID: "123", Video: &openrtb2.Video{}}},
},
Expand Down Expand Up @@ -279,6 +282,7 @@ func TestModifyBidVAST(t *testing.T) {
ModifyingVastXmlAllowed: false,
},
},
enabledVideoEvents: tc.args.enabledVideoEvents,
}
ev.modifyBidVAST(&entities.PbsOrtbBid{
Bid: tc.args.bid,
Expand Down
Loading
Loading