Skip to content

Commit

Permalink
Adnuntius Bid Adapter, Pass DSA back if it's needed by the requesting…
Browse files Browse the repository at this point in the history
… adserver.
  • Loading branch information
mikael-lundin committed Jun 27, 2024
1 parent 3295c41 commit 5be5c75
Show file tree
Hide file tree
Showing 2 changed files with 198 additions and 0 deletions.
45 changes: 45 additions & 0 deletions adapters/adnuntius/adnuntius.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ type extDeviceAdnuntius struct {
type siteExt struct {
Data interface{} `json:"data"`
}
type adnAdvertiser struct {
LegalName string `json:"legalName,omitempty"`
Name string `json:"name,omitempty"`
}

type Ad struct {
Bid struct {
Expand All @@ -56,6 +60,7 @@ type Ad struct {
LineItemId string
Html string
DestinationUrls map[string]string
Advertiser adnAdvertiser
}

type AdUnit struct {
Expand Down Expand Up @@ -369,6 +374,38 @@ func getGDPR(request *openrtb2.BidRequest) (string, string, error) {
return gdpr, consent, nil
}

func generateReturnExt(ad Ad, request *openrtb2.BidRequest) (json.RawMessage, error) {
// We always force the publisher to render
var adRender int8 = 0

var requestRegsExt *openrtb_ext.ExtRegs
if request.Regs != nil && request.Regs.Ext != nil {
if err := json.Unmarshal(request.Regs.Ext, &requestRegsExt); err != nil {

return nil, fmt.Errorf("Failed to parse Ext information in Adnuntius: %v", err)
}
}

if requestRegsExt != nil && requestRegsExt.DSA != nil && requestRegsExt.DSA.PubRender != &adRender {
ext := &openrtb_ext.ExtBid{
DSA: &openrtb_ext.ExtBidDSA{
AdRender: &adRender,
Paid: ad.Advertiser.LegalName,
Behalf: ad.Advertiser.LegalName,
},
}
returnExt, err := json.Marshal(ext)
if err != nil {
return nil, fmt.Errorf("Failed to parse Ext information in Adnuntius: %v", err)
}

return returnExt, nil
} else {
return nil, nil
}

}

func generateAdResponse(ad Ad, imp openrtb2.Imp, html string, request *openrtb2.BidRequest) (*openrtb2.Bid, []error) {

creativeWidth, widthErr := strconv.ParseInt(ad.CreativeWidth, 10, 64)
Expand Down Expand Up @@ -410,6 +447,13 @@ func generateAdResponse(ad Ad, imp openrtb2.Imp, html string, request *openrtb2.
}
}

extJson, err := generateReturnExt(ad, request)
if err != nil {
return nil, []error{&errortypes.BadInput{
Message: fmt.Sprintf("Error extracting Ext: %s", err.Error()),
}}
}

adDomain := []string{}
for _, url := range ad.DestinationUrls {
domainArray := strings.Split(url, "/")
Expand All @@ -429,6 +473,7 @@ func generateAdResponse(ad Ad, imp openrtb2.Imp, html string, request *openrtb2.
Price: price * 1000,
AdM: html,
ADomain: adDomain,
Ext: extJson,
}
return &bid, nil

Expand Down
153 changes: 153 additions & 0 deletions adapters/adnuntius/adnuntiustest/supplemental/check-dsa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
{
"imp": [
{
"ext": {
"data": {

},
"prebid": {
"bidder": {
"adnuntius": {
"auId": "000000000021aca6"
}
},
"adunitcode": "/19660636/adn_rect_01"
}
},
"id": "/19660636/adn_rect_01",
"banner": {
"topframe": 1,
"format": [
{
"w": 300,
"h": 250
}
]
}
}
],
"user": {
"data": [
{
"name": "adnuntius",
"segment": [
{
"id": "outerSegment123"
},
{
"id": "moooore!"
}
]
}
],
"ext": {
"eids": [
{
"source": "SCHNO-EnvHash",
"uids": [
{
"id": "eyJraWQiOiIyIiwiYWxnIjoiSFMyNTYifQ--EwULowzgAb-9XhVnWLSB8eun29QCbpuMK0rf9S5kJyw",
"atype": 1,
"ext": {
"stype": "ppuid"
}
}
]
}
]
}
},
"regs": {
"ext": {
"dsa": {
"dsarequired": 3,
"pubrender": 0,
"datatopub": 2,
"transparency": [
{
"domain": "platform1domain.com",
"dsaparams": [
1
]
},
{
"domain": "SSP2domain.com",
"dsaparams": [
1,
2
]
}
]
}
}
},
"site": {
"domain": "adnun.net",
"publisher": {
"domain": "adnun.net",
"id": "1"
},
"page": "https://adnun.net/prebid/server/?pbjs_debug=true",
"ext": {
"data": {
"no-sch-geo": [
"glcountry_no",
"glwe_shower_in_vicinity"
]
}
}
},
"device": {
"w": 567,
"h": 1328,
"dnt": 0,
"ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
"language": "en",
"sua": {
"source": 1,
"platform": {
"brand": "macOS"
},
"browsers": [
{
"brand": "Not/A)Brand",
"version": [
"8"
]
},
{
"brand": "Chromium",
"version": [
"126"
]
},
{
"brand": "Google Chrome",
"version": [
"126"
]
}
],
"mobile": 0
}
},
"id": "5bda7aea-2d3b-4927-88ed-b835144e2b6e",
"test": 0,
"ext": {
"prebid": {
"auctiontimestamp": 1719324329757,
"targeting": {
"includewinners": true,
"includebidderkeys": false
},
"debug": true,
"channel": {
"name": "pbjs",
"version": "v9.2.0"
},
"createtids": false
},
"tmaxmax": 1000
},
"tmax": 500
}

0 comments on commit 5be5c75

Please sign in to comment.