Skip to content

Commit

Permalink
Merge branch 'ci' into prebid_v2.32.0-1
Browse files Browse the repository at this point in the history
  • Loading branch information
pm-priyanka-bagade committed Dec 31, 2024
2 parents d508c58 + f6320a8 commit 7f6147c
Show file tree
Hide file tree
Showing 16 changed files with 444 additions and 131 deletions.
43 changes: 24 additions & 19 deletions analytics/pubmatic/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,25 +414,30 @@ func getPartnerRecordsByImp(ao analytics.AuctionObject, rCtx *models.RequestCtx)
}

pr := PartnerRecord{
PartnerID: partnerID, // prebid biddercode
BidderCode: seat, // pubmatic biddercode: pubmatic2
Latency1: rCtx.BidderResponseTimeMillis[seat], // it is set inside auctionresponsehook for all bidders
KGPV: kgpv,
KGPSV: kgpsv,
BidID: utils.GetOriginalBidId(bid.ID),
OrigBidID: utils.GetOriginalBidId(bid.ID),
DefaultBidStatus: 0, // this will be always 0 , decide whether to drop this field in future
ServerSide: 1,
MatchedImpression: rCtx.MatchedImpression[seat],
OriginalCPM: models.GetGrossEcpm(bidExt.OriginalBidCPM),
OriginalCur: bidExt.OriginalBidCur,
DealID: bid.DealID,
Nbr: nbr,
Adformat: adFormat,
NetECPM: tracker.Tracker.PartnerInfo.NetECPM,
GrossECPM: tracker.Tracker.PartnerInfo.GrossECPM,
PartnerSize: tracker.Tracker.PartnerInfo.AdSize,
ADomain: tracker.Tracker.PartnerInfo.Advertiser,
PartnerID: partnerID, // prebid biddercode
BidderCode: seat, // pubmatic biddercode: pubmatic2
Latency1: rCtx.BidderResponseTimeMillis[seat], // it is set inside auctionresponsehook for all bidders
KGPV: kgpv,
KGPSV: kgpsv,
BidID: utils.GetOriginalBidId(bid.ID),
OrigBidID: utils.GetOriginalBidId(bid.ID),
DefaultBidStatus: 0, // this will be always 0 , decide whether to drop this field in future
ServerSide: 1,
MatchedImpression: rCtx.MatchedImpression[seat],
OriginalCPM: models.GetGrossEcpm(bidExt.OriginalBidCPM),
OriginalCur: bidExt.OriginalBidCur,
DealID: bid.DealID,
Nbr: nbr,
Adformat: adFormat,
NetECPM: tracker.Tracker.PartnerInfo.NetECPM,
GrossECPM: tracker.Tracker.PartnerInfo.GrossECPM,
PartnerSize: tracker.Tracker.PartnerInfo.AdSize,
ADomain: tracker.Tracker.PartnerInfo.Advertiser,
MultiBidMultiFloorFlag: tracker.Tracker.PartnerInfo.MultiBidMultiFloorFlag,
}

if pr.MultiBidMultiFloorFlag == 0 && bidExt.MultiBidMultiFloorValue > 0 {
pr.MultiBidMultiFloorFlag = 1
}

