Skip to content

Commit

Permalink
FPD: Allow imp.ext.data To Passthrough To Adapters (#1765)
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxNode authored Mar 23, 2021
1 parent 2f1a0e0 commit 080843b
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 45 deletions.
2 changes: 2 additions & 0 deletions endpoints/openrtb2/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,8 @@ func isBidderToValidate(bidder string) bool {
switch openrtb_ext.BidderName(bidder) {
case openrtb_ext.BidderReservedContext:
return false
case openrtb_ext.BidderReservedData:
return false
case openrtb_ext.BidderReservedPrebid:
return false
case openrtb_ext.BidderReservedSKAdN:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,29 @@
"appnexus": {
"placementId": 12883451
},
"data": {
"keywords": "prebid server example"
},
"context": {
"data": {
"keywords": "prebid server example"
"keywords": "another prebid server example"
}
}
}
}]
},
"expectedBidResponse": {
"id":"some-request-id",
"seatbid": [
{
"bid": [
{
"id": "appnexus-bid",
"impid": "",
"price": 0
}
],
"seat": "appnexus-bids"
}
],
"bidid":"test bid id",
"nbr":0
"id": "some-request-id",
"seatbid": [{
"bid": [{
"id": "appnexus-bid",
"impid": "",
"price": 0
}],
"seat": "appnexus-bids"
}],
"bidid": "test bid id",
"nbr": 0
},
"expectedReturnCode": 200
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,29 @@
}
}
},
"data": {
"keywords": "prebid server example"
},
"context": {
"data": {
"keywords": "prebid server example"
"keywords": "another prebid server example"
}
}
}
}]
},
"expectedBidResponse": {
"id":"some-request-id",
"seatbid": [
{
"bid": [
{
"id": "appnexus-bid",
"impid": "",
"price": 0
}
],
"seat": "appnexus-bids"
}
],
"bidid":"test bid id",
"nbr":0
"id": "some-request-id",
"seatbid": [{
"bid": [{
"id": "appnexus-bid",
"impid": "",
"price": 0
}],
"seat": "appnexus-bids"
}],
"bidid": "test bid id",
"nbr": 0
},
"expectedReturnCode": 200
}
}
15 changes: 12 additions & 3 deletions exchange/exchangetest/firstpartydata-imp-ext-multiple-bidders.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
"siteId": 2,
"zoneId": 3
},
"data": {
"keywords": "prebid server example"
},
"context": {
"data": {
"keywords": "prebid server example"
"keywords": "another prebid server example"
}
}
}
Expand Down Expand Up @@ -57,9 +60,12 @@
"bidder": {
"placementId": 1
},
"data": {
"keywords": "prebid server example"
},
"context": {
"data": {
"keywords": "prebid server example"
"keywords": "another prebid server example"
}
}
}
Expand Down Expand Up @@ -107,9 +113,12 @@
"siteId": 2,
"zoneId": 3
},
"data": {
"keywords": "prebid server example"
},
"context": {
"data": {
"keywords": "prebid server example"
"keywords": "another prebid server example"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
}
}
},
"data": {
"keywords": "prebid server example"
},
"context": {
"data": {
"keywords": "prebid server example"
"keywords": "another prebid server example"
}
}
}
Expand Down Expand Up @@ -61,9 +64,12 @@
"bidder": {
"placementId": 1
},
"data": {
"keywords": "prebid server example"
},
"context": {
"data": {
"keywords": "prebid server example"
"keywords": "another prebid server example"
}
}
}
Expand Down Expand Up @@ -111,9 +117,12 @@
"siteId": 2,
"zoneId": 3
},
"data": {
"keywords": "prebid server example"
},
"context": {
"data": {
"keywords": "prebid server example"
"keywords": "another prebid server example"
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions exchange/exchangetest/firstpartydata-imp-ext-one-bidder.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
"appnexus": {
"placementId": 1
},
"data": {
"keywords": "prebid server example"
},
"context": {
"data": {
"keywords": "prebid server example"
"keywords": "another prebid server example"
}
}
}
Expand Down Expand Up @@ -52,9 +55,12 @@
"bidder": {
"placementId": 1
},
"data": {
"keywords": "prebid server example"
},
"context": {
"data": {
"keywords": "prebid server example"
"keywords": "another prebid server example"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
}
}
},
"data": {
"keywords": "prebid server example"
},
"context": {
"data": {
"keywords": "prebid server example"
"keywords": "another prebid server example"
}
}
}
Expand Down Expand Up @@ -56,9 +59,12 @@
"bidder": {
"placementId": 1
},
"data": {
"keywords": "prebid server example"
},
"context": {
"data": {
"keywords": "prebid server example"
"keywords": "another prebid server example"
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions exchange/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ func createSanitizedImpExt(impExt, impExtPrebid map[string]json.RawMessage) (map
}
}

if v, exists := impExt[openrtb_ext.FirstPartyDataExtKey]; exists {
sanitizedImpExt[openrtb_ext.FirstPartyDataExtKey] = v
}

if v, exists := impExt[openrtb_ext.FirstPartyDataContextExtKey]; exists {
sanitizedImpExt[openrtb_ext.FirstPartyDataContextExtKey] = v
}
Expand Down Expand Up @@ -419,6 +423,7 @@ func extractBidderExts(impExt, impExtPrebidBidders map[string]json.RawMessage) m

func isSpecialField(bidder string) bool {
return bidder == openrtb_ext.FirstPartyDataContextExtKey ||
bidder == openrtb_ext.FirstPartyDataExtKey ||
bidder == openrtb_ext.SKAdNExtKey ||
bidder == openrtb_ext.PrebidExtKey
}
Expand Down
11 changes: 11 additions & 0 deletions exchange/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,15 @@ func TestCreateSanitizedImpExt(t *testing.T) {
description: "imp.ext.prebid - Bidders Only",
givenImpExt: map[string]json.RawMessage{
"prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`),
"data": json.RawMessage(`"anyData"`),
"context": json.RawMessage(`"anyContext"`),
"skadn": json.RawMessage(`"anySKAdNetwork"`),
},
givenImpExtPrebid: map[string]json.RawMessage{
"bidder": json.RawMessage(`"anyBidder"`),
},
expected: map[string]json.RawMessage{
"data": json.RawMessage(`"anyData"`),
"context": json.RawMessage(`"anyContext"`),
"skadn": json.RawMessage(`"anySKAdNetwork"`),
},
Expand All @@ -249,6 +251,7 @@ func TestCreateSanitizedImpExt(t *testing.T) {
description: "imp.ext.prebid - Bidders + Other Values",
givenImpExt: map[string]json.RawMessage{
"prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`),
"data": json.RawMessage(`"anyData"`),
"context": json.RawMessage(`"anyContext"`),
"skadn": json.RawMessage(`"anySKAdNetwork"`),
},
Expand All @@ -258,6 +261,7 @@ func TestCreateSanitizedImpExt(t *testing.T) {
},
expected: map[string]json.RawMessage{
"prebid": json.RawMessage(`{"someOther":"value"}`),
"data": json.RawMessage(`"anyData"`),
"context": json.RawMessage(`"anyContext"`),
"skadn": json.RawMessage(`"anySKAdNetwork"`),
},
Expand All @@ -267,11 +271,13 @@ func TestCreateSanitizedImpExt(t *testing.T) {
description: "imp.ext",
givenImpExt: map[string]json.RawMessage{
"anyBidder": json.RawMessage(`"anyBidderValues"`),
"data": json.RawMessage(`"anyData"`),
"context": json.RawMessage(`"anyContext"`),
"skadn": json.RawMessage(`"anySKAdNetwork"`),
},
givenImpExtPrebid: map[string]json.RawMessage{},
expected: map[string]json.RawMessage{
"data": json.RawMessage(`"anyData"`),
"context": json.RawMessage(`"anyContext"`),
"skadn": json.RawMessage(`"anySKAdNetwork"`),
},
Expand All @@ -282,13 +288,15 @@ func TestCreateSanitizedImpExt(t *testing.T) {
givenImpExt: map[string]json.RawMessage{
"anyBidder": json.RawMessage(`"anyBidderValues"`),
"prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`),
"data": json.RawMessage(`"anyData"`),
"context": json.RawMessage(`"anyContext"`),
"skadn": json.RawMessage(`"anySKAdNetwork"`),
},
givenImpExtPrebid: map[string]json.RawMessage{
"bidder": json.RawMessage(`"anyBidder"`),
},
expected: map[string]json.RawMessage{
"data": json.RawMessage(`"anyData"`),
"context": json.RawMessage(`"anyContext"`),
"skadn": json.RawMessage(`"anySKAdNetwork"`),
},
Expand All @@ -299,6 +307,7 @@ func TestCreateSanitizedImpExt(t *testing.T) {
givenImpExt: map[string]json.RawMessage{
"anyBidder": json.RawMessage(`"anyBidderValues"`),
"prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`),
"data": json.RawMessage(`"anyData"`),
"context": json.RawMessage(`"anyContext"`),
"skadn": json.RawMessage(`"anySKAdNetwork"`),
},
Expand All @@ -308,6 +317,7 @@ func TestCreateSanitizedImpExt(t *testing.T) {
},
expected: map[string]json.RawMessage{
"prebid": json.RawMessage(`{"someOther":"value"}`),
"data": json.RawMessage(`"anyData"`),
"context": json.RawMessage(`"anyContext"`),
"skadn": json.RawMessage(`"anySKAdNetwork"`),
},
Expand All @@ -317,6 +327,7 @@ func TestCreateSanitizedImpExt(t *testing.T) {
description: "Marshal Error - imp.ext.prebid",
givenImpExt: map[string]json.RawMessage{
"prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`),
"data": json.RawMessage(`"anyData"`),
"context": json.RawMessage(`"anyContext"`),
"skadn": json.RawMessage(`"anySKAdNetwork"`),
},
Expand Down
5 changes: 4 additions & 1 deletion openrtb_ext/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import (
"errors"
)

// FirstPartyDataContextExtKey defines the field name within request.ext reserved for first party data.
// FirstPartyDataExtKey defines a field name within request.ext and request.imp.ext reserved for first party data.
const FirstPartyDataExtKey = "data"

// FirstPartyDataContextExtKey defines a field name within request.ext and request.imp.ext reserved for first party data.
const FirstPartyDataContextExtKey = "context"

// SKAdNExtKey defines the field name within request.ext reserved for Apple's SKAdNetwork.
Expand Down

0 comments on commit 080843b

Please sign in to comment.