From b5026af79a30a3c6b2b966b297e926bc06a85041 Mon Sep 17 00:00:00 2001 From: valentino Date: Mon, 15 Jun 2020 16:04:53 +0200 Subject: [PATCH 01/17] Added full outstream support with onetag renderer, updated request parameters --- modules/onetagBidAdapter.js | 130 ++++++++++++++++++++++++++++++------ 1 file changed, 111 insertions(+), 19 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index f2cea34bb1a..5a5bdfe160a 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -1,7 +1,10 @@ 'use strict'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { OUTSTREAM, INSTREAM } from '../src/video.js'; const { registerBidder } = require('../src/adapters/bidderFactory.js'); +import { Renderer } from '../src/Renderer.js'; +import find from 'core-js-pure/features/array/find.js'; const ENDPOINT = 'https://onetag-sys.com/prebid-request'; const USER_SYNC_ENDPOINT = 'https://onetag-sys.com/usync/'; @@ -29,9 +32,7 @@ export function isValid(type, bid) { return parseSizes(bid).length > 0; } else if (type === VIDEO && hasTypeVideo(bid)) { const context = bid.mediaTypes.video.context; - if (context === 'outstream') { - return parseVideoSize(bid).length > 0 && typeof bid.renderer !== 'undefined' && typeof bid.renderer.render !== 'undefined' && typeof bid.renderer.url !== 'undefined'; - } else if (context === 'instream') { + if (context === 'outstream' || context === 'instream') { return parseVideoSize(bid).length > 0; } } @@ -67,6 +68,10 @@ function buildRequests(validBidRequests, bidderRequest) { payload.userId = bidderRequest.userId; } + if (window.localStorage) { + payload.onetagSid = window.localStorage.getItem("onetag_sid"); + } + const payloadString = JSON.stringify(payload); return { @@ -76,7 +81,7 @@ function buildRequests(validBidRequests, bidderRequest) { } } -function interpretResponse(serverResponse, request) { +function interpretResponse(serverResponse, bidderRequest) { let body = serverResponse.body; const bids = []; @@ -112,7 +117,23 @@ function interpretResponse(serverResponse, request) { if (bid.mediaType === BANNER) { responseBid.ad = bid.ad; } else if (bid.mediaType === VIDEO) { - responseBid.vastXml = bid.ad; + const context = utils.deepAccess(bidderRequest, 'mediaTypes.video.context'); + if (context === INSTREAM) { + // TODO get VAST url from server bid + responseBid.vastUrl = ''; + // TODO get cache key from server bid + responseBid.videoCacheKey = ''; + } else if (context === OUTSTREAM) { + // TODO get player url from server + bid.rendererUrl = "https://local.onetag.net:9000/dist/PlayerStandalone.js"; + // TODO get VAST xml from server bid + responseBid.vastXml = ''; + // TODO get VAST url from server bid + responseBid.vastUrl = ''; + const videoBid = find(bidderRequest.bids, bidRequest.bidId === bid.requestId); + const rendererOptions = utils.deepAccess(videoBid, 'renderer.options'); + responseBid.renderer = createRenderer(bid, rendererOptions); + } } bids.push(responseBid); @@ -121,6 +142,36 @@ function interpretResponse(serverResponse, request) { return bids; } +function createRenderer(bid, rendererOptions = {}) { + const renderer = Renderer.install({ + id: bid.requestId, + url: bid.rendererUrl, + config: rendererOptions, + adUnitCode: bid.adUnitCode, + loaded: false + }); + + try { + renderer.setRender(ourRenderer); + } catch (e) { + console.log(e); + } + + return renderer; +} + +function ourRenderer(bidResponse) { + bidResponse.renderer.push(() => { + window.onetag.PlayerStandalone.init({ + width: bidResponse.width, + height: bidResponse.height, + vastXml: bidResponse.vastXml, + nodeId: bidResponse.adUnitCode, + config: bidResponse.renderer.getConfig() + }); + }); +} + /** * Returns information about the page needed by the server in an object to be converted in JSON * @returns {{location: *, referrer: (*|string), masked: *, wWidth: (*|Number), wHeight: (*|Number), sWidth, sHeight, date: string, timeOffset: number}} @@ -176,8 +227,7 @@ function getPageInfo() { yOffset: yOffset, docHidden: isDocHidden, hLength: history.length, - date: t.toUTCString(), - timeOffset: t.getTimezoneOffset() + timing = getTiming() }; } @@ -223,6 +273,43 @@ function setGeneralInfo(bidRequest) { if (params.dealId) { this['dealId'] = params.dealId; } + if (params.floor) { + this['floor'] = params.floor; + } + const coords = getSpaceCoords(bidRequest.adUnitCode); + if (coords) { + this['coords'] = coords; + } +} + +function getSpaceCoords(id) { + const space = document.getElementById(id); + if (space && space.getBoundingClientRect) { + const rect = space.getBoundingClientRect(); + const coords = {}; + coords.top = rect.top + window.pageYOffset; + coords.right = rect.right + window.pageXOffset; + coords.bottom = rect.bottom + window.pageYOffset; + coords.left = rect.left + window.pageXOffset; + return coords; + } + return null; +} + +function getTiming() { + try { + if (window.performance != null && window.performance.timing != null) { + const timing = {}; + const perf = window.performance.timing; + timing.plt = perf.loadEventEnd - perf.navigationStart; + timing.ct = perf.responseEnd - perf.requestStart; + timing.rt = perf.domComplete - perf.domLoading; + return timing; + } + } catch(e) { + return null; + } + return null; } function parseVideoSize(bid) { @@ -256,26 +343,31 @@ function getSizes(sizes) { function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { const syncs = []; + let params = ''; + if (gdprConsent && typeof gdprConsent.consentString === 'string') { + params += '&gdpr_consent=' + gdprConsent.consentString; + if (typeof gdprConsent.gdprApplies === 'boolean') { + params += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0); + } + } + if (uspConsent && typeof uspConsent === 'string') { + params += '&us_privacy=' + uspConsent; + } if (syncOptions.iframeEnabled) { const rnd = new Date().getTime(); - let params = '?cb=' + rnd; - - if (gdprConsent && typeof gdprConsent.consentString === 'string') { - params += '&gdpr_consent=' + gdprConsent.consentString; - if (typeof gdprConsent.gdprApplies === 'boolean') { - params += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0); - } - } - - if (uspConsent && typeof uspConsent === 'string') { - params += '&us_privacy=' + uspConsent; - } + params = '?cb=' + rnd + params syncs.push({ type: 'iframe', url: USER_SYNC_ENDPOINT + params }); } + if (syncOptions.pixelEnabled && serverResponses.length > 0) { + const res = serverResponses[0]; + if (res.pixelsUrls && res.pixelsUrls.length > 0) { + syncs = syncs.concat(res.pixelsUrls.map(url => ({type: 'image', url: url + '?' + params.splice(0,1)}))); + } + } return syncs; } From a5751db4897ac10b64ca416616af3e0d7b42df14 Mon Sep 17 00:00:00 2001 From: Nicola Date: Tue, 16 Jun 2020 09:46:57 +0200 Subject: [PATCH 02/17] Code updates --- modules/onetagBidAdapter.js | 61 +++++++++++-------------------------- 1 file changed, 17 insertions(+), 44 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 5a5bdfe160a..38d8af606f1 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -5,6 +5,7 @@ import { OUTSTREAM, INSTREAM } from '../src/video.js'; const { registerBidder } = require('../src/adapters/bidderFactory.js'); import { Renderer } from '../src/Renderer.js'; import find from 'core-js-pure/features/array/find.js'; +import { deepAccess } from "../src/utils"; const ENDPOINT = 'https://onetag-sys.com/prebid-request'; const USER_SYNC_ENDPOINT = 'https://onetag-sys.com/usync/'; @@ -84,7 +85,6 @@ function buildRequests(validBidRequests, bidderRequest) { function interpretResponse(serverResponse, bidderRequest) { let body = serverResponse.body; const bids = []; - if (typeof serverResponse === 'string') { try { body = JSON.parse(serverResponse); @@ -92,53 +92,31 @@ function interpretResponse(serverResponse, bidderRequest) { return bids; } } - if (!body || (body.nobid && body.nobid === true)) { return bids; } if (!body.bids || !Array.isArray(body.bids) || body.bids.length === 0) { return bids; } - body.bids.forEach(function(bid) { let responseBid = { - requestId: bid.requestId, - cpm: bid.cpm, - width: bid.width, - height: bid.height, - creativeId: bid.creativeId, - dealId: bid.dealId ? bid.dealId : '', - currency: bid.currency, + ...bid, + ...bid.ad, netRevenue: false, - mediaType: bid.mediaType, - ttl: bid.ttl || 300 }; - if (bid.mediaType === BANNER) { - responseBid.ad = bid.ad; - } else if (bid.mediaType === VIDEO) { - const context = utils.deepAccess(bidderRequest, 'mediaTypes.video.context'); - if (context === INSTREAM) { - // TODO get VAST url from server bid - responseBid.vastUrl = ''; - // TODO get cache key from server bid - responseBid.videoCacheKey = ''; - } else if (context === OUTSTREAM) { - // TODO get player url from server - bid.rendererUrl = "https://local.onetag.net:9000/dist/PlayerStandalone.js"; - // TODO get VAST xml from server bid - responseBid.vastXml = ''; - // TODO get VAST url from server bid - responseBid.vastUrl = ''; + responseBid.ttl = responseBid.ttl || 300; + responseBid.dealId = responseBid.dealId || ''; + if (bid.mediaType === VIDEO) { + const context = deepAccess(bidderRequest, 'mediaTypes.video.context'); + if (context === OUTSTREAM) { const videoBid = find(bidderRequest.bids, bidRequest.bidId === bid.requestId); - const rendererOptions = utils.deepAccess(videoBid, 'renderer.options'); + const rendererOptions = deepAccess(videoBid, 'renderer.options'); responseBid.renderer = createRenderer(bid, rendererOptions); } } - bids.push(responseBid); }); - return bids; } @@ -150,13 +128,11 @@ function createRenderer(bid, rendererOptions = {}) { adUnitCode: bid.adUnitCode, loaded: false }); - try { renderer.setRender(ourRenderer); } catch (e) { console.log(e); } - return renderer; } @@ -227,7 +203,7 @@ function getPageInfo() { yOffset: yOffset, docHidden: isDocHidden, hLength: history.length, - timing = getTiming() + timing: getTiming() }; } @@ -301,9 +277,9 @@ function getTiming() { if (window.performance != null && window.performance.timing != null) { const timing = {}; const perf = window.performance.timing; - timing.plt = perf.loadEventEnd - perf.navigationStart; - timing.ct = perf.responseEnd - perf.requestStart; - timing.rt = perf.domComplete - perf.domLoading; + timing.pageLoadTime = perf.loadEventEnd - perf.navigationStart; + timing.connectTime = perf.responseEnd - perf.requestStart; + timing.renderTime = perf.domComplete - perf.domLoading; return timing; } } catch(e) { @@ -342,7 +318,7 @@ function getSizes(sizes) { } function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { - const syncs = []; + let syncs = []; let params = ''; if (gdprConsent && typeof gdprConsent.consentString === 'string') { params += '&gdpr_consent=' + gdprConsent.consentString; @@ -355,7 +331,7 @@ function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { } if (syncOptions.iframeEnabled) { const rnd = new Date().getTime(); - params = '?cb=' + rnd + params + params = '?cb=' + rnd + params; syncs.push({ type: 'iframe', @@ -364,18 +340,16 @@ function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { } if (syncOptions.pixelEnabled && serverResponses.length > 0) { const res = serverResponses[0]; - if (res.pixelsUrls && res.pixelsUrls.length > 0) { - syncs = syncs.concat(res.pixelsUrls.map(url => ({type: 'image', url: url + '?' + params.splice(0,1)}))); + if (res.pixelUrls && res.pixelUrls.length > 0) { + syncs = syncs.concat(res.pixelUrls.map(url => ({type: 'image', url: url + '?' + params.splice(0,1)}))); } } return syncs; } export const spec = { - code: BIDDER_CODE, supportedMediaTypes: [BANNER, VIDEO], - isBidRequestValid: isBidRequestValid, buildRequests: buildRequests, interpretResponse: interpretResponse, @@ -383,5 +357,4 @@ export const spec = { }; -// Starting point registerBidder(spec); From 80da341a4e316617cfbe5ff4616847f72d471b57 Mon Sep 17 00:00:00 2001 From: Nicola Date: Tue, 16 Jun 2020 13:15:13 +0200 Subject: [PATCH 03/17] Fixies outstream --- modules/onetagBidAdapter.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 38d8af606f1..bf283316aba 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -92,6 +92,7 @@ function interpretResponse(serverResponse, bidderRequest) { return bids; } } + const requestData = JSON.parse(bidderRequest.data); if (!body || (body.nobid && body.nobid === true)) { return bids; } @@ -101,18 +102,15 @@ function interpretResponse(serverResponse, bidderRequest) { body.bids.forEach(function(bid) { let responseBid = { ...bid, - ...bid.ad, netRevenue: false, }; - responseBid.ttl = responseBid.ttl || 300; responseBid.dealId = responseBid.dealId || ''; if (bid.mediaType === VIDEO) { - const context = deepAccess(bidderRequest, 'mediaTypes.video.context'); - if (context === OUTSTREAM) { - const videoBid = find(bidderRequest.bids, bidRequest.bidId === bid.requestId); - const rendererOptions = deepAccess(videoBid, 'renderer.options'); - responseBid.renderer = createRenderer(bid, rendererOptions); + const videoBid = find(requestData.bids, (item) => item.bidId === bid.requestId); + if (videoBid.context === OUTSTREAM) { + // const rendererOptions = deepAccess(videoBid, 'renderer.options'); + responseBid.renderer = createRenderer(bid); } } bids.push(responseBid); From b300226fc4d066e6fe82e981f708c436db015fe7 Mon Sep 17 00:00:00 2001 From: valentino Date: Fri, 19 Jun 2020 16:35:55 +0200 Subject: [PATCH 04/17] Removed wrong pixel calls, code refactoring --- modules/onetagBidAdapter.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index bf283316aba..164d2105d5b 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -5,7 +5,6 @@ import { OUTSTREAM, INSTREAM } from '../src/video.js'; const { registerBidder } = require('../src/adapters/bidderFactory.js'); import { Renderer } from '../src/Renderer.js'; import find from 'core-js-pure/features/array/find.js'; -import { deepAccess } from "../src/utils"; const ENDPOINT = 'https://onetag-sys.com/prebid-request'; const USER_SYNC_ENDPOINT = 'https://onetag-sys.com/usync/'; @@ -83,15 +82,8 @@ function buildRequests(validBidRequests, bidderRequest) { } function interpretResponse(serverResponse, bidderRequest) { - let body = serverResponse.body; + const body = serverResponse.body; const bids = []; - if (typeof serverResponse === 'string') { - try { - body = JSON.parse(serverResponse); - } catch (e) { - return bids; - } - } const requestData = JSON.parse(bidderRequest.data); if (!body || (body.nobid && body.nobid === true)) { return bids; @@ -109,7 +101,6 @@ function interpretResponse(serverResponse, bidderRequest) { if (bid.mediaType === VIDEO) { const videoBid = find(requestData.bids, (item) => item.bidId === bid.requestId); if (videoBid.context === OUTSTREAM) { - // const rendererOptions = deepAccess(videoBid, 'renderer.options'); responseBid.renderer = createRenderer(bid); } } @@ -336,11 +327,11 @@ function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { url: USER_SYNC_ENDPOINT + params }); } - if (syncOptions.pixelEnabled && serverResponses.length > 0) { - const res = serverResponses[0]; - if (res.pixelUrls && res.pixelUrls.length > 0) { - syncs = syncs.concat(res.pixelUrls.map(url => ({type: 'image', url: url + '?' + params.splice(0,1)}))); - } + if (syncOptions.pixelEnabled) { + syncs.push({ + type: 'image', + url: USER_SYNC_ENDPOINT + '?tag=img' + params + }); } return syncs; } From a5b868912b0b009e60edf0c1a889ae4efa59c0e9 Mon Sep 17 00:00:00 2001 From: francesco Date: Fri, 19 Jun 2020 18:38:46 +0200 Subject: [PATCH 05/17] Corregge funzione di calcolo coordinate spazio --- modules/onetagBidAdapter.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 164d2105d5b..f99f4a74e8a 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -249,16 +249,23 @@ function setGeneralInfo(bidRequest) { function getSpaceCoords(id) { const space = document.getElementById(id); - if (space && space.getBoundingClientRect) { - const rect = space.getBoundingClientRect(); - const coords = {}; - coords.top = rect.top + window.pageYOffset; - coords.right = rect.right + window.pageXOffset; - coords.bottom = rect.bottom + window.pageYOffset; - coords.left = rect.left + window.pageXOffset; + try { + let window = space.ownerDocument.defaultView; + let frame = window.frameElement; + const coords = { top: 0, bottom: 0, left: 0, right: 0 }; + do { + const { top, bottom, left, right } = frame.getBoundingClientRect(); + coords.top += top + window.pageXOffset; + coords.bottom += bottom + window.pageXOffset; + coords.left += left + window.pageXOffset; + coords.right += right + window.pageXOffset; + window = window.parent; + frame = window.frameElement; + } while (window !== window.top); return coords; + } catch(e) { + return null; } - return null; } function getTiming() { From 203f3bb784354e331450c98ff63da44fe326f3c3 Mon Sep 17 00:00:00 2001 From: francesco Date: Mon, 22 Jun 2020 14:37:36 +0200 Subject: [PATCH 06/17] =?UTF-8?q?Migliora=20leggibilit=C3=A0=20funzione=20?= =?UTF-8?q?estrazione=20info=20pagina?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/onetagBidAdapter.js | 112 +++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 54 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index f99f4a74e8a..0af18f14f0d 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -1,10 +1,10 @@ 'use strict'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import { OUTSTREAM, INSTREAM } from '../src/video.js'; -const { registerBidder } = require('../src/adapters/bidderFactory.js'); +import { OUTSTREAM } from '../src/video.js'; import { Renderer } from '../src/Renderer.js'; import find from 'core-js-pure/features/array/find.js'; +const { registerBidder } = require('../src/adapters/bidderFactory.js'); const ENDPOINT = 'https://onetag-sys.com/prebid-request'; const USER_SYNC_ENDPOINT = 'https://onetag-sys.com/usync/'; @@ -69,7 +69,7 @@ function buildRequests(validBidRequests, bidderRequest) { } if (window.localStorage) { - payload.onetagSid = window.localStorage.getItem("onetag_sid"); + payload.onetagSid = window.localStorage.getItem('onetag_sid'); } const payloadString = JSON.stringify(payload); @@ -120,7 +120,7 @@ function createRenderer(bid, rendererOptions = {}) { try { renderer.setRender(ourRenderer); } catch (e) { - console.log(e); + } return renderer; } @@ -137,60 +137,63 @@ function ourRenderer(bidResponse) { }); } -/** - * Returns information about the page needed by the server in an object to be converted in JSON - * @returns {{location: *, referrer: (*|string), masked: *, wWidth: (*|Number), wHeight: (*|Number), sWidth, sHeight, date: string, timeOffset: number}} +/*** + * Returns information about current frame nesting */ -function getPageInfo() { - let w, d, l, r, m, p, e, t, s; - for (w = window, d = w.document, l = d.location.href, r = d.referrer, m = 0, e = encodeURIComponent, t = new Date(), s = screen; w !== w.parent;) { - try { - p = w.parent; l = p.location.href; r = p.document.referrer; w = p; - } catch (e) { - m = top !== w.parent ? 2 : 1; - break +function getFrameNesting() { + let frame = window; + try { + while (frame !== frame.top) { + // eslint-disable-next-line no-unused-expressions + frame.location.href; + frame = frame.parent; } + } catch (e) {} + return { + topmostFrame: frame, + currentFrameNesting: frame.top === frame ? 1 : 2 } - let isDocHidden; - let xOffset; - let yOffset; +} + +function getDocumentVisibility(window) { try { - if (typeof w.document.hidden !== 'undefined') { - isDocHidden = w.document.hidden; - } else if (typeof w.document['msHidden'] !== 'undefined') { - isDocHidden = w.document['msHidden']; - } else if (typeof w.document['webkitHidden'] !== 'undefined') { - isDocHidden = w.document['webkitHidden']; + if (typeof window.document.hidden !== 'undefined') { + return window.document.hidden; + } else if (typeof window.document['msHidden'] !== 'undefined') { + return window.document['msHidden']; + } else if (typeof window.document['webkitHidden'] !== 'undefined') { + return window.document['webkitHidden']; } else { - isDocHidden = null; + return null; } } catch (e) { - isDocHidden = null; - } - try { - xOffset = w.pageXOffset; - yOffset = w.pageYOffset; - } catch (e) { - xOffset = null; - yOffset = null; + return null; } +} + +/** + * Returns information about the page needed by the server in an object to be converted in JSON + * @returns {{location: *, referrer: (*|string), masked: *, wWidth: (*|Number), wHeight: (*|Number), sWidth, sHeight, date: string, timeOffset: number}} + */ +function getPageInfo() { + const { topmostFrame, currentFrameNesting } = getFrameNesting(); return { - location: e(l), - referrer: e(r) || '0', - masked: m, - wWidth: w.innerWidth, - wHeight: w.innerHeight, - oWidth: w.outerWidth, - oHeight: w.outerHeight, - sWidth: s.width, - sHeight: s.height, - aWidth: s.availWidth, - aHeight: s.availHeight, - sLeft: 'screenLeft' in w ? w.screenLeft : w.screenX, - sTop: 'screenTop' in w ? w.screenTop : w.screenY, - xOffset: xOffset, - yOffset: yOffset, - docHidden: isDocHidden, + location: encodeURIComponent(topmostFrame.location.href), + referrer: encodeURIComponent(topmostFrame.document.referrer) || '0', + masked: currentFrameNesting, + wWidth: topmostFrame.innerWidth, + wHeight: topmostFrame.innerHeight, + oWidth: topmostFrame.outerWidth, + oHeight: topmostFrame.outerHeight, + sWidth: topmostFrame.screen.width, + sHeight: topmostFrame.screen.height, + aWidth: topmostFrame.screen.availWidth, + aHeight: topmostFrame.screen.availHeight, + sLeft: 'screenLeft' in topmostFrame ? topmostFrame.screenLeft : topmostFrame.screenX, + sTop: 'screenTop' in topmostFrame ? topmostFrame.screenTop : topmostFrame.screenY, + xOffset: topmostFrame.pageXOffset, + yOffset: topmostFrame.pageYOffset, + docHidden: getDocumentVisibility(topmostFrame), hLength: history.length, timing: getTiming() }; @@ -250,10 +253,11 @@ function setGeneralInfo(bidRequest) { function getSpaceCoords(id) { const space = document.getElementById(id); try { + const { top, bottom, left, right } = space.getBoundingClientRect(); + const coords = { top, bottom, left, right }; let window = space.ownerDocument.defaultView; let frame = window.frameElement; - const coords = { top: 0, bottom: 0, left: 0, right: 0 }; - do { + while (frame != null) { const { top, bottom, left, right } = frame.getBoundingClientRect(); coords.top += top + window.pageXOffset; coords.bottom += bottom + window.pageXOffset; @@ -261,9 +265,9 @@ function getSpaceCoords(id) { coords.right += right + window.pageXOffset; window = window.parent; frame = window.frameElement; - } while (window !== window.top); + } return coords; - } catch(e) { + } catch (e) { return null; } } @@ -278,7 +282,7 @@ function getTiming() { timing.renderTime = perf.domComplete - perf.domLoading; return timing; } - } catch(e) { + } catch (e) { return null; } return null; From 765f69d7c5ef60f892682d812154e06577aa3c19 Mon Sep 17 00:00:00 2001 From: Nicola Date: Mon, 22 Jun 2020 17:01:57 +0200 Subject: [PATCH 07/17] Fix space coordinates --- modules/onetagBidAdapter.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 0af18f14f0d..8b205d4c8b3 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -253,16 +253,14 @@ function setGeneralInfo(bidRequest) { function getSpaceCoords(id) { const space = document.getElementById(id); try { - const { top, bottom, left, right } = space.getBoundingClientRect(); - const coords = { top, bottom, left, right }; + const { top, left, width, height } = space.getBoundingClientRect(); + const coords = { top, left, width, height }; let window = space.ownerDocument.defaultView; let frame = window.frameElement; while (frame != null) { - const { top, bottom, left, right } = frame.getBoundingClientRect(); + const { top, left } = frame.getBoundingClientRect(); coords.top += top + window.pageXOffset; - coords.bottom += bottom + window.pageXOffset; coords.left += left + window.pageXOffset; - coords.right += right + window.pageXOffset; window = window.parent; frame = window.frameElement; } From 095abfcb8ee9a16c835264ec5cf93ab1d0fbf777 Mon Sep 17 00:00:00 2001 From: francesco Date: Tue, 23 Jun 2020 16:23:28 +0200 Subject: [PATCH 08/17] Adds bidRequest data --- modules/onetagBidAdapter.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 8b205d4c8b3..74f62390ae6 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -45,7 +45,6 @@ export function isValid(type, bid) { * @param {validBidRequests[]} - an array of bids * @return ServerRequest Info describing the request to the server. */ - function buildRequests(validBidRequests, bidderRequest) { const bids = requestsToBids(validBidRequests); const bidObject = {'bids': bids}; @@ -137,9 +136,6 @@ function ourRenderer(bidResponse) { }); } -/*** - * Returns information about current frame nesting - */ function getFrameNesting() { let frame = window; try { @@ -194,6 +190,7 @@ function getPageInfo() { xOffset: topmostFrame.pageXOffset, yOffset: topmostFrame.pageYOffset, docHidden: getDocumentVisibility(topmostFrame), + docHeight: topmostFrame.document.body.scrollHeight, hLength: history.length, timing: getTiming() }; From 6f54a4008324ea103be356adb90948f43a30cb42 Mon Sep 17 00:00:00 2001 From: valentino Date: Fri, 26 Jun 2020 11:30:09 +0200 Subject: [PATCH 09/17] Updated function interpretResponse --- modules/onetagBidAdapter.js | 67 ++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 74f62390ae6..9c6762641ea 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -90,17 +90,46 @@ function interpretResponse(serverResponse, bidderRequest) { if (!body.bids || !Array.isArray(body.bids) || body.bids.length === 0) { return bids; } - body.bids.forEach(function(bid) { - let responseBid = { - ...bid, + body.bids.forEach(({ + requestId, + cpm, + width, + height, + creativeId, + dealId, + currency, + mediaType, + ttl, + rendererUrl, + ad, + vastUrl, + videoCacheKey + }) => { + const responseBid = { + requestId, + cpm, + width, + height, + creativeId, + dealId: dealId ? dealId : '', + currency, netRevenue: false, + mediaType, + ttl: ttl || 300 }; - responseBid.ttl = responseBid.ttl || 300; - responseBid.dealId = responseBid.dealId || ''; - if (bid.mediaType === VIDEO) { - const videoBid = find(requestData.bids, (item) => item.bidId === bid.requestId); - if (videoBid.context === OUTSTREAM) { - responseBid.renderer = createRenderer(bid); + if (mediaType === BANNER) { + responseBid.ad = ad; + } else if (mediaType === VIDEO) { + const {context, adUnitCode} = find(requestData.bids, (item) => item.bidId === requestId); + if (context === INSTREAM) { + responseBid.vastUrl = vastUrl; + responseBid.videoCacheKey = videoCacheKey; + } else if (context === OUTSTREAM) { + responseBid.vastXml = ad; + responseBid.vastUrl = vastUrl; + if (rendererUrl) { + responseBid.renderer = createRenderer({requestId, rendererUrl, adUnitCode}); + } } } bids.push(responseBid); @@ -117,20 +146,20 @@ function createRenderer(bid, rendererOptions = {}) { loaded: false }); try { - renderer.setRender(ourRenderer); + renderer.setRender(onetagRenderer); } catch (e) { } return renderer; } -function ourRenderer(bidResponse) { - bidResponse.renderer.push(() => { - window.onetag.PlayerStandalone.init({ - width: bidResponse.width, - height: bidResponse.height, - vastXml: bidResponse.vastXml, - nodeId: bidResponse.adUnitCode, +function onetagRenderer({renderer, width, height, vastXml, adUnitCode}) { + renderer.push(() => { + window.onetag.Player.init({ + width, + height, + vastXml, + nodeId: adUnitCode, config: bidResponse.renderer.getConfig() }); }); @@ -251,12 +280,12 @@ function getSpaceCoords(id) { const space = document.getElementById(id); try { const { top, left, width, height } = space.getBoundingClientRect(); - const coords = { top, left, width, height }; let window = space.ownerDocument.defaultView; + const coords = { top: top + window.pageYOffset, left: left + window.pageXOffset, width, height }; let frame = window.frameElement; while (frame != null) { const { top, left } = frame.getBoundingClientRect(); - coords.top += top + window.pageXOffset; + coords.top += top + window.pageYOffset; coords.left += left + window.pageXOffset; window = window.parent; frame = window.frameElement; From 5a7823a059c2931356f7f8170ec925723372368b Mon Sep 17 00:00:00 2001 From: valentino Date: Fri, 26 Jun 2020 16:32:23 +0200 Subject: [PATCH 10/17] Minor bug fixing --- modules/onetagBidAdapter.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 9c6762641ea..599c617d2d3 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -1,7 +1,7 @@ 'use strict'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import { OUTSTREAM } from '../src/video.js'; +import { INSTREAM, OUTSTREAM } from '../src/video.js'; import { Renderer } from '../src/Renderer.js'; import find from 'core-js-pure/features/array/find.js'; const { registerBidder } = require('../src/adapters/bidderFactory.js'); @@ -111,7 +111,7 @@ function interpretResponse(serverResponse, bidderRequest) { width, height, creativeId, - dealId: dealId ? dealId : '', + dealId: dealId == null ? dealId : '', currency, netRevenue: false, mediaType, @@ -160,7 +160,7 @@ function onetagRenderer({renderer, width, height, vastXml, adUnitCode}) { height, vastXml, nodeId: adUnitCode, - config: bidResponse.renderer.getConfig() + config: renderer.getConfig() }); }); } From aa2b798bb900f49fb536d60cb47ca4273358cdcf Mon Sep 17 00:00:00 2001 From: francesco Date: Fri, 26 Jun 2020 18:11:17 +0200 Subject: [PATCH 11/17] Fixes body.scrollHeight call --- modules/onetagBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 599c617d2d3..d938cd9169c 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -219,7 +219,7 @@ function getPageInfo() { xOffset: topmostFrame.pageXOffset, yOffset: topmostFrame.pageYOffset, docHidden: getDocumentVisibility(topmostFrame), - docHeight: topmostFrame.document.body.scrollHeight, + docHeight: topmostFrame.document.body ? topmostFrame.document.body.scrollHeight : null, hLength: history.length, timing: getTiming() }; From 7926a5aed796091b52e867e68790d8e8582ec45a Mon Sep 17 00:00:00 2001 From: francesco Date: Mon, 29 Jun 2020 12:26:23 +0200 Subject: [PATCH 12/17] Removes Object.assign occurrence --- modules/onetagBidAdapter.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index d938cd9169c..1a588f463bc 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -46,33 +46,26 @@ export function isValid(type, bid) { * @return ServerRequest Info describing the request to the server. */ function buildRequests(validBidRequests, bidderRequest) { - const bids = requestsToBids(validBidRequests); - const bidObject = {'bids': bids}; - const pageInfo = getPageInfo(); - - const payload = Object.assign(bidObject, pageInfo); - + const payload = { + bids: requestsToBids(validBidRequests), + ...getPageInfo() + }; if (bidderRequest && bidderRequest.gdprConsent) { payload.gdprConsent = { consentString: bidderRequest.gdprConsent.consentString, consentRequired: bidderRequest.gdprConsent.gdprApplies }; } - if (bidderRequest && bidderRequest.uspConsent) { payload.usPrivacy = bidderRequest.uspConsent; } - if (bidderRequest && bidderRequest.userId) { payload.userId = bidderRequest.userId; } - if (window.localStorage) { payload.onetagSid = window.localStorage.getItem('onetag_sid'); } - const payloadString = JSON.stringify(payload); - return { method: 'POST', url: ENDPOINT, From 757c0267f615fd13bfbd9f67e4bf1e0c27604a24 Mon Sep 17 00:00:00 2001 From: francesco Date: Mon, 29 Jun 2020 16:36:42 +0200 Subject: [PATCH 13/17] Updates test file --- test/spec/modules/onetagBidAdapter_spec.js | 219 ++++++++++++++------- 1 file changed, 147 insertions(+), 72 deletions(-) diff --git a/test/spec/modules/onetagBidAdapter_spec.js b/test/spec/modules/onetagBidAdapter_spec.js index 2b31c875502..aed08738486 100644 --- a/test/spec/modules/onetagBidAdapter_spec.js +++ b/test/spec/modules/onetagBidAdapter_spec.js @@ -1,6 +1,8 @@ import { spec, isValid, hasTypeVideo } from 'modules/onetagBidAdapter.js'; import { expect } from 'chai'; +import find from 'core-js-pure/features/array/find.js'; import { BANNER, VIDEO } from 'src/mediaTypes.js'; +import {INSTREAM, OUTSTREAM} from 'src/video.js'; describe('onetag', function () { function createBid() { @@ -26,7 +28,7 @@ describe('onetag', function () { return bid; } - function createVideoBid(bidRequest) { + function createInstreamVideoBid(bidRequest) { const bid = bidRequest || createBid(); bid.mediaTypes = bid.mediaTypes || {}; bid.mediaTypes.video = { @@ -37,7 +39,7 @@ describe('onetag', function () { return bid; } - function createWrongVideoOutstreamBid(bidRequest) { + function createOutstreamVideoBid(bidRequest) { const bid = bidRequest || createBid(); bid.mediaTypes = bid.mediaTypes || {}; bid.mediaTypes.video = { @@ -49,12 +51,12 @@ describe('onetag', function () { } function createMultiFormatBid() { - return createVideoBid(createBannerBid()); + return createInstreamVideoBid(createBannerBid()); } const bannerBid = createBannerBid(); - const videoBid = createVideoBid(); - const outstreamVideoBid = createWrongVideoOutstreamBid(); + const instreamVideoBid = createInstreamVideoBid(); + const outstreamVideoBid = createOutstreamVideoBid(); describe('isBidRequestValid', function () { it('Should return true when required params are found', function () { @@ -76,30 +78,30 @@ describe('onetag', function () { }); describe('video bidRequest', function () { it('Should return false when the context is undefined', function () { - videoBid.mediaTypes.video.context = undefined; - expect(spec.isBidRequestValid(videoBid)).to.be.false; + instreamVideoBid.mediaTypes.video.context = undefined; + expect(spec.isBidRequestValid(instreamVideoBid)).to.be.false; }); it('Should return false when the context is not instream or outstream', function () { - videoBid.mediaTypes.video.context = 'wrong'; - expect(spec.isBidRequestValid(videoBid)).to.be.false; + instreamVideoBid.mediaTypes.video.context = 'wrong'; + expect(spec.isBidRequestValid(instreamVideoBid)).to.be.false; }); it('Should return false when playerSize is undefined', function () { - const videoBid = createVideoBid(); + const videoBid = createInstreamVideoBid(); videoBid.mediaTypes.video.playerSize = undefined; expect(spec.isBidRequestValid(videoBid)).to.be.false; }); it('Should return false when playerSize is not an array', function () { - const videoBid = createVideoBid(); + const videoBid = createInstreamVideoBid(); videoBid.mediaTypes.video.playerSize = 30; expect(spec.isBidRequestValid(videoBid)).to.be.false; }); it('Should return false when playerSize is an empty array', function () { - const videoBid = createVideoBid(); + const videoBid = createInstreamVideoBid(); videoBid.mediaTypes.video.playerSize = []; expect(spec.isBidRequestValid(videoBid)).to.be.false; }); - it('Should return false when context is outstream but no renderer object is defined', function () { - expect(spec.isBidRequestValid(outstreamVideoBid)).to.be.false; + it('Should return true when context is outstream', function () { + expect(spec.isBidRequestValid(outstreamVideoBid)).to.be.true; }); }); describe('multi format bidRequest', function () { @@ -111,7 +113,7 @@ describe('onetag', function () { }); describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bannerBid, videoBid]); + let serverRequest = spec.buildRequests([bannerBid, instreamVideoBid]); it('Creates a ServerRequest object with method, URL and data', function () { expect(serverRequest).to.exist; expect(serverRequest.method).to.exist; @@ -128,9 +130,9 @@ describe('onetag', function () { const d = serverRequest.data; try { const data = JSON.parse(d); - it('Should contains all keys', function () { + it('Should contain all keys', function () { expect(data).to.be.an('object'); - expect(data).to.have.all.keys('location', 'masked', 'referrer', 'sHeight', 'sWidth', 'timeOffset', 'date', 'wHeight', 'wWidth', 'oHeight', 'oWidth', 'aWidth', 'aHeight', 'sLeft', 'sTop', 'hLength', 'bids', 'docHidden', 'xOffset', 'yOffset'); + expect(data).to.include.all.keys('location', 'referrer', 'masked', 'sHeight', 'sWidth', 'docHeight', 'wHeight', 'wWidth', 'oHeight', 'oWidth', 'aWidth', 'aHeight', 'sLeft', 'sTop', 'hLength', 'bids', 'docHidden', 'xOffset', 'yOffset', 'onetagSid'); expect(data.location).to.be.a('string'); expect(data.masked).to.be.a('number'); expect(data.referrer).to.be.a('string'); @@ -145,10 +147,7 @@ describe('onetag', function () { expect(data.sLeft).to.be.a('number'); expect(data.sTop).to.be.a('number'); expect(data.hLength).to.be.a('number'); - expect(data.timeOffset).to.be.a('number'); - expect(data.date).to.be.a('string'); expect(data.bids).to.be.an('array'); - const bids = data['bids']; for (let i = 0; i < bids.length; i++) { const bid = bids[i]; @@ -190,7 +189,7 @@ describe('onetag', function () { expect(payload.gdprConsent.consentString).to.exist.and.to.equal(consentString); expect(payload.gdprConsent.consentRequired).to.exist.and.to.be.true; }); - it('should send us privacy string', function () { + it('Should send us privacy string', function () { let consentString = 'us_foo'; let bidderRequest = { 'bidderCode': 'onetag', @@ -207,70 +206,44 @@ describe('onetag', function () { }); }); describe('interpretResponse', function () { - function getBannerRes() { - return { - ad: '
Advertising
', - cpm: 13, - width: 300, - height: 250, - creativeId: '1820', - dealId: 'dishfo', - currency: 'USD', - requestId: 'sdiceobxcw', - mediaType: BANNER - } - } - function getVideoRes() { - return { - ad: '', - cpm: 13, - width: 300, - height: 250, - creativeId: '1820', - dealId: 'dishfo', - currency: 'USD', - requestId: 'sdiceobxcw', - mediaType: VIDEO - } - } - function getBannerAdnVideoRes() { - return { - body: { - nobid: false, - bids: [getBannerRes(), getVideoRes()] - } - }; - } - const responseObj = getBannerAdnVideoRes(); + const request = getBannerVideoRequest(); + const response = getBannerVideoResponse(); + const requestData = JSON.parse(request.data); it('Returns an array of valid server responses if response object is valid', function () { - const serverResponses = spec.interpretResponse(responseObj); - - expect(serverResponses).to.be.an('array').that.is.not.empty; - for (let i = 0; i < serverResponses.length; i++) { - let dataItem = serverResponses[i]; + const interpretedResponse = spec.interpretResponse(response, request); + expect(interpretedResponse).to.be.an('array').that.is.not.empty; + for (let i = 0; i < interpretedResponse.length; i++) { + let dataItem = interpretedResponse[i]; + expect(dataItem).to.include.all.keys('requestId', 'cpm', 'width', 'height', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'dealId'); if (dataItem.mediaType === VIDEO) { - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'vastXml', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'dealId'); + const {context} = find(requestData.bids, (item) => item.bidId === dataItem.requestId); + if (context === INSTREAM) { + expect(dataItem).to.include.all.keys('videoCacheKey', 'vastUrl'); + expect(dataItem.vastUrl).to.be.a('string'); + expect(dataItem.videoCacheKey).to.be.a('string'); + } else if (context === OUTSTREAM) { + expect(dataItem).to.include.all.keys('renderer', 'vastXml', 'vastUrl'); + expect(dataItem.renderer).to.be.an('object'); + expect(dataItem.vastUrl).to.be.a('string'); + expect(dataItem.vastXml).to.be.a('string'); + } } else if (dataItem.mediaType === BANNER) { - expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'dealId'); + expect(dataItem).to.include.all.keys('ad'); + expect(dataItem.ad).to.be.a('string'); } expect(dataItem.requestId).to.be.a('string'); expect(dataItem.cpm).to.be.a('number'); expect(dataItem.width).to.be.a('number'); expect(dataItem.height).to.be.a('number'); - if (dataItem.mediaType === VIDEO) { - expect(dataItem.vastXml).to.be.a('string'); - } else if (dataItem.mediaType === BANNER) { - expect(dataItem.ad).to.be.a('string'); - } expect(dataItem.ttl).to.be.a('number'); expect(dataItem.creativeId).to.be.a('string'); expect(dataItem.netRevenue).to.be.a('boolean'); expect(dataItem.currency).to.be.a('string'); } - it('Returns an empty array if invalid response is passed', function () { - const serverResponses = spec.interpretResponse('invalid_response'); - expect(serverResponses).to.be.an('array').that.is.empty; - }); + }); + it('Returns an empty array if response is not valid', function () { + const serverResponses = spec.interpretResponse('invalid_response', { data: '{}' }); + expect(serverResponses).to.be.an('array').that.is.empty; }); }); describe('getUserSyncs', function () { @@ -333,3 +306,105 @@ describe('onetag', function () { }); }); }); + +function getBannerVideoResponse() { + return { + body: { + nobid: false, + bids: [ + { + ad: '
Advertising
', + cpm: 13, + width: 300, + height: 250, + creativeId: '1820', + dealId: 'dishfo', + currency: 'USD', + requestId: 'banner', + mediaType: BANNER, + }, + { + cpm: 13, + width: 300, + height: 250, + creativeId: '1820', + dealId: 'dishfo', + currency: 'USD', + requestId: 'videoInstream', + vastUrl: 'https://videoinstream.org', + videoCacheKey: 'key', + mediaType: VIDEO + }, + { + cpm: 13, + width: 300, + height: 250, + creativeId: '1820', + dealId: 'dishfo', + currency: 'USD', + vastUrl: 'https://videooutstream.org', + requestId: 'videoOutstream', + ad: '', + rendererUrl: 'https://testRenderer', + mediaType: VIDEO + } + ] + } + }; +} + +function getBannerVideoRequest() { + return { + data: JSON.stringify({ + bids: [ + { + adUnitCode: 'target-div', + bidId: 'videoOutstream', + bidderRequestId: '12bb1e0f9fb669', + auctionId: '80784b4d-79ad-49ef-a006-75d8888b7609', + transactionId: '5f132731-3091-49b2-8fab-0e9c917733bc', + pubId: '386276e072', + context: 'outstream', + mimes: [], + playerSize: [], + type: 'video' + }, + { + adUnitCode: 'target-div', + bidId: 'videoInstream', + bidderRequestId: '12bb1e0f9fb669', + auctionId: '80784b4d-79ad-49ef-a006-75d8888b7609', + transactionId: '5f132731-3091-49b2-8fab-0e9c917733bc', + pubId: '386276e072', + context: 'instream', + mimes: [], + playerSize: [], + type: 'video' + } + ], + location: 'https%3A%2F%2Flocal.onetag.net%3A9000%2Fv2%2Fprebid-video%2Fvideo.html%3Fpbjs_debug%3Dtrue', + referrer: '0', + masked: 0, + wWidth: 860, + wHeight: 949, + oWidth: 1853, + oHeight: 1053, + sWidth: 1920, + sHeight: 1080, + aWidth: 1920, + aHeight: 1053, + sLeft: 1987, + sTop: 27, + xOffset: 0, + yOffset: 0, + docHidden: false, + hLength: 2, + timing: { + pageLoadTime: -1593433770022, + connectTime: 42, + renderTime: -1593433770092 + }, + onetagSid: 'user_id' + }) + } +} From bf72830d8b83fbd0d99fb8539b5e596483bf7365 Mon Sep 17 00:00:00 2001 From: valentino Date: Mon, 29 Jun 2020 16:46:05 +0200 Subject: [PATCH 14/17] Updated payload in request --- modules/onetagBidAdapter.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 1a588f463bc..c58f60d35f9 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -260,9 +260,6 @@ function setGeneralInfo(bidRequest) { if (params.dealId) { this['dealId'] = params.dealId; } - if (params.floor) { - this['floor'] = params.floor; - } const coords = getSpaceCoords(bidRequest.adUnitCode); if (coords) { this['coords'] = coords; From 8a16572e0b87b61a13f5bc039b05a1bb913faa53 Mon Sep 17 00:00:00 2001 From: francesco Date: Mon, 29 Jun 2020 18:49:30 +0200 Subject: [PATCH 15/17] Fixes user sync query string --- modules/onetagBidAdapter.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index c58f60d35f9..8713342c628 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -344,12 +344,9 @@ function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { params += '&us_privacy=' + uspConsent; } if (syncOptions.iframeEnabled) { - const rnd = new Date().getTime(); - params = '?cb=' + rnd + params; - syncs.push({ type: 'iframe', - url: USER_SYNC_ENDPOINT + params + url: USER_SYNC_ENDPOINT + '?cb=' + new Date().getTime() + params }); } if (syncOptions.pixelEnabled) { From 4ce8319a39cdff5157043836c41236f195f9a70f Mon Sep 17 00:00:00 2001 From: valentino Date: Fri, 3 Jul 2020 20:07:25 +0200 Subject: [PATCH 16/17] Sets mediaType into meta field within bidResponse object --- modules/onetagBidAdapter.js | 4 +++- test/spec/modules/onetagBidAdapter_spec.js | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 8713342c628..6280dd12268 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -107,7 +107,9 @@ function interpretResponse(serverResponse, bidderRequest) { dealId: dealId == null ? dealId : '', currency, netRevenue: false, - mediaType, + meta: { + mediaType + }, ttl: ttl || 300 }; if (mediaType === BANNER) { diff --git a/test/spec/modules/onetagBidAdapter_spec.js b/test/spec/modules/onetagBidAdapter_spec.js index aed08738486..a951c74b20b 100644 --- a/test/spec/modules/onetagBidAdapter_spec.js +++ b/test/spec/modules/onetagBidAdapter_spec.js @@ -214,8 +214,8 @@ describe('onetag', function () { expect(interpretedResponse).to.be.an('array').that.is.not.empty; for (let i = 0; i < interpretedResponse.length; i++) { let dataItem = interpretedResponse[i]; - expect(dataItem).to.include.all.keys('requestId', 'cpm', 'width', 'height', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'dealId'); - if (dataItem.mediaType === VIDEO) { + expect(dataItem).to.include.all.keys('requestId', 'cpm', 'width', 'height', 'ttl', 'creativeId', 'netRevenue', 'currency', 'meta', 'dealId'); + if (dataItem.meta.mediaType === VIDEO) { const {context} = find(requestData.bids, (item) => item.bidId === dataItem.requestId); if (context === INSTREAM) { expect(dataItem).to.include.all.keys('videoCacheKey', 'vastUrl'); @@ -227,7 +227,7 @@ describe('onetag', function () { expect(dataItem.vastUrl).to.be.a('string'); expect(dataItem.vastXml).to.be.a('string'); } - } else if (dataItem.mediaType === BANNER) { + } else if (dataItem.meta.mediaType === BANNER) { expect(dataItem).to.include.all.keys('ad'); expect(dataItem.ad).to.be.a('string'); } From c5f39903a04b449fa9d163cfc76e28614f75b377 Mon Sep 17 00:00:00 2001 From: valentino Date: Mon, 6 Jul 2020 14:43:05 +0200 Subject: [PATCH 17/17] Update documentation in md file --- modules/onetagBidAdapter.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/onetagBidAdapter.md b/modules/onetagBidAdapter.md index 9757be4d440..7814403afbe 100644 --- a/modules/onetagBidAdapter.md +++ b/modules/onetagBidAdapter.md @@ -27,7 +27,7 @@ OneTag Bid Adapter supports banner and video at present. } }] }, { - code: 'video-space', + code: 'video-instream-space', mediaTypes: { video: { context: "instream", @@ -41,6 +41,20 @@ OneTag Bid Adapter supports banner and video at present. pubId: "your_publisher_id" // required, testing pubId: "386276e072" } }] + }, { + code: 'video-outstream-space', + mediaTypes: { + video: { + context: "outstream", + playerSize: [640,480] + } + }, + bids: [{ + bidder: "onetag", + params: { + pubId: "your_publisher_id" // required, testing pubId: "386276e072" + } + }] }]; ```