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

Support price granularity per mediaType #2348

Conversation

idettman
Copy link
Contributor

@idettman idettman commented Apr 4, 2018

Type of change

  • Feature

Description of change

Add support for setting price granularity per mediaType.

  • It's possible to specify a priceGranularity per mediaType that overrides the global priceGranularity.
  • The priceGranularity specified can be low, med, high, auto, dense, or custom
  • Auction results for each bid response are processed with the specified granularity
  • Auction results for a bid without a specified mediaType-based priceGranularity are processed with the globally-defined priceGranularity as normal.

Use case:

  • Video AdUnits require non-standard PBJS priceGranularities because the cap can be > $20
  • The Pub wants to run both video and display AdUnits on the same page
  • The results for video AdUnits need to be processed with a different priceGranularity than the display AdUnits

Proposal is to allow the definition of the priceGranularity at a mediaType level:

pbjs.setConfig({
   priceGranularity: "medium",   // the global default is kept for backwards compatibility
   mediaTypePriceGranularity: {
         "banner": "medium",
         "video": customPriceGranularity,
         "native": "medium"
   }
});

Other information

https://jira.rubiconproject.com/projects/HB/issues/HB-2347

@mkendall07 mkendall07 requested review from jaiminpanchal27, mkendall07 and snapwich and removed request for mkendall07 April 4, 2018 21:14
@mkendall07 mkendall07 self-assigned this Apr 4, 2018
Copy link
Collaborator

@snapwich snapwich left a comment

Choose a reason for hiding this comment

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

LGTM

@jaiminpanchal27
Copy link
Collaborator

@idettman Need docs PR open to merge this

set mediaTypePriceGranularity(val) {
this._mediaTypePriceGranularity = Object.keys(val).reduce((aggregate, item) => {
if (validatePriceGranularity(val[item])) {
if (typeof val === 'string') {
Copy link
Member

Choose a reason for hiding this comment

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

looks like this code was copied from the function above around line ~90. Can we combine it/make more generic?

Copy link
Contributor Author

@idettman idettman May 15, 2018

Choose a reason for hiding this comment

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

I initially had the logic for both extracted into a generic function, but the added complexity specific for mediaTypesGranularity resulted in more code than inlining with the additional conditionals

@mkendall07
Copy link
Member

@idettman
docs?

Isaac Dettman added 2 commits May 2, 2018 11:58
@bretg
Copy link
Collaborator

bretg commented May 15, 2018

Docs PR at prebid/prebid.github.io#764 -- since it touched the Pub API, combined it with some refactoring.

@mkendall07 mkendall07 merged commit 82fdbf6 into prebid:master May 16, 2018
dluxemburg pushed a commit to Genius/Prebid.js that referenced this pull request Jul 17, 2018
* Add config support for mediaTypePriceGranularity

* Update to set default granularity to use config default

* Formatting change, comment updated

* Formatting change

* Added test for mediaTypePriceGranularity enabled

* Added test for mediaTypePriceGranularity video type

* Changed double quotes to single in config_spec

* Linting fixes for indentation and spacing
@idettman idettman deleted the HB-2347-support-price-granularity-per-mediatype branch March 18, 2019 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants