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

Fix astraoneBidAdapter #6230

Merged
merged 5 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 7 additions & 10 deletions modules/astraoneBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ function buildBid(bidData) {
creativeId: bidData.content.seanceId,
currency: bidData.currency,
netRevenue: true,
mediaType: BANNER,
meta: {
mediaType: BANNER,
},
ttl: TTL,
content: bidData.content
};
Expand Down Expand Up @@ -62,7 +64,7 @@ function wrapAd(bid, bidData) {
parentDocument.style.height = "100%";
parentDocument.style.width = "100%";
}
var _html = "${encodeURIComponent(JSON.stringify(bid))}";
var _html = "${encodeURIComponent(JSON.stringify({...bid, content: bidData.content}))}";
window._ao_ssp.registerInImage(JSON.parse(decodeURIComponent(_html)));
</script>
</body>
Expand Down Expand Up @@ -126,14 +128,9 @@ export const spec = {
* @return {Bid[]} An array of bids which were nested inside the server.
*/
interpretResponse: function(serverResponse) {
const serverBody = serverResponse.body;
if (serverBody && utils.isArray(serverBody)) {
return utils._map(serverBody, function(bid) {
return buildBid(bid);
});
} else {
return [];
}
const bids = serverResponse.body && serverResponse.body.bids;

return Array.isArray(bids) ? bids.map(bid => buildBid(bid)) : []
}

}
Expand Down
292 changes: 148 additions & 144 deletions modules/astraoneBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ About us: https://astraone.io
var adUnits = [{
code: 'test-div',
mediaTypes: {
banner: {
sizes: [1, 1]
}
banner: {
sizes: [1, 1],
}
},
bids: [{
bidder: "astraone",
params: {
placement: "inImage",
placeId: "5af45ad34d506ee7acad0c26",
imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg"
}
bidder: "astraone",
params: {
placement: "inImage",
placeId: "5f477bf94d506ebe2c4240f3",
imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg"
}
}]
}];
```
Expand All @@ -39,66 +39,69 @@ var adUnits = [{
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Prebid.js Banner Example</title>
<script async src="prebid.js"></script>
<style>
.banner-block {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 1;
border: none;
overflow: hidden;
<meta charset="UTF-8">
<title>Prebid.js Banner Example</title>
<script src="../../../build/dev/prebid.js"></script>
<style>
.banner-block {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 1;
border: none;
overflow: hidden;
}
</style>
<script>
var adUnits = [{
code: 'test-div',
mediaTypes: {
banner: {
sizes: [1, 1],
}
</style>
<script>
var adUnits = [{
code: 'test-div',
sizes: [1, 1],
bids: [{
bidder: "astraone",
params: {
placement: "inImage",
placeId: "5af45ad34d506ee7acad0c26",
imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg"
}
}]
}];

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

pbjs.que.push(function() {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: function (e) {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;

var params = pbjs.getAdserverTargetingForAdUnitCode("test-div");
var iframe = document.getElementById('test-div');

if (params && params['hb_adid']) {
iframe.parentElement.style.position = "relative";
iframe.style.display = "block";
pbjs.renderAd(iframe.contentDocument, params['hb_adid']);
}
}
});
});
</script>
},
bids: [{
bidder: "astraone",
params: {
placement: "inImage",
placeId: "5f477bf94d506ebe2c4240f3",
imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg"
}
}]
}];

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

pbjs.que.push(function() {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: function (e) {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
var params = pbjs.getAdserverTargetingForAdUnitCode("test-div");
var iframe = document.getElementById('test-div');

if (params && params['hb_adid']) {
iframe.parentElement.style.position = "relative";
iframe.style.display = "block";
pbjs.renderAd(iframe.contentDocument, params['hb_adid']);
}
}
});
});
</script>
</head>

<body>
<h2>Prebid.js InImage Banner Test</h2>
<h2>Prebid.js InImage Banner Test</h2>

<div style="width: 600px;">
<img src="https://creative.astraone.io/files/default_image-1-600x400.jpg" />
<iframe id='test-div' class="banner-block" style="display: none;"></iframe>
</div>
<div style="width: 600px;">
<img src="https://creative.astraone.io/files/default_image-1-600x400.jpg" width="100%" />
<iframe id='test-div' class="banner-block" style="display: none;"></iframe>
</div>
</body>

</html>
Expand All @@ -109,90 +112,91 @@ var adUnits = [{
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Prebid.js Banner Example</title>
<script async src="prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<style>
.banner-block {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 1;
border: none;
overflow: hidden;
}
.banner-block div {
width: 100%;
height: 100%;
}
</style>
<script>
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

var adUnits = [{
code: 'div-gpt-ad-1574864639578-0',
mediaTypes: {
banner: {
sizes: [1, 1]
}
},
bids: [{
bidder: "astraone",
params: {
placement: "inImage",
placeId: "5af45ad34d506ee7acad0c26",
imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg"
}
}]
}];

var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];

googletag.cmd.push(() => {
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(() => {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({ bidsBackHandler: sendAdServerRequest });
});

function sendAdServerRequest() {
googletag.cmd.push(() => {
pbjs.que.push(() => {
pbjs.setTargetingForGPTAsync('div-gpt-ad-1574864639578-0');
googletag.pubads().refresh();
});
});
}

googletag.cmd.push(() => {
googletag
.defineSlot('/21877108735/rtb-pbjs', [1, 1], 'div-gpt-ad-1574864639578-0')
.addService(googletag.pubads());

googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
<meta charset="UTF-8">
<title>Prebid.js Banner gpt Example</title>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script async src="../../../build/dev/prebid.js"></script>
<style>
.banner-block {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 1;
border: none;
overflow: hidden;
}
.banner-block div {
width: 100%;
height: 100%;
}
</style>
<script>
var sizes = [1, 1];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

var adUnits = [{
code: 'div-gpt-ad-1574864639578-0',
mediaTypes: {
banner: {
sizes: sizes,
}
},
bids: [{
bidder: "astraone",
params: {
placement: "inImage",
placeId: "5f477bf94d506ebe2c4240f3",
imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg"
}
}]
}];

var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];

googletag.cmd.push(() => {
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(() => {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({ bidsBackHandler: sendAdServerRequest });
});

function sendAdServerRequest() {
googletag.cmd.push(() => {
pbjs.que.push(() => {
pbjs.setTargetingForGPTAsync('div-gpt-ad-1574864639578-0');
googletag.pubads().refresh();
});
});
}

googletag.cmd.push(() => {
googletag
.defineSlot('/21877108735/rtb-pbjs', sizes, 'div-gpt-ad-1574864639578-0')
.addService(googletag.pubads());

googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>
<body>
<h2>Prebid.js Banner Ad Unit Test</h2>
<h2>Prebid.js InImage Banner gpt Test</h2>

<div style="width: 600px; position: relative">
<img src="https://creative.astraone.io/files/default_image-1-600x400.jpg" />
<div style="width: 600px; position: relative">
<img src="https://creative.astraone.io/files/default_image-1-600x400.jpg" />

<div id='div-gpt-ad-1574864639578-0' class="banner-block">
<script>
googletag.cmd.push(() => { googletag.display('div-gpt-ad-1574864639578-0'); });
</script>
</div>
</div>
<div id='div-gpt-ad-1574864639578-0' class="banner-block">
<script>
googletag.cmd.push(() => { googletag.display('div-gpt-ad-1574864639578-0'); });
</script>
</div>
</div>
</body>
</html>
```
Loading