Skip to content

Commit 647553e

Browse files
Merge branch 'ci' of github.com:PubMatic-OpenWrap/prebid-server into UOE-12649
2 parents 64dda14 + 3cb8e9f commit 647553e

File tree

13 files changed

+465
-30
lines changed

13 files changed

+465
-30
lines changed

adapters/bidder.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ type BidderResponse struct {
6464
Bids []*TypedBid
6565
FledgeAuctionConfigs []*openrtb_ext.FledgeAuctionConfig
6666
XMLMetrics *openrtb_ext.XMLMetrics
67+
BidderAlias openrtb_ext.BidderName
6768
}
6869

6970
// NewBidderResponseWithBidsCapacity create a new BidderResponse initialising the bids array capacity and the default currency value

adapters/ortbbidder/response_builder_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ func TestBidderResponseFields(t *testing.T) {
383383
"Bids": reflect.TypeOf([]*adapters.TypedBid{nil}),
384384
"FledgeAuctionConfigs": reflect.TypeOf([]*openrtb_ext.FledgeAuctionConfig{}),
385385
"XMLMetrics": reflect.TypeOf(&openrtb_ext.XMLMetrics{}),
386+
"BidderAlias": reflect.TypeOf(openrtb_ext.BidderName("")),
386387
}
387388
structType := reflect.TypeOf(adapters.BidderResponse{})
388389
err := resolver.ValidateStructFields(expectedFields, structType)

exchange/bidder.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ func (bidder *BidderAdapter) requestBid(ctx context.Context, bidderRequest Bidde
272272
if bidResponse != nil {
273273
recordOpenWrapBidResponseMetrics(bidder, bidResponse)
274274

275+
bidResponse.BidderAlias = bidderRequest.BidderName
275276
reject := hookExecutor.ExecuteRawBidderResponseStage(bidResponse, string(bidder.BidderName))
276277
if reject != nil {
277278
errs = append(errs, reject)

modules/pubmatic/openwrap/applovinmax.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ func updateImpression(signalImps []openrtb2.Imp, maxImps []openrtb2.Imp) {
7272
}
7373
}
7474

75+
// Update native
76+
maxImps[0].Native = signalImps[0].Native
77+
7578
maxImps[0].Ext = setIfKeysExists(signalImp.Ext, maxImps[0].Ext, "reward", "skadn", "gpid")
7679
}
7780

@@ -261,6 +264,9 @@ func updateAppLovinMaxRequest(requestBody []byte, rctx models.RequestCtx) []byte
261264
return requestBody
262265
}
263266

