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: Displayio #3691

Merged
merged 10 commits into from
Jul 22, 2024
Merged

New Adapter: Displayio #3691

merged 10 commits into from
Jul 22, 2024

Conversation

xdevel
Copy link
Contributor

@xdevel xdevel commented May 21, 2024

Display.io prebid server adapter

Docs PR: prebid/prebid.github.io#5330

Display.io prebid adapter
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, 412159e

displayio

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:27:	MakeRequests			76.2%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:138:	MakeBids			95.2%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:181:	Builder				80.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:193:	getBidMediaTypeFromMtype	75.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:204:	buildEndpointURL		100.0%
total:									(statements)			81.1%

@onkarvhanumante
Copy link
Contributor

@xdevel
should update json test

  • to have request with multiple imps
  • to have multi-format imp request

fix single placement/inventory per imp
rename DisplayioAdapter to Adapter
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, 61a4085

displayio

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:27:	MakeRequests			78.3%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:132:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:175:	Builder				80.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:187:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:198:	buildEndpointURL		100.0%
total:									(statements)			84.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, e76504c

displayio

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:27:	MakeRequests			78.3%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:132:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:175:	Builder				80.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:187:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:198:	buildEndpointURL		100.0%
total:									(statements)			84.8%

@xdevel xdevel requested a review from onkarvhanumante May 30, 2024 09:18
Copy link

github-actions bot commented Jun 6, 2024

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, 3284f21

displayio

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:27:	MakeRequests			78.3%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:132:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:175:	Builder				80.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:187:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:198:	buildEndpointURL		100.0%
total:									(statements)			84.8%

@onkarvhanumante
Copy link
Contributor

@xdevel should update json test

  • to have request with multiple imps
  • to have multi-format imp request

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, 4267bd2

displayio

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:27:	MakeRequests			78.3%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:132:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:175:	Builder				80.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:187:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:198:	buildEndpointURL		100.0%
total:									(statements)			84.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, d4ef043

displayio

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:27:	MakeRequests			78.3%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:132:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:175:	Builder				80.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:187:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:198:	buildEndpointURL		100.0%
total:									(statements)			84.8%

@xdevel
Copy link
Contributor Author

xdevel commented Jun 11, 2024

@onkarvhanumante both tests are already added, please take a look on multi-format.json / multi-imp.json

@rgushel
Copy link

rgushel commented Jun 24, 2024

@onkarvhanumante any updates on this one?

Comment on lines 87 to 94
dioExt = reqDioExt{PlacementId: impressionExt.PlacementId, InventoryId: impressionExt.InventoryId}

err = json.Unmarshal(request.Ext, &requestExt)
if err != nil {
requestExt = make(map[string]interface{})
}

requestExt["displayio"] = dioExt
Copy link
Contributor

Choose a reason for hiding this comment

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

any particular reason to unMarshal request.Ext on line 89? unMarshalled value is always overwritten by dioExt assignment on line 94

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@onkarvhanumante it's not overwritten but modified. We alter request.ext with dio-related data.

Comment on lines 76 to 79
if len(bidderExt.Bidder) == 0 {
errs = append(errs, errors.New("bidder required"))
continue
}
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to add this check. Prebid core code will make sure Bidder value is present

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, removed

@onkarvhanumante
Copy link
Contributor

@onkarvhanumante any updates on this one?

@xdevel @xdevel please address following comments:

@bsardo bsardo assigned bsardo and unassigned Sonali-More-Xandr Jun 28, 2024
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, dbfb1b5

displayio

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:27:	MakeRequests			78.3%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:132:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:175:	Builder				80.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:187:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:198:	buildEndpointURL		100.0%
total:									(statements)			84.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, 58a4f96

displayio

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:27:	MakeRequests			80.7%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:129:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:172:	Builder				80.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:184:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:195:	buildEndpointURL		100.0%
total:									(statements)			86.5%

