Skip to content

Commit

Permalink
Merge branch 'master' into digitrustFacade3911
Browse files Browse the repository at this point in the history
  • Loading branch information
goosemanjack committed Jul 1, 2019
2 parents 7ec30f9 + 2bd04a1 commit dd6d612
Show file tree
Hide file tree
Showing 12 changed files with 351 additions and 79 deletions.
3 changes: 2 additions & 1 deletion integrationExamples/gpt/x-domain/creative.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// this script can be returned by an ad server delivering a cross domain iframe, into which the
// creative will be rendered, e.g. DFP delivering a SafeFrame

let windowLocation = window.location;
var urlParser = document.createElement('a');
urlParser.href = '%%PATTERN:url%%';
var publisherDomain = urlParser.protocol + '//' + urlParser.hostname;
var adServerDomain = urlParser.protocol + '//tpc.googlesyndication.com';
var adServerDomain = windowLocation.protocol + '//tpc.googlesyndication.com';

function renderAd(ev) {
var key = ev.message ? 'message' : 'data';
Expand Down
4 changes: 2 additions & 2 deletions modules/bidglassBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as utils from 'src/utils';
import * as utils from '../src/utils';
// import {config} from 'src/config';
import {registerBidder} from 'src/adapters/bidderFactory';
import {registerBidder} from '../src/adapters/bidderFactory';

const BIDDER_CODE = 'bidglass';

Expand Down
4 changes: 2 additions & 2 deletions modules/hpmdnetworkBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { registerBidder } from 'src/adapters/bidderFactory';
import { BANNER } from 'src/mediaTypes';
import { registerBidder } from '../src/adapters/bidderFactory';
import { BANNER } from '../src/mediaTypes';

const BIDDER_CODE = 'hpmdnetwork';
const BIDDER_CODE_ALIAS = 'hpmd';
Expand Down
2 changes: 1 addition & 1 deletion modules/open8BidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Renderer } from '../src/Renderer';
import {ajax} from '../src/ajax';
import * as utils from 'src/utils';
import * as utils from '../src/utils';
import { registerBidder } from '../src/adapters/bidderFactory';
import { VIDEO, BANNER } from '../src/mediaTypes';

Expand Down
2 changes: 1 addition & 1 deletion modules/openxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const spec = {
};

function isVideoRequest(bidRequest) {
return utils.deepAccess(bidRequest, 'mediaTypes.video') || bidRequest.mediaType === VIDEO;
return (utils.deepAccess(bidRequest, 'mediaTypes.video') && !utils.deepAccess(bidRequest, 'mediaTypes.banner')) || bidRequest.mediaType === VIDEO;
}