267+
//set maxRequest native to nil always
268+
maxRequest.Imp[0].Native = nil
269+
264270
addSignalDataInRequest(signalData, maxRequest)
265271
if maxRequestbytes, err := json.Marshal(maxRequest); err == nil {
266272
return maxRequestbytes
@@ -360,6 +366,10 @@ func modifyRequestBody(requestBody []byte) []byte {
360366
if bannertype, err := jsonparser.GetString(requestBody, "imp", "[0]", "banner", "ext", "bannertype"); err == nil && bannertype == models.TypeRewarded {
361367
requestBody = jsonparser.Delete(requestBody, "imp", "[0]", "banner")
362368
}
369+
370+
//set maxRequest native to nil always
371+
requestBody = jsonparser.Delete(requestBody, "imp", "[0]", "native")
372+
363373
return requestBody
364374
}
365375

modules/pubmatic/openwrap/applovinmax_test.go

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,30 @@ func TestUpdateImpression(t *testing.T) {
128128
},
129129
want: []openrtb2.Imp{{Ext: json.RawMessage(`{"reward":1,"skadn":{"versions":["2.0","2.1"],"sourceapp":"11111","skadnetids":["424m5254lk.skadnetwork","4fzdc2evr5.skadnetwork"]},"gpid":"/adunitname/234"}`)}},
130130
},
131+
{
132+
name: "signalImp has Native, maxImp doesn't have Native",
133+
args: args{
134+
signalImps: []openrtb2.Imp{{Native: &openrtb2.Native{Request: "native_request_data", Ver: "1.2"}}},
135+
maxImps: []openrtb2.Imp{{}},
136+
},
137+
want: []openrtb2.Imp{{Native: &openrtb2.Native{Request: "native_request_data", Ver: "1.2"}}},
138+
},
139+
{
140+
name: "signalImp has Native, maxImp also has Native",
141+
args: args{
142+
signalImps: []openrtb2.Imp{{Native: &openrtb2.Native{Request: "signal_native_request", Ver: "1.2"}}},
143+
maxImps: []openrtb2.Imp{{Native: &openrtb2.Native{Request: "max_native_request", Ver: "1.0"}}},
144+
},
145+
want: []openrtb2.Imp{{Native: &openrtb2.Native{Request: "signal_native_request", Ver: "1.2"}}},
146+
},
147+
{
148+
name: "maxImp has Native but signalImp doesn't have Native",
149+
args: args{
150+
signalImps: []openrtb2.Imp{{}},
151+
maxImps: []openrtb2.Imp{{Native: &openrtb2.Native{Request: "max_native_request", Ver: "1.0"}}},
152+
},
153+
want: []openrtb2.Imp{{Native: nil}},
154+
},
131155
}
132156
for _, tt := range tests {
133157
t.Run(tt.name, func(t *testing.T) {
@@ -844,10 +868,23 @@ func TestUpdateAppLovinMaxRequest(t *testing.T) {
844868
{
845869
name: "update maxrequest body from signal",
846870
args: args{
847-
requestBody: []byte(`{"id":"test-case-1","at":1,"bcat":["IAB26-4","IAB26-2","IAB25-6","IAB25-5","IAB25-4","IAB25-3","IAB25-1","IAB25-7","IAB8-18","IAB26-3","IAB26-1","IAB8-5","IAB25-2","IAB11-4"],"tmax":1000,"app":{"publisher":{"name":"New Story Inc.","id":"5890","ext":{"installed_sdk":{"id":"MOLOCO_BIDDING","sdk_version":{"major":1,"minor":0,"micro":0},"adapter_version":{"major":1,"minor":0,"micro":0}}}},"paid":0,"name":"DrawHappyAngel","ver":"0.5.4","bundle":"com.newstory.DrawHappyAngel","cat":["IAB9-30"],"id":"1234567","ext":{"orientation":1}},"device":{"ifa":"497a10d6-c4dd-4e04-a986-c32b7180d462","ip":"38.158.207.171","carrier":"MYTEL","language":"en_US","hwv":"ruby","ppi":440,"pxratio":2.75,"devicetype":4,"connectiontype":2,"js":1,"h":2400,"w":1080,"geo":{"type":2,"ipservice":3,"lat":40.7429,"lon":-73.9392,"long":-73.9392,"city":"Queens","country":"USA","region":"ny","dma":"501","metro":"501","zip":"11101","ext":{"org":"Myanmar Broadband Telecom Co.","isp":"Myanmar Broadband Telecom Co."}},"ext":{},"osv":"13.0.0","ua":"Mozilla/5.0 (Linux; Android 13; 22101316C Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/120.0.6099.230 Mobile Safari/537.36","make":"xiaomi","model":"22101316c","os":"android"},"imp":[{"id":"1","displaymanager":"applovin_mediation","displaymanagerver":"11.8.2","instl":0,"secure":0,"tagid":"/43743431/DMDemo","bidfloor":0.01,"bidfloorcur":"USD","exp":14400,"banner":{"format":[{"w":728,"h":90},{"w":300,"h":250}],"w":700,"h":900},"video":{"mimes":["video/mp4","video/mpeg"],"w":640,"h":480},"rwdd":0}],"user":{"data":[{"id":"1","name":"Publisher Passed","segment":[{"signal":"{\"id\":\"95d6643c-3da6-40a2-b9ca-12279393ffbf\",\"at\":1,\"tmax\":500,\"cur\":[\"USD\"],\"imp\":[{\"id\":\"imp176227948\",\"clickbrowser\":0,\"displaymanager\":\"PubMatic_OpenBid_SDK\",\"displaymanagerver\":\"1.4.0\",\"tagid\":\"/43743431/DMDemo\",\"secure\":0,\"banner\":{\"pos\":7,\"format\":[{\"w\":300,\"h\":250}],\"api\":[5,6,7]},\"instl\":1}],\"app\":{\"paid\":4,\"name\":\"OpenWrapperSample\",\"bundle\":\"com.pubmatic.openbid.app\",\"storeurl\":\"https://itunes.apple.com/us/app/pubmatic-sdk-app/id1175273098\",\"ver\":\"1.0\",\"publisher\":{\"id\":\"5890\"}},\"device\":{\"geo\":{\"type\":1,\"lat\":37.421998333333335,\"lon\":-122.08400000000002},\"pxratio\":2.625,\"mccmnc\":\"310-260\",\"lmt\":0,\"ifa\":\"07c387f2-e030-428f-8336-42f682150759\",\"connectiontype\":5,\"carrier\":\"Android\",\"js\":1,\"ua\":\"signal_UA\",\"make\":\"Google\",\"model\":\"AndroidSDKbuiltforx86\",\"os\":\"Android\",\"osv\":\"9\",\"h\":1794,\"w\":1080,\"language\":\"en-US\",\"devicetype\":4,\"ext\":{\"atts\":3}},\"source\":{\"ext\":{\"omidpn\":\"PubMatic\",\"omidpv\":\"1.2.11-Pubmatic\"}},\"user\":{\"data\":[{\"id\":\"1234\"}]},\"ext\":{\"wrapper\":{\"ssauction\":1,\"sumry_disable\":0,\"profileid\":58135,\"versionid\":1,\"clientconfig\":1}}}"}]}],"ext":{"gdpr":0}},"regs":{"coppa":0,"ext":{"gdpr":0}},"source":{"ext":{"schain":{"ver":"1.0","complete":1,"nodes":[{"asi":"applovin.com","sid":"53bf468f18c5a0e2b7d4e3f748c677c1","rid":"494dbe15a3ce08c54f4e456363f35a022247f997","hp":1}]}}},"ext":{"prebid":{"bidderparams":{"pubmatic":{"wrapper":{"profileid":12929,"versionid":1,"clientconfig":1}}}}}}`),
871+
requestBody: []byte(`{"id":"test-case-1","at":1,"bcat":["IAB26-4","IAB26-2","IAB25-6","IAB25-5","IAB25-4","IAB25-3","IAB25-1","IAB25-7","IAB8-18","IAB26-3","IAB26-1","IAB8-5","IAB25-2","IAB11-4"],"tmax":1000,"app":{"publisher":{"name":"New Story Inc.","id":"5890","ext":{"installed_sdk":{"id":"MOLOCO_BIDDING","sdk_version":{"major":1,"minor":0,"micro":0},"adapter_version":{"major":1,"minor":0,"micro":0}}}},"paid":0,"name":"DrawHappyAngel","ver":"0.5.4","bundle":"com.newstory.DrawHappyAngel","cat":["IAB9-30"],"id":"1234567","ext":{"orientation":1}},"device":{"ifa":"497a10d6-c4dd-4e04-a986-c32b7180d462","ip":"38.158.207.171","carrier":"MYTEL","language":"en_US","hwv":"ruby","ppi":440,"pxratio":2.75,"devicetype":4,"connectiontype":2,"js":1,"h":2400,"w":1080,"geo":{"type":2,"ipservice":3,"lat":40.7429,"lon":-73.9392,"long":-73.9392,"city":"Queens","country":"USA","region":"ny","dma":"501","metro":"501","zip":"11101","ext":{"org":"Myanmar Broadband Telecom Co.","isp":"Myanmar Broadband Telecom Co."}},"ext":{},"osv":"13.0.0","ua":"Mozilla/5.0 (Linux; Android 13; 22101316C Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/120.0.6099.230 Mobile Safari/537.36","make":"xiaomi","model":"22101316c","os":"android"},"imp":[{"id":"1","displaymanager":"applovin_mediation","displaymanagerver":"11.8.2","instl":0,"secure":0,"tagid":"/43743431/DMDemo","bidfloor":0.01,"bidfloorcur":"USD","exp":14400,"banner":{"format":[{"w":728,"h":90},{"w":300,"h":250}],"w":700,"h":900},"video":{"mimes":["video/mp4","video/mpeg"],"w":640,"h":480},"native":{"request":"native_request","ver":"1.2"},"rwdd":0}],"user":{"data":[{"id":"1","name":"Publisher Passed","segment":[{"signal":"{\"id\":\"95d6643c-3da6-40a2-b9ca-12279393ffbf\",\"at\":1,\"tmax\":500,\"cur\":[\"USD\"],\"imp\":[{\"id\":\"imp176227948\",\"clickbrowser\":0,\"displaymanager\":\"PubMatic_OpenBid_SDK\",\"displaymanagerver\":\"1.4.0\",\"tagid\":\"/43743431/DMDemo\",\"secure\":0,\"banner\":{\"pos\":7,\"format\":[{\"w\":300,\"h\":250}],\"api\":[5,6,7]},\"instl\":1}],\"app\":{\"paid\":4,\"name\":\"OpenWrapperSample\",\"bundle\":\"com.pubmatic.openbid.app\",\"storeurl\":\"https://itunes.apple.com/us/app/pubmatic-sdk-app/id1175273098\",\"ver\":\"1.0\",\"publisher\":{\"id\":\"5890\"}},\"device\":{\"geo\":{\"type\":1,\"lat\":37.421998333333335,\"lon\":-122.08400000000002},\"pxratio\":2.625,\"mccmnc\":\"310-260\",\"lmt\":0,\"ifa\":\"07c387f2-e030-428f-8336-42f682150759\",\"connectiontype\":5,\"carrier\":\"Android\",\"js\":1,\"ua\":\"signal_UA\",\"make\":\"Google\",\"model\":\"AndroidSDKbuiltforx86\",\"os\":\"Android\",\"osv\":\"9\",\"h\":1794,\"w\":1080,\"language\":\"en-US\",\"devicetype\":4,\"ext\":{\"atts\":3}},\"source\":{\"ext\":{\"omidpn\":\"PubMatic\",\"omidpv\":\"1.2.11-Pubmatic\"}},\"user\":{\"data\":[{\"id\":\"1234\"}]},\"ext\":{\"wrapper\":{\"ssauction\":1,\"sumry_disable\":0,\"profileid\":58135,\"versionid\":1,\"clientconfig\":1}}}"}]}],"ext":{"gdpr":0}},"regs":{"coppa":0,"ext":{"gdpr":0}},"source":{"ext":{"schain":{"ver":"1.0","complete":1,"nodes":[{"asi":"applovin.com","sid":"53bf468f18c5a0e2b7d4e3f748c677c1","rid":"494dbe15a3ce08c54f4e456363f35a022247f997","hp":1}]}}},"ext":{"prebid":{"bidderparams":{"pubmatic":{"wrapper":{"profileid":12929,"versionid":1,"clientconfig":1}}}}}}`),
848872
},
849873
want: []byte(`{"id":"test-case-1","imp":[{"id":"1","banner":{"format":[{"w":728,"h":90},{"w":300,"h":250}],"w":700,"h":900,"api":[5,6,7]},"video":{"mimes":["video/mp4","video/mpeg"],"w":640,"h":480},"displaymanager":"PubMatic_OpenBid_SDK","displaymanagerver":"1.4.0","tagid":"/43743431/DMDemo","bidfloor":0.01,"bidfloorcur":"USD","clickbrowser":0,"secure":0,"exp":14400}],"app":{"id":"1234567","name":"DrawHappyAngel","bundle":"com.newstory.DrawHappyAngel","storeurl":"https://itunes.apple.com/us/app/pubmatic-sdk-app/id1175273098","cat":["IAB9-30"],"ver":"0.5.4","paid":4,"publisher":{"id":"5890","name":"New Story Inc.","ext":{"installed_sdk":{"id":"MOLOCO_BIDDING","sdk_version":{"major":1,"minor":0,"micro":0},"adapter_version":{"major":1,"minor":0,"micro":0}}}},"ext":{"orientation":1}},"device":{"geo":{"lat":40.7429,"lon":-73.9392,"type":2,"ipservice":3,"country":"USA","region":"ny","metro":"501","city":"Queens","zip":"11101","ext":{"org":"Myanmar Broadband Telecom Co.","isp":"Myanmar Broadband Telecom Co."}},"ua":"signal_UA","ip":"38.158.207.171","devicetype":4,"make":"xiaomi","model":"AndroidSDKbuiltforx86","os":"android","osv":"13.0.0","hwv":"ruby","h":2400,"w":1080,"ppi":440,"pxratio":2.75,"js":1,"language":"en_US","carrier":"MYTEL","mccmnc":"310-260","connectiontype":5,"ifa":"497a10d6-c4dd-4e04-a986-c32b7180d462","ext":{"atts":3}},"user":{"data":[{"id":"1234"}],"ext":{"gdpr":0}},"at":1,"tmax":1000,"bcat":["IAB26-4","IAB26-2","IAB25-6","IAB25-5","IAB25-4","IAB25-3","IAB25-1","IAB25-7","IAB8-18","IAB26-3","IAB26-1","IAB8-5","IAB25-2","IAB11-4"],"source":{"ext":{"schain":{"ver":"1.0","complete":1,"nodes":[{"asi":"applovin.com","sid":"53bf468f18c5a0e2b7d4e3f748c677c1","rid":"494dbe15a3ce08c54f4e456363f35a022247f997","hp":1}]},"omidpn":"PubMatic","omidpv":"1.2.11-Pubmatic"}},"regs":{"ext":{"gdpr":0}},"ext":{"prebid":{"bidderparams":{"pubmatic":{"wrapper":{"profileid":12929,"versionid":1,"clientconfig":1}}}}}}`),
850874
},
875+
{
876+
name: "signal not present, native format removed from impression",
877+
args: args{
878+
requestBody: []byte(`{"id":"test","app":{"publisher":{"id":"5890"}},"imp":[{"id":"1","native":{"request":"{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"title\":{\"text\":\"Test\"}}]}","ver":"1.2"}}],"ext":{"prebid":{"bidderparams":{"pubmatic":{"wrapper":{"profileid":1234}}}}}}`),
879+
rctx: models.RequestCtx{
880+
MetricsEngine: mockEngine,
881+
},
882+
},
883+
setup: func() {
884+
mockEngine.EXPECT().RecordSignalDataStatus("5890", "1234", models.MissingSignal)
885+
},
886+
want: []byte(`{"id":"test","app":{"publisher":{"id":"5890"}},"imp":[{"id":"1","displaymanager":"PubMatic_OpenWrap_SDK"}],"ext":{"prebid":{"bidderparams":{"pubmatic":{"wrapper":{"profileid":1234}}}}}}`),
887+
},
851888
}
852889
for _, tt := range tests {
853890
t.Run(tt.name, func(t *testing.T) {
@@ -1213,6 +1250,33 @@ func TestModifyRequestBody(t *testing.T) {
12131250
},
12141251
want: []byte(`{"imp":[{"displaymanager":"PubMatic_OpenWrap_SDK"}]}`),
12151252
},
1253+
{
1254+
name: "native format removed from impression",
1255+
args: args{
1256+
requestBody: []byte(`{
1257+
"id": "test",
1258+
"imp": [{
1259+
"id": "1",
1260+
"displaymanager": "applovin_mediation",
1261+
"displaymanagerver": "1.0",
1262+
"native": {
1263+
"request": "{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"title\":{\"text\":\"Test\"}}]}",
1264+
"ver": "1.2",
1265+
"battr": [1, 2, 3],
1266+
"api": [1, 2, 3],
1267+
"ext": {}
1268+
}
1269+
}]
1270+
}`),
1271+
},
1272+
want: []byte(`{
1273+
"id": "test",
1274+
"imp": [{
1275+
"id": "1",
1276+
"displaymanager": "PubMatic_OpenWrap_SDK"
1277+
}]
1278+
}`),
1279+
},
12161280
}
12171281
for _, tt := range tests {
12181282
t.Run(tt.name, func(t *testing.T) {

modules/pubmatic/openwrap/beforevalidationhook_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5583,13 +5583,12 @@ func TestOpenWrapHandleBeforeValidationHook(t *testing.T) {
55835583
mockEngine.EXPECT().RecordPublisherProfileRequests("5890", "1234")
55845584
mockEngine.EXPECT().RecordPublisherRequests(models.EndpointAppLovinMax, "5890", rctx.Platform)
55855585
mockEngine.EXPECT().RecordPlatformPublisherPartnerReqStats(rctx.Platform, "5890", "appnexus")
5586-
mockEngine.EXPECT().RecordMBMFRequests(models.EndpointAppLovinMax, rctx.PubIDStr, models.MBMFSuccess)
5586+
mockEngine.EXPECT().RecordMBMFRequests(models.EndpointAppLovinMax, rctx.PubIDStr, models.MBMFInvalidAdFormat)
55875587
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
55885588
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
55895589
mockFeature.EXPECT().IsMaxFloorsEnabled(gomock.Any()).Return(false)
55905590
mockFeature.EXPECT().IsMBMFCountryForPublisher(gomock.Any(), gomock.Any()).Return(true)
55915591
mockFeature.EXPECT().IsMBMFPublisherEnabled(gomock.Any()).Return(true)
5592-
mockFeature.EXPECT().GetProfileAdUnitMultiFloors(1234).Return(map[string]*models.MultiFloors{"adunit": {IsActive: true, Tier1: 1.1, Tier2: 2.1, Tier3: 3.1}})
55935592
mockProfileMetaData.EXPECT().GetProfileTypePlatform(gomock.Any()).Return(0, false)
55945593
},
55955594
want: want{

modules/pubmatic/openwrap/hook_raw_bidder_response.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func applyMutation(bidInfo []*rawBidderResponseHookResult, result *hookstage.Hoo
4444
BidType: bidResult.bid.BidType,
4545
BidVideo: bidResult.bid.BidVideo,
4646
OriginalBidCur: payload.BidderResponse.Currency,
47-
}), payload.Bidder)
47+
}), payload.BidderResponse.BidderAlias.String())
4848
continue
4949
}
5050

modules/pubmatic/openwrap/hook_raw_bidder_response_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ func TestHandleRawBidderResponseHook(t *testing.T) {
670670
BidType: "video",
671671
},
672672
},
673+
BidderAlias: "pubmatic2",
673674
},
674675
Bidder: "pubmatic",
675676
},
@@ -701,7 +702,7 @@ func TestHandleRawBidderResponseHook(t *testing.T) {
701702
},
702703
},
703704
},
704-
}, "pubmatic")
705+
}, "pubmatic2")
705706
return seatNonBid
706707
}(),
707708
},
@@ -736,6 +737,7 @@ func TestHandleRawBidderResponseHook(t *testing.T) {
736737
BidType: "video",
737738
},
738739
},
740+
BidderAlias: "pubmatic2",
739741
},
740742
Bidder: "pubmatic",
741743
},
@@ -767,7 +769,7 @@ func TestHandleRawBidderResponseHook(t *testing.T) {
767769
},
768770
},
769771
},
770-
}, "pubmatic")
772+
}, "pubmatic2")
771773
return seatNonBid
772774
}(),
773775
},

