Skip to content

Commit d7aa618

Browse files
Rubicon: Add bid meta seat (#4348)
1 parent 2ca5bb5 commit d7aa618

16 files changed

+133
-69
lines changed

adapters/rubicon/rubicon.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ func (a *RubiconAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external
976976
for i := 0; i < len(sb.Bid); i++ {
977977
bid := sb.Bid[i]
978978

979-
updatedBidExt := updateBidExtWithMetaNetworkId(bid, buyer)
979+
updatedBidExt := updateBidExtWithMeta(bid, buyer, sb.Seat)
980980
if updatedBidExt != nil {
981981
bid.Ext = updatedBidExt
982982
}
@@ -1067,8 +1067,8 @@ func cmpOverrideFromBidRequest(bidRequest *openrtb2.BidRequest) float64 {
10671067
return bidRequestExt.Prebid.Bidders.Rubicon.Debug.CpmOverride
10681068
}
10691069

1070-
func updateBidExtWithMetaNetworkId(bid rubiconBid, buyer int) json.RawMessage {
1071-
if buyer <= 0 {
1070+
func updateBidExtWithMeta(bid rubiconBid, buyer int, seat string) json.RawMessage {
1071+
if buyer <= 0 && seat == "" {
10721072
return nil
10731073
}
10741074
var bidExt *extPrebid
@@ -1082,14 +1082,15 @@ func updateBidExtWithMetaNetworkId(bid rubiconBid, buyer int) json.RawMessage {
10821082
if bidExt.Prebid != nil {
10831083
if bidExt.Prebid.Meta != nil {
10841084
bidExt.Prebid.Meta.NetworkID = buyer
1085+
bidExt.Prebid.Meta.Seat = seat
10851086
} else {
1086-
bidExt.Prebid.Meta = &openrtb_ext.ExtBidPrebidMeta{NetworkID: buyer}
1087+
bidExt.Prebid.Meta = &openrtb_ext.ExtBidPrebidMeta{NetworkID: buyer, Seat: seat}
10871088
}
10881089
} else {
1089-
bidExt.Prebid = &openrtb_ext.ExtBidPrebid{Meta: &openrtb_ext.ExtBidPrebidMeta{NetworkID: buyer}}
1090+
bidExt.Prebid = &openrtb_ext.ExtBidPrebid{Meta: &openrtb_ext.ExtBidPrebidMeta{NetworkID: buyer, Seat: seat}}
10901091
}
10911092
} else {
1092-
bidExt = &extPrebid{Prebid: &openrtb_ext.ExtBidPrebid{Meta: &openrtb_ext.ExtBidPrebidMeta{NetworkID: buyer}}}
1093+
bidExt = &extPrebid{Prebid: &openrtb_ext.ExtBidPrebid{Meta: &openrtb_ext.ExtBidPrebidMeta{NetworkID: buyer, Seat: seat}}}
10931094
}
10941095

10951096
marshalledExt, err := json.Marshal(&bidExt)

adapters/rubicon/rubicon_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,33 @@ func TestOpenRTBResponseSettingOfNetworkId(t *testing.T) {
993993
}
994994
}
995995

996+
func TestUpdateBidExtWithMeta_OnlySeatSet(t *testing.T) {
997+
bid := rubiconBid{
998+
Bid: openrtb2.Bid{
999+
Ext: nil,
1000+
},
1001+
AdmNative: nil,
1002+
}
1003+
seat := "test-seat"
1004+
buyer := 0
1005+
1006+
ext := updateBidExtWithMeta(bid, buyer, seat)
1007+
assert.NotNil(t, ext, "Expected non-nil ext when seat is set")
1008+
1009+
var extPrebidWrapper struct {
1010+
Prebid struct {
1011+
Meta struct {
1012+
Seat string `json:"seat"`
1013+
NetworkID *int `json:"networkId,omitempty"`
1014+
} `json:"meta"`
1015+
} `json:"prebid"`
1016+
}
1017+
err := json.Unmarshal(ext, &extPrebidWrapper)
1018+
assert.NoError(t, err, "Unmarshal should succeed")
1019+
assert.Equal(t, seat, extPrebidWrapper.Prebid.Meta.Seat, "Seat should be set")
1020+
assert.Zero(t, extPrebidWrapper.Prebid.Meta.NetworkID, "NetworkID should be omitted or zero")
1021+
}
1022+
9961023
func TestOpenRTBResponseBidExtPrebidMetaPassthrough(t *testing.T) {
9971024
request := &openrtb2.BidRequest{
9981025
Imp: []openrtb2.Imp{{

adapters/rubicon/rubicontest/exemplary/25-26-transition-period.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@
414414
}
415415
}
416416
],
417-
"seat": "adman"
417+
"seat": "rubicon"
418418
}
419419
],
420420
"cur": "USD"
@@ -438,7 +438,8 @@
438438
"ext": {
439439
"prebid": {
440440
"meta": {
441-
"networkId": 123
441+
"networkId": 123,
442+
"seat": "rubicon"
442443
},
443444
"type": "banner"
444445
}

adapters/rubicon/rubicontest/exemplary/app-imp-fpd.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@
374374
}
375375
}
376376
],
377-
"seat": "adman"
377+
"seat": "rubicon"
378378
}
379379
],
380380
"cur": "USD"
@@ -397,7 +397,10 @@
397397
"dealid": "test_dealid",
398398
"ext": {
399399
"prebid": {
400-
"type": "video"
400+
"type": "video",
401+
"meta": {
402+
"seat": "rubicon"
403+
}
401404
}
402405
}
403406
},

