Skip to content
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

Smaato: DOOH support #3751

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions adapters/smaato/banner.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ import (
)

func extractAdmBanner(adMarkup string, curls []string) string {
var clickEvent string
if len(curls) > 0 {
var clickEvent string
var clicks strings.Builder
for _, clicktracker := range curls {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How many curls do you expect the adm to contain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unlikely more than 3
I believe atm we mostly supply 1

Copy link
Contributor Author

@Enigo Enigo Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also changed it to only execute this logic when curls field is sent
and added quotes for onlick

cc @el-chuck

clicks.WriteString("fetch(decodeURIComponent('" + url.QueryEscape(clicktracker) + "'.replace(/\\+/g, ' ')), " +
"{cache: 'no-cache'});")
}
clickEvent = fmt.Sprintf(`onclick=%s`, clicks.String())
clickEvent = fmt.Sprintf(`onclick="%s"`, clicks.String())
return fmt.Sprintf(`<div style="cursor:pointer" %s>%s</div>`, clickEvent, adMarkup)
}

return fmt.Sprintf(`<div style="cursor:pointer" %s>%s</div>`, clickEvent, adMarkup)
return adMarkup
}
6 changes: 3 additions & 3 deletions adapters/smaato/banner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ func TestExtractAdmBanner(t *testing.T) {
{
testName: "extract_banner_without_curls",
adMarkup: `<a rel="nofollow" href="https://prebid.net/click"><img src="https://prebid.net/images/image.png" alt="" width="480" height="320" /></a>`,
expectedAdMarkup: `<div style="cursor:pointer" ><a rel="nofollow" href="https://prebid.net/click"><img src="https://prebid.net/images/image.png" alt="" width="480" height="320" /></a></div>`,
expectedAdMarkup: `<a rel="nofollow" href="https://prebid.net/click"><img src="https://prebid.net/images/image.png" alt="" width="480" height="320" /></a>`,
curls: []string{},
},
{
testName: "extract_banner_with_nil_curls",
adMarkup: `<a rel="nofollow" href="https://prebid.net/click"><img src="https://prebid.net/images/image.png" alt="" width="480" height="320" /></a>`,
expectedAdMarkup: `<div style="cursor:pointer" ><a rel="nofollow" href="https://prebid.net/click"><img src="https://prebid.net/images/image.png" alt="" width="480" height="320" /></a></div>`,
expectedAdMarkup: `<a rel="nofollow" href="https://prebid.net/click"><img src="https://prebid.net/images/image.png" alt="" width="480" height="320" /></a>`,
curls: nil,
},
{
testName: "extract_banner_with_curls",
adMarkup: `<a rel="nofollow" href="https://prebid.net/click"><img src="https://prebid.net/images/image.png" alt="" width="480" height="320" /></a>`,
expectedAdMarkup: `<div style="cursor:pointer" onclick=fetch(decodeURIComponent('curls.net'.replace(/\+/g, ' ')), {cache: 'no-cache'});><a rel="nofollow" href="https://prebid.net/click"><img src="https://prebid.net/images/image.png" alt="" width="480" height="320" /></a></div>`,
expectedAdMarkup: `<div style="cursor:pointer" onclick="fetch(decodeURIComponent('curls.net'.replace(/\+/g, ' ')), {cache: 'no-cache'});"><a rel="nofollow" href="https://prebid.net/click"><img src="https://prebid.net/images/image.png" alt="" width="480" height="320" /></a></div>`,
curls: []string{"curls.net"},
},
}
Expand Down
18 changes: 15 additions & 3 deletions adapters/smaato/smaato.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/prebid/prebid-server/v2/util/timeutil"
)

const clientVersion = "prebid_server_1.0"
const clientVersion = "prebid_server_1.1"
Enigo marked this conversation as resolved.
Show resolved Hide resolved

type adMarkupType string

Expand Down Expand Up @@ -271,7 +271,7 @@ func getAdMarkupType(response *adapters.ResponseData) (adMarkupType, error) {
return admType, nil
} else {
return "", &errortypes.BadServerResponse{
Message: fmt.Sprintf("X-Smt-Adtype header is missing!"),
Message: fmt.Sprintf("X-Smt-Adtype header is missing."),
}
}
}
Expand Down Expand Up @@ -330,6 +330,7 @@ func prepareCommonRequest(request *openrtb2.BidRequest) error {
}

setApp(request)
setDOOH(request)

return setExt(request)
}
Expand Down Expand Up @@ -434,6 +435,13 @@ func setApp(request *openrtb2.BidRequest) {
}
}

func setDOOH(request *openrtb2.BidRequest) {
if request.DOOH != nil {
doohCopy := *request.DOOH
request.DOOH = &doohCopy
}
}

