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

engagebdr adapter #966

Merged
merged 13 commits into from
Sep 11, 2019
Merged

Conversation

yannaingkyaw1986
Copy link
Contributor

No description provided.

Copy link
Contributor

@guscarreon guscarreon left a comment

Choose a reason for hiding this comment

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

Can you please address the issues with the Travis build?

@yannaingkyaw1986
Copy link
Contributor Author

yannaingkyaw1986 commented Jul 17, 2019 via email

@mansinahar mansinahar self-assigned this Jul 19, 2019
"encoding/json"
"github.com/prebid/prebid-server/openrtb_ext"
"net/http"
//"regexp"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please remove this?

adapters/engagebdr/usersync_test.go Show resolved Hide resolved
config/config.go Outdated
@@ -613,6 +613,7 @@ func SetupViper(v *viper.Viper, filename string) {
v.SetDefault("adapters.mgid.endpoint", "https://prebid.mgid.com/prebid/")
v.SetDefault("adapters.visx.endpoint", "https://t.visx.net/s2s_bid?wrapperType=s2s_prebid_standard")
v.SetDefault("adapters.tappx.endpoint", "https://{{.Host}}")
v.SetDefault("adapters.engagebdr.endpoint", "http://dsp.bnmla.com/hb")
Copy link
Contributor

Choose a reason for hiding this comment

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

You should also set a default usersync endpoint in the setDerivedDefaults function on L419

}
sspidImps[impExt.Sspid] = append(sspidImps[impExt.Sspid], imp)
}

Copy link
Contributor

@mansinahar mansinahar Jul 19, 2019

Choose a reason for hiding this comment

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

Just a suggestion: Since you're adapter only supports banner and video ads, might be a good idea to add a check somewhere here in this function to discard imps of any other type. I am sure this must be something that you'd be already handling on your end but it's always better to check and fail early.

@mansinahar
Copy link
Contributor

@yannaingkyaw1986 pinging to see if you have had the chance to address the above comments

@yannaingkyaw1986
Copy link
Contributor Author

yannaingkyaw1986 commented Jul 24, 2019 via email

@mansinahar
Copy link
Contributor

Cool. Thank you @yannaingkyaw1986!