adapters/rubicon/rubicontest/exemplary/bidonmultiformat.json

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@
115115
}
116116
]
117117
},
118-
"impIDs":["test-imp-id"]
118+
"impIDs": [
119+
"test-imp-id"
120+
]
119121
},
120122
"mockResponse": {
121123
"status": 200,
@@ -139,7 +141,7 @@
139141
}
140142
}
141143
],
142-
"seat": "adman"
144+
"seat": "rubicon"
143145
}
144146
],
145147
"cur": "USD"
@@ -185,8 +187,7 @@
185187
"video": {
186188
"placement": 3,
187189
"ext": {
188-
"rp": {
189-
}
190+
"rp": {}
190191
},
191192
"mimes": [
192193
"video/mp4"
@@ -218,7 +219,9 @@
218219
}
219220
]
220221
},
221-
"impIDs":["test-imp-id"]
222+
"impIDs": [
223+
"test-imp-id"
224+
]
222225
},
223226
"mockResponse": {
224227
"status": 200,
@@ -242,7 +245,7 @@
242245
}
243246
}
244247
],
245-
"seat": "adman"
248+
"seat": "rubicon"
246249
}
247250
],
248251
"cur": "USD"
@@ -265,7 +268,10 @@
265268
"dealid": "test_dealid",
266269
"ext": {
267270
"prebid": {
268-
"type": "banner"
271+
"type": "banner",
272+
"meta": {
273+
"seat": "rubicon"
274+
}
269275
}
270276
}
271277
},
@@ -287,7 +293,10 @@
287293
"dealid": "test_dealid",
288294
"ext": {
289295
"prebid": {
290-
"type": "video"
296+
"type": "video",
297+
"meta": {
298+
"seat": "rubicon"
299+
}
291300
}
292301
}
293302
},
@@ -296,4 +305,4 @@
296305
]
297306
}
298307
]
299-
}
308+
}

adapters/rubicon/rubicontest/exemplary/flexible-schema.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@
376376
}
377377
}
378378
],
379-
"seat": "adman"
379+
"seat": "rubicon"
380380
}
381381
],
382382
"cur": "USD"
@@ -399,7 +399,10 @@
399399
"dealid": "test_dealid",
400400
"ext": {
401401
"prebid": {
402-
"type": "video"
402+
"type": "video",
403+
"meta": {
404+
"seat": "rubicon"
405+
}
403406
}
404407
}
405408
},

adapters/rubicon/rubicontest/exemplary/hardcode-secure.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@
361361
}
362362
}
363363
],
364-
"seat": "adman"
364+
"seat": "rubicon"
365365
}
366366
],
367367
"cur": "USD"
@@ -385,7 +385,8 @@
385385
"ext": {
386386
"prebid": {
387387
"meta": {
388-
"networkId": 123
388+
"networkId": 123,
389+
"seat": "rubicon"
389390
},
390391
"type": "video"
391392
}

adapters/rubicon/rubicontest/exemplary/non-bidonmultiformat.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@
114114
}
115115
]
116116
},
117-
"impIDs":["test-imp-id"]
117+
"impIDs": [
118+
"test-imp-id"
119+
]
118120
},
119121
"mockResponse": {
120122
"status": 200,
@@ -138,7 +140,7 @@
138140
}
139141
}
140142
],
141-
"seat": "adman"
143+
"seat": "rubicon"
142144
}
143145
],
144146
"cur": "USD"
@@ -161,7 +163,10 @@
161163
"dealid": "test_dealid",
162164
"ext": {
163165
"prebid": {
164-
"type": "banner"
166+
"type": "banner",
167+
"meta": {
168+
"seat": "rubicon"
169+
}
165170
}
166171
}
167172
},
@@ -170,4 +175,4 @@
170175
]
171176
}
172177
]
173-
}
178+
}

adapters/rubicon/rubicontest/exemplary/simple-banner.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@
371371
}
372372
}
373373
],
374-
"seat": "adman"
374+
"seat": "rubicon"
375375
}
376376
],
377377
"cur": "USD"
@@ -395,7 +395,8 @@
395395
"ext": {
396396
"prebid": {
397397
"meta": {
398-
"networkId": 123
398+
"networkId": 123,
399+
"seat": "rubicon"
399400
},
400401
"type": "banner"
401402
}

adapters/rubicon/rubicontest/exemplary/simple-native.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@
348348
}
349349
}
350350
],
351-
"seat": "adman"
351+
"seat": "rubicon"
352352
}
353353
],
354354
"cur": "USD"
@@ -372,7 +372,8 @@
372372
"ext": {
373373
"prebid": {
374374
"meta": {
375-
"networkId": 123
375+
"networkId": 123,
376+
"seat": "rubicon"
376377
},
377378
"type": "native"
378379
}

0 commit comments

Comments
 (0)