function createBannerBidResponses(oxResponseObj, {bids, startTime}) {
Expand Down
67 changes: 49 additions & 18 deletions modules/ozoneBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { Renderer } from '../src/Renderer'
const BIDDER_CODE = 'ozone';

const OZONEURI = 'https://elb.the-ozone-project.com/openrtb2/auction';
const OZONE_RENDERER_URL = 'https://prebid.the-ozone-project.com/ozone-renderer.js'

const OZONECOOKIESYNC = 'https://elb.the-ozone-project.com/static/load-cookie.html';
const OZONEVERSION = '2.0.0';
const OZONE_RENDERER_URL = 'https://prebid.the-ozone-project.com/ozone-renderer.js';

const OZONEVERSION = '2.1.1';

export const spec = {
code: BIDDER_CODE,
Expand Down Expand Up @@ -57,12 +57,6 @@ export const spec = {
utils.logInfo('OZONE: OZONE BID ADAPTER VALIDATION FAILED : customParams should be renamed to customData');
return false;
}
if (bid.params.hasOwnProperty('ozoneData')) {
if (typeof bid.params.ozoneData !== 'object') {
utils.logInfo('OZONE: OZONE BID ADAPTER VALIDATION FAILED : ozoneData is not an object');
return false;
}
}
if (bid.params.hasOwnProperty('lotameData')) {
if (typeof bid.params.lotameData !== 'object') {
utils.logInfo('OZONE: OZONE BID ADAPTER VALIDATION FAILED : lotameData is not an object');
Expand Down Expand Up @@ -90,18 +84,35 @@ export const spec = {
let htmlParams = validBidRequests[0].params; // the html page config params will be included in each element
let ozoneRequest = {}; // we only want to set specific properties on this, not validBidRequests[0].params
delete ozoneRequest.test; // don't allow test to be set in the config - ONLY use $_GET['pbjs_debug']
if (bidderRequest.gdprConsent) {

if (bidderRequest && bidderRequest.gdprConsent) {
utils.logInfo('OZONE: ADDING GDPR info');
ozoneRequest.regs = {};
ozoneRequest.regs.ext = {};
ozoneRequest.regs.ext.gdpr = bidderRequest.gdprConsent.gdprApplies === true ? 1 : 0;
ozoneRequest.regs.ext.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0;
if (ozoneRequest.regs.ext.gdpr) {
ozoneRequest.user = {};
ozoneRequest.user.ext = {'consent': bidderRequest.gdprConsent.consentString};
ozoneRequest.user = ozoneRequest.user || {};
if (
bidderRequest.gdprConsent.vendorData &&
bidderRequest.gdprConsent.vendorData.vendorConsents &&
typeof bidderRequest.gdprConsent.consentString !== 'undefined'
) {
utils.logInfo('OZONE: found all info we need for GDPR - will add info to request object');
ozoneRequest.user.ext = {'consent': bidderRequest.gdprConsent.consentString};
// are we able to make this request?
let vendorConsents = bidderRequest.gdprConsent.vendorData.vendorConsents;
let boolGdprConsentForOzone = vendorConsents[524];
let arrGdprConsents = toFlatArray(bidderRequest.gdprConsent.vendorData.purposeConsents);
ozoneRequest.regs.ext.oz_con = boolGdprConsentForOzone ? 1 : 0;
ozoneRequest.regs.ext.gap = arrGdprConsents;
}
} else {
utils.logInfo('OZONE: **** Failed to find required info for GDPR for request object, even though bidderRequest.gdprConsent is TRUE ****');
}
} else {
utils.logInfo('OZONE: WILL NOT ADD GDPR info');
utils.logInfo('OZONE: WILL NOT ADD GDPR info; no bidderRequest.gdprConsent object was present.');
}

ozoneRequest.device = {'w': window.innerWidth, 'h': window.innerHeight};
let tosendtags = validBidRequests.map(ozoneBidRequest => {
var obj = {};
Expand Down Expand Up @@ -157,9 +168,6 @@ export const spec = {
if (ozoneBidRequest.params.hasOwnProperty('customData')) {
obj.ext.ozone.customData = ozoneBidRequest.params.customData;
}
if (ozoneBidRequest.params.hasOwnProperty('ozoneData')) {
obj.ext.ozone.ozoneData = ozoneBidRequest.params.ozoneData;
}
if (ozoneBidRequest.params.hasOwnProperty('lotameData')) {
obj.ext.ozone.lotameData = ozoneBidRequest.params.lotameData;
}
Expand Down Expand Up @@ -226,8 +234,8 @@ export const spec = {
serverResponse.seatbid = injectAdIdsIntoAllBidResponses(serverResponse.seatbid); // we now make sure that each bid in the bidresponse has a unique (within page) adId attribute.
for (let i = 0; i < serverResponse.seatbid.length; i++) {
let sb = serverResponse.seatbid[i];
const {defaultWidth, defaultHeight} = defaultSize(request.bidderRequest.bids[i]);
for (let j = 0; j < sb.bid.length; j++) {
const {defaultWidth, defaultHeight} = defaultSize(request.bidderRequest.bids[j]); // there should be the same number of bids as requests, so index [j] should always exist.
let thisBid = ozoneAddStandardProperties(sb.bid[j], defaultWidth, defaultHeight);

// from https://github.com/prebid/Prebid.js/pull/1082
Expand Down Expand Up @@ -310,6 +318,13 @@ export function checkDeepArray(Arr) {
}
}
export function defaultSize(thebidObj) {
if (!thebidObj) {
utils.logInfo('defaultSize received empty bid obj! going to return fixed default size');
return {
'defaultHeight': 250,
'defaultWidth': 300
};
}
const {sizes} = thebidObj;
const returnObject = {};
returnObject.defaultWidth = checkDeepArray(sizes)[0];
Expand Down Expand Up @@ -499,5 +514,21 @@ function outstreamRender(bid) {
window.ozoneVideo.outstreamRender(bid);
}

/**
* convert {1: true,
2: true,
3: true,
4: true,
5: true}
to : [1,2,3,4,5]
* @param obj
*/
function toFlatArray(obj) {
let ret = [];
Object.keys(obj).forEach(function(key) { if (obj[key]) { ret.push(parseInt(key)); } });
utils.logInfo('toFlatArray:', obj, 'returning', ret);
return ret;
}

registerBidder(spec);
utils.logInfo('OZONE: ozoneBidAdapter ended');
6 changes: 2 additions & 4 deletions modules/ozoneBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ adUnits = [{
publisherId: 'OZONENUK0001', /* an ID to identify the publisher account - required */
siteId: '4204204201', /* An ID used to identify a site within a publisher account - required */
placementId: '0420420421', /* an ID used to identify the piece of inventory - required - for appnexus test use 13144370. */
customData": [{"settings": {}, "targeting": {"key": "value", "key2": ["value1", "value2"],}}] /* optional array with 'targeting' placeholder for passing publisher specific key-values for targeting. */
ozoneData: {"key1": "value1", "key2": "value2"}, /* optional JSON placeholder for for passing ozone project key-values for targeting. */
customData: [{"settings": {}, "targeting": {"key": "value", "key2": ["value1", "value2"]}}],/* optional array with 'targeting' placeholder for passing publisher specific key-values for targeting. */
lotameData: {"key1": "value1", "key2": "value2"} /* optional JSON placeholder for passing Lotame DMP data */
}
}]
Expand Down Expand Up @@ -65,8 +64,7 @@ adUnits = [{
siteId: '4204204201', /* An ID used to identify a site within a publisher account - required */
customData: [{"settings": {}, "targeting": { "key": "value", "key2": ["value1", "value2"]}}]
placementId: '0440440442', /* an ID used to identify the piece of inventory - required - for unruly test use 0440440442. */
customData": [{"settings": {}, "targeting": {"key": "value", "key2": ["value1", "value2"],}}] /* optional array with 'targeting' placeholder for passing publisher specific key-values for targeting. */
ozoneData: {"key1": "value1", "key2": "value2"}, /* optional JSON placeholder for for passing ozone project key-values for targeting. */
customData: [{"settings": {}, "targeting": {"key": "value", "key2": ["value1", "value2"]}}],/* optional array with 'targeting' placeholder for passing publisher specific key-values for targeting. */
lotameData: {"key1": "value1", "key2": "value2"}, /* optional JSON placeholder for passing Lotame DMP data */
video: {
skippable: true, /* optional */
Expand Down
4 changes: 2 additions & 2 deletions modules/reloadBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
BANNER
}
from 'src/mediaTypes';
from '../src/mediaTypes';
import {
registerBidder
}
from 'src/adapters/bidderFactory';
from '../src/adapters/bidderFactory';

const BIDDER_CODE = 'reload';

Expand Down
1 change: 1 addition & 0 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ var sizeMap = {
126: '200x600',
144: '980x600',
145: '980x150',
156: '640x320',
159: '320x250',
179: '250x600',
195: '600x300',
Expand Down
2 changes: 1 addition & 1 deletion modules/yieldlabBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as utils from '../src/utils'
import { registerBidder } from '../src/adapters/bidderFactory'
import find from 'core-js/library/fn/array/find'
import { VIDEO, BANNER } from '../src/mediaTypes'
import { Renderer } from 'src/Renderer'
import { Renderer } from '../src/Renderer'

const ENDPOINT = 'https://ad.yieldlab.net'
const BIDDER_CODE = 'yieldlab'
Expand Down
35 changes: 35 additions & 0 deletions test/spec/modules/openxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,41 @@ describe('OpenxAdapter', function () {
});
});

describe('when request is for a multiformat ad', function () {
describe('and request config uses mediaTypes video and banner', () => {
const multiformatBid = {
bidder: 'openx',
params: {
unit: '12345678',
delDomain: 'test-del-domain'
},
adUnitCode: 'adunit-code',
mediaTypes: {
banner: {
sizes: [[300, 250]]
},
video: {
playerSize: [300, 250]
}
},
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e'
};
it('should return true multisize when required params found', function () {
expect(spec.isBidRequestValid(multiformatBid)).to.equal(true);
});

it('should send bid request to openx url via GET, with mediaType specified as banner', function () {
const request = spec.buildRequests([multiformatBid]);
expect(request[0].url).to.equal(`//${multiformatBid.params.delDomain}${URLBASE}`);
expect(request[0].data.ph).to.be.undefined;
expect(request[0].method).to.equal('GET');
});
});
});

describe('when request is for a video ad', function () {
describe('and request config uses mediaTypes', () => {
const videoBidWithMediaTypes = {
Expand Down
Loading

0 comments on commit dd6d612

Please sign in to comment.