-
Notifications
You must be signed in to change notification settings - Fork 741
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
New Adapter: Compass #2102
New Adapter: Compass #2102
Conversation
@guscarreon thanks for the comments, everything has been corrected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CompassSSP thank you for adressing my feedback. Your code looks good to me and in this second pass I only let a couple of nitpicks. If you decide to leave them as is, I won't complain. Let me know your decision.
adapters/compass/compass.go
Outdated
|
||
finalyImpExt := reqCopy.Imp[0].Ext | ||
if compassExt.PlacementID != "" { | ||
finalyImpExt, err = json.Marshal(map[string]interface{}{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CompassSSP thank you for addressing my feedback. This nitpick is purely aesthetic: the omitempty
keyword could prove useful in avoiding the in-line declaration of the marshaled fields inside the two branches of the if/else
statement. The struct
s that follow:
type reqBodyExt struct {
CompassBidderExt reqBodyExtBidder `json:"bidder"`
}
type reqBodyExtBidder struct {
Type string `json:"type"`
PlacementID string `json:"placementId,omitempty"`
EndpointID string `json:"endpointId,omitempty"`
}
would not include either PlacementID
or EndpointID
in the resulting JSON object if not defined. Therefore, we could simplify to only have one json.Marshal()
call:
44
45 finalyImpExt := reqCopy.Imp[0].Ext
+ temp := reqBodyExt{CompassBidderExt: reqBodyExtBidder{}}
46 if compassExt.PlacementID != "" {
47 - finalyImpExt, err = json.Marshal(map[string]interface{}{
48 - "bidder": map[string]string{
49 - "placementId": compassExt.PlacementID,
50 - "type": "publisher",
51 - },
52 - })
53 - if err != nil {
54 - return nil, append(errs, err)
55 - }
+ temp.CompassBidderExt.PlacementID = compassExt.PlacementID
+ temp.CompassBidderExt.Type = "publisher"
56 } else if compassExt.EndpointID != "" {
57 - finalyImpExt, err = json.Marshal(map[string]interface{}{
58 - "bidder": map[string]string{
59 - "endpointId": compassExt.EndpointID,
60 - "type": "network",
61 - },
62 - })
63 - if err != nil {
64 - return nil, append(errs, err)
65 - }
+ temp.CompassBidderExt.EndpointID = compassExt.EndpointID
+ temp.CompassBidderExt.Type = "network"
66 }
+
+ finalyImpExt, err = json.Marshal(temp)
+ if err != nil {
+ return nil, append(errs, err)
+ }
67
68 reqCopy.Imp[0].Ext = finalyImpExt
69
adapters/compass/compass.go
adapters/compass/compass.go
Outdated
return nil, append(errs, err) | ||
} | ||
|
||
finalyImpExt := reqCopy.Imp[0].Ext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the finalyImpExt
variable is going to get overwritten anyways, a small optimization is to avoid copying reqCopy.Imp[0].Ext
in the first place.
45 finalyImpExt := reqCopy.Imp[0].Ext
+ var finalyImpExt json.RawMessage
adapters/compass/compass.go
@guscarreon Thanks! We have fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. @CompassSSP thanks for addressing my feedback
@SyntaxNode thanks for the review. I fixed some issues and included 883 in the config file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for quickly addressing the feedback. The last commit you pushed opened up a small refactor which I've commented on. Otherwise looks good and I'm glad to see good test coverage using the json test framework.
adapters/compass/compass.go
Outdated
} | ||
|
||
func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { | ||
var errs []error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: This is no longer required with the last fix refactor you pushed. You can replace all return nil, append(errs, err)
statements with return nil, []error{err}
like you do in MakeBids
. The last return of this method will become return adapterRequests, nil
which is a bit more straightforward IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, refactored
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you to responding to all the feedback, I'll approve, but there's one nitpick left that Scott commented on that I think should be fixed before merge!
* 'master' of https://github.com/wwwyyy/prebid-server: GDPR: pass geo based on special feature 1 opt-in (prebid#2122) Adyoulike: Fix adapter errors if no content (prebid#2134) Update adyoulike.yaml (prebid#2131) Add ORTB 2.4 schain support (prebid#2108) Stored response fetcher (with new func for stored resp) (prebid#2099) Adot: Add OpenRTB macros resolution (prebid#2118) Rubicon adapter: accept accountId, siteId, zoneId as strings (prebid#2110) Operaads: support multiformat request (prebid#2121) Update go-gdpr to v1.11.0 (prebid#2125) Adgeneration: Update request to include device and app related info in headers and query params (prebid#2109) Adnuntius: Read device information from ortb Request (prebid#2112) New Adapter: apacdex and Remove Adapter: valueimpression (prebid#2097) New Adapter: Compass (prebid#2102) Orbidder: bidfloor currency handling (prebid#2093)
doc - prebid/prebid.github.io#3441