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

New Adapter: Compass #2102

Merged
merged 6 commits into from
Dec 20, 2021
Merged

New Adapter: Compass #2102

merged 6 commits into from
Dec 20, 2021

Conversation

CompassSSP
Copy link
Contributor

@SyntaxNode SyntaxNode changed the title Compass Adapter: add new adapter New Adapter: Compass Dec 3, 2021
@mansinahar mansinahar requested review from AlexBVolcy and removed request for VeronikaSolovei9 December 6, 2021 18:22
static/bidder-info/compass.yaml Show resolved Hide resolved
adapters/compass/compass.go Show resolved Hide resolved
adapters/compass/compass.go Outdated Show resolved Hide resolved
adapters/compass/compass.go Outdated Show resolved Hide resolved
@CompassSSP
Copy link
Contributor Author

@guscarreon thanks for the comments, everything has been corrected

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.

@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.


finalyImpExt := reqCopy.Imp[0].Ext
if compassExt.PlacementID != "" {
finalyImpExt, err = json.Marshal(map[string]interface{}{
Copy link
Contributor

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 structs 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

return nil, append(errs, err)
}

finalyImpExt := reqCopy.Imp[0].Ext
Copy link
Contributor

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

@CompassSSP
Copy link
Contributor Author

@guscarreon Thanks! We have fixed

guscarreon
guscarreon previously approved these changes Dec 9, 2021
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.

Looks good to me. @CompassSSP thanks for addressing my feedback

static/bidder-info/compass.yaml Show resolved Hide resolved
adapters/compass/compass.go Show resolved Hide resolved
adapters/compass/compass.go Outdated Show resolved Hide resolved
adapters/compass/compass.go Outdated Show resolved Hide resolved
adapters/compass/compass.go Outdated Show resolved Hide resolved
adapters/compass/compass.go Show resolved Hide resolved
@CompassSSP
Copy link
Contributor Author

@SyntaxNode thanks for the review. I fixed some issues and included 883 in the config file

Copy link
Contributor

@SyntaxNode SyntaxNode left a 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.

}

func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
var errs []error
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, refactored

AlexBVolcy
AlexBVolcy previously approved these changes Dec 15, 2021
Copy link
Contributor

@AlexBVolcy AlexBVolcy left a 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!

@mansinahar mansinahar merged commit d4d25d1 into prebid:master Dec 20, 2021
wwwyyy pushed a commit to wwwyyy/prebid-server that referenced this pull request Jan 18, 2022
* '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)
jorgeluisrocha pushed a commit to jwplayer/prebid-server that referenced this pull request Sep 28, 2022
shunj-nb pushed a commit to ParticleMedia/prebid-server that referenced this pull request Nov 8, 2022
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.

6 participants