diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 2ecab4013f9..8bb084a7aeb 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -27,8 +27,8 @@ function _createBidResponse(response) { } } -function _isViewabilityMeasurable() { - return !_isIframe(); +function _isViewabilityMeasurable(element) { + return !_isIframe() && element !== null; } function _getViewability(element, topWin, { w, h } = {}) { @@ -46,12 +46,16 @@ function _createServerRequest(bidRequest, gdprConsent) { const sizes = _transformSizes(bidRequest.sizes); const minSize = _getMinSize(sizes); - const viewabilityAmount = _isViewabilityMeasurable() + const viewabilityAmount = _isViewabilityMeasurable(element) ? _getViewability(element, utils.getWindowTop(), minSize) : NON_MEASURABLE; const contributeViewability = ViewabilityContributor(viewabilityAmount); + if (element === null) { + utils.logWarn(`Unable to locate element with id: '${bidRequest.adUnitCode}'`); + } + /* * Infer data for the request payload */ @@ -90,7 +94,7 @@ function _createServerRequest(bidRequest, gdprConsent) { 'version': '$prebid.version$' }] } - } + }; // Finally, set the openRTB 'test' param if this is to be a test bid if (params.test === 1) { diff --git a/src/utils.js b/src/utils.js index 843c0c11c76..ce3897392c1 100644 --- a/src/utils.js +++ b/src/utils.js @@ -124,7 +124,7 @@ exports.transformAdServerTargetingObj = function (targeting) { * Read an adUnit object and return the sizes used in an [[728, 90]] format (even if they had [728, 90] defined) * Preference is given to the `adUnit.mediaTypes.banner.sizes` object over the `adUnit.sizes` * @param {object} adUnit one adUnit object from the normal list of adUnits - * @returns {array[array[number]]} array of arrays containing numeric sizes + * @returns {Array.} array of arrays containing numeric sizes */ export function getAdUnitSizes(adUnit) { if (!adUnit) { @@ -151,8 +151,8 @@ export function getAdUnitSizes(adUnit) { /** * Parse a GPT-Style general size Array like `[[300, 250]]` or `"300x250,970x90"` into an array of sizes `["300x250"]` or '['300x250', '970x90']' - * @param {array[array|number]} sizeObj Input array or double array [300,250] or [[300,250], [728,90]] - * @return {array[string]} Array of strings like `["300x250"]` or `["300x250", "728x90"]` + * @param {(Array.|Array.)} sizeObj Input array or double array [300,250] or [[300,250], [728,90]] + * @return {Array.} Array of strings like `["300x250"]` or `["300x250", "728x90"]` */ export function parseSizesInput(sizeObj) { var parsedSizes = []; @@ -190,7 +190,7 @@ export function parseSizesInput(sizeObj) { } return parsedSizes; -}; +} // parse a GPT style sigle size array, (i.e [300,250]) // into an AppNexus style string, (i.e. 300x250) @@ -199,7 +199,7 @@ export function parseGPTSingleSizeArray(singleSize) { if (exports.isArray(singleSize) && singleSize.length === 2 && (!isNaN(singleSize[0]) && !isNaN(singleSize[1]))) { return singleSize[0] + 'x' + singleSize[1]; } -}; +} /** * @deprecated This function will be removed soon. Use http://prebid.org/dev-docs/bidder-adaptor.html#referrers @@ -215,7 +215,7 @@ exports.getTopWindowLocation = function() { if (loc) return parse(loc, {'decodeSearchAsString': true}); } return exports.getWindowLocation(); -} +}; /** * @deprecated This function will be removed soon. Use http://prebid.org/dev-docs/bidder-adaptor.html#referrers @@ -375,9 +375,9 @@ exports.getParameterByName = getParameterByName; /** * This function validates paramaters. - * @param {object[string]} paramObj [description] + * @param {Object} paramObj [description] * @param {string[]} requiredParamsArr [description] - * @return {bool} Bool if paramaters are valid + * @return {boolean} Bool if paramaters are valid */ exports.hasValidBidRequest = function (paramObj, requiredParamsArr, adapter) { var found = false; @@ -439,11 +439,11 @@ exports.isNumber = function(object) { exports.isPlainObject = function(object) { return exports.isA(object, tObject); -} +}; exports.isBoolean = function(object) { return exports.isA(object, tBoolean); -} +}; /** * Return if the object is "empty"; @@ -669,8 +669,8 @@ exports.createTrackPixelIframeHtml = function (url, encodeUri = true, sandbox = /** * Returns iframe document in a browser agnostic way - * @param {object} iframe reference - * @return {object} iframe `document` reference + * @param {Object} iframe reference + * @return {Object} iframe `document` reference */ exports.getIframeDocument = function (iframe) { if (!iframe) { @@ -874,7 +874,7 @@ export function delayExecution(func, numRequiredCalls) { * @export * @param {array} xs * @param {string} key - * @returns {${key_value}: ${groupByArray}, key_value: {groupByArray}} + * @returns {Object} {${key_value}: ${groupByArray}, key_value: {groupByArray}} */ export function groupBy(xs, key) { return xs.reduce(function(rv, x) { @@ -885,7 +885,7 @@ export function groupBy(xs, key) { /** * deepAccess utility function useful for doing safe access (will not throw exceptions) of deep object paths. - * @param {object} obj The object containing the values you would like to access. + * @param {Object} obj The object containing the values you would like to access. * @param {string|number} path Object path to the value you would like to access. Non-strings are coerced to strings. * @returns {*} The value found at the specified object path, or undefined if path is not found. */ @@ -905,7 +905,7 @@ export function deepAccess(obj, path) { /** * Returns content for a friendly iframe to execute a URL in script tag - * @param {url} URL to be executed in a script tag in a friendly iframe + * @param {string} url URL to be executed in a script tag in a friendly iframe * and are macros left to be replaced if required */ export function createContentToExecuteExtScriptInFriendlyFrame(url) { @@ -919,9 +919,9 @@ export function createContentToExecuteExtScriptInFriendlyFrame(url) { /** * Build an object consisting of only defined parameters to avoid creating an * object with defined keys and undefined values. - * @param {object} object The object to pick defined params out of + * @param {Object} object The object to pick defined params out of * @param {string[]} params An array of strings representing properties to look for in the object - * @returns {object} An object containing all the specified values that are defined + * @returns {Object} An object containing all the specified values that are defined */ export function getDefinedParams(object, params) { return params @@ -966,8 +966,8 @@ export function getBidderRequest(bidRequests, bidder, adUnitCode) { } /** * Returns user configured bidder params from adunit - * @param {object} adunits - * @param {string} adunit code + * @param {Object} adUnits + * @param {string} adUnitCode code * @param {string} bidder code * @return {Array} user configured param for the given bidder adunit configuration */ @@ -1002,7 +1002,7 @@ const compareCodeAndSlot = (slot, adUnitCode) => slot.getAdUnitPath() === adUnit /** * Returns filter function to match adUnitCode in slot - * @param {object} slot GoogleTag slot + * @param {Object} slot GoogleTag slot * @return {function} filter function */ export function isAdUnitCodeMatchingSlot(slot) { @@ -1041,9 +1041,9 @@ export function unsupportedBidderMessage(adUnit, bidder) { * @return {Object} object */ export function deletePropertyFromObject(object, prop) { - let result = Object.assign({}, object) + let result = Object.assign({}, object); delete result[prop]; - return result + return result; } /** @@ -1081,7 +1081,7 @@ export function convertCamelToUnderscore(value) { * normally read from bidder params * eg { foo: ['bar', 'baz'], fizz: ['buzz'] } * becomes [{ key: 'foo', value: ['bar', 'baz']}, {key: 'fizz', value: ['buzz']}] - * @param {Object{Arrays}} keywords object of arrays representing keyvalue pairs + * @param {Object} keywords object of arrays representing keyvalue pairs * @param {string} paramName name of parent object (eg 'keywords') containing keyword data, used in error handling */ export function transformBidderParamKeywords(keywords, paramName = 'keywords') {