Skip to content

Commit

Permalink
pubmatic: add fledge support (#3174)
Browse files Browse the repository at this point in the history
  • Loading branch information
pm-nilesh-chate authored Oct 11, 2023
1 parent c8f3b2d commit 81c78ff
Show file tree
Hide file tree
Showing 2 changed files with 191 additions and 0 deletions.
25 changes: 25 additions & 0 deletions adapters/pubmatic/pubmatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (

const MAX_IMPRESSIONS_PUBMATIC = 30

const ae = "ae"

type PubmaticAdapter struct {
URI string
}
Expand All @@ -42,6 +44,7 @@ type pubmaticBidExtVideo struct {
type ExtImpBidderPubmatic struct {
adapters.ExtImpBidder
Data json.RawMessage `json:"data,omitempty"`
AE int `json:"ae,omitempty"`
}

type ExtAdServer struct {
Expand All @@ -60,6 +63,10 @@ type extRequestAdServer struct {
openrtb_ext.ExtRequest
}

type respExt struct {
FledgeAuctionConfigs map[string]json.RawMessage `json:"fledge_auction_configs,omitempty"`
}

const (
dctrKeyName = "key_val"
pmZoneIDKeyName = "pmZoneId"
Expand Down Expand Up @@ -304,6 +311,10 @@ func parseImpressionObject(imp *openrtb2.Imp, extractWrapperExtFromImp, extractP
populateFirstPartyDataImpAttributes(bidderExt.Data, extMap)
}

if bidderExt.AE != 0 {
extMap[ae] = bidderExt.AE
}

imp.Ext = nil
if len(extMap) > 0 {
ext, err := json.Marshal(extMap)
Expand Down Expand Up @@ -465,6 +476,20 @@ func (a *PubmaticAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externa
if bidResp.Cur != "" {
bidResponse.Currency = bidResp.Cur
}

if bidResp.Ext != nil {
var bidRespExt respExt
if err := json.Unmarshal(bidResp.Ext, &bidRespExt); err == nil && bidRespExt.FledgeAuctionConfigs != nil {
bidResponse.FledgeAuctionConfigs = make([]*openrtb_ext.FledgeAuctionConfig, 0, len(bidRespExt.FledgeAuctionConfigs))
for impId, config := range bidRespExt.FledgeAuctionConfigs {
fledgeAuctionConfig := &openrtb_ext.FledgeAuctionConfig{
ImpId: impId,
Config: config,
}
bidResponse.FledgeAuctionConfigs = append(bidResponse.FledgeAuctionConfigs, fledgeAuctionConfig)
}
}
}
return bidResponse, errs
}

Expand Down
166 changes: 166 additions & 0 deletions adapters/pubmatic/pubmatictest/exemplary/fledge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"ext": {
"ae": 1,
"bidder": {
"publisherId": "999",
"adSlot": "AdTag_Div1@300x250"
}
}
}
]
},
"httpCalls": [
{
"expectedRequest": {
"uri": "https://hbopenbid.pubmatic.com/translator?source=prebid-server",
"body": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 728,
"h": 90
}
],
"h": 250,
"w": 300
},
"tagid": "AdTag_Div1",
"ext": {
"ae": 1
}
}
],
"ext": {"prebid":{}}
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [
{
"seat": "pubmatic",
"bid": [
{
"id": "9d8e77c2-ee0f-4781-af59-5359493b11af",
"impid": "test-imp-id",
"price": 1.1,
"adm": "some-test-ad",
"crid": "crid_10",
"h": 90,
"w": 728,
"ext": {}
}
]
}
],
"cur": "USD",
"ext": {
"fledge_auction_configs": {
"test-imp-id": {
"seller": "PUBMATIC_SELLER_CONSTANT_STRING",
"sellerTimeout": 123,
"decisionLogicUrl": "PUBMATIC_URL_CONSTANT_STRING",
"interestGroupBuyers": [
"somedomain1.com",
"somedomain2.com",
"somedomain3.com",
"somedomain4.com"
],
"perBuyerSignals": {
"somedomain1.com": {
"multiplier": 1,
"win_reporting_id": "1234"
},
"somedomain2.com": {
"multiplier": 2,
"win_reporting_id": "2345"
},
"somedomain3.com": {
"multiplier": 3,
"win_reporting_id": "3456"
},
"somedomain4.com": {
"multiplier": 4,
"win_reporting_id": "4567"
}
}
}
}
}
}
}
}
],
"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "9d8e77c2-ee0f-4781-af59-5359493b11af",
"impid": "test-imp-id",
"price": 1.1,
"adm": "some-test-ad",
"crid": "crid_10",
"w": 728,
"h": 90,
"ext": {}
},
"type": "banner"
}
],
"fledgeauctionconfigs": [
{
"impid": "test-imp-id",
"config": {
"seller": "PUBMATIC_SELLER_CONSTANT_STRING",
"sellerTimeout": 123,
"decisionLogicUrl": "PUBMATIC_URL_CONSTANT_STRING",
"interestGroupBuyers": [
"somedomain1.com",
"somedomain2.com",
"somedomain3.com",
"somedomain4.com"
],
"perBuyerSignals": {
"somedomain1.com": {
"multiplier": 1,
"win_reporting_id": "1234"
},
"somedomain2.com": {
"multiplier": 2,
"win_reporting_id": "2345"
},
"somedomain3.com": {
"multiplier": 3,
"win_reporting_id": "3456"
},
"somedomain4.com": {
"multiplier": 4,
"win_reporting_id": "4567"
}
}
}
}
]
}
]
}

0 comments on commit 81c78ff

Please sign in to comment.