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: MadSense #4169

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

madsenseops
Copy link

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, c6dc0a9

madsense

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/madsense/madsense.go:21:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/madsense/madsense.go:28:	MakeRequests		89.5%
github.com/prebid/prebid-server/v3/adapters/madsense/madsense.go:61:	makeRequest		75.0%
github.com/prebid/prebid-server/v3/adapters/madsense/madsense.go:89:	getEndpointURL		100.0%
github.com/prebid/prebid-server/v3/adapters/madsense/madsense.go:95:	MakeBids		83.3%
github.com/prebid/prebid-server/v3/adapters/madsense/utils.go:13:	parseImpExt		75.0%
github.com/prebid/prebid-server/v3/adapters/madsense/utils.go:33:	getHeaders		88.2%
github.com/prebid/prebid-server/v3/adapters/madsense/utils.go:64:	getTypedBidFromBid	90.9%
github.com/prebid/prebid-server/v3/adapters/madsense/utils.go:87:	getMediaTypeForBid	75.0%
total:									(statements)		85.1%

@bsardo bsardo added the adapter label Jan 22, 2025
@bsardo bsardo self-assigned this Jan 22, 2025
@bsardo
Copy link
Collaborator

bsardo commented Jan 22, 2025

@pm-jaydeep-mohite can you please review?

@@ -0,0 +1,12 @@
endpoint: "https://ads.madsense.io/pbs"
Copy link
Contributor

Choose a reason for hiding this comment

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

Endpoint is reachable
curl -i --location --request POST https://ads.madsense.io/pbs
HTTP/2 200
content-length: 0

return openrtb_ext.BidTypeBanner, nil
case openrtb2.MarkupVideo:
return openrtb_ext.BidTypeVideo, nil
default:
Copy link
Contributor

Choose a reason for hiding this comment

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

UT can be added to cover default case

Copy link
Author

Choose a reason for hiding this comment

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

added UT for default case

bidErrors = append(bidErrors, err)
continue
}

Copy link
Contributor

@pm-jaydeep-mohite pm-jaydeep-mohite Jan 30, 2025

Choose a reason for hiding this comment

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

Nitpick: Remove blank line

Copy link
Author

Choose a reason for hiding this comment

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

removed

Comment on lines 4 to 10
"fmt"
"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/prebid-server/v3/adapters"
"github.com/prebid/prebid-server/v3/errortypes"
"github.com/prebid/prebid-server/v3/openrtb_ext"
"github.com/prebid/prebid-server/v3/util/jsonutil"
"net/http"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be re-ordered as

  `
     "fmt"
"net/http"

"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/prebid-server/v3/adapters"
"github.com/prebid/prebid-server/v3/errortypes"
"github.com/prebid/prebid-server/v3/openrtb_ext"
"github.com/prebid/prebid-server/v3/util/jsonutil"

  `

Copy link
Author

Choose a reason for hiding this comment

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

re-ordered

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 2db4f8f

madsense

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/madsense/madsense.go:21:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/madsense/madsense.go:28:	MakeRequests		89.5%
github.com/prebid/prebid-server/v3/adapters/madsense/madsense.go:61:	makeRequest		75.0%
github.com/prebid/prebid-server/v3/adapters/madsense/madsense.go:89:	getEndpointURL		100.0%
github.com/prebid/prebid-server/v3/adapters/madsense/madsense.go:95:	MakeBids		94.4%
github.com/prebid/prebid-server/v3/adapters/madsense/utils.go:14:	parseImpExt		75.0%
github.com/prebid/prebid-server/v3/adapters/madsense/utils.go:34:	getHeaders		88.2%
github.com/prebid/prebid-server/v3/adapters/madsense/utils.go:65:	getTypedBidFromBid	100.0%
github.com/prebid/prebid-server/v3/adapters/madsense/utils.go:88:	getMediaTypeForBid	100.0%
total:									(statements)		89.4%

@madsenseops
Copy link
Author