func setPublisherId(request *openrtb2.BidRequest, imp *openrtb2.Imp) error {
publisherID, err := jsonparser.GetString(imp.Ext, "bidder", "publisherId")
if err != nil {
Expand All @@ -448,8 +456,12 @@ func setPublisherId(request *openrtb2.BidRequest, imp *openrtb2.Imp) error {
// App is already a copy
request.App.Publisher = &openrtb2.Publisher{ID: publisherID}
return nil
} else if request.DOOH != nil {
// DOOH is already a copy
request.DOOH.Publisher = &openrtb2.Publisher{ID: publisherID}
return nil
} else {
return &errortypes.BadInput{Message: "Missing Site/App."}
return &errortypes.BadInput{Message: "Missing Site/App/DOOH."}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.0"
"client": "prebid_server_1.1"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down Expand Up @@ -350,7 +350,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.0"
"client": "prebid_server_1.1"
}
},
"impIDs":["postbid_iframe"]
Expand Down Expand Up @@ -421,7 +421,7 @@
"bids": [
{
"bid": {
"adm": "<div style=\"cursor:pointer\" ><a rel=\"nofollow\" href=\"https://prebid.net/click\"><img src=\"https://prebid.net/images/image.png\" alt=\"\" width=\"480\" height=\"320\" /></a></div>",
"adm": "<a rel=\"nofollow\" href=\"https://prebid.net/click\"><img src=\"https://prebid.net/images/image.png\" alt=\"\" width=\"480\" height=\"320\" /></a>",
"adomain": [
"smaato.com"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.0"
"client": "prebid_server_1.1"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down Expand Up @@ -270,7 +270,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.0"
"client": "prebid_server_1.1"
}
},
"impIDs":["postbid_iframe"]
Expand Down Expand Up @@ -317,7 +317,7 @@
"bids": [
{
"bid": {
"adm": "<div style=\"cursor:pointer\" ><a rel=\"nofollow\" href=\"https://prebid.net/click\"><img src=\"https://prebid.net/images/image.png\" alt=\"\" width=\"480\" height=\"320\" /></a></div>",
"adm": "<a rel=\"nofollow\" href=\"https://prebid.net/click\"><img src=\"https://prebid.net/images/image.png\" alt=\"\" width=\"480\" height=\"320\" /></a>",
"adomain": [
"smaato.com"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.0"
"client": "prebid_server_1.1"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down Expand Up @@ -327,7 +327,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.0"
"client": "prebid_server_1.1"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down Expand Up @@ -398,7 +398,7 @@
"bids": [
{
"bid": {
"adm": "<div style=\"cursor:pointer\" ><a rel=\"nofollow\" href=\"https://prebid.net/click\"><img src=\"https://prebid.net/images/image.png\" alt=\"\" width=\"480\" height=\"320\" /></a></div>",
"adm": "<a rel=\"nofollow\" href=\"https://prebid.net/click\"><img src=\"https://prebid.net/images/image.png\" alt=\"\" width=\"480\" height=\"320\" /></a>",
"adomain": [
"smaato.com"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.0"
"client": "prebid_server_1.1"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down Expand Up @@ -260,7 +260,7 @@
"keywords": "power tools"
},
"ext": {
"client": "prebid_server_1.0"
"client": "prebid_server_1.1"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down Expand Up @@ -307,7 +307,7 @@
"bids": [
{
"bid": {
"adm": "<div style=\"cursor:pointer\" ><a rel=\"nofollow\" href=\"https://prebid.net/click\"><img src=\"https://prebid.net/images/image.png\" alt=\"\" width=\"480\" height=\"320\" /></a></div>",
"adm": "<a rel=\"nofollow\" href=\"https://prebid.net/click\"><img src=\"https://prebid.net/images/image.png\" alt=\"\" width=\"480\" height=\"320\" /></a>",
"adomain": [
"smaato.com"
],
Expand Down
2 changes: 1 addition & 1 deletion adapters/smaato/smaatotest/exemplary/native.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
}
},
"ext": {
"client": "prebid_server_1.0"
"client": "prebid_server_1.1"
}
},
"impIDs":["postbid_iframe"]
Expand Down
4 changes: 2 additions & 2 deletions adapters/smaato/smaatotest/exemplary/simple-banner-app.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
"keywords": "keywords"
},
"ext": {
"client": "prebid_server_1.0"
"client": "prebid_server_1.1"
}
},
"impIDs":["1C86242D-9535-47D6-9576-7B1FE87F282C"]
Expand Down Expand Up @@ -205,7 +205,7 @@
"bids": [
{
"bid": {
"adm": "<div style=\"cursor:pointer\" ><a rel=\"nofollow\" href=\"https://prebid.net/click\"><img src=\"https://prebid.net/images/image.png\" alt=\"\" width=\"480\" height=\"320\" /></a></div>",
"adm": "<a rel=\"nofollow\" href=\"https://prebid.net/click\"><img src=\"https://prebid.net/images/image.png\" alt=\"\" width=\"480\" height=\"320\" /></a>",
"adomain": [
"smaato.com"
],
Expand Down
Loading
Loading