Skip to content

Commit

Permalink
UOE-10589: Add profile metadata in logger and tracker (#803)
Browse files Browse the repository at this point in the history
  • Loading branch information
AvinashKapre authored Jun 5, 2024
1 parent fcf0a71 commit de534e9
Show file tree
Hide file tree
Showing 18 changed files with 885 additions and 69 deletions.
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)
})
}
}
2 changes: 2 additions & 0 deletions analytics/pubmatic/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ func GetLogAuctionObjectAsURL(ao analytics.AuctionObject, rCtx *models.RequestCt
},
}

wlog.logProfileMetaData(rCtx)

wlog.logIntegrationType(rCtx.Endpoint)

wlog.logDeviceObject(&rCtx.DeviceCtx)
Expand Down
Loading

0 comments on commit de534e9

Please sign in to comment.