Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
SylviaF committed May 24, 2024
2 parents fcc0e0f + 72d040b commit 34517f7
Show file tree
Hide file tree
Showing 16 changed files with 382 additions and 48 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,9 @@ We welcome everyone to contribute to this project by implementing a specificatio

### Bug Fix
Bug reports may be submitted by [opening a new issue](https://github.com/prebid/prebid-server/issues/new/choose) and describing the error in detail with the steps to reproduce and example data. A member of the core development team will validate the bug and discuss next steps. You're encouraged to open an exploratory draft pull request to either demonstrate the bug by adding a test or offering a potential fix.
The quickest way to start developing Prebid Server in a reproducible environment isolated from your host OS
is by using Visual Studio Code with [Remote Container Setup](devcontainer.md).

## Learning Materials

To understand more about how Prebid Server in Go works and quickly spins up sample instances, refer to the `sample` folder which describes various structured and integrated examples. The examples are designed to run on any platform that supports `docker` container.
6 changes: 6 additions & 0 deletions adapters/pubmatic/pubmatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type ExtImpBidderPubmatic struct {
adapters.ExtImpBidder
Data json.RawMessage `json:"data,omitempty"`
AE int `json:"ae,omitempty"`
GpId string `json:"gpid,omitempty"`
}

type ExtAdServer struct {
Expand Down Expand Up @@ -78,6 +79,7 @@ const (
AdServerGAM = "gam"
AdServerKey = "adserver"
PBAdslotKey = "pbadslot"
gpIdKey = "gpid"
)

func (a *PubmaticAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
Expand Down Expand Up @@ -319,6 +321,10 @@ func parseImpressionObject(imp *openrtb2.Imp, extractWrapperExtFromImp, extractP
extMap[ae] = bidderExt.AE
}

if bidderExt.GpId != "" {
extMap[gpIdKey] = bidderExt.GpId
}

imp.Ext = nil
if len(extMap) > 0 {
ext, err := json.Marshal(extMap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"rugby",
"cricket"
]
}
},
"gpid":"/1111/home"
}
}
],
Expand Down Expand Up @@ -68,7 +69,8 @@
},
"ext": {
"dfp_ad_unit_code": "/1111/home",
"key_val": "k1=v1|k2=v2|sport=rugby,cricket"
"key_val": "k1=v1|k2=v2|sport=rugby,cricket",
"gpid":"/1111/home"
}
}
],
Expand Down
20 changes: 0 additions & 20 deletions adapters/rubicon/rubicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,9 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada
}

userExtRP := rubiconUserExt{RP: rubiconUserExtRP{Target: target}}
userBuyerUID := userCopy.BuyerUID

if len(userCopy.EIDs) > 0 {
userExtRP.Eids = userCopy.EIDs

if userBuyerUID == "" {
userBuyerUID = extractUserBuyerUID(userExtRP.Eids)
}
}

if userCopy.Consent != "" {
Expand All @@ -354,7 +349,6 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada
userCopy.Geo = nil
userCopy.Yob = 0
userCopy.Gender = ""
userCopy.BuyerUID = userBuyerUID
userCopy.EIDs = nil

rubiconRequest.User = &userCopy
Expand Down Expand Up @@ -914,20 +908,6 @@ func contains(s []int, e int) bool {
return false
}

func extractUserBuyerUID(eids []openrtb2.EID) string {
for _, eid := range eids {
if eid.Source != "rubiconproject.com" {
continue
}

for _, uid := range eid.UIDs {
return uid.ID
}
}

return ""
}

func isVideo(imp openrtb2.Imp) bool {
video := imp.Video
if video != nil {
Expand Down
2 changes: 1 addition & 1 deletion adapters/unruly/unruly.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest
}}
}

bidResponse := adapters.NewBidderResponseWithBidsCapacity(5)
bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(internalRequest.Imp))