onkarvhanumante
onkarvhanumante previously approved these changes Jul 1, 2024
Comment on lines 14 to 15
config.Adapter{Endpoint: "https://prebid.display.io/?publisher={{.PublisherID}}"},
config.Server{ExternalUrl: "https://prebid.display.io/?publisher=101"},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: I suggest using a fake URL for these to decouple your tests. It'll be less maintenance if you ever need to change the URL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

URLs updated

Comment on lines 13 to 14
"net/http"
"text/template"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: I suggest organizing your imports so all standard packages are listed first, in which case you would move these after "fmt" and before all of the github imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Imports reorganized

InventoryId string `json:"inventoryId"`
}

func (adapter *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You might want to consider making a copy of request even though MakeRequests is provided with a shallow copy of it. It looks like you're modifying request, particularly request.ext, for each impression with each subsequent impression reading a previously modified version of request.ext instead of the version that was originally passed into MakeRequests.
On second look, this might not be a problem right now since you're always writing placementId and inventoryId to request.ext and those are guaranteed to exist for every impression which means the previous imp values are always overwritten. However, maybe this a change you want to consider to make your adapter future proof?

I should also note that any changes made to request in MakeRequests will be part of the request passed into MakeBids as the adapter shares the same shallow request copy provided to your adapter by PBS core. In that case, MakeBids will see request.ext.displayio with the placementId and inventoryId fields set to whatever their values are in the last impression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, thanks for suggestion. I changed the code to use a copy of request for each imp

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll leave it up to you to decide of course but I just wanted to point out that you could really simplify your JSON tests, perhaps cutting their size in half, by removing a lot of the noise. I understand that your JSON tests as currently written probably more accurately represent how your server processes bid requests, however, it is arguable as to whether that is of value here. A lot of the fields here can be deleted as they are not handled directly by your adapter. Other fields like adm can simply be just HTML tags with no markup between them.
I think such changes will make your tests a lot easier to follow and draw attention to the specific fields that your adapter cares about.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests simplified. I didn't dive a lot into it but tried to clear some unnecessary fields

Comment on lines 36 to 38
"placementId": "1021",
"publisherId": "101",
"inventoryId": "1011"
Copy link
Collaborator

@bsardo bsardo Jul 2, 2024

Choose a reason for hiding this comment

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

Given my comment on your adapter MakeRequests function here, I suggest having different values for your two impressions to make sure everything works properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, updated

Comment on lines 72 to 77
"ext": {
"displayio": {
"placementId": "1011",
"inventoryId": "1011"
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it typical for this information to exist in the request.ext of the incoming request? It seemed like your adapter was getting this information from imp.ext.bidder and populating request.ext.displayio in the bid requests generated in MakeRequests.

Copy link
Contributor Author

@xdevel xdevel Jul 3, 2024

Choose a reason for hiding this comment

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

Is it typical for this information to exist in the request.ext of the incoming request?

No, no matter what will be send under request.ext.displayio, it will be replaced by adapter code.
I dropped it from incoming request tests to keep it straight

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this one titled missing-bidfloorcur.json? Would currency-conversion.json be a better name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. File renamed

use of request copy for makeRequests
Copy link

github-actions bot commented Jul 3, 2024

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

displayio

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:28:	MakeRequests			80.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:128:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:171:	Builder				80.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:183:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:194:	buildEndpointURL		100.0%
total:									(statements)			86.2%

@xdevel xdevel requested review from bsardo and onkarvhanumante July 3, 2024 04:01
@rgushel
Copy link

rgushel commented Jul 11, 2024

@onkarvhanumante looking forward to your final check. Thanks!

@rgushel
Copy link

rgushel commented Jul 17, 2024

@onkarvhanumante we've fixed all the blockers and are waiting for your approval

@onkarvhanumante
Copy link
Contributor

@onkarvhanumante we've fixed all the blockers and are waiting for your approval

Thanks for being patient with PR reviews. PR is merged

@onkarvhanumante onkarvhanumante merged commit 0a3271d into prebid:master Jul 22, 2024
5 checks passed
AvinashKapre pushed a commit to PubMatic-OpenWrap/prebid-server that referenced this pull request Nov 25, 2024
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.

5 participants