@pm-jaydeep-mohite I addressed all comments, could you please review again?

Comment on lines 7 to 10
"company_id": {
"type": "string",
"description": "An id used to identify madSense company"
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just checking, how do you want to treat an empty string? If you require at least one character you should add a minLength property.

Copy link
Author

Choose a reason for hiding this comment

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

added minLength property

Comment on lines 41 to 55
var validParams = []string{
`{"company_id": "9876543"}`,
}

var invalidParams = []string{
``,
`null`,
`true`,
`5`,
`4.2`,
`[]`,
`{}`,
`{"companyId": "987654a"}`,
`{"companyId": "98765432"}`,
}
Copy link
Collaborator

@bsardo bsardo Feb 3, 2025

Choose a reason for hiding this comment

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

Please add a test for the company_id empty string case.

Copy link
Author

Choose a reason for hiding this comment

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

added

@@ -0,0 +1,12 @@
endpoint: "https://ads.madsense.io/pbs"
maintainer:
email: "[email protected]"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sent an email to this address. Please respond to the email with a "received" message.

Copy link
Author

Choose a reason for hiding this comment

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

sent


func TestJsonSamples(t *testing.T) {
bidder, buildErr := Builder(openrtb_ext.BidderMadSense, config.Adapter{
Endpoint: "https://ads.madsense.io/pbs"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: we recommend using test urls for maintenance reasons.

Copy link
Author

Choose a reason for hiding this comment

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

updated test urls


func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) (requests []*adapters.RequestData, errors []error) {
reqs := make([]*adapters.RequestData, 0, len(request.Imp))
var errs []error
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's an issue here because you're mixing named returns with local variable declarations. I suggest deleting the named returns requests and errors and always using the local variables reqs and errs.

Copy link
Author

Choose a reason for hiding this comment

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

agreed, I switched to only using local variables

}

if len(request.Device.IPv6) > 0 {
headers.Add("X-Forwarded-For", request.Device.IPv6)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add test coverage for this line.

Copy link
Author

Choose a reason for hiding this comment

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

added

headers.Add("Origin", request.Site.Domain)
}
if request.Site.Ref != "" {
headers.Set("Referer", request.Site.Ref)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add test coverage for this line.

Copy link
Author

Choose a reason for hiding this comment

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

added

Comment on lines +106 to +108
return nil, []error{&errortypes.BadServerResponse{
Message: "Bad Server Response",
}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add a supplemental test case where the response.Body unmarshal fails.

Copy link
Author

Choose a reason for hiding this comment

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

tested in new supplemental test bad-response-error

}

if request.Test == 1 {
ext.CompanyId = "test"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add test coverage for this line.

Copy link
Author

Choose a reason for hiding this comment

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

tested in new supplemental test test-response

Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider renaming this to bad-response-status-400.json.

Copy link
Author

Choose a reason for hiding this comment

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

renamed

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, c1696fb

madsense

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/madsense/madsense.go:21:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/madsense/madsense.go:28:	MakeRequests		89.5%
github.com/prebid/prebid-server/v3/adapters/madsense/madsense.go:61:	makeRequest		83.3%
github.com/prebid/prebid-server/v3/adapters/madsense/madsense.go:89:	getEndpointURL		100.0%
github.com/prebid/prebid-server/v3/adapters/madsense/madsense.go:95:	MakeBids		100.0%
github.com/prebid/prebid-server/v3/adapters/madsense/utils.go:14:	parseImpExt		75.0%
github.com/prebid/prebid-server/v3/adapters/madsense/utils.go:34:	getHeaders		100.0%
github.com/prebid/prebid-server/v3/adapters/madsense/utils.go:65:	getTypedBidFromBid	100.0%
github.com/prebid/prebid-server/v3/adapters/madsense/utils.go:88:	getMediaTypeForBid	100.0%
total:									(statements)		93.6%

}

request.Imp = imps
body, err := json.Marshal(request)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use jsonutil for marshaling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants