Skip to content

Commit

Permalink
Sharethrough: Add support for GPID (prebid#1925)
Browse files Browse the repository at this point in the history
  • Loading branch information
epechuzal authored Jul 22, 2021
1 parent 0aa427e commit a68f7e2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
10 changes: 10 additions & 0 deletions adapters/sharethrough/butler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const defaultTmax = 10000 // 10 sec
type StrAdSeverParams struct {
Pkey string
BidID string
GPID string
ConsentRequired bool
ConsentString string
USPrivacySignal string
Expand Down Expand Up @@ -97,6 +98,11 @@ func (s StrOpenRTBTranslator) requestFromOpenRTB(imp openrtb2.Imp, request *open
return nil, err
}

var gpid string
if strImpParams.Data != nil && strImpParams.Data.PBAdSlot != "" {
gpid = strImpParams.Data.PBAdSlot
}

usPolicySignal := ""
if usPolicy, err := ccpa.ReadFromRequest(request); err == nil {
usPolicySignal = usPolicy.Consent
Expand All @@ -107,6 +113,7 @@ func (s StrOpenRTBTranslator) requestFromOpenRTB(imp openrtb2.Imp, request *open
Uri: s.UriHelper.buildUri(StrAdSeverParams{
Pkey: pKey,
BidID: imp.ID,
GPID: gpid,
ConsentRequired: s.Util.gdprApplies(request),
ConsentString: userInfo.Consent,
USPrivacySignal: usPolicySignal,
Expand Down Expand Up @@ -191,6 +198,9 @@ func (h StrUriHelper) buildUri(params StrAdSeverParams) string {
v := url.Values{}
v.Set("placement_key", params.Pkey)
v.Set("bidId", params.BidID)
if params.GPID != "" {
v.Set("gpid", params.GPID)
}
v.Set("consent_required", fmt.Sprintf("%t", params.ConsentRequired))
v.Set("consent_string", params.ConsentString)
if params.USPrivacySignal != "" {
Expand Down
4 changes: 3 additions & 1 deletion adapters/sharethrough/butler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestSuccessRequestFromOpenRTB(t *testing.T) {
"Generates the correct AdServer request from Imp (no user provided)": {
inputImp: openrtb2.Imp{
ID: "abc",
Ext: []byte(`{ "bidder": {"pkey": "pkey", "iframe": true, "iframeSize": [10, 20], "bidfloor": 1.0} }`),
Ext: []byte(`{ "bidder": {"pkey": "pkey", "iframe": true, "iframeSize": [10, 20], "bidfloor": 1.0, "data": { "pbadslot": "adslot" } } }`),
Banner: &openrtb2.Banner{
Format: []openrtb2.Format{{H: 30, W: 40}},
},
Expand Down Expand Up @@ -435,6 +435,7 @@ func TestBuildUri(t *testing.T) {
inputParams: StrAdSeverParams{
Pkey: "pkey",
BidID: "bid",
GPID: "gpid",
ConsentRequired: true,
ConsentString: "consent",
USPrivacySignal: "ccpa",
Expand All @@ -449,6 +450,7 @@ func TestBuildUri(t *testing.T) {
"http://abc.com?",
"placement_key=pkey",
"bidId=bid",
"gpid=gpid",
"consent_required=true",
"consent_string=consent",
"us_privacy=ccpa",
Expand Down
15 changes: 10 additions & 5 deletions openrtb_ext/imp_sharethrough.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package openrtb_ext

type ExtImpSharethrough struct {
Pkey string `json:"pkey"`
Iframe bool `json:"iframe"`
IframeSize []int `json:"iframeSize"`
BidFloor float64 `json:"bidfloor"`
type ExtData struct {
PBAdSlot string `json:"pbadslot"`
}

// ExtImpSharethrough defines the contract for bidrequest.imp[i].ext.sharethrough
type ExtImpSharethrough struct {
Pkey string `json:"pkey"`
Iframe bool `json:"iframe"`
IframeSize []int `json:"iframeSize"`
BidFloor float64 `json:"bidfloor"`
Data *ExtData `json:"data,omitempty"`
}

type ExtImpSharethroughResponse struct {
AdServerRequestID string `json:"adserverRequestId"`
BidID string `json:"bidId"`
Expand Down
10 changes: 10 additions & 0 deletions static/bidder-params/sharethrough.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
"bidfloor": {
"type": "number",
"description": "The floor price, or minimum amount, a publisher will accept for an impression, given in CPM in USD"
},
"data": {
"type": "object",
"description": "Ad-specific first party data",
"properties": {
"pbadslot": {
"type": "string",
"description": "Prebid Ad Slot, see: https://docs.prebid.org/features/pbAdSlot.html"
}
}
}
},
"required": ["pkey"]
Expand Down

0 comments on commit a68f7e2

Please sign in to comment.