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: Ogury #4082

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

New Adapter: Ogury #4082

wants to merge 12 commits into from

Conversation

krdzo
Copy link

@krdzo krdzo commented Nov 28, 2024

PR for the documentation prebid/prebid.github.io#5742

adapters/ogury/ogury.go Outdated Show resolved Hide resolved
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, cfc66d0

ogury

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:21:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:28:	MakeRequests		75.7%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:119:	filterValidImps		92.9%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:149:	getAdUnitCode		87.5%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:164:	setHeaders		57.1%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:176:	getMediaTypeForBid	57.1%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:196:	MakeBids		70.0%
total:								(statements)		75.8%

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

ogury

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:21:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:26:	MakeRequests		75.7%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:117:	filterValidImps		92.9%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:147:	getAdUnitCode		87.5%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:162:	setHeaders		57.1%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:174:	getMediaTypeForBid	57.1%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:194:	MakeBids		70.0%
total:								(statements)		75.5%

@krdzo
Copy link
Author

krdzo commented Dec 3, 2024

Hello I have a question with this PR.
We are using adUnitCode in our backend and I wanted to read it from imp[].Ext.Prebid.AdUnitCode but I see that this field is not forwarded to bidders (also opened this issue #4077 to see if this is a bug or intended behaviour), so we using imp.Id as a fallback for adunitcode.
Is this a right assumption, can we relay on imp[].id to always have adUnitCode?

always use imp.id for adunitcode, to map to imp.tagid
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, 2289c6c

ogury

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:21:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:25:	MakeRequests		74.3%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:113:	filterValidImps		92.9%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:143:	setHeaders		57.1%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:155:	getMediaTypeForBid	57.1%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:175:	MakeBids		70.0%
total:								(statements)		73.8%

- global
maintainer:
email: [email protected]
gvlVendorID: 31
Copy link
Contributor

Choose a reason for hiding this comment

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

Verified GVL ID.

adapters/ogury/ogury.go Outdated Show resolved Hide resolved
adapters/ogury/ogury.go Outdated Show resolved Hide resolved
adapters/ogury/ogury.go Outdated Show resolved Hide resolved
adapters/ogury/ogury.go Show resolved Hide resolved
adapters/ogury/ogury.go Show resolved Hide resolved
@SyntaxNode
Copy link
Contributor

Hello I have a question with this PR. We are using adUnitCode in our backend and I wanted to read it from imp[].Ext.Prebid.AdUnitCode but I see that this field is not forwarded to bidders (also opened this issue #4077 to see if this is a bug or intended behaviour), so we using imp.Id as a fallback for adunitcode. Is this a right assumption, can we relay on imp[].id to always have adUnitCode?

Let's leave the discussion on the mentioned issue.

* use jsonutil package instead standard json lib

* don't allocate newImpExt, use impExt for hoisting bidder.params

* rename to buildHeader

* set IPv6 header

* use mtype from response
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, 119a517

ogury

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:22:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:26:	MakeRequests		71.0%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:106:	filterValidImps		92.9%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:136:	buildHeaders		50.0%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:149:	getMediaTypeForBid	33.3%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:166:	MakeBids		70.0%
total:								(statements)		70.0%

@krdzo
Copy link
Author

krdzo commented Dec 16, 2024

@SyntaxNode I pushed changes to address comments on PR
Can you take a look again at it?

@bsardo bsardo added the adapter label Jan 6, 2025
@krdzo
Copy link
Author

krdzo commented Jan 13, 2025

Hello, would like to ask for your help with reviewing this PR.
When could we expect for the review to continue
Thank you in advance for your time


}

func filterValidImps(request *openrtb2.BidRequest) (validImps []openrtb2.Imp) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You may want to return an array of the results of unmarshling the imp.ext's since you unmarshal them again in the calling function. It is true that you unmarshal imp.ext.bidder into different structs on the two passes, but you could either save the imp.ext unmarshal, or just use map[string]json.RawMessage target for both purposes, and then unmarshal the AssetKey and AdUnitID keys into strings as one last step. Unmarshalling JSON tends to be a CPU heavy process.

Comment on lines +20 to +29
"allOf": [
{
"if": { "required": ["assetKey"] },
"then": { "required": ["adUnitId"] }
},
{
"if": { "required": ["adUnitId"] },
"then": { "required": ["assetKey"] }
}
]
Copy link
Contributor

Choose a reason for hiding this comment

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

This expression makes both of assetKey and adUnitId required or passes the imp to bidder if none of them are specified. Is this intentional?

Based on this code

if impExtOgury.AssetKey != "" && impExtOgury.AdUnitID != "" {
	validImps = append(validImps, imp)
}

it looks like you expect both assetKey and adUnitId to be specified. If so just replace this part of json file to:

"required": ["assetKey", "adUnitId"]

And remove this check if impExtOgury.AssetKey != "" && impExtOgury.AdUnitID != "" { because it will be done in PBS core before passing the request to adapter.

The only thing you will need to check is
if request.Site != nil && request.Site.Publisher.ID != "" { return request.Imp }
it can be moved to the MakeRequests function and you can delete filterValidImps.

Copy link
Author

Choose a reason for hiding this comment

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

This expression makes both of assetKey and adUnitId required or passes the imp to bidder if none of them are specified. Is this intentional?

Yes it is intentional. We accept request that have assetKey and adUnitId or we can accept request that have just request.Site.Publisher.ID (in this case we don't need assetKey/adUnitId).
We have a preference for imp that have assetKey/adunitId so that's why we filter out only those that have them and if three are no imps that have them we accept the request if it has publisherID.
The only way I see to achieve this is like this, to check manually in code and filter.

The only thing that I see that we can improve here is what @hhhjort said in the comment above and that's to "unify" filtering so we do unmarshal only once.

func (a adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
headers := buildHeaders(request)

request.Imp = filterValidImps(request)
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this function can be deleted, please my another comment in augury.json file

}

var errors []error
for i, imp := range request.Imp {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please consolidate this for loop with the for loop starting at the line 72.

Comment on lines +38 to +65
var impExt, impExtBidderHoist map[string]json.RawMessage
// extract ext
if err := jsonutil.Unmarshal(imp.Ext, &impExt); err != nil {
return nil, append(errors, &errortypes.BadInput{
Message: "Bidder extension not provided or can't be unmarshalled",
})
}
// find Ogury bidder params
if bidder, ok := impExt[openrtb_ext.PrebidExtBidderKey]; ok {
if err := jsonutil.Unmarshal(bidder, &impExtBidderHoist); err != nil {
return nil, append(errors, &errortypes.BadInput{
Message: "Ogury bidder extension not provided or can't be unmarshalled",
})
}
}

// extract every value from imp[].ext.bidder to imp[].ext
for key, value := range impExtBidderHoist {
impExt[key] = value
}

ext, err := jsonutil.Marshal(impExt)
if err != nil {
return nil, append(errors, &errortypes.BadInput{
Message: "Error while marshaling Imp.Ext bidder exension",
})
}
request.Imp[i].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.

Can you modify this to

var impExt adapters.ExtImpBidder
if err := jsonutil.Unmarshal(imp.Ext, &impExt); err != nil {
	return ..
}

var impExtOgury openrtb_ext.ImpExtOgury
if err := jsonutil.Unmarshal(impExt.Bidder, &impExtOgury); err != nil {
	return...
}

this is a preferable way to handle imp.ext in PBS.
Or you can directly set imp.Ext = impExt.Bidder without unmarshalling to impExtOgury

Copy link
Author

Choose a reason for hiding this comment

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

If we do imp.Ext = impExt.Bidder then we will lose all the other important fields that are in imp.Ext (here I'm mainly referring to gpid but there maybe some other that we will like to use in the future like tid).

If we do

var impExtOgury openrtb_ext.ImpExtOgury
if err := jsonutil.Unmarshal(impExt.Bidder, &impExtOgury); err != nil {
	return...
}

then we will lose all the other field besides what is in ImpExtOgury (we often experiment with some optional fields in the ImpExtOgury).

So the best way I see to handle this problem is like this, to unmarshal to map[string]json.RawMessage and hoist fields from impExtBidder to impExt. This looks like the most robust solution so we don't need to make any feature PRs if we want just to pass to or bidder some other field that in impExt.

consolidate all imp changed to one `for` loop
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, 12c4a88

ogury

Refer here for heat map coverage report

github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:22:	Builder			100.0%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:26:	MakeRequests		75.0%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:113:	buildHeaders		50.0%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:126:	getMediaTypeForBid	33.3%
github.com/prebid/prebid-server/v3/adapters/ogury/ogury.go:143:	MakeBids		70.0%
total:								(statements)		67.6%

@krdzo
Copy link
Author

krdzo commented Jan 16, 2025

Hello @hhhjort @VeronikaSolovei9
made changes to the PR, consolidated every change to to Imp array to one for loop so now we only unmarshal ext once. The for loop in MakeRequests is updating ext so to hoist ext.bidder fields to parent ext, setting currency for the imp and filtering imps that have ogury parameters. After the for loop we check if the request is valid and send it to our bidder.
Can you take a look again?

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