if pr.NetECPM == 0 {
Expand Down
55 changes: 29 additions & 26 deletions analytics/pubmatic/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,15 +695,16 @@ func TestGetPartnerRecordsByImpForTracker(t *testing.T) {
"bid-id-1": {
Tracker: models.Tracker{
PartnerInfo: models.Partner{
Adformat: models.Native,
KGPV: "kgpv",
NetECPM: 10,
GrossECPM: 12,
AdSize: "15x15",
FloorValue: 1,
FloorRuleValue: 2,
Advertiser: "sony.com",
PriceBucket: "10.00",
Adformat: models.Native,
KGPV: "kgpv",
NetECPM: 10,
GrossECPM: 12,
AdSize: "15x15",
FloorValue: 1,
FloorRuleValue: 2,
Advertiser: "sony.com",
PriceBucket: "10.00",
MultiBidMultiFloorFlag: 1,
},
LoggerData: models.LoggerData{
KGPSV: "kgpsv",
Expand All @@ -728,23 +729,24 @@ func TestGetPartnerRecordsByImpForTracker(t *testing.T) {
partners: map[string][]PartnerRecord{
"imp1": {
{
PartnerID: "pubmatic",
BidderCode: "pubmatic",
PartnerSize: "15x15",
BidID: "bid-id-1",
OrigBidID: "bid-id-1",
DealID: "-1",
ServerSide: 1,
OriginalCur: "USD",
Adformat: models.Native,
NetECPM: 10,
GrossECPM: 12,
FloorValue: 1,
FloorRuleValue: 2,
ADomain: "sony.com",
KGPV: "kgpv",
KGPSV: "kgpsv",
PriceBucket: "10.00",
PartnerID: "pubmatic",
BidderCode: "pubmatic",
PartnerSize: "15x15",
BidID: "bid-id-1",
OrigBidID: "bid-id-1",
DealID: "-1",
ServerSide: 1,
OriginalCur: "USD",
Adformat: models.Native,
NetECPM: 10,
GrossECPM: 12,
FloorValue: 1,
FloorRuleValue: 2,
ADomain: "sony.com",
KGPV: "kgpv",
KGPSV: "kgpsv",
PriceBucket: "10.00",
MultiBidMultiFloorFlag: 1,
},
},
},
Expand Down Expand Up @@ -1029,6 +1031,7 @@ func TestGetPartnerRecordsByImpForDefaultBids(t *testing.T) {
},
},
},
TagID: "adunit_1234",
},
},
},
Expand Down
9 changes: 5 additions & 4 deletions analytics/pubmatic/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ type PartnerRecord struct {
OriginalCur string `json:"ocry"`
MetaData *MetaData `json:"md,omitempty"`

FloorValue float64 `json:"fv,omitempty"`
FloorRuleValue float64 `json:"frv,omitempty"`
Nbr *openrtb3.NoBidReason `json:"nbr,omitempty"` // NonBR reason code
PriceBucket string `json:"pb,omitempty"`
FloorValue float64 `json:"fv,omitempty"`
FloorRuleValue float64 `json:"frv,omitempty"`
Nbr *openrtb3.NoBidReason `json:"nbr,omitempty"` // NonBR reason code
PriceBucket string `json:"pb,omitempty"`
MultiBidMultiFloorFlag int `json:"mbmf,omitempty"`
}

type MetaData struct {
Expand Down
19 changes: 19 additions & 0 deletions modules/pubmatic/openwrap/adapters/bidders.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,3 +730,22 @@ func builderAidem(params BidderParameters) (json.RawMessage, error) {

return jsonStr.Bytes(), nil
}

func builderCompass(params BidderParameters) (json.RawMessage, error) {
jsonStr := bytes.Buffer{}
jsonStr.WriteByte('{')
oneOf := []string{"placementId", "endpointId"}
for _, param := range oneOf {
if key, ok := getString(params.FieldMap[param]); ok {
fmt.Fprintf(&jsonStr, `"%s":"%s"`, param, key)
break
}
}
// len=0 (no mandatory params present)
if jsonStr.Len() == 1 {
return nil, fmt.Errorf(errMandatoryParameterMissingFormat, params.AdapterName, oneOf)
}

jsonStr.WriteByte('}')
return jsonStr.Bytes(), nil
}
47 changes: 47 additions & 0 deletions modules/pubmatic/openwrap/adapters/bidders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3119,3 +3119,50 @@ func Test_builderAidem(t *testing.T) {
})
}
}

func TestBuilderCompass(t *testing.T) {
type args struct {
params BidderParameters
}
tests := []struct {
name string
args args
want json.RawMessage
wantErr bool
}{
{
name: "Valid Scenerio (oneOf placementId or endpointId) is present-placementId",
args: args{params: BidderParameters{FieldMap: JSONObject{"placementId": "dbdsfh"}}},
want: json.RawMessage(`{"placementId": "dbdsfh"}`),
wantErr: false,
},
{
name: "Valid Scenerio (oneOf placementId or endpointId) is present-endpointId",
args: args{params: BidderParameters{FieldMap: JSONObject{"endpointId": "dbdsfh"}}},
want: json.RawMessage(`{"endpointId": "dbdsfh"}`),
wantErr: false,
},
{
name: "Valid Scenerio (oneOf placementId or endpointId), Both are present",
args: args{params: BidderParameters{FieldMap: JSONObject{"placementId": "sdhks", "endpointId": "sdjksd"}}},
want: json.RawMessage(`{"placementId": "sdhks"}`),
wantErr: false,
},
{
name: "Invalid Scenerio (None Of placementId or endpointId) is present",
args: args{params: BidderParameters{FieldMap: JSONObject{}}},
want: json.RawMessage(``),
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := builderCompass(tt.args.params)
if (err != nil) != tt.wantErr {
t.Errorf("builderCompass() error = %v, wantErr %v", err, tt.wantErr)
return
}
AssertJSON(t, tt.want, got)
})
}
}
1 change: 1 addition & 0 deletions modules/pubmatic/openwrap/adapters/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func initBidderBuilderFactory() {
string(openrtb_ext.BidderKargo): builderKargo,
string(openrtb_ext.BidderPGAMSsp): builderPGAMSSP,
string(openrtb_ext.BidderAidem): builderAidem,
string(openrtb_ext.BidderCompass): builderCompass,
}
}

Expand Down
15 changes: 15 additions & 0 deletions modules/pubmatic/openwrap/adapters/tests/s2s_bidders.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,20 @@
"siteId":"abcdefg"
}
}
},
{
"name": "compass_json_OneOf - placementId/endpointId",
"args" : {
"adapterName": "compass",
"requestJSON": {
"placementId": "123456",
"endpointId": "abcdefg"
}
},
"want": {
"expectedJSON": {
"placementId": "123456"
}
}
}
]
3 changes: 3 additions & 0 deletions modules/pubmatic/openwrap/auctionresponsehook.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ func (m OpenWrap) handleAuctionResponseHook(
bidExt.CreativeType = models.GetCreativeType(&bid, bidExt, &impCtx)
}

if bidExt.CreativeType != string(openrtb_ext.BidTypeBanner) {
bidExt.ClickTrackers = nil
}
// set response netecpm and logger/tracker en
revShare := models.GetRevenueShare(rctx.PartnerConfigMap[partnerID])
bidExt.NetECPM = models.ToFixed(bid.Price, models.BID_PRECISION)
Expand Down
Loading

0 comments on commit 7f6147c

Please sign in to comment.