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

33Across: Enable Support for SRA requests #2079

Merged
merged 34 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cfb4cea
add video support
curlyblueeagle Oct 28, 2020
b37978e
renamed folder for tests per code review from Prebid
curlyblueeagle Nov 4, 2020
e248833
updated path to renamed test folder
curlyblueeagle Nov 4, 2020
820fb30
Added more unit tests
curlyblueeagle Nov 6, 2020
193c42f
Merge pull request #1 from 33Across/add_test_coverage
curlyblueeagle Nov 6, 2020
67e04cd
Added a newline between structs
curlyblueeagle Nov 9, 2020
8725d45
breaking up multi-imps
curlyblueeagle Dec 1, 2020
88dfe5e
Added tests for multi-imp
curlyblueeagle Dec 2, 2020
a29a0f7
Adding caller info
curlyblueeagle Dec 2, 2020
0b02576
We do not support app
curlyblueeagle Dec 3, 2020
662c02d
fixed typo in debug messages
curlyblueeagle Dec 3, 2020
9a6a4e0
removed confusing comment
curlyblueeagle Dec 3, 2020
a14bb1b
removed outdated comments
curlyblueeagle Dec 3, 2020
8f35484
Merge pull request #2 from 33Across/handle_multi-imp_requests
curlyblueeagle Dec 3, 2020
5f20987
Merge branch 'master' of https://github.com/prebid/prebid-server
curlyblueeagle Dec 3, 2020
7ac08dd
Code review feedback
curlyblueeagle Dec 8, 2020
79bf68b
Refactored creating request ext
curlyblueeagle Dec 14, 2020
29f98fd
More optimizations based on code review
curlyblueeagle Dec 16, 2020
3827313
Fixed comments
curlyblueeagle Dec 16, 2020
171a13d
made better comments
curlyblueeagle Dec 16, 2020
bc77e9a
fixed endpoint to s2s
curlyblueeagle Mar 5, 2021
a0dd8b5
Merge pull request #3 from 33Across/s2s_endpoint_fix
curlyblueeagle Mar 5, 2021
11103a3
Merge branch 'master' of https://github.com/prebid/prebid-server
curlyblueeagle Mar 5, 2021
242c792
Merge branch 'master' of https://github.com/33Across/prebid-server
curlyblueeagle Mar 5, 2021
3a9fd07
Merge branch 'master' of https://github.com/prebid/prebid-server
curlyblueeagle Sep 10, 2021
8f002cb
SRA in make requests
curlyblueeagle Sep 13, 2021
64e3946
fixed tests to include SRA support
curlyblueeagle Sep 14, 2021
a9dafaf
added more test cases for grouping imps
curlyblueeagle Sep 14, 2021
eaa6479
update user sync url
curlyblueeagle Sep 14, 2021
41acf9b
testing groups by prod as well
curlyblueeagle Sep 21, 2021
323aa33
Merge branch 'master' of github.com:prebid/prebid-server
curlyblueeagle Nov 8, 2021
1df8693
Merge branch 'master' into XCH-2399_support_sra
curlyblueeagle Nov 8, 2021
4123121
Merge pull request #4 from 33Across/XCH-2399_support_sra
curlyblueeagle Nov 8, 2021
2437cb1
removed test that triggers flaky behavior in framework
curlyblueeagle Nov 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"containerEnv": {
"GOPRIVATE": "${localEnv:GOPRIVATE}",
"PBS_GDPR_DEFAULT_VALUE": "0"
},
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

