Skip to content

ozone adapter now explicitly sets site.page object, adds debug flag #3403

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

Merged
merged 1 commit into from
Jan 3, 2019
Merged
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
59 changes: 39 additions & 20 deletions modules/ozoneBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ export const spec = {
bidderRequest.publisherId = (bidderRequest.publisherId).toString();
}

if (!ozoneRequest.test) {
delete ozoneRequest.test;
}
// if (!ozoneRequest.test) {
delete ozoneRequest.test; // don't allow test to be set in the config - ONLY use $_GET['pbjs_debug']
// }
if (bidderRequest.gdprConsent) {
ozoneRequest.regs = {};
ozoneRequest.regs.ext = {};
Expand All @@ -124,38 +124,40 @@ export const spec = {
ozoneRequest.regs.ext.consent = bidderRequest.gdprConsent.consentString;
}
}
let tosendtags = validBidRequests.map(ozone => {
let tosendtags = validBidRequests.map(ozoneBidRequest => {
var obj = {};
obj.id = ozone.bidId;
obj.tagid = String(ozone.params.ozoneid);
obj.id = ozoneBidRequest.bidId;
obj.tagid = String(ozoneBidRequest.params.ozoneid);
obj.secure = window.location.protocol === 'https:' ? 1 : 0;
obj.banner = {
topframe: 1,
w: ozone.sizes[0][0] || 0,
h: ozone.sizes[0][1] || 0,
format: ozone.sizes.map(s => {
w: ozoneBidRequest.sizes[0][0] || 0,
h: ozoneBidRequest.sizes[0][1] || 0,
format: ozoneBidRequest.sizes.map(s => {
return {w: s[0], h: s[1]};
})
};
if (ozone.params.hasOwnProperty('customData')) {
obj.customData = ozone.params.customData;
if (ozoneBidRequest.params.hasOwnProperty('customData')) {
obj.customData = ozoneBidRequest.params.customData;
}
if (ozone.params.hasOwnProperty('ozoneData')) {
obj.ozoneData = ozone.params.ozoneData;
if (ozoneBidRequest.params.hasOwnProperty('ozoneData')) {
obj.ozoneData = ozoneBidRequest.params.ozoneData;
}
if (ozone.params.hasOwnProperty('lotameData')) {
obj.lotameData = ozone.params.lotameData;
if (ozoneBidRequest.params.hasOwnProperty('lotameData')) {
obj.lotameData = ozoneBidRequest.params.lotameData;
}
if (ozone.params.hasOwnProperty('publisherId')) {
obj.publisherId = (ozone.params.publisherId).toString();
if (ozoneBidRequest.params.hasOwnProperty('publisherId')) {
obj.publisherId = (ozoneBidRequest.params.publisherId).toString();
}
if (ozone.params.hasOwnProperty('siteId')) {
obj.siteId = (ozone.params.siteId).toString();
if (ozoneBidRequest.params.hasOwnProperty('siteId')) {
obj.siteId = (ozoneBidRequest.params.siteId).toString();
}
obj.ext = {'prebid': {'storedrequest': {'id': (ozone.params.placementId).toString()}}};
obj.ext = {'prebid': {'storedrequest': {'id': (ozoneBidRequest.params.placementId).toString()}}};
return obj;
});
ozoneRequest.imp = tosendtags;
ozoneRequest.site = {'publisher': {'id': ozoneRequest.publisherId}, 'page': document.location.href};
ozoneRequest.test = parseInt(getTestQuerystringValue()); // will be 1 or 0
var ret = {
method: 'POST',
url: OZONEURI,
Expand Down Expand Up @@ -255,4 +257,21 @@ export function ozoneAddStandardProperties(seatBid, defaultWidth, defaultHeight)
return seatBid;
}

/**
* we need to add test=1 or test=0 to the get params sent to the server.
* Get the value set as pbjs_debug= in the url, OR 0.
* @returns {*}
*/
export function getTestQuerystringValue() {
let searchString = window.location.search.substring(1);
let params = searchString.split('&');
for (let i = 0; i < params.length; i++) {
let val = params[i].split('=');
if (val[0] === 'pbjs_debug') {
return val[1] === 'true' ? 1 : 0;
}
}
return 0;
}

registerBidder(spec);