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

OMS: Video support #4172

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

Conversation

denis-s-oms
Copy link

No description provided.

oms: changed required parameters
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, a858a3f

oms

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/oms/oms.go:32:	Builder		100.0%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:39:	MakeRequests	85.7%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:69:	MakeBids	94.7%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:112:	getBidType	100.0%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:121:	getBidVideo	100.0%
total:								(statements)	93.2%

@denis-s-oms
Copy link
Author

Related docs PR: prebid/prebid.github.io#5830

@bsardo bsardo changed the title OMS Adapter: Video support OMS: Video support Jan 24, 2025
@@ -53,4 +56,5 @@ var invalidParams = []string{
`[]`,
`{}`,
`{"pid": "0"}`,
`{"publisherId": 9999}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: add test covering wrong type as well, publisherId as string

Copy link
Author

Choose a reason for hiding this comment

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

Done.

var publisherID string
if len(request.Imp[0].Ext) > 0 {
ext := pbsExt{}
err = json.Unmarshal(request.Imp[0].Ext, &ext)
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: please use jsonutil - so the choice of fastest json implementation can be central

Suggested change
err = json.Unmarshal(request.Imp[0].Ext, &ext)
err = jsonutil.Unmarshal(request.Imp[0].Ext, &ext)

Copy link
Author

Choose a reason for hiding this comment

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

Done.

requestData := &adapters.RequestData{
Method: "POST",
Uri: a.endpoint,
Uri: a.endpoint + fmt.Sprintf("?publisherId=%v", publisherID),
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: if you're already using sprintf, can you just include a.endpoint as an argument and %s where it goes?

Suggested change
Uri: a.endpoint + fmt.Sprintf("?publisherId=%v", publisherID),
Uri: fmt.Sprintf("%s?publisherId=%v", a.endpoint, publisherID),

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@@ -72,12 +96,40 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R
}
for _, seatBid := range response.SeatBid {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion/question: I'm curious about the type of SeatBid if it's an []SomeStruct then this should also use an index - otherwise, seatBid will do a struct copy (shallow) for each loop iteration.

If the type supports it, consider something like this

Suggested change
for _, seatBid := range response.SeatBid {
for sbIndex := range response.SeatBid {
seatBid := &response.SeatBid[sbIndex]

Copy link
Author

Choose a reason for hiding this comment

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

These lines are unchanged.

bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{
Bid: &seatBid.Bid[i],
BidType: openrtb_ext.BidTypeBanner,
Bid: &seatBid.Bid[i],
Copy link
Contributor

Choose a reason for hiding this comment

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

observation/curiosity: hmm… so this is a pointer to the copy - see previous comment, is that intended? If you move to seatBid to a pointer, it'll point to that same instance's bid - that's efficient - any worries about contention here? you're not making changes here, I think it's ok

Copy link
Author

Choose a reason for hiding this comment

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

Yes, these lines are unchanged.

})
}
}

return bidResponse, nil
}

func getBidType(markupType openrtb2.MarkupType) openrtb_ext.BidType {
Copy link
Contributor

Choose a reason for hiding this comment

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

observation: hmm… this seems like it could be general… is there some central place that can do this mapping?

Copy link
Author

Choose a reason for hiding this comment

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

What you mean by central place?

Copy link
Author

Choose a reason for hiding this comment

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

After checking other adapters I made a conclusion that it depends on how any of them want to process bid types (some of them return error if mapping isn't succeeded, some of them return default value). In our case we want to support backward compatibility that's why banner type is returned as default value.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@scr-oath are you asking if there is a helper function offered that can be used by any adapter? There isn't. We might be able to offer that at some point but we should keep in mind that not all adapters support the same media types and the default case will vary. Also some adapters will fall back to deriving the media type from the request imp if mtype is not in the response.

Copy link

github-actions bot commented Feb 2, 2025

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, 40801cc

oms

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/oms/oms.go:32:	Builder		100.0%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:39:	MakeRequests	85.7%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:69:	MakeBids	94.7%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:113:	getBidType	100.0%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:122:	getBidVideo	100.0%
total:								(statements)	93.2%

requestData := &adapters.RequestData{
Method: "POST",
Uri: a.endpoint,
Uri: fmt.Sprintf("%s?publisherId=%v", a.endpoint, publisherID),
Copy link
Contributor

Choose a reason for hiding this comment

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

question: why do you need Itoa? Could you just use %d to format the number into the query param?

Copy link
Author

Choose a reason for hiding this comment

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

Done

Copy link

github-actions bot commented Feb 9, 2025

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, 85ec4eb

oms

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/oms/oms.go:31:	Builder		100.0%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:38:	MakeRequests	85.7%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:68:	MakeBids	94.7%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:112:	getBidType	100.0%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:121:	getBidVideo	100.0%
total:								(statements)	93.2%

@bsardo bsardo self-assigned this Feb 11, 2025
@@ -42,6 +42,9 @@ func TestInvalidParams(t *testing.T) {
var validParams = []string{
`{"pid": "12345"}`,
`{"pid": "123456"}`,
`{"publisherId": 12345}`,
`{"publisherId": 123456}`,
`{"publisherId": 12345,"pid": "12345"}`,
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 valid boundary test for publisherId:
{"publisherId": 10000}

Copy link
Author

Choose a reason for hiding this comment

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

Done

})
}
}

return bidResponse, nil
}

func getBidType(markupType openrtb2.MarkupType) openrtb_ext.BidType {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@scr-oath are you asking if there is a helper function offered that can be used by any adapter? There isn't. We might be able to offer that at some point but we should keep in mind that not all adapters support the same media types and the default case will vary. Also some adapters will fall back to deriving the media type from the request imp if mtype is not in the response.

ext := pbsExt{}
err = jsonutil.Unmarshal(request.Imp[0].Ext, &ext)
if err != nil {
return nil, []error{err}
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 unmarshal fails. You can do this by simply setting your imp.ext to a type other than object.

Copy link
Author

Choose a reason for hiding this comment

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

Done

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, 9b589fe

oms

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/oms/oms.go:31:	Builder		100.0%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:38:	MakeRequests	92.9%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:68:	MakeBids	94.7%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:112:	getBidType	100.0%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:121:	getBidVideo	100.0%
total:								(statements)	95.5%

Comment on lines 16 to 25
type pbsExt struct {
Bidder genericPID `json:"bidder"`
Tid string `json:"tid"`
}

type genericPID struct {
Pid string `json:"pid"`
PublisherID int `json:"publisherId"`
}

Copy link
Contributor

Choose a reason for hiding this comment

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

These new types are not needed here.
You will need to add new field to ExtImpOms, it already exists in the openrtb_ext directory:

type ExtImpOms struct {
	Pid         string `json:"pid"`
	PublisherID int    `json:"publisherId"`
}

And then in MakeRequests follow a general approach to Unmarshal imp.ext:
example

Copy link
Author

Choose a reason for hiding this comment

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

Done

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, 7ae703f

oms

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/oms/oms.go:21:	Builder		100.0%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:28:	MakeRequests	87.5%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:62:	MakeBids	94.7%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:106:	getBidType	100.0%
github.com/prebid/prebid-server/v3/adapters/oms/oms.go:115:	getBidVideo	100.0%
total:								(statements)	93.5%

Copy link
Contributor

@VeronikaSolovei9 VeronikaSolovei9 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

5 participants