Expand Down
51 changes: 32 additions & 19 deletions adapters/33across/33across.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type bidTtxExt struct {
func (a *TtxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
var errs []error
var adapterRequests []*adapters.RequestData
var groupedImps = make(map[string][]openrtb2.Imp)

// Construct request extension common to all imps
// NOTE: not blocking adapter requests on errors
Expand All @@ -64,27 +65,39 @@ func (a *TtxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapter
}
request.Ext = reqExt

// Break up multi-imp request into multiple external requests since we don't
// support SRA in our exchange server
// We only support SRA for requests containing same prod and
// zoneID, therefore group all imps accordingly and create a http
// request for each such group
for i := 0; i < len(request.Imp); i++ {
if adapterReq, err := a.makeRequest(*request, request.Imp[i]); err == nil {
adapterRequests = append(adapterRequests, adapterReq)
if impCopy, err := makeImps(request.Imp[i]); err == nil {
var impExt Ext

// Skip over imps whose extensions cannot be read since
// we cannot glean Prod or ZoneID which are required to
// group together. However let's not block request creation.
if err := json.Unmarshal(impCopy.Ext, &impExt); err == nil {
impKey := impExt.Ttx.Prod + impExt.Ttx.Zoneid
groupedImps[impKey] = append(groupedImps[impKey], impCopy)
} else {
errs = append(errs, err)
}
} else {
errs = append(errs, err)
}
}

for _, impList := range groupedImps {
if adapterReq, err := a.makeRequest(*request, impList); err == nil {
adapterRequests = append(adapterRequests, adapterReq)
} else {
errs = append(errs, err)
}
}
return adapterRequests, errs
}

func (a *TtxAdapter) makeRequest(request openrtb2.BidRequest, imp openrtb2.Imp) (*adapters.RequestData, error) {
impCopy, err := makeImps(imp)

if err != nil {
return nil, err
}

request.Imp = []openrtb2.Imp{*impCopy}
func (a *TtxAdapter) makeRequest(request openrtb2.BidRequest, impList []openrtb2.Imp) (*adapters.RequestData, error) {
request.Imp = impList

// Last Step
reqJSON, err := json.Marshal(request)
Expand All @@ -103,23 +116,23 @@ func (a *TtxAdapter) makeRequest(request openrtb2.BidRequest, imp openrtb2.Imp)
}, nil
}

func makeImps(imp openrtb2.Imp) (*openrtb2.Imp, error) {
func makeImps(imp openrtb2.Imp) (openrtb2.Imp, error) {
if imp.Banner == nil && imp.Video == nil {
return nil, &errortypes.BadInput{
return openrtb2.Imp{}, &errortypes.BadInput{
Message: fmt.Sprintf("Imp ID %s must have at least one of [Banner, Video] defined", imp.ID),
}
}

var bidderExt adapters.ExtImpBidder
if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {
return nil, &errortypes.BadInput{
return openrtb2.Imp{}, &errortypes.BadInput{
Message: err.Error(),
}
}

var ttxExt openrtb_ext.ExtImp33across
if err := json.Unmarshal(bidderExt.Bidder, &ttxExt); err != nil {
return nil, &errortypes.BadInput{
return openrtb2.Imp{}, &errortypes.BadInput{
Message: err.Error(),
}
}
Expand All @@ -135,7 +148,7 @@ func makeImps(imp openrtb2.Imp) (*openrtb2.Imp, error) {

impExtJSON, err := json.Marshal(impExt)
if err != nil {
return nil, &errortypes.BadInput{
return openrtb2.Imp{}, &errortypes.BadInput{
Message: err.Error(),
}
}
Expand All @@ -149,13 +162,13 @@ func makeImps(imp openrtb2.Imp) (*openrtb2.Imp, error) {
imp.Video = videoCopy

if err != nil {
return nil, &errortypes.BadInput{
return openrtb2.Imp{}, &errortypes.BadInput{
Message: err.Error(),
}
}
}

return &imp, nil
return imp, nil
}

func makeReqExt(request *openrtb2.BidRequest) ([]byte, error) {
Expand Down
200 changes: 0 additions & 200 deletions adapters/33across/33acrosstest/exemplary/multi-imp-banner.json

This file was deleted.

2 changes: 1 addition & 1 deletion static/bidder-info/33across.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ capabilities:
- video
userSync:
iframe:
url: "https://ic.tynt.com/r/d?m=xch&rt=html&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&ru={{.RedirectURL}}&id=zzz000000000002zzz"
url: "https://ssc-cms.33across.com/ps/?m=xch&rt=html&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&ru={{.RedirectURL}}&id=zzz000000000002zzz"
userMacro: "33XUSERID33X"