Skip to content

Commit

Permalink
Merge branch 'ci' of github.com:PubMatic-OpenWrap/prebid-server into …
Browse files Browse the repository at this point in the history
…prebid_v2.1.0
  • Loading branch information
Pubmatic-Supriya-Patil committed Feb 14, 2024
2 parents dbb3b41 + 3382af0 commit e09eb13
Show file tree
Hide file tree
Showing 59 changed files with 5,984 additions and 452 deletions.
11 changes: 6 additions & 5 deletions analytics/pubmatic/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ func GetLogAuctionObjectAsURL(ao analytics.AuctionObject, rCtx *models.RequestCt
}

wlog.logIntegrationType(rCtx.Endpoint)
wlog.logDeviceObject(rCtx, ao.RequestWrapper.BidRequest)

wlog.logDeviceObject(&rCtx.DeviceCtx)

if ao.RequestWrapper.User != nil {
extUser := openrtb_ext.ExtUser{}
Expand Down Expand Up @@ -360,8 +361,8 @@ func getPartnerRecordsByImp(ao analytics.AuctionObject, rCtx *models.RequestCtx)

price := bid.Price
if ao.Response.Cur != models.USD {
if bidCtx.EG != 0 { // valid-bids + dropped-bids+ default-bids
price = bidCtx.EG
if bidCtx.EN != 0 { // valid-bids + dropped-bids+ default-bids
price = bidCtx.EN
} else if bidExt.OriginalBidCPMUSD != 0 { // valid non-bids
price = bidExt.OriginalBidCPMUSD
}
Expand Down Expand Up @@ -403,11 +404,11 @@ func getPartnerRecordsByImp(ao analytics.AuctionObject, rCtx *models.RequestCtx)
}

if pr.NetECPM == 0 {
pr.NetECPM = models.GetNetEcpm(price, revShare)
pr.NetECPM = models.ToFixed(price, models.BID_PRECISION)
}

if pr.GrossECPM == 0 {
pr.GrossECPM = models.GetGrossEcpm(price)
pr.GrossECPM = models.GetGrossEcpmFromNetEcpm(price, revShare)
}

if pr.PartnerSize == "" {
Expand Down
57 changes: 44 additions & 13 deletions analytics/pubmatic/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3024,8 +3024,8 @@ func TestGetPartnerRecordsByImpForRevShareAndBidCPM(t *testing.T) {
partners: map[string][]PartnerRecord{
"imp1": {
{
NetECPM: 90,
GrossECPM: 100,
NetECPM: 100,
GrossECPM: 111.11,
OriginalCPM: 100,
OriginalCur: "USD",
PartnerID: "pubmatic",
Expand Down Expand Up @@ -3198,8 +3198,8 @@ func TestGetPartnerRecordsByImpForRevShareAndBidCPM(t *testing.T) {
partners: map[string][]PartnerRecord{
"imp1": {
{
NetECPM: 90,
GrossECPM: 100,
NetECPM: 100,
GrossECPM: 111.11,
OriginalCPM: 200,
OriginalCur: "INR",
PartnerID: "pubmatic",
Expand Down Expand Up @@ -3513,8 +3513,10 @@ func TestGetLogAuctionObjectAsURL(t *testing.T) {
Response: &openrtb2.BidResponse{},
},
rCtx: &models.RequestCtx{
DevicePlatform: models.DevicePlatformMobileAppAndroid,
PubID: 5890,
PubID: 5890,
DeviceCtx: models.DeviceCtx{
Platform: models.DevicePlatformMobileAppAndroid,
},
},
logInfo: true,
forRespExt: true,
Expand All @@ -3532,17 +3534,16 @@ func TestGetLogAuctionObjectAsURL(t *testing.T) {
args: args{
ao: analytics.AuctionObject{
RequestWrapper: &openrtb_ext.RequestWrapper{
BidRequest: &openrtb2.BidRequest{
Device: &openrtb2.Device{
Ext: json.RawMessage(`{"ifa_type":"sspid"}`),
},
},
BidRequest: &openrtb2.BidRequest{},
},
Response: &openrtb2.BidResponse{},
},
rCtx: &models.RequestCtx{
DevicePlatform: models.DevicePlatformMobileAppAndroid,
PubID: 5890,
PubID: 5890,
DeviceCtx: models.DeviceCtx{
Platform: models.DevicePlatformMobileAppAndroid,
IFATypeID: ptrutil.ToPtr(8),
},
},
logInfo: true,
forRespExt: true,
Expand All @@ -3555,6 +3556,36 @@ func TestGetLogAuctionObjectAsURL(t *testing.T) {
},
},
},
{
name: "log_device.ext.atts",
args: args{
ao: analytics.AuctionObject{
RequestWrapper: &openrtb_ext.RequestWrapper{
BidRequest: &openrtb2.BidRequest{},
},
Response: &openrtb2.BidResponse{},
},
rCtx: &models.RequestCtx{
PubID: 5890,
DeviceCtx: models.DeviceCtx{
Ext: &models.ExtDevice{
ExtDevice: openrtb_ext.ExtDevice{
ATTS: ptrutil.ToPtr(openrtb_ext.IOSAppTrackingStatusRestricted),
},
},
},
},
logInfo: true,
forRespExt: true,
},
want: want{
logger: ow.cfg.PublicEndpoint + `?json={"pubid":5890,"pid":"0","pdvid":"0","sl":1,"dvc":{"atts":1},"ft":0}&pubid=5890`,
header: http.Header{
models.USER_AGENT_HEADER: []string{""},
models.IP_HEADER: []string{""},
},
},
},
{
name: "log content from site object",
args: args{
Expand Down
62 changes: 24 additions & 38 deletions analytics/pubmatic/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package pubmatic

import (
"encoding/json"
"strings"

"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/openrtb/v19/openrtb3"
Expand Down Expand Up @@ -39,21 +38,22 @@ type record struct {
AdPodPercentage *AdPodPercentage `json:"aps,omitempty"`
Content *Content `json:"ct,omitempty"`
TestConfigApplied int `json:"tgid,omitempty"`
//Geo GeoRecord `json:"geo,omitempty"`
FloorModelVersion string `json:"fmv,omitempty"`
FloorSource *int `json:"fsrc,omitempty"`
FloorType int `json:"ft"`
IntegrationType string `json:"it,omitempty"`
FloorFetchStatus *int `json:"ffs,omitempty"`
FloorProvider string `json:"fp,omitempty"`
PDC string `json:"pdc,omitempty"`
CustomDimensions string `json:"cds,omitempty"`
FloorModelVersion string `json:"fmv,omitempty"`
FloorSource *int `json:"fsrc,omitempty"`
FloorType int `json:"ft"`
IntegrationType string `json:"it,omitempty"`
FloorFetchStatus *int `json:"ffs,omitempty"`
FloorProvider string `json:"fp,omitempty"`
PDC string `json:"pdc,omitempty"`
CustomDimensions string `json:"cds,omitempty"`
//Geo GeoRecord `json:"geo,omitempty"`
}

// Device struct for storing device information
type Device struct {
Platform models.DevicePlatform `json:"plt,omitempty"`
IFAType *models.DeviceIFAType `json:"ifty,omitempty"` //OTT-416, adding device.ext.ifa_type
Platform models.DevicePlatform `json:"plt,omitempty"`
IFAType *models.DeviceIFAType `json:"ifty,omitempty"` //OTT-416, adding device.ext.ifa_type
ATTS *openrtb_ext.IOSAppTrackingStatus `json:"atts,omitempty"` //device.ext.atts
}

/*
Expand Down Expand Up @@ -173,32 +173,6 @@ var FetchStatusMap = map[string]int{
openrtb_ext.FetchTimeout: 4,
}

// logDeviceObject is used to add device specific parameters like platform and ifa_type in logger
func (wlog *WloggerRecord) logDeviceObject(rctx *models.RequestCtx, ortbBidRequest *openrtb2.BidRequest) {
dvc := Device{
Platform: rctx.DevicePlatform,
}

if ortbBidRequest != nil && ortbBidRequest.Device != nil && ortbBidRequest.Device.Ext != nil {
ext := make(map[string]interface{})
err := json.Unmarshal(ortbBidRequest.Device.Ext, &ext)
if err != nil {
return
}

//use ext object for logging any other extension parameters
//log device.ext.ifa_type parameter to ifty in logger record
if value, ok := ext["ifa_type"].(string); ok {
//ifa_type checking is valid parameter and log its respective id
ifaType := models.DeviceIFATypeID[strings.ToLower(value)]
dvc.IFAType = &ifaType
}
}

//settind device object
wlog.Device = dvc
}

// SetIntegrationType sets the integration type in WloggerRecord
func (wlog *WloggerRecord) logIntegrationType(endpoint string) {
switch endpoint {
Expand All @@ -217,6 +191,18 @@ func (wlog *WloggerRecord) logIntegrationType(endpoint string) {
}
}

func (wlog *WloggerRecord) logDeviceObject(dvc *models.DeviceCtx) {
if dvc == nil {
return
}

wlog.Device.Platform = dvc.Platform
wlog.Device.IFAType = dvc.IFATypeID
if dvc.Ext != nil {
wlog.record.Device.ATTS = dvc.Ext.ATTS
}
}

// logFloorType will be used to log floor type
func (wlog *WloggerRecord) logFloorType(prebid *openrtb_ext.ExtRequestPrebid) {
wlog.record.FloorType = models.SoftFloor
Expand Down
Loading

0 comments on commit e09eb13

Please sign in to comment.