Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Bid Adjustments #2678

Merged
merged 32 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1635031
Initial major implementation, no tests
AlexBVolcy Mar 29, 2023
b942b42
Move/add merge/validation to HoldAuction
AlexBVolcy Mar 30, 2023
1302f86
Bid Adj Testing
AlexBVolcy Apr 3, 2023
0449d99
Merge branch 'master' into upgrade_bid_adjustments
AlexBVolcy Apr 3, 2023
14c79ec
Remove unused value from merge
AlexBVolcy Apr 3, 2023
eff488a
Merge branch 'master' into upgrade_bid_adjustments
AlexBVolcy Apr 3, 2023
d055f96
Fix failed tests post merge
AlexBVolcy Apr 3, 2023
4ff5ede
Better function names
AlexBVolcy Apr 4, 2023
9b2e525
Address feedback
AlexBVolcy Apr 11, 2023
fb2ab84
Tweak to validation
AlexBVolcy Apr 12, 2023
4659a9a
Combine adjustment functions, round bid price
AlexBVolcy Apr 14, 2023
0c688fd
Moved exchange adjustment functions/tests
AlexBVolcy Apr 17, 2023
5306357
Merge branch 'master' into upgrade_bid_adjustments
AlexBVolcy Apr 18, 2023
05a132f
Address module error
AlexBVolcy Apr 18, 2023
3d4a341
Address half of feedback, remove ptrs,update tests
AlexBVolcy Apr 20, 2023
fdf5edc
Updates to adj array apply
AlexBVolcy Apr 20, 2023
b756794
Move bid adjustment logic to own package
AlexBVolcy Apr 20, 2023
7d6b4fc
Big changes to GetAdjustmentArray, minor to merge
AlexBVolcy Apr 23, 2023
1a99400
Merge branch 'master' into upgrade_bid_adjustments
AlexBVolcy Apr 24, 2023
6e17639
Address variety of feedback
AlexBVolcy Apr 24, 2023
816d3e2
Update to not return map unnecessarily
AlexBVolcy Apr 24, 2023
a4fcab8
Add more test cases for validation
AlexBVolcy Apr 25, 2023
20cd02a
Renaming, updating bidadjustment package files
AlexBVolcy Apr 26, 2023
7b8b5cb
Add nil checks to validation, update tests, rename
AlexBVolcy Apr 26, 2023
3ee1931
Video instream/outstream support
AlexBVolcy Apr 27, 2023
9708f82
Address all feedback
AlexBVolcy May 2, 2023
db1df54
Merge branch 'master' into upgrade_bid_adjustments
AlexBVolcy May 3, 2023
39cfec9
Fix error after merge
AlexBVolcy May 3, 2023
8c1e089
Address error handling, edge cases
AlexBVolcy May 3, 2023
1ce1b43
Add invalid end to end test
AlexBVolcy May 3, 2023
77b4dd0
Fatal error tweak
AlexBVolcy May 3, 2023
4c55dea
Re-add comment, tweak error handling
AlexBVolcy May 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions config/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,23 @@ const (

// Account represents a publisher account configuration
type Account struct {
ID string `mapstructure:"id" json:"id"`
Disabled bool `mapstructure:"disabled" json:"disabled"`
CacheTTL DefaultTTLs `mapstructure:"cache_ttl" json:"cache_ttl"`
EventsEnabled bool `mapstructure:"events_enabled" json:"events_enabled"`
CCPA AccountCCPA `mapstructure:"ccpa" json:"ccpa"`
GDPR AccountGDPR `mapstructure:"gdpr" json:"gdpr"`
DebugAllow bool `mapstructure:"debug_allow" json:"debug_allow"`
DefaultIntegration string `mapstructure:"default_integration" json:"default_integration"`
CookieSync CookieSync `mapstructure:"cookie_sync" json:"cookie_sync"`
Events Events `mapstructure:"events" json:"events"` // Don't enable this feature. It is still under developmment - https://github.com/prebid/prebid-server/issues/1725
TruncateTargetAttribute *int `mapstructure:"truncate_target_attr" json:"truncate_target_attr"`
AlternateBidderCodes *openrtb_ext.ExtAlternateBidderCodes `mapstructure:"alternatebiddercodes" json:"alternatebiddercodes"`
Hooks AccountHooks `mapstructure:"hooks" json:"hooks"`
PriceFloors AccountPriceFloors `mapstructure:"price_floors" json:"price_floors"`
Validations Validations `mapstructure:"validations" json:"validations"`
DefaultBidLimit int `mapstructure:"default_bid_limit" json:"default_bid_limit"`
ID string `mapstructure:"id" json:"id"`
Disabled bool `mapstructure:"disabled" json:"disabled"`
CacheTTL DefaultTTLs `mapstructure:"cache_ttl" json:"cache_ttl"`
EventsEnabled bool `mapstructure:"events_enabled" json:"events_enabled"`
CCPA AccountCCPA `mapstructure:"ccpa" json:"ccpa"`
GDPR AccountGDPR `mapstructure:"gdpr" json:"gdpr"`
DebugAllow bool `mapstructure:"debug_allow" json:"debug_allow"`
DefaultIntegration string `mapstructure:"default_integration" json:"default_integration"`
CookieSync CookieSync `mapstructure:"cookie_sync" json:"cookie_sync"`
Events Events `mapstructure:"events" json:"events"` // Don't enable this feature. It is still under developmment - https://github.com/prebid/prebid-server/issues/1725
TruncateTargetAttribute *int `mapstructure:"truncate_target_attr" json:"truncate_target_attr"`
AlternateBidderCodes *openrtb_ext.ExtAlternateBidderCodes `mapstructure:"alternatebiddercodes" json:"alternatebiddercodes"`
Hooks AccountHooks `mapstructure:"hooks" json:"hooks"`
PriceFloors AccountPriceFloors `mapstructure:"price_floors" json:"price_floors"`
Validations Validations `mapstructure:"validations" json:"validations"`
DefaultBidLimit int `mapstructure:"default_bid_limit" json:"default_bid_limit"`
BidAdjustments *openrtb_ext.ExtRequestPrebidBidAdjustments `mapstructure:"bidadjustments" json:"bidadjustments"`
}

// CookieSync represents the account-level defaults for the cookie sync endpoint.
Expand Down
9 changes: 9 additions & 0 deletions endpoints/openrtb2/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,15 @@ func validateRequestExt(req *openrtb_ext.RequestWrapper) []error {
reqExt.SetPrebid(prebid)
}

if valid := prebid.BidAdjustments.ValidateBidAdjustments(); !valid {
prebid.BidAdjustments = nil
reqExt.SetPrebid(prebid)
Copy link
Collaborator

@bsardo bsardo May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double check that we don't need to call RebuildRequest after setting prebid on the wrapper.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No action required here. We shouldn't need to call RebuildRequest at this point. The call to SetPrebid is modifying the request ext object on the wrapper and marking it as dirty which is sufficient. The code that follows operates off of the request ext object and does not need access to a marshaled ext. In HoldAuction, we rebuild the request prior to cleaning and splitting the request by bidder to ensure that each bidder uses a copy of the mutated request including any modifications made to the request ext through calls to methods like SetPrebid.

errs = append(errs, &errortypes.Warning{
WarningCode: errortypes.BidAdjustmentWarningCode,
Message: "Bid Adjustment From Request Was Invalid",
AlexBVolcy marked this conversation as resolved.
Show resolved Hide resolved
})
}

return errs
}

