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

Size mapping functionality #651

Merged
merged 7 commits into from
Sep 26, 2016
Merged

Size mapping functionality #651

merged 7 commits into from
Sep 26, 2016

Conversation

mkendall07
Copy link
Member

@mkendall07 mkendall07 commented Sep 22, 2016

Type of change

  • Feature

Description of change

Adding support for #87 - size mapping.

  • Usage:
var adUnit = {
  code: 'code',
  sizeMapping: [  //new!
    {
      minWidth : 1024,  //if device screen width is greater than 1024, use these sizes
      sizes : [[300,250],[728,90]]
    },
    {
      minWidth : 480,  //if device screen width is < 1024 && > 480, use these sizes
      sizes : [120,60]
    },
    {
      minWidth : 0,  //if device screen width is < 480 && > 0, use these sizes
      sizes : [20,20]
    }
  ]
  bids: [...]
}

Other information

@prebid/core for review.

if(!isSizeMappingValid(adUnit.sizeMapping)){
return adUnit.sizes;
}
const width = this.getScreenWidth();
Copy link
Collaborator

@matthewlane matthewlane Sep 23, 2016

Choose a reason for hiding this comment

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

On a test page, this line gave me TypeError: Cannot read property 'getScreenWidth' of undefined due to this module using CommonJS-style exports but adapter manager using ES2015-style imports. Line 4 of adaptermanager could be changed to use a require statement, or the functions in this module could be exported with the ES2015 export keyword--in that case the unit tests fail though and would need to be changed as well

if(utils.isArray(sizeMapping) && sizeMapping.length > 0){
return true;
}
utils.logError('sizeMapping needs at least one screen size defined');
Copy link
Collaborator

Choose a reason for hiding this comment

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

On pages that haven't set up any sizeMappings but are still using sizes array(s), this message still gets logged

const sizes = adUnit.sizeMapping.find(sizeMapping =>{
return width > sizeMapping.minWidth;
}).sizes;
utils.logMessage(`AdUnit : ${adUnit.code} resized based on device width to : ${adUnit.sizes}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

If a sizeMapping is configured, is that meant to replace the sizes property? If so this message will show width as undefined

it('mapSizes 1029 width', function() {
let stub = sinon.stub(sizeMapping, 'getScreenWidth').returns(1029);
let sizes = sizeMapping.mapSizes(validAdUnit);
console.log(sizeMapping.getScreenWidth());
Copy link
Collaborator

@matthewlane matthewlane Sep 23, 2016

Choose a reason for hiding this comment

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

May want to remove this line

@mkendall07
Copy link
Member Author

@matthewlane
PR notes addressed.

Copy link
Collaborator

@matthewlane matthewlane left a comment

Choose a reason for hiding this comment

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

Tests pass, functionality works on test page, LGTM

return adUnit.sizes;
}
const width = getScreenWidth();
console.log('internal screen width: ' + width);
Copy link
Collaborator

Choose a reason for hiding this comment

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

console.log snuck in here

@mkendall07 mkendall07 merged commit 2c0ca80 into master Sep 26, 2016
@mkendall07 mkendall07 deleted the size_mapping_functionality branch September 30, 2016 18:45
Studnicky pushed a commit to sonobi/Prebid.js that referenced this pull request Oct 4, 2016
* Size mapping initial draft.

* Unit tests

* Use desktop size if cannot determine width

* Hygiene.

* Increase unit coverage to 100%

* Change to ES6 style export and updating unit tests

* Remove console.log
Studnicky pushed a commit to sonobi/Prebid.js that referenced this pull request Oct 4, 2016
* Size mapping initial draft.

* Unit tests

* Use desktop size if cannot determine width

* Hygiene.

* Increase unit coverage to 100%

* Change to ES6 style export and updating unit tests

* Remove console.log
marian-r pushed a commit to aol/Prebid.js that referenced this pull request Nov 2, 2016
…ebid-0.13.1 to release/1.4.0

* commit 'd174ef271e55e7f26210f50caac52c0a036bc9a1':
  CHANGELOG.
  0.13.1 release
  add an --https flag to run local dev server over https (prebid#670)
  test ie variant of url parse pathname (prebid#669)
  Prevent SpringServe TypeError (prebid#663)
  XDomainRequest does not support `readyState` and was not executing the callback. (prebid#668)
  Prevent Sovrn TypeError (prebid#664)
  Prevent TripleLift TypeError (prebid#662)
  fixed bug with using non standard "standard" keys and sendAllBids (prebid#665)
  Initial value 0 for adder. (prebid#656)
  Prevent bidmanager TypeError (prebid#661)
  Prevent Pubmatic TypeError (prebid#666)
  Size mapping functionality (prebid#651)
  Added '320x80': 59, '320x320': 72, '320x160': 73 to RUBICON_SIZE_MAP (prebid#649)
  Add defy alias + increment version. (prebid#650)
  Add additional sizes to rubicon size mapping (prebid#646)
marian-r added a commit to aol/Prebid.js that referenced this pull request Nov 2, 2016
…4.0 to master

* commit '5e7eec42d84ec5de47a28ba493a9357b595761d3':
  CHANGELOG.
  New adapter.
  0.13.1 release
  add an --https flag to run local dev server over https (prebid#670)
  test ie variant of url parse pathname (prebid#669)
  Prevent SpringServe TypeError (prebid#663)
  XDomainRequest does not support `readyState` and was not executing the callback. (prebid#668)
  Prevent Sovrn TypeError (prebid#664)
  Prevent TripleLift TypeError (prebid#662)
  fixed bug with using non standard "standard" keys and sendAllBids (prebid#665)
  Initial value 0 for adder. (prebid#656)
  Prevent bidmanager TypeError (prebid#661)
  Prevent Pubmatic TypeError (prebid#666)
  Size mapping functionality (prebid#651)
  Added '320x80': 59, '320x320': 72, '320x160': 73 to RUBICON_SIZE_MAP (prebid#649)
  Add defy alias + increment version. (prebid#650)
  Add additional sizes to rubicon size mapping (prebid#646)
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.

None yet

2 participants