var errs []error
for _, sb := range bidResp.SeatBid {
Expand Down
34 changes: 24 additions & 10 deletions adapters/yeahmobi/yeahmobi.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ import (
type adapter struct {
EndpointTemplate *template.Template
}
type yeahmobiBidExt struct {
VideoCreativeInfo *yeahmobiBidExtVideo `json:"video,omitempty"`
}
type yeahmobiBidExtVideo struct {
Duration *int `json:"duration,omitempty"`
}

// Builder builds a new instance of the Yeahmobi adapter for the given bidder with the given config.
func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) {
Expand Down Expand Up @@ -134,34 +140,42 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest
if response.StatusCode == http.StatusNoContent {
return nil, nil
}

if response.StatusCode == http.StatusBadRequest {
return nil, []error{&errortypes.BadInput{
Message: fmt.Sprintf("Unexpected status code: %d.", response.StatusCode),
}}
}

if response.StatusCode != http.StatusOK {
return nil, []error{&errortypes.BadServerResponse{
Message: fmt.Sprintf("Unexpected status code: %d.", response.StatusCode),
}}
}

var bidResp openrtb2.BidResponse

if err := json.Unmarshal(response.Body, &bidResp); err != nil {
return nil, []error{err}
}

bidResponse := adapters.NewBidderResponseWithBidsCapacity(1)

for _, sb := range bidResp.SeatBid {
for i := range sb.Bid {
var mediaType = getBidType(sb.Bid[i].ImpID, internalRequest.Imp)
bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{
Bid: &sb.Bid[i],
BidType: mediaType,
})
bid := sb.Bid[i]
typedBid := &adapters.TypedBid{
Bid: &bid,
BidType: mediaType,
BidVideo: &openrtb_ext.ExtBidPrebidVideo{},
}
if bid.Ext != nil {
var bidExt *yeahmobiBidExt
err := json.Unmarshal(bid.Ext, &bidExt)
if err != nil {
return nil, []error{fmt.Errorf("bid.ext json unmarshal error")}
} else if bidExt != nil {
if bidExt.VideoCreativeInfo != nil && bidExt.VideoCreativeInfo.Duration != nil {
typedBid.BidVideo.Duration = *bidExt.VideoCreativeInfo.Duration
}
}
}
bidResponse.Bids = append(bidResponse.Bids, typedBid)
}
}
return bidResponse, nil
Expand Down
41 changes: 28 additions & 13 deletions adapters/yeahmobi/yeahmobitest/exemplary/simple-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
}
]
},

"httpCalls": [
{
"expectedRequest": {
Expand All @@ -29,7 +28,7 @@
"id": "test-request-id",
"imp": [
{
"id":"test-imp-id",
"id": "test-imp-id",
"video": {
"w": 300,
"h": 250,
Expand All @@ -46,7 +45,9 @@
}
]
},
"impIDs":["test-imp-id"]
"impIDs": [
"test-imp-id"
]
},
"mockResponse": {
"status": 200,
Expand All @@ -55,21 +56,27 @@
"seatbid": [
{
"seat": "ttx",
"bid": [{
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id",
"price": 1.2,
"adm": "some-ads",
"crid": "crid_testid"
}]
"bid": [
{
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id",
"price": 1.2,
"adm": "some-ads",
"crid": "crid_testid",
"ext": {
"video": {
"duration": 300
}
}
}
]
}
],
"cur": "USD"
}
}
}
],

"expectedBidResponses": [
{
"currency": "USD",
Expand All @@ -80,9 +87,17 @@
"impid": "test-imp-id",
"price": 1.2,
"adm": "some-ads",
"crid": "crid_testid"
"crid": "crid_testid",
"ext": {
"video": {
"duration": 300
}
}
},
"type": "video"
"type": "video",
"video": {
"duration": 300
}
}
]
}
Expand Down
20 changes: 20 additions & 0 deletions sample/001_banner/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
port: 8000 # main auction server port
admin_port: 6060 # admin server listening port

external_url: localhost # host url of all 2 servers above
status_response: "ok" # default response string for /status endpoint

gdpr:
default_value: "0" # disable gdpr, explicitly specifying a default value is a requirement in prebid server config

# set up stored request storage using local file system
stored_requests:
filesystem:
enabled: true
directorypath: ./stored_requests/data/by_id

# set up stored response storage using local file system
stored_responses:
filesystem:
enabled: true
directorypath: ./stored_responses/data/by_id
Loading

0 comments on commit 34517f7

Please sign in to comment.