Skip to content

Commit

Permalink
Merge branch 'prebid:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
xdevel authored Jun 6, 2024
2 parents e76504c + 7702a78 commit 3284f21
Show file tree
Hide file tree
Showing 98 changed files with 4,190 additions and 1,783 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.
25 changes: 11 additions & 14 deletions adapters/medianet/medianet.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest

for _, sb := range bidResp.SeatBid {
for i := range sb.Bid {
bidType, err := getMediaTypeForImp(sb.Bid[i].ImpID, internalRequest.Imp)
bidType, err := getBidMediaTypeFromMtype(&sb.Bid[i])
if err != nil {
errs = append(errs, err)
} else {
Expand All @@ -90,19 +90,16 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co
}, nil
}

func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) {
mediaType := openrtb_ext.BidTypeBanner
for _, imp := range imps {
if imp.ID == impID {
if imp.Banner == nil && imp.Video != nil {
mediaType = openrtb_ext.BidTypeVideo
}
return mediaType, nil
}
}

return "", &errortypes.BadInput{
Message: fmt.Sprintf("Failed to find impression \"%s\" ", impID),
func getBidMediaTypeFromMtype(bid *openrtb2.Bid) (openrtb_ext.BidType, error) {
switch bid.MType {
case openrtb2.MarkupBanner:
return openrtb_ext.BidTypeBanner, nil
case openrtb2.MarkupVideo:
return openrtb_ext.BidTypeVideo, nil
case openrtb2.MarkupNative:
return openrtb_ext.BidTypeNative, nil
default:
return "", fmt.Errorf("Unable to fetch mediaType for imp: %s", bid.ImpID)
}
}

Expand Down
6 changes: 4 additions & 2 deletions adapters/medianet/medianettest/exemplary/multi-imps.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@
"adm": "some-test-ad",
"crid": "test-crid",
"h": 50,
"w": 320
"w": 320,
"mtype": 1
}
]
}
Expand All @@ -123,7 +124,8 @@
"adm": "some-test-ad",
"crid": "test-crid",
"w": 320,
"h": 50
"h": 50,
"mtype": 1
},
"type": "banner"
}
Expand Down
6 changes: 4 additions & 2 deletions adapters/medianet/medianettest/exemplary/simple-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
"adm": "some-test-ad",
"crid": "test-crid",
"h": 50,
"w": 320
"w": 320,
"mtype": 1
}
]
}
Expand All @@ -89,7 +90,8 @@
"adm": "some-test-ad",
"crid": "test-crid",
"w": 320,
"h": 50
"h": 50,
"mtype": 1
},
"type": "banner"
}
Expand Down
6 changes: 4 additions & 2 deletions adapters/medianet/medianettest/exemplary/simple-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"adm": "some-test-ad",
"crid": "test-crid",
"w": 320,
"h": 480
"h": 480,
"mtype": 2
}
]
}
Expand All @@ -92,7 +93,8 @@
"adm": "some-test-ad",
"crid": "test-crid",
"w": 320,
"h": 480
"h": 480,
"mtype": 2
},
"type": "video"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@
"cid": "987",
"crid": "12345678",
"h": 250,
"w": 300
"w": 300,
"mtype": 1
}
]
}
Expand All @@ -123,7 +124,8 @@
"cid": "987",
"crid": "12345678",
"h": 250,
"w": 300
"w": 300,
"mtype": 1
},
"type": "banner"
}]
Expand Down
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
30 changes: 2 additions & 28 deletions adapters/smaato/smaato.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import (
"github.com/prebid/prebid-server/v2/errortypes"
"github.com/prebid/prebid-server/v2/metrics"
"github.com/prebid/prebid-server/v2/openrtb_ext"
"github.com/prebid/prebid-server/v2/util/ptrutil"
"github.com/prebid/prebid-server/v2/util/timeutil"
)

const clientVersion = "prebid_server_0.6"
const clientVersion = "prebid_server_0.7"

type adMarkupType string

Expand Down Expand Up @@ -471,18 +470,7 @@ func setImpForAdspace(imp *openrtb2.Imp) error {
return err
}

if imp.Banner != nil {
bannerCopy, err := setBannerDimension(imp.Banner)
if err != nil {
return err
}
imp.Banner = bannerCopy
imp.TagID = adSpaceID
imp.Ext = impExt
return nil
}

if imp.Video != nil || imp.Native != nil {
if imp.Banner != nil || imp.Video != nil || imp.Native != nil {
imp.TagID = adSpaceID
imp.Ext = impExt
return nil
Expand Down Expand Up @@ -545,20 +533,6 @@ func makeImpExt(impExtRaw *json.RawMessage) (json.RawMessage, error) {
}
}

func setBannerDimension(banner *openrtb2.Banner) (*openrtb2.Banner, error) {
if banner.W != nil && banner.H != nil {
return banner, nil
}
if len(banner.Format) == 0 {
return banner, &errortypes.BadInput{Message: "No sizes provided for Banner."}
}
bannerCopy := *banner
bannerCopy.W = ptrutil.ToPtr(banner.Format[0].W)
bannerCopy.H = ptrutil.ToPtr(banner.Format[0].H)

return &bannerCopy, nil
}

func groupImpressionsByPod(imps []openrtb2.Imp) (map[string]([]openrtb2.Imp), []string, []error) {
pods := make(map[string][]openrtb2.Imp)
orderKeys := make([]string, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@
"tagid": "130563103",
"bidfloor": 0.00123,
"banner": {
"h": 50,
"w": 320,
"format": [
{
"w": 320,
Expand Down Expand Up @@ -203,7 +201,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_0.6"
"client": "prebid_server_0.7"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down Expand Up @@ -349,7 +347,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_0.6"
"client": "prebid_server_0.7"
}
},
"impIDs":["postbid_iframe"]
Expand Down Expand Up @@ -509,4 +507,4 @@
]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@
"tagid": "130563103",
"bidfloor": 0.00123,
"banner": {
"h": 50,
"w": 320,
"format": [
{
"w": 320,
Expand Down Expand Up @@ -162,7 +160,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_0.6"
"client": "prebid_server_0.7"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down Expand Up @@ -269,7 +267,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_0.6"
"client": "prebid_server_0.7"
}
},
"impIDs":["postbid_iframe"]
Expand Down Expand Up @@ -357,4 +355,4 @@
]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@
"tagid": "130563103",
"bidfloor": 0.00123,
"banner": {
"h": 50,
"w": 320,
"format": [
{
"w": 320,
Expand Down Expand Up @@ -180,7 +178,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_0.6"
"client": "prebid_server_0.7"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down Expand Up @@ -326,7 +324,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_0.6"
"client": "prebid_server_0.7"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down Expand Up @@ -486,4 +484,4 @@
]
}
]
}
}
Loading

0 comments on commit 3284f21

Please sign in to comment.