// EngageBDR uses different sspid parameters for banner and video.
sspidImps := make(map[string][]openrtb.Imp)
for _, imp := range request.Imp {
if imp.Native != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this if condition be probably changed to if imp.Native != nil && imp.Site == nil && imp.App == nil in case of possible multiformat requests?

@mansinahar
Copy link
Contributor

LGTM other than the minor comment mentioned above

@@ -6,7 +6,7 @@ import (
"strings"

"github.com/prebid/prebid-server/adapters"
ttx "github.com/prebid/prebid-server/adapters/33across"
"github.com/prebid/prebid-server/adapters/33across"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to keep the ttx part or you will break the line below that access the adapter by this alias

@@ -5,7 +5,7 @@ import (
"text/template"

"github.com/golang/glog"
ttx "github.com/prebid/prebid-server/adapters/33across"
Copy link
Collaborator

Choose a reason for hiding this comment

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

again please don't blindly remove these aliases.

hhhjort
hhhjort previously approved these changes Aug 1, 2019
guscarreon
guscarreon previously approved these changes Aug 6, 2019
Copy link
Contributor

@guscarreon guscarreon left a comment

Choose a reason for hiding this comment

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

Reviewed the source code and left a few comments. Also, we probably should include more test cases in the adapters/engagebdr/engagebdrtest/exemplary/, adapters/engagebdr/engagebdrtest/supplemental/, and adapters/engagebdr/engagebdrtest/params/race/ directories to make percent of code coverage.

╰─➤  go test -coverprofile=c.out
PASS
coverage: 64.3% of statements
╰─➤  go tool cover -func=c.out
github.com/prebid/prebid-server/adapters/engagebdr/engagebdr.go:20:     MakeRequests            75.0%
github.com/prebid/prebid-server/adapters/engagebdr/engagebdr.go:85:     MakeBids                64.3%
github.com/prebid/prebid-server/adapters/engagebdr/engagebdr.go:120:    getMediaTypeForImp      0.0%
github.com/prebid/prebid-server/adapters/engagebdr/engagebdr.go:133:    NewEngageBDRBidder      100.0%
github.com/prebid/prebid-server/adapters/engagebdr/usersync.go:9:       NewEngageBDRSyncer      100.0%
total:                                                                  (statements)            64.3%

if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {
errors = append(errors, &errortypes.BadInput{
Message: fmt.Sprintf("Ignoring imp id=%s, error while decoding extImpBidder, err: %s", imp.ID, err),
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Would a continue statement make sense after this line? If we have an error for some reason, I believe the following if statement found in line 39 will most likely also print an error (if not an NULL pointer de-reference in line 38) and we'll end up with a stack of errors that have one common source.

Breakpoint 1 set at 0x1626558 for github.com/prebid/prebid-server/adapters/engagebdr.(*EngageBDRAdapter).MakeRequests() ./engagebdr.go:32
(dlv) c
> github.com/prebid/prebid-server/adapters/engagebdr.(*EngageBDRAdapter).MakeRequests() ./engagebdr.go:32 (hits goroutine(21):1 total:1) (PC: 0x1626558)
    27:                 if imp.Native != nil {
    28:                         // filter native imps from bid request
    29:                         continue
    30:                 }
    31:                 var bidderExt adapters.ExtImpBidder
=>  32:                 if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {
    33:                         errors = append(errors, &errortypes.BadInput{
    34:                                 Message: fmt.Sprintf("Ignoring imp id=%s, error while decoding extImpBidder, err: %s", imp.ID, err),
    35:                         })
    36:                 }
    37:                 impExt := openrtb_ext.ExtImpEngageBDR{}
    38:					err := json.Unmarshal(bidderExt.Bidder, &impExt)
    39:					if err != nil {
(dlv) p bidderExt.Bidder
encoding/json.RawMessage len: 0, cap: 0, nil

if err != nil {
errors = append(errors, &errortypes.BadInput{
Message: fmt.Sprintf("Ignoring imp id=%s, error while decoding impExt, err: %s", imp.ID, err),
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as line 35 above. Seems like a continue statement would be useful because we'll de-reference impExt in line 44 and there's a possibility that the Unmarshal didn't go well by then.

if impExt.Sspid == "" {
errors = append(errors, &errortypes.BadInput{
Message: fmt.Sprintf("Ignoring imp id=%s, no sspid present", imp.ID),
})
Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't put a continue statement here, we'd be mapping an empty impExt.Sspid value into sspidImps

}

if len(adapterRequests) == 0 {
errors = append(errors, &errortypes.BadInput{Message: fmt.Sprintf("No imps present")})
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this error message a little bit misleading? There's a possibility that Imp objects were actually present in the request.Imp array but all of them were invalid

mediaType := openrtb_ext.BidTypeBanner
for _, imp := range imps {
if imp.ID == impId {
if imp.Banner == nil && imp.Video != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

The Imp object also has an Audio and Native fields which are the other two data types supported by prebid-server but this particular adapter, according to static/bidder-info/engagebdr.yaml
does not support them. Therefore, the following scenarios might set the mediaType to openrtb_ext.BidTypeBanner. Is the behavior we want? Maybe we want to modify the if statement

Imp[i].Banner | Imp[i].Video | Imp[i].Audio | Imp[i].Native  |  mediaType 
--------------|--------------|--------------|----------------|-------------
    nil       |     nil      |    not nil   |     nil        |openrtb_ext.BidTypeBanner
    nil       |     nil      |      nil     |     nil        |openrtb_ext.BidTypeBanner

@guscarreon guscarreon dismissed their stale review August 6, 2019 02:26

Meant to request changes, not approve. M bad

Copy link
Contributor

@guscarreon guscarreon left a comment

Choose a reason for hiding this comment

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

Sorry, meant to request changes. All the requests are listed in the comments above.

Copy link
Contributor

@mansinahar mansinahar left a comment

Choose a reason for hiding this comment

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

I'd suggest adding some additional tests with multiple imps and adding an example too, if possible.

adapters/engagebdr/engagebdr.go Outdated Show resolved Hide resolved
adapters/engagebdr/engagebdr.go Outdated Show resolved Hide resolved
adapters/engagebdr/params_test.go Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
static/bidder-info/engagebdr.yaml Show resolved Hide resolved
@mansinahar
Copy link
Contributor

@yannaingkyaw1986 LGTM in general but there are couple minor comments from the last review that are still unaddressed. If you can please address them when you have a chance, we can get this merged.

@stale
Copy link

stale bot commented Sep 2, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added stale and removed stale labels Sep 2, 2019
Copy link
Contributor

@guscarreon guscarreon left a comment

Choose a reason for hiding this comment

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

LGTM

@mansinahar mansinahar merged commit 692d6de into prebid:master Sep 11, 2019
mansinahar pushed a commit to mansinahar/prebid-server that referenced this pull request Nov 1, 2019
katsuo5 pushed a commit to flux-dev-team/prebid-server-1 that referenced this pull request Dec 1, 2020
katsuo5 pushed a commit to flux-dev-team/prebid-server-1 that referenced this pull request Dec 2, 2020
katsuo5 pushed a commit to flux-dev-team/prebid-server-1 that referenced this pull request Dec 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants