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 V2 #4520

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3d5760a
implement size bucket filtration logic
Fawke Nov 25, 2019
d8c96fc
Merge branch 'master' of https://github.com/prebid/Prebid.js into adv…
Fawke Nov 25, 2019
240cfce
finish implmenation of getFilteredMediaTypes
Fawke Nov 26, 2019
8d7d35d
implement getBids function
Fawke Dec 2, 2019
5264373
log useful information to the console
Fawke Dec 2, 2019
ac0007d
enable test workflow
Fawke Dec 2, 2019
4b876a6
modify checkAdUnitSetup function to account for the new sizeConfig ob…
Fawke Dec 4, 2019
c7b3816
remove unrelated example
Fawke Dec 5, 2019
751ceff
add decider function to choose between sizeMapping v1 and sizeMapping v2
Fawke Dec 6, 2019
cbf2a61
add getBidsHook for s2s bidders
Fawke Dec 6, 2019
60847f0
handle edge case where all mediaTypes get filtered out and the case w…
Fawke Dec 6, 2019
5c35aed
add test examples for banner media type
Fawke Dec 7, 2019
ca521ba
update label check to pick up the fist label operator instead of the …
Fawke Dec 7, 2019
9ca28cf
added example for label checks with banner ad
Fawke Dec 7, 2019
eeb07e7
add checkAdUnit setup hook on sizeMappingV2 modules to check presence…
Fawke Dec 8, 2019
0d6e27c
restore old hello world example
Fawke Dec 8, 2019
208861a
give free pass to video mediaTypes configured with sizeConfig propert…
Fawke Dec 8, 2019
bbb1888
fixing minor bus and enchancing bidder level sizeConfig checks
Fawke Dec 8, 2019
72b5607
bugfix: checkBidderSizeConfigFormat
Fawke Dec 8, 2019
d554866
add more scenarios for testing sizeMapping V2
Fawke Dec 8, 2019
ff0d348
small docs changes
Fawke Dec 8, 2019
0c30a75
feedback1 changes
Fawke Dec 11, 2019
613a830
modify logic for bailing out
Fawke Dec 12, 2019
4040fad
add module description
Fawke Dec 12, 2019
1efc71c
refactor isUsingNewSizeMapping function by making it a pure function
Fawke Dec 13, 2019
723c298
add unit test case for isUsingNewSizeMapping function
Fawke Dec 13, 2019
043626d
sync with master
Fawke Dec 13, 2019
4c20b1b
made adUnit checks more robusts and fully make adUnit.mediaTypes mand…
Fawke Dec 13, 2019
f0a29ca
remove redundancy in checAdUnitSetupHook
Fawke Dec 17, 2019
2165a8b
add banner units test cases for checkAdUnitSetupHook function
Fawke Dec 19, 2019
5afc8d1
add video and native mediaTypes units test for checkAdUnitSetupHook f…
Fawke Dec 20, 2019
66a43c5
rewrite some of the log messages
Fawke Dec 26, 2019
b4cf490
redefine log messages to make it simple to the end user
Fawke Dec 26, 2019
57c27e6
code optimization done so that getFilteredMediaTypes function gets ca…
Fawke Dec 31, 2019
aa65876
add code comments
Fawke Dec 31, 2019
7a02628
code refactorization and more unit test cases
Fawke Jan 2, 2020
72b69df
more unit tests for getBids function
Fawke Jan 3, 2020
ce36722
add sizeMapping usage example
Fawke Jan 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions integrationExamples/gpt/sizeMappingv2/banner_ad.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<html>

<head>
<script async src="../../../build/dev/prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script>
const FAILSAFE_TIMEOUT = 3300;
const PREBID_TIMEOUT = 1000;

const adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
sizeConfig: [
{ minViewPort: [0, 0], sizes: [] }, // remove if < 750px
{ minViewPort: [750, 0], sizes: [[300, 250], [300, 600]] }, // between 750px and 1199px
{ minViewPort: [1200, 0], sizes: [[970, 90], [728, 90], [300, 250]] }, // between 1200px and 1599px
{ minViewPort: [1600, 0], sizes: [[1000, 300], [970, 90], [728, 90], [300, 250]] } // greater than 1600px
]
}
},
bids: [{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}, {
bidder: 'rubicon',
params: {
accountId: 14062,
siteId: 70608,
zoneId: 498816
}
}]
}];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

</script>

<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function () {
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(function () {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: sendAdserverRequest,
timeout: PREBID_TIMEOUT
});
});

function sendAdserverRequest() {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
googletag.cmd.push(function () {
pbjs.que.push(function () {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
}

setTimeout(function () {
sendAdserverRequest();
}, FAILSAFE_TIMEOUT);

</script>

<script>
googletag.cmd.push(function () {
googletag.defineSlot('/19968336/header-bid-tag-0', [728, 90], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads());

googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>

<body>
<h2>Prebid.js Test</h2>
<h5>Div-1</h5>
<div id='div-gpt-ad-1460505748561-0'>
<script type='text/javascript'>
googletag.cmd.push(function () { googletag.display('div-gpt-ad-1460505748561-0'); });
</script>
</div>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<html>

<head>
<script async src="../../../build/dev/prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script>
const FAILSAFE_TIMEOUT = 3300;
const PREBID_TIMEOUT = 1000;

const adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
sizeConfig: [
{ minViewPort: [0, 0], sizes: [] }, // remove if < 750px
{ minViewPort: [750, 0], sizes: [[300, 250], [300, 600]] }, // between 750px and 1199px
{ minViewPort: [1200, 0], sizes: [[970, 90], [728, 90], [300, 250]] }, // between 1200px and 1599px
{ minViewPort: [1600, 0], sizes: [[1000, 300], [970, 90], [728, 90], [300, 250]] } // greater than 1600px
]
}
},
bids: [{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}, {
bidder: 'rubicon',
params: {
accountId: 14062,
siteId: 70608,
zoneId: 498816
},
sizeConfig: [
{ minViewPort: [0, 0], relevantMediaTypes: ['none'] },
{ minViewPort: [1200, 0], relevantMediaTypes: ['banner'] },
{ minViewPort: [1600, 0], relevantMediaTypes: ['none'] }
]
}]
}];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

</script>

<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function () {
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(function () {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: sendAdserverRequest,
timeout: PREBID_TIMEOUT
});
});

function sendAdserverRequest() {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
googletag.cmd.push(function () {
pbjs.que.push(function () {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
}

setTimeout(function () {
sendAdserverRequest();
}, FAILSAFE_TIMEOUT);

</script>

<script>
googletag.cmd.push(function () {
googletag.defineSlot('/19968336/header-bid-tag-0', [728, 90], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads());

googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>

<body>
<h2>Prebid.js Test</h2>
<h5>Div-1</h5>
<div id='div-gpt-ad-1460505748561-0'>
<script type='text/javascript'>
googletag.cmd.push(function () { googletag.display('div-gpt-ad-1460505748561-0'); });
</script>
</div>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<html>

<head>
<script async src="../../../build/dev/prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script>
const FAILSAFE_TIMEOUT = 3300;
const PREBID_TIMEOUT = 1000;

const adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
sizeConfig: [
{ minViewPort: [0, 0], sizes: [] }, // remove if < 750px
{ minViewPort: [750, 0], sizes: [[300, 250], [300, 600]] }, // between 750px and 1199px
{ minViewPort: [1200, 0], sizes: [[970, 90], [728, 90], [300, 250]] }, // between 1200px and 1599px
{ minViewPort: [1600, 0], sizes: [[1000, 300], [970, 90], [728, 90], [300, 250]] } // greater than 1600px
]
}
},
// incase multiple label operators are declared, it'll select the first operator, and throw a warning to the console
// indicating multiple label operators are present in this Ad Unit.
// So, in this case, it'll select 'labelAny' operator, the first declared label operator.
labelAny: ['desktop'],
labelAll: ['desktop', 'tablet'],
bids: [{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}, {
bidder: 'rubicon',
params: {
accountId: 14062,
siteId: 70608,
zoneId: 498816
},
// Again, it'll select the labelAll opertor and 'Rubicon' will NOT participate in the auction.
labelAll: ['desktop', 'tablet'],
labelAny: ['desktop', 'tablet'],
}]
}, {
code: 'div-gpt-ad-1460505748561-1',
mediaTypes: {
banner: {
sizeConfig: [
{ minViewPort: [0, 0], sizes: [] }, // remove if < 750px
{ minViewPort: [750, 0], sizes: [[300, 250], [300, 600]] }, // between 750px and 1199px
{ minViewPort: [1200, 0], sizes: [[970, 90], [728, 90], [300, 250]] }, // between 1200px and 1599px
{ minViewPort: [1600, 0], sizes: [[1000, 300], [970, 90], [728, 90], [300, 250]] } // greater than 1600px
]
}
},
// Ad Unit will remail active.
labelAll: ['desktop', 'mobile', 'euro'],
bids: [{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}, {
bidder: 'rubicon',
params: {
accountId: 14062,
siteId: 70608,
zoneId: 498816
},
labelAny: ['desktop', 'tablet'], // Rubicon will remain active
}]
}];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

</script>

<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function () {
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(function () {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: sendAdserverRequest,
labels: ['desktop', 'mobile', 'euro'],
timeout: PREBID_TIMEOUT
});
});

function sendAdserverRequest() {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
googletag.cmd.push(function () {
pbjs.que.push(function () {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
}

setTimeout(function () {
sendAdserverRequest();
}, FAILSAFE_TIMEOUT);

</script>

<script>
googletag.cmd.push(function () {
googletag.defineSlot('/19968336/header-bid-tag-0', [728, 90], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads());

googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>

<body>
<h2>Prebid.js Test</h2>
<h5>Div-1</h5>
<div id='div-gpt-ad-1460505748561-0'>
<script type='text/javascript'>
googletag.cmd.push(function () { googletag.display('div-gpt-ad-1460505748561-0'); });
</script>
</div>
</body>

</html>
Loading