modules/pubmatic/openwrap/models/constants.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ const (
621621
FeatureMBMFPublisher = 10
622622
FeatureMBMFInstlFloors = 11
623623
FeatureMBMFRwddFloors = 12
624+
FeatureMBMFBannerFloors = 13
624625
)
625626

626627
// constants for sdk integrations
@@ -638,6 +639,7 @@ const (
638639
MultiBidMultiFloorValue = "mbmfv"
639640
ProcessingTime = "processing_time_ms"
640641
AdUnitFormatInstl = "instl"
642+
AdUnitFormatBanner = "banner"
641643
AdUnitFormatRwddVideo = "rwddvideo"
642644
DefaultAdUnitFormatFloors = 0
643645
)
@@ -664,4 +666,5 @@ const (
664666
MBMFAdUnitDisabled = 4
665667
MBMFAdUnitFormatNotFound = 5
666668
MBMFNoEntryFound = 6
669+
MBMFInvalidAdFormat = 7
667670
)

modules/pubmatic/openwrap/publisherfeature/mbmf.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type mbmfData struct {
1616
profileAdUnitLevelFloors models.ProfileAdUnitMultiFloors
1717
instlFloors map[int]*models.MultiFloors
1818
rwddFloors map[int]*models.MultiFloors
19+
bannerFloors map[int]*models.MultiFloors
1920
}
2021

