diff --git a/modules/oxxionRtdProvider.js b/modules/oxxionRtdProvider.js index b4964818ddf..6d5ad6906ba 100644 --- a/modules/oxxionRtdProvider.js +++ b/modules/oxxionRtdProvider.js @@ -1,20 +1,24 @@ import { submodule } from '../src/hook.js' import { deepAccess, logInfo } from '../src/utils.js' +import MD5 from 'crypto-js/md5.js'; +// import { ajax } from '../src/ajax.js'; const oxxionRtdSearchFor = [ 'adUnitCode', 'auctionId', 'bidder', 'bidderCode', 'bidId', 'cpm', 'creativeId', 'currency', 'width', 'height', 'mediaType', 'netRevenue', 'originalCpm', 'originalCurrency', 'requestId', 'size', 'source', 'status', 'timeToRespond', 'transactionId', 'ttl', 'sizes', 'mediaTypes', 'src', 'userId', 'labelAny', 'adId' ]; const LOG_PREFIX = 'oxxionRtdProvider submodule: '; - +const CHECK_INTEREST_URL = 'http://wwww.interest.com/api/'; const allAdUnits = []; /** @type {RtdSubmodule} */ export const oxxionSubmodule = { name: 'oxxionRtd', init: init, + onAuctionInitEvent: onAuctionInit, onAuctionEndEvent: onAuctionEnd, getBidRequestData: getAdUnits, }; function init(config, userConsent) { + logInfo(LOG_PREFIX, 'init()', config, userConsent); if (!config.params || !config.params.domain || !config.params.contexts || !Array.isArray(config.params.contexts) || config.params.contexts.length == 0) { return false } @@ -32,6 +36,35 @@ function getAdUnits(reqBidsConfigObj, callback, config, userConsent) { } } +function onAuctionInit (auctionDetails, config, userConsent) { + logInfo(LOG_PREFIX, 'onAuctionInit()', { + auctionDetails, + config, + userConsent + }); + const { keys } = Object; + const { stringify } = JSON; + const gdpr = userConsent.gdpr.consentString; + let index = 0; + const requests = auctionDetails.adUnits.flatMap(({ bids = [], mediaTypes = [], code = '' }) => { + return bids.flatMap(({ bidder, params = {} }) => { + return keys(mediaTypes).map((mediaTypeKey) => ({ + id: index++, + adUnit: code, + bidder, + mediaType: mediaTypeKey, + params: MD5(stringify(params)).toString(), + sizes: mediaTypes[mediaTypeKey].sizes || [] + })); + }); + }); + const payload = { + gdpr, + requests + }; + logInfo(LOG_PREFIX, 'onAuctionInit() payload', payload); +} + function insertVideoTracking(bidResponse, config, maxCpm) { if (bidResponse.mediaType === 'video') { const trackingUrl = getImpUrl(config, bidResponse, maxCpm); @@ -116,4 +149,22 @@ function onAuctionEnd(auctionDetails, config, userConsent) { }); } +function getPromisifiedAjax (url, data = {}, options = {}) { + return new Promise((resolve, reject) => { + const callbacks = { + success(responseText, { response }) { + resolve(JSON.parse(response)); + }, + error(error) { + reject(error); + } + }; + ajax(url, callbacks, data, options); + }) +} + +function getRandomNumber (max) { + return Math.round(Math.random() * max); +} + submodule('realTimeData', oxxionSubmodule); diff --git a/package.json b/package.json index 4b52267af26..07b89bdf088 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "header bidding", "prebid" ], - "globalVarName": "pbjs", + "globalVarName": "msq_pbjs", "author": "the prebid.js contributors", "license": "Apache-2.0", "engines": {