Skip to content

Commit

Permalink
Openwrap 11 June 2024 Release (#808)
Browse files Browse the repository at this point in the history
UOE-10579: Add builder for Partner Rise (#804)
OTT-1168: support for traffic shaping based on country code (#794)
OTT-1450: add support of Netacuity geoDB for ip-to-geo lookup (#663)
OTT-1449: Traffic Shapping Framework (#671)
OTT-908: Add support to get country from IP address  (#679)
OTT-1450: Introduce ignoreNetacuity build flag in validate.sh (#682)
OTT-1521:: Support to read adpod configs from database (#700)
UOE-10589: Add profile metadata in logger and tracker (#803)
  • Loading branch information
Pubmatic-Dhruv-Sonone authored Jun 7, 2024
1 parent 98d1802 commit 28dd1b1
Show file tree
Hide file tree
Showing 66 changed files with 3,433 additions and 255 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ mockgenmetrics:
mkdir -p modules/pubmatic/openwrap/metrics/mock
mockgen github.com/PubMatic-OpenWrap/prebid-server/v2/modules/pubmatic/openwrap/metrics MetricsEngine > modules/pubmatic/openwrap/metrics/mock/mock.go

mockgengeodb:
mkdir -p modules/pubmatic/openwrap/geodb/mock
mockgen github.com/PubMatic-OpenWrap/prebid-server/v2/modules/pubmatic/openwrap/geodb Geography > modules/pubmatic/openwrap/geodb/mock/mock.go

mockgenlogger:
mkdir -p analytics/pubmatic/mhttp/mock
mockgen github.com/PubMatic-OpenWrap/prebid-server/v2/analytics/pubmatic/mhttp HttpCallInterface,MultiHttpContextInterface > analytics/pubmatic/mhttp/mock/mock.go
Expand Down
12 changes: 12 additions & 0 deletions analytics/pubmatic/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,15 @@ func RestoreBidResponse(rctx *models.RequestCtx, ao analytics.AuctionObject) err
*ao.Response = *orignalResponse
return nil
}

func (wlog *WloggerRecord) logProfileMetaData(rctx *models.RequestCtx) {
wlog.ProfileType = rctx.ProfileType
wlog.ProfileTypePlatform = rctx.ProfileTypePlatform
wlog.AppPlatform = rctx.AppPlatform
if rctx.AppIntegrationPath != nil && *rctx.AppIntegrationPath >= 0 {
wlog.AppIntegrationPath = rctx.AppIntegrationPath
}
if rctx.AppSubIntegrationPath != nil && *rctx.AppSubIntegrationPath >= 0 {
wlog.AppSubIntegrationPath = rctx.AppSubIntegrationPath
}
}
101 changes: 101 additions & 0 deletions analytics/pubmatic/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,104 @@ func TestRestoreBidResponse(t *testing.T) {
})
}
}

func TestWloggerRecord_logProfileMetaData(t *testing.T) {
type fields struct {
record record
}
type args struct {
rctx *models.RequestCtx
}
tests := []struct {
name string
fields fields
args args
wantRecord record
}{
{
name: "all feilds are empty",
args: args{
rctx: &models.RequestCtx{},
},
fields: fields{
record: record{},
},
wantRecord: record{},
},
{
name: "all feilds are set",
args: args{
rctx: &models.RequestCtx{
ProfileType: 1,
ProfileTypePlatform: 2,
AppPlatform: 3,
AppIntegrationPath: ptrutil.ToPtr(4),
AppSubIntegrationPath: ptrutil.ToPtr(5),
},
},
fields: fields{
record: record{},
},
wantRecord: record{
ProfileType: 1,
ProfileTypePlatform: 2,
AppPlatform: 3,
AppIntegrationPath: ptrutil.ToPtr(4),
AppSubIntegrationPath: ptrutil.ToPtr(5),
},
},
{
name: "appIntegrationPath and appSubIntegrationPath are nil",
args: args{
rctx: &models.RequestCtx{
ProfileType: 1,
ProfileTypePlatform: 2,
AppPlatform: 3,
AppIntegrationPath: nil,
AppSubIntegrationPath: nil,
},
},
fields: fields{
record: record{},
},
wantRecord: record{
ProfileType: 1,
ProfileTypePlatform: 2,
AppPlatform: 3,
AppIntegrationPath: nil,
AppSubIntegrationPath: nil,
},
},
{
name: "appIntegrationPath and appSubIntegrationPath are not nil but less than 0",
args: args{
rctx: &models.RequestCtx{
ProfileType: 1,
ProfileTypePlatform: 2,
AppPlatform: 3,
AppIntegrationPath: ptrutil.ToPtr(-1),
AppSubIntegrationPath: ptrutil.ToPtr(-1),
},
},
fields: fields{
record: record{},
},
wantRecord: record{
ProfileType: 1,
ProfileTypePlatform: 2,
AppPlatform: 3,
AppIntegrationPath: nil,
AppSubIntegrationPath: nil,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
wlog := &WloggerRecord{
record: tt.fields.record,
}
wlog.logProfileMetaData(tt.args.rctx)
assert.Equal(t, tt.wantRecord, wlog.record, tt.name)
})
}
}
14 changes: 14 additions & 0 deletions analytics/pubmatic/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/prebid/prebid-server/v2/hooks/hookexecution"
"github.com/prebid/prebid-server/v2/modules/pubmatic/openwrap/customdimensions"
"github.com/prebid/prebid-server/v2/modules/pubmatic/openwrap/models"
"github.com/prebid/prebid-server/v2/modules/pubmatic/openwrap/models/nbr"
"github.com/prebid/prebid-server/v2/modules/pubmatic/openwrap/utils"
"github.com/prebid/prebid-server/v2/openrtb_ext"
uuid "github.com/satori/go.uuid"
Expand All @@ -30,6 +31,11 @@ var GetUUID = func() string {
return uuid.NewV4().String()
}

var blockListedNBR = map[openrtb3.NoBidReason]struct{}{
nbr.RequestBlockedPartnerThrottle: {},
nbr.RequestBlockedPartnerFiltered: {},
}

// 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 || rCtx.LoggerDisabled {
Expand All @@ -55,6 +61,8 @@ func GetLogAuctionObjectAsURL(ao analytics.AuctionObject, rCtx *models.RequestCt
},
}

wlog.logProfileMetaData(rCtx)

wlog.logIntegrationType(rCtx.Endpoint)

wlog.logDeviceObject(&rCtx.DeviceCtx)
Expand Down Expand Up @@ -395,6 +403,12 @@ func getPartnerRecordsByImp(ao analytics.AuctionObject, rCtx *models.RequestCtx)
nbr = bidExt.Nbr // valid-bids + default-bids + dropped-bids
}

if nbr != nil {
if _, ok := blockListedNBR[*nbr]; ok {
continue
}
}

pr := PartnerRecord{
PartnerID: partnerID, // prebid biddercode
BidderCode: seat, // pubmatic biddercode: pubmatic2
Expand Down
Loading

0 comments on commit 28dd1b1

Please sign in to comment.