Expand Down
AlexBVolcy marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
AlexBVolcy marked this conversation as resolved.
Show resolved Hide resolved
"description": "Bid Adjustment Test with CPM, and WildCard Preference Testing",
"config": {
"mockBidders": [
{"bidderName": "appnexus", "currency": "USD", "price": 20.00}
]
},
"mockBidRequest": {
"id": "some-request-id",
"site": {
"page": "prebid.org"
},
"imp": [
{
"id": "some-impression-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
},
{
"w": 300,
"h": 600
}
]
},
"ext": {
"appnexus": {
"placementId": 12883451
}
}
}
],
"tmax": 500,
"ext": {
"prebid": {
"currency": {
"rates": {
"EUR": {
"USD": 2.0
}
},
"usepbsrates": false
},
"bidadjustments": {
"mediatype": {
"banner": {
"appnexus": {
"*": [
{
"adjtype": "cpm",
"value": 5.0,
"currency": "EUR"
}
]
},
"*": {
"*": [
{
"adjtype": "multiplier",
"value": 3.0
}
]
}
}
}
}
}
}
},
"expectedBidResponse": {
"id":"some-request-id",
"seatbid": [
{
"bid": [
{
"id": "appnexus-bid",
"impid": "some-impression-id",
"price": 17.5,
"ext": {"origbidcpm": 20, "origbidcur": "USD", "prebid": {"meta": {"adaptercode": "appnexus"}, "type": "banner"}}
}
],
"seat": "appnexus"
}
],
"bidid":"test bid id",
"cur":"USD",
"nbr":0
},
"expectedReturnCode": 200
}
AlexBVolcy marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"description": "Bid Adjustment Test With One Adjustment",
"config": {
"mockBidders": [
{"bidderName": "appnexus", "currency": "USD", "price": 2.00, "dealid": "some-deal-id"}
]
},
"mockBidRequest": {
"id": "some-request-id",
"site": {
"page": "prebid.org"
},
"imp": [
{
"id": "some-impression-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
},
{
"w": 300,
"h": 600
}
]
},
"ext": {
"appnexus": {
"placementId": 12883451
}
}
}
],
"tmax": 500,
"ext": {
"prebid": {
"bidadjustments": {
"mediatype": {
"banner": {
"appnexus": {
"some-deal-id": [
{
"adjtype": "multiplier",
"value": 2.0
}
]
}
}
}
}
}
}
},
"expectedBidResponse": {
"id":"some-request-id",
"seatbid": [
{
"bid": [
{
"id": "appnexus-bid",
"impid": "some-impression-id",
"price": 4.0,
"ext": {"origbidcpm": 2, "origbidcur": "USD", "prebid": {"meta": {"adaptercode": "appnexus"}, "type": "banner"}}
}
],
"seat": "appnexus"
}
],
"bidid":"test bid id",
"cur":"USD",
"nbr":0
},
"expectedReturnCode": 200
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"description": "Bid Adjustment with Static and WildCard testing",
"config": {
"mockBidders": [
{"bidderName": "appnexus", "currency": "USD", "price": 2.00, "dealid": "some-deal-id"}
]
},
"mockBidRequest": {
"id": "some-request-id",
"site": {
"page": "prebid.org"
},
"imp": [
{
"id": "some-impression-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
},
{
"w": 300,
"h": 600
}
]
},
"ext": {
"appnexus": {
"placementId": 12883451
}
}
}
],
"tmax": 500,
"ext": {
"prebid": {
"currency": {
"rates": {
"EUR": {
"USD": 2.0
}
},
"usepbsrates": false
},
"bidadjustments": {
"mediatype": {
"banner": {
"*": {
"some-deal-id": [
{
"adjtype": "static",
"value": 5.0,
"currency": "EUR"
}
]
},
"some-bidder-name": {
"*": [
{
"adjtype": "multiplier",
"value": 2.0
}
]
}
}
}
}
}
}
},
"expectedBidResponse": {
"id":"some-request-id",
"seatbid": [
{
"bid": [
{
"id": "appnexus-bid",
"impid": "some-impression-id",
"price": 2.5,
AlexBVolcy marked this conversation as resolved.
Show resolved Hide resolved
"ext": {"origbidcpm": 2, "origbidcur": "USD", "prebid": {"meta": {"adaptercode": "appnexus"}, "type": "banner"}}
}
],
"seat": "appnexus"
}
],
"bidid":"test bid id",
"cur":"USD",
AlexBVolcy marked this conversation as resolved.
Show resolved Hide resolved
"nbr":0
},
"expectedReturnCode": 200
}
8 changes: 5 additions & 3 deletions endpoints/openrtb2/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ type mockBidderHandler struct {
BidderName string `json:"bidderName"`
Currency string `json:"currency"`
Price float64 `json:"price"`
DealId string `json:"dealid"`
AlexBVolcy marked this conversation as resolved.
Show resolved Hide resolved
}

func (b mockBidderHandler) bid(w http.ResponseWriter, req *http.Request) {
Expand Down Expand Up @@ -970,9 +971,10 @@ func (b mockBidderHandler) bid(w http.ResponseWriter, req *http.Request) {
{
Bid: []openrtb2.Bid{
{
ID: b.BidderName + "-bid",
ImpID: openrtb2Request.Imp[0].ID,
Price: b.Price,
ID: b.BidderName + "-bid",
ImpID: openrtb2Request.Imp[0].ID,
Price: b.Price,
DealID: b.DealId,
},
},
Seat: b.BidderName,
Expand Down
1 change: 1 addition & 0 deletions errortypes/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
AlternateBidderCodeWarningCode
MultiBidWarningCode
AdServerTargetingWarningCode
BidAdjustmentWarningCode
)

// Coder provides an error or warning code with severity.
Expand Down
Loading