2122
// mbmf represents Multi-Bid Multi-Floor settings using double-buffering
@@ -33,13 +34,15 @@ func newMBMF() *mbmf {
3334
profileAdUnitLevelFloors: make(models.ProfileAdUnitMultiFloors),
3435
instlFloors: make(map[int]*models.MultiFloors),
3536
rwddFloors: make(map[int]*models.MultiFloors),
37+
bannerFloors: make(map[int]*models.MultiFloors),
3638
},
3739
{
3840
enabledCountries: make(map[int]models.HashSet),
3941
enabledPublishers: make(map[int]bool),
4042
profileAdUnitLevelFloors: make(models.ProfileAdUnitMultiFloors),
4143
instlFloors: make(map[int]*models.MultiFloors),
4244
rwddFloors: make(map[int]*models.MultiFloors),
45+
bannerFloors: make(map[int]*models.MultiFloors),
4346
},
4447
},
4548
}
@@ -57,6 +60,7 @@ func (fe *feature) updateMBMF() {
5760
fe.updateProfileAdUnitLevelFloors(nextIdx)
5861
fe.updateMBMFInstlFloors(nextIdx)
5962
fe.updateMBMFRwddFloors(nextIdx)
63+
fe.updateMBMFBannerFloors(nextIdx)
6064
fe.mbmf.index.Store(nextIdx)
6165
}
6266

