-
Notifications
You must be signed in to change notification settings - Fork 731
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
Adds keyvalue hb_format support #1414
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,6 +173,7 @@ to set these params on the response at `response.seatbid[i].bid[j].ext.prebid.ta | |
}, | ||
"includewinners": false, // Optional param defaulting to true | ||
"includebidderkeys": false // Optional param defaulting to true | ||
"includeformat": false //Optional param defaulting to false | ||
} | ||
} | ||
} | ||
|
@@ -184,6 +185,8 @@ For backwards compatibility the following strings will also be allowed as price | |
|
||
One of "includewinners" or "includebidderkeys" must be true (both default to true if unset). If both were false, then no targeting keys would be set, which is better configured by omitting targeting altogether. | ||
|
||
The parameter "includeformat" is for multiformat support. It will add the key `hb_format` and/or `hb_format_{bidderName}` as per "includewinners" and "includebidderkeys" above. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about modifying this a little bit to say:
|
||
|
||
MediaType PriceGranularity (PBS-Java only) - when a single OpenRTB request contains multiple impressions with different mediatypes, or a single impression supports multiple formats, the different mediatypes may need different price granularities. If `mediatypepricegranularity` is present, `pricegranularity` would only be used for any mediatypes not specified. | ||
|
||
``` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,3 +247,166 @@ func (f *mockFetcher) GetId(bidder openrtb_ext.BidderName) (string, bool) { | |
func mockServer(w http.ResponseWriter, req *http.Request) { | ||
w.Write([]byte("{}")) | ||
} | ||
|
||
type TargetingTestData struct { | ||
Description string | ||
TargetData targetData | ||
Auction auction | ||
IsApp bool | ||
CategoryMapping map[string]string | ||
ExpectedBidTargetsByBidder map[string]map[openrtb_ext.BidderName]map[string]string | ||
} | ||
|
||
func TestSetTargeting(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please put test fixture after the test cases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean by "test fixture"? |
||
for _, test := range TargetingTests { | ||
auc := &test.Auction | ||
// Set rounded prices from the auction data | ||
auc.setRoundedPrices(test.TargetData.priceGranularity) | ||
winningBids := make(map[string]*pbsOrtbBid) | ||
// Set winning bids from the auction data | ||
for imp, bidsByBidder := range auc.winningBidsByBidder { | ||
for _, bid := range bidsByBidder { | ||
if winningBid, ok := winningBids[imp]; ok { | ||
if winningBid.bid.Price < bid.bid.Price { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to filter by price in a unit test? |
||
winningBids[imp] = bid | ||
} | ||
} else { | ||
winningBids[imp] = bid | ||
} | ||
} | ||
} | ||
auc.winningBids = winningBids | ||
targData := test.TargetData | ||
targData.setTargeting(auc, test.IsApp, test.CategoryMapping) | ||
for imp, targetsByBidder := range test.ExpectedBidTargetsByBidder { | ||
for bidder, expected := range targetsByBidder { | ||
assert.Equal(t, | ||
expected, | ||
auc.winningBidsByBidder[imp][bidder].bidTargets, | ||
"Test: %s\nTargeting failed for bidder %s on imp %s.", | ||
test.Description, | ||
string(bidder), | ||
imp) | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
var TargetingTests []TargetingTestData = []TargetingTestData{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of these tests aren't related to hb_format. Did we have testing gaps before that you're addressing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe so. We had no testing on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks a lot @hhhjort for adding these tests. They are definitely very helpful. Could we maybe also add some test cases around the other targeting keys like the cache ones and the deal ones? I understand that this PR doesn't make any code changes for those but since we have this framework in place now, I am hoping that it wouldn't be too much of an effort to add that. I will leave this up to you though. |
||
{ | ||
Description: "Targeting winners only (most basic targeting example)", | ||
TargetData: targetData{ | ||
priceGranularity: openrtb_ext.PriceGranularityFromString("med"), | ||
includeWinners: true, | ||
}, | ||
Auction: auction{ | ||
winningBidsByBidder: map[string]map[openrtb_ext.BidderName]*pbsOrtbBid{ | ||
"ImpId-1": { | ||
openrtb_ext.BidderAppnexus: { | ||
bid: &openrtb.Bid{ | ||
Price: 1.23, | ||
}, | ||
bidType: openrtb_ext.BidTypeBanner, | ||
}, | ||
openrtb_ext.BidderRubicon: { | ||
bid: &openrtb.Bid{ | ||
Price: 0.84, | ||
}, | ||
bidType: openrtb_ext.BidTypeBanner, | ||
}, | ||
}, | ||
}, | ||
}, | ||
ExpectedBidTargetsByBidder: map[string]map[openrtb_ext.BidderName]map[string]string{ | ||
"ImpId-1": { | ||
openrtb_ext.BidderAppnexus: { | ||
"hb_bidder": "appnexus", | ||
"hb_pb": "1.20", | ||
}, | ||
openrtb_ext.BidderRubicon: {}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
Description: "Targeting on bidders only", | ||
TargetData: targetData{ | ||
priceGranularity: openrtb_ext.PriceGranularityFromString("med"), | ||
includeBidderKeys: true, | ||
}, | ||
Auction: auction{ | ||
winningBidsByBidder: map[string]map[openrtb_ext.BidderName]*pbsOrtbBid{ | ||
"ImpId-1": { | ||
openrtb_ext.BidderAppnexus: { | ||
bid: &openrtb.Bid{ | ||
Price: 1.23, | ||
}, | ||
bidType: openrtb_ext.BidTypeBanner, | ||
}, | ||
openrtb_ext.BidderRubicon: { | ||
bid: &openrtb.Bid{ | ||
Price: 0.84, | ||
}, | ||
bidType: openrtb_ext.BidTypeBanner, | ||
}, | ||
}, | ||
}, | ||
}, | ||
ExpectedBidTargetsByBidder: map[string]map[openrtb_ext.BidderName]map[string]string{ | ||
"ImpId-1": { | ||
openrtb_ext.BidderAppnexus: { | ||
"hb_bidder_appnexus": "appnexus", | ||
"hb_pb_appnexus": "1.20", | ||
}, | ||
openrtb_ext.BidderRubicon: { | ||
"hb_bidder_rubicon": "rubicon", | ||
"hb_pb_rubicon": "0.80", | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
Description: "Full basic targeting with hd_format", | ||
TargetData: targetData{ | ||
priceGranularity: openrtb_ext.PriceGranularityFromString("med"), | ||
includeWinners: true, | ||
includeBidderKeys: true, | ||
includeFormat: true, | ||
}, | ||
Auction: auction{ | ||
winningBidsByBidder: map[string]map[openrtb_ext.BidderName]*pbsOrtbBid{ | ||
"ImpId-1": { | ||
openrtb_ext.BidderAppnexus: { | ||
bid: &openrtb.Bid{ | ||
Price: 1.23, | ||
}, | ||
bidType: openrtb_ext.BidTypeBanner, | ||
}, | ||
openrtb_ext.BidderRubicon: { | ||
bid: &openrtb.Bid{ | ||
Price: 0.84, | ||
}, | ||
bidType: openrtb_ext.BidTypeBanner, | ||
}, | ||
}, | ||
}, | ||
}, | ||
ExpectedBidTargetsByBidder: map[string]map[openrtb_ext.BidderName]map[string]string{ | ||
"ImpId-1": { | ||
openrtb_ext.BidderAppnexus: { | ||
"hb_bidder": "appnexus", | ||
"hb_bidder_appnexus": "appnexus", | ||
"hb_pb": "1.20", | ||
"hb_pb_appnexus": "1.20", | ||
"hb_format": "banner", | ||
"hb_format_appnexus": "banner", | ||
}, | ||
openrtb_ext.BidderRubicon: { | ||
"hb_bidder_rubicon": "rubicon", | ||
"hb_pb_rubicon": "0.80", | ||
"hb_format_rubicon": "banner", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Please add a space before the comment for consistency.