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

Oculus 68 map ad slot path to element #18

Merged
merged 2 commits into from
Nov 15, 2018
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
12 changes: 8 additions & 4 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ function _createBidResponse(response) {
}
}

function _isViewabilityMeasurable() {
return !_isIframe();
function _isViewabilityMeasurable(element) {
return !_isIframe() && element !== null;
}

function _getViewability(element, topWin, { w, h } = {}) {
Expand All @@ -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
*/
Expand Down Expand Up @@ -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) {
Expand Down
46 changes: 23 additions & 23 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.<number[]>} array of arrays containing numeric sizes
*/
export function getAdUnitSizes(adUnit) {
if (!adUnit) {
Expand All @@ -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.<number[]>|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"]`
*/
export function parseSizesInput(sizeObj) {
var parsedSizes = [];
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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.
*/
Expand All @@ -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
* <!--PRE_SCRIPT_TAG_MACRO--> and <!--POST_SCRIPT_TAG_MACRO--> are macros left to be replaced if required
*/
export function createContentToExecuteExtScriptInFriendlyFrame(url) {
Expand All @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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') {
Expand Down