@@ -120,6 +124,17 @@ func (fe *feature) updateMBMFRwddFloors(nextIdx int32) {
120124
fe.mbmf.data[nextIdx].rwddFloors = rwddFloors
121125
}
122126

127+
// updateMBMFBannerFloors updates mbmfBannerFloors fetched from DB to pubFeatureMap
128+
func (fe *feature) updateMBMFBannerFloors(nextIdx int32) {
129+
bannerFloors := make(map[int]*models.MultiFloors)
130+
for pubID, feature := range fe.publisherFeature {
131+
if floors := extractMultiFloors(feature, models.FeatureMBMFBannerFloors, pubID); floors != nil {
132+
bannerFloors[pubID] = floors
133+
}
134+
}
135+
fe.mbmf.data[nextIdx].bannerFloors = bannerFloors
136+
}
137+
123138
// IsMBMFCountryForPublisher returns true if country specified for MBMF in DB
124139
func (fe *feature) IsMBMFCountryForPublisher(countryCode string, pubID int) bool {
125140
idx := fe.mbmf.index.Load()
@@ -157,6 +172,10 @@ func (fe *feature) IsMBMFEnabledForAdUnitFormat(pubID int, adunitFormat string)
157172
floors = fe.mbmf.data[idx].instlFloors
158173
case models.AdUnitFormatRwddVideo:
159174
floors = fe.mbmf.data[idx].rwddFloors
175+
case models.AdUnitFormatBanner:
176+
floors = fe.mbmf.data[idx].bannerFloors
177+
multiFloors, isPresent := floors[pubID]
178+
return isPresent && multiFloors.IsActive
160179
default:
161180
return false
162181
}

0 commit comments

Comments
 (0)