-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Debugging Module: Bid responses for various media types (+ TestBidder) #12720
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0c0b08e
12512 Mock bid responses for various media types
mkomorski ff7adf6
lint fix
mkomorski 18c51d5
resolvers execution fix
mkomorski 7379f8c
Merge branch 'master' into mkomorski/debugging-mock-responses
mkomorski e94b789
+ basic examples
mkomorski 1ee8306
comments
mkomorski bcd3b58
adapt native to ortb & refactor video example
mkomorski e38c31d
moving renderer to bid response
mkomorski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
integrationExamples/testBidder/testBidderBannerExample.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<html> | ||
<head> | ||
<title>Prebid Test Bidder Example</title> | ||
<script src="../../build/dev/prebid.js" async></script> | ||
<script> | ||
var pbjs = pbjs || {}; | ||
pbjs.que = pbjs.que || []; | ||
|
||
const adUnitCode = 'adUnit-0000'; | ||
|
||
const adUnits = [{ | ||
mediaTypes: { | ||
banner: { | ||
sizes: [600, 500] | ||
} | ||
}, | ||
code: adUnitCode, | ||
bids: [ | ||
{bidder: 'testBidder', params: {}} | ||
] | ||
}] | ||
|
||
pbjs.que.push(function () { | ||
|
||
/** | ||
* BID RESPONSE SIMULATION SECTION START | ||
* | ||
* This section handles simulating a bidder | ||
* that will always respond with bid responses. | ||
* | ||
* This part should not be present in production. | ||
*/ | ||
pbjs.registerBidAdapter(null, 'testBidder', { | ||
supportedMediaTypes: ['banner', 'video', 'native'], | ||
isBidRequestValid: () => true | ||
}); | ||
|
||
pbjs.setConfig({ | ||
debugging: { | ||
enabled: true, | ||
intercept: [ | ||
{ | ||
when: { | ||
bidder: 'testBidder', | ||
}, | ||
then: { | ||
creativeId: 'testCreativeId', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this just to have something here? I think it should work with an empty object. |
||
} | ||
} | ||
] | ||
} | ||
}); | ||
/** | ||
* BID RESPONSE SIMULATION SECTION END | ||
*/ | ||
|
||
pbjs.addAdUnits(adUnits); | ||
pbjs.requestBids({ | ||
adUnitCodes: [adUnitCode], | ||
bidsBackHandler: function() { | ||
const bids = pbjs.getHighestCpmBids(adUnitCode); | ||
const winningBid = bids[0]; | ||
const div = document.getElementById('banner'); | ||
let iframe = document.createElement('iframe'); | ||
iframe.frameBorder = '0'; | ||
div.appendChild(iframe); | ||
var iframeDoc = iframe.contentWindow.document; | ||
pbjs.renderAd(iframeDoc, winningBid.adId); | ||
} | ||
}); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<h2>Prebid Test Bidder Example</h2> | ||
<h5>Banner ad</h5> | ||
<div id="banner"></div> | ||
</body> | ||
</html> |
151 changes: 151 additions & 0 deletions
151
integrationExamples/testBidder/testBidderNativeExample.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<html> | ||
<head> | ||
<title>Prebid Test Bidder Example</title> | ||
<script src="../../build/dev/prebid.js" async></script> | ||
<script> | ||
var pbjs = pbjs || {}; | ||
pbjs.que = pbjs.que || []; | ||
|
||
const adUnitCode = 'adUnit-0000'; | ||
|
||
const adUnits = [{ | ||
mediaTypes: { | ||
native: { | ||
ortb: { | ||
assets: [ | ||
{ | ||
required: true, | ||
id: 1, | ||
img: { | ||
type: 3, | ||
wmin: 100, | ||
hmin: 100, | ||
} | ||
}, | ||
{ | ||
required: true, | ||
id: 2, | ||
img: { | ||
type: 3, | ||
wmin: 200, | ||
hmin: 200 | ||
} | ||
}, | ||
{ | ||
required: true, | ||
id: 3, | ||
data: { | ||
type: 3, | ||
len: 20 | ||
} | ||
}, | ||
{ | ||
required: true, | ||
id: 4, | ||
title: { | ||
len: 20 | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
code: adUnitCode, | ||
bids: [ | ||
{bidder: 'testBidder', params: {}} | ||
] | ||
}] | ||
|
||
pbjs.que.push(function () { | ||
|
||
/** | ||
* BID RESPONSE SIMULATION SECTION START | ||
* | ||
* This section handles simulating a bidder | ||
* that will always respond with bid responses. | ||
* | ||
* This part should not be present in production. | ||
*/ | ||
pbjs.registerBidAdapter(null, 'testBidder', { | ||
supportedMediaTypes: ['banner', 'video', 'native'], | ||
isBidRequestValid: () => true | ||
}); | ||
|
||
pbjs.setConfig({ | ||
debugging: { | ||
enabled: true, | ||
intercept: [ | ||
{ | ||
when: { | ||
bidder: 'testBidder', | ||
}, | ||
then: { | ||
creativeId: 'testCreativeId', | ||
} | ||
} | ||
] | ||
} | ||
}); | ||
/** | ||
* BID RESPONSE SIMULATION SECTION END | ||
*/ | ||
|
||
pbjs.addAdUnits(adUnits); | ||
pbjs.requestBids({ | ||
adUnitCodes: [adUnitCode], | ||
bidsBackHandler: function() { | ||
const bids = pbjs.getHighestCpmBids(adUnitCode); | ||
const bid = bids[0]; | ||
const slot = document.getElementById('native'); | ||
const iframe = document.createElement('iframe'); | ||
Object.entries({ | ||
frameBorder: 0, | ||
marginWidth: 0, | ||
marginHeight: 0, | ||
width: 600, | ||
height: 500, | ||
scrolling: 'no', | ||
srcdoc: document.getElementById('native-template').innerHTML | ||
}).forEach(([prop, val]) => iframe.setAttribute(prop, val)); | ||
slot.appendChild(iframe); | ||
iframe.onload = () => pbjs.renderAd(iframe.contentDocument, bid.adId); | ||
} | ||
}); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<template id="native-template"> | ||
<style> | ||
body { | ||
display: inline-block; | ||
} | ||
|
||
.container { | ||
display: inline-block; | ||
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; | ||
font-size: 14px; | ||
line-height: 1.42857143; | ||
box-sizing: border-box; | ||
border: 3px dashed red; | ||
padding: 20px; | ||
color: #333; | ||
} | ||
|
||
.img { | ||
width: 300px; | ||
height: 200px; | ||
} | ||
|
||
</style> | ||
<div class="container"> | ||
<h1>##hb_native_asset_id_4##</h1> | ||
<h3>Rating: ##hb_native_asset_id_3##</h3> | ||
<img class="img" src="##hb_native_asset_id_1##" alt="bg" /> | ||
</div> | ||
</template> | ||
<h2>Prebid Test Bidder Example</h2> | ||
<h5>Native ad</h5> | ||
<div id="native"></div> | ||
</body> | ||
</html> |
75 changes: 75 additions & 0 deletions
75
integrationExamples/testBidder/testBidderVideoExample.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<html> | ||
<head> | ||
<title>Prebid Test Bidder Example</title> | ||
<script src="../../build/dev/prebid.js" async></script> | ||
<script> | ||
var pbjs = pbjs || {}; | ||
pbjs.que = pbjs.que || []; | ||
|
||
const adUnitCode = 'adUnit-0000'; | ||
|
||
const adUnits = [{ | ||
mediaTypes: { | ||
video: { | ||
playerSize: [640, 360], | ||
context: 'outstream' | ||
} | ||
}, | ||
code: adUnitCode, | ||
bids: [ | ||
{bidder: 'testBidder', params: {}} | ||
] | ||
}] | ||
|
||
pbjs.que.push(function () { | ||
|
||
/** | ||
* BID RESPONSE SIMULATION SECTION START | ||
* | ||
* This section handles simulating a bidder | ||
* that will always respond with bid responses. | ||
* | ||
* This part should not be present in production. | ||
*/ | ||
pbjs.registerBidAdapter(null, 'testBidder', { | ||
supportedMediaTypes: ['banner', 'video', 'native'], | ||
isBidRequestValid: () => true | ||
}); | ||
|
||
pbjs.setConfig({ | ||
debugging: { | ||
enabled: true, | ||
intercept: [ | ||
{ | ||
when: { | ||
bidder: 'testBidder', | ||
}, | ||
then: { | ||
creativeId: 'testCreativeId', | ||
} | ||
} | ||
] | ||
} | ||
}); | ||
/** | ||
* BID RESPONSE SIMULATION SECTION END | ||
*/ | ||
|
||
pbjs.addAdUnits(adUnits); | ||
pbjs.requestBids({ | ||
adUnitCodes: [adUnitCode], | ||
bidsBackHandler: function() { | ||
const bids = pbjs.getHighestCpmBids(adUnitCode); | ||
const winningBid = bids[0]; | ||
pbjs.renderAd(document, winningBid.adId); | ||
} | ||
}); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<h2>Prebid Test Bidder Example</h2> | ||
<h5>Video ad</h5> | ||
<div id="player"></div> | ||
</body> | ||
</html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost nothing in any integration example should be left in production.