diff --git a/PR_REVIEW.md b/PR_REVIEW.md
index 45ca30a7a3d..9deac9963fb 100644
--- a/PR_REVIEW.md
+++ b/PR_REVIEW.md
@@ -55,7 +55,6 @@ Follow steps above for general review process. In addition, please verify the fo
- Adapters that accept a floor parameter must also support the [floors module](https://docs.prebid.org/dev-docs/modules/floors.html) -- look for a call to the `getFloor()` function.
- Adapters cannot accept an schain parameter. Rather, they must look for the schain parameter at bidRequest.schain.
- The bidderRequest.refererInfo.referer must be checked in addition to any bidder-specific parameter.
- - If they're getting the COPPA flag, it must come from config.getConfig('coppa');
- Page position must come from bidrequest.mediaTypes.banner.pos or bidrequest.mediaTypes.video.pos
- Global OpenRTB fields should come from [getConfig('ortb2');](https://docs.prebid.org/dev-docs/publisher-api-reference/setConfig.html#setConfig-fpd):
- bcat, battr, badv
diff --git a/features.json b/features.json
index ccb2166a05f..4d8377cda7d 100644
--- a/features.json
+++ b/features.json
@@ -1,4 +1,5 @@
[
"NATIVE",
- "VIDEO"
+ "VIDEO",
+ "UID2_CSTG"
]
diff --git a/gulpfile.js b/gulpfile.js
index 09de874e389..5e16af8b0c1 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -158,6 +158,20 @@ function makeWebpackPkg(extraConfig = {}) {
}
}
+function buildCreative() {
+ return gulp.src(['**/*'])
+ .pipe(webpackStream(require('./webpack.creative.js')))
+ .pipe(gulp.dest('build/creative'))
+}
+
+function updateCreativeExample(cb) {
+ const CREATIVE_EXAMPLE = 'integrationExamples/gpt/x-domain/creative.html';
+ const root = require('node-html-parser').parse(fs.readFileSync(CREATIVE_EXAMPLE));
+ root.querySelectorAll('script')[0].textContent = fs.readFileSync('build/creative/creative.js')
+ fs.writeFileSync(CREATIVE_EXAMPLE, root.toString())
+ cb();
+}
+
function getModulesListToAddInBanner(modules) {
if (!modules || modules.length === helpers.getModuleNames().length) {
return 'All available modules for this version.'
@@ -405,6 +419,7 @@ function watchTaskMaker(options = {}) {
return function watch(done) {
var mainWatcher = gulp.watch([
'src/**/*.js',
+ 'libraries/**/*.js',
'modules/**/*.js',
].concat(options.alsoWatch));
@@ -415,8 +430,8 @@ function watchTaskMaker(options = {}) {
}
}
-const watch = watchTaskMaker({alsoWatch: ['test/**/*.js'], task: () => gulp.series(clean, gulp.parallel(lint, 'build-bundle-dev', test))});
-const watchFast = watchTaskMaker({livereload: false, task: () => gulp.series('build-bundle-dev')});
+const watch = watchTaskMaker({alsoWatch: ['test/**/*.js'], task: () => gulp.series(clean, gulp.parallel(lint, 'build-bundle-dev', test, buildCreative))});
+const watchFast = watchTaskMaker({livereload: false, task: () => gulp.parallel('build-bundle-dev', buildCreative)});
// support tasks
gulp.task(lint);
@@ -447,21 +462,23 @@ gulp.task('build-bundle-verbose', gulp.series(makeWebpackPkg({
}
}), gulpBundle.bind(null, false)));
+gulp.task('build-creative', gulp.series(buildCreative, updateCreativeExample));
+
// public tasks (dependencies are needed for each task since they can be ran on their own)
gulp.task('test-only', test);
gulp.task('test-all-features-disabled', testTaskMaker({disableFeatures: require('./features.json'), oneBrowser: 'chrome', watch: false}));
-gulp.task('test', gulp.series(clean, lint, gulp.series('test-all-features-disabled', 'test-only')));
+gulp.task('test', gulp.series(clean, lint, gulp.parallel('build-creative', gulp.series('test-all-features-disabled', 'test-only'))));
gulp.task('test-coverage', gulp.series(clean, testCoverage));
gulp.task(viewCoverage);
gulp.task('coveralls', gulp.series('test-coverage', coveralls));
-gulp.task('build', gulp.series(clean, 'build-bundle-prod'));
+gulp.task('build', gulp.series(clean, 'build-bundle-prod', 'build-creative'));
gulp.task('build-postbid', gulp.series(escapePostbidConfig, buildPostbid));
gulp.task('serve', gulp.series(clean, lint, gulp.parallel('build-bundle-dev', watch, test)));
-gulp.task('serve-fast', gulp.series(clean, gulp.parallel('build-bundle-dev', watchFast)));
+gulp.task('serve-fast', gulp.series(clean, gulp.parallel('build-bundle-dev', buildCreative, watchFast)));
gulp.task('serve-prod', gulp.series(clean, gulp.parallel('build-bundle-prod', startLocalServer)));
gulp.task('serve-and-test', gulp.series(clean, gulp.parallel('build-bundle-dev', watchFast, testTaskMaker({watch: true}))));
gulp.task('serve-e2e', gulp.series(clean, 'build-bundle-prod', gulp.parallel(() => startIntegServer(), startLocalServer)));
diff --git a/integrationExamples/gpt/tpmn_example.html b/integrationExamples/gpt/tpmn_example.html
new file mode 100644
index 00000000000..f215181c7e0
--- /dev/null
+++ b/integrationExamples/gpt/tpmn_example.html
@@ -0,0 +1,168 @@
+
+
+
+
+ Prebid.js Banner Example
+
+
+
+
+
+
+
+
+
+
+ Prebid.js TPMN Banner Example
+
+
+
+
+ Prebid.js TPMN Video Example
+
+
+
+
+
+
diff --git a/integrationExamples/gpt/tpmn_serverless_example.html b/integrationExamples/gpt/tpmn_serverless_example.html
new file mode 100644
index 00000000000..0acaefbeb9c
--- /dev/null
+++ b/integrationExamples/gpt/tpmn_serverless_example.html
@@ -0,0 +1,121 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+Ad Serverless Test Page
+
+
+
+
+
+
diff --git a/integrationExamples/gpt/x-domain/creative.html b/integrationExamples/gpt/x-domain/creative.html
index 2216d0ed6ae..f1c0c647e72 100644
--- a/integrationExamples/gpt/x-domain/creative.html
+++ b/integrationExamples/gpt/x-domain/creative.html
@@ -1,105 +1,13 @@
-
-}
-
-
-function requestAdFromPrebid() {
- const message = JSON.stringify({
- message: 'Prebid Request',
- adId
- });
- const channel = new MessageChannel();
- channel.port1.onmessage = renderAd;
- window.parent.postMessage(message, publisherDomain, [channel.port2]);
-}
-
-function listenAdFromPrebid() {
- window.addEventListener('message', receiveMessage, false);
-}
-
-listenAdFromPrebid();
-requestAdFromPrebid();
+
diff --git a/libraries/creativeRender/constants.js b/libraries/creativeRender/constants.js
new file mode 100644
index 00000000000..7b67f8ed5cd
--- /dev/null
+++ b/libraries/creativeRender/constants.js
@@ -0,0 +1,10 @@
+import events from '../../src/constants.json';
+
+export const PREBID_NATIVE = 'Prebid Native';
+export const PREBID_REQUEST = 'Prebid Request';
+export const PREBID_RESPONSE = 'Prebid Response';
+export const PREBID_EVENT = 'Prebid Event';
+export const AD_RENDER_SUCCEEDED = events.EVENTS.AD_RENDER_SUCCEEDED;
+export const AD_RENDER_FAILED = events.EVENTS.AD_RENDER_FAILED;
+export const NO_AD = events.AD_RENDER_FAILED_REASON.NO_AD;
+export const EXCEPTION = events.AD_RENDER_FAILED_REASON.EXCEPTION;
diff --git a/libraries/creativeRender/crossDomain.js b/libraries/creativeRender/crossDomain.js
new file mode 100644
index 00000000000..ffa8b468f12
--- /dev/null
+++ b/libraries/creativeRender/crossDomain.js
@@ -0,0 +1,57 @@
+import {mkFrame, writeAd} from './writer.js';
+import {
+ AD_RENDER_FAILED,
+ AD_RENDER_SUCCEEDED,
+ PREBID_EVENT,
+ PREBID_RESPONSE,
+ PREBID_REQUEST,
+ EXCEPTION
+} from './constants.js';
+
+export function renderer(win = window) {
+ return function ({adId, pubUrl, clickUrl}) {
+ const pubDomain = (function() {
+ const a = win.document.createElement('a');
+ a.href = pubUrl;
+ return a.protocol + '//' + a.host;
+ })();
+ function sendMessage(type, payload, transfer) {
+ win.parent.postMessage(JSON.stringify(Object.assign({message: type, adId}, payload)), pubDomain, transfer);
+ }
+ function cb(err) {
+ sendMessage(PREBID_EVENT, {
+ event: err == null ? AD_RENDER_SUCCEEDED : AD_RENDER_FAILED,
+ info: err
+ });
+ }
+ function onMessage(ev) {
+ let data = {};
+ try {
+ data = JSON.parse(ev[ev.message ? 'message' : 'data']);
+ } catch (e) {
+ return;
+ }
+ if (data.message === PREBID_RESPONSE && data.adId === adId) {
+ try {
+ let doc = win.document
+ if (data.ad) {
+ doc = mkFrame(doc, {width: data.width, height: data.height}).contentDocument;
+ doc.open();
+ }
+ writeAd(data, cb, doc);
+ } catch (e) {
+ // eslint-disable-next-line standard/no-callback-literal
+ cb({ reason: EXCEPTION, message: e.message })
+ }
+ }
+ }
+
+ const channel = new MessageChannel();
+ channel.port1.onmessage = onMessage;
+ sendMessage(PREBID_REQUEST, {
+ options: {clickUrl}
+ }, [channel.port2]);
+ win.addEventListener('message', onMessage, false);
+ }
+}
+window.renderAd = renderer();
diff --git a/libraries/creativeRender/direct.js b/libraries/creativeRender/direct.js
new file mode 100644
index 00000000000..0b4fb2f0a75
--- /dev/null
+++ b/libraries/creativeRender/direct.js
@@ -0,0 +1,62 @@
+import {emitAdRenderFail, emitAdRenderSucceeded, handleRender} from '../../src/adRendering.js';
+import {writeAd} from './writer.js';
+import {auctionManager} from '../../src/auctionManager.js';
+import CONSTANTS from '../../src/constants.json';
+import {inIframe, insertElement} from '../../src/utils.js';
+import {getGlobal} from '../../src/prebidGlobal.js';
+import {EXCEPTION} from './constants.js';
+
+export function renderAdDirect(doc, adId, options) {
+ let bid;
+ function cb(err) {
+ if (err != null) {
+ emitAdRenderFail(Object.assign({id: adId, bid}, err));
+ } else {
+ emitAdRenderSucceeded({doc, bid, adId})
+ }
+ }
+ function renderFn(adData) {
+ writeAd(adData, cb, doc);
+ if (doc.defaultView && doc.defaultView.frameElement) {
+ doc.defaultView.frameElement.width = adData.width;
+ doc.defaultView.frameElement.height = adData.height;
+ }
+ // TODO: this is almost certainly the wrong way to do this
+ const creativeComment = document.createComment(`Creative ${bid.creativeId} served by ${bid.bidder} Prebid.js Header Bidding`);
+ insertElement(creativeComment, doc, 'html');
+ }
+ try {
+ if (!adId || !doc) {
+ // eslint-disable-next-line standard/no-callback-literal
+ cb({
+ reason: CONSTANTS.AD_RENDER_FAILED_REASON.MISSING_DOC_OR_ADID,
+ message: `missing ${adId ? 'doc' : 'adId'}`
+ });
+ } else {
+ bid = auctionManager.findBidByAdId(adId);
+
+ if (FEATURES.VIDEO) {
+ // TODO: could the video module implement this as a custom renderer, rather than a special case in here?
+ const adUnit = bid && auctionManager.index.getAdUnit(bid);
+ const videoModule = getGlobal().videoModule;
+ if (adUnit?.video && videoModule) {
+ videoModule.renderBid(adUnit.video.divId, bid);
+ return;
+ }
+ }
+
+ if ((doc === document && !inIframe())) {
+ // eslint-disable-next-line standard/no-callback-literal
+ cb({
+ reason: CONSTANTS.AD_RENDER_FAILED_REASON.PREVENT_WRITING_ON_MAIN_DOCUMENT,
+ message: `renderAd was prevented from writing to the main document.`
+ })
+ } else {
+ handleRender(renderFn, {adId, options: {clickUrl: options?.clickThrough}, bidResponse: bid});
+ }
+ }
+ } catch (e) {
+ // eslint-disable-next-line standard/no-callback-literal
+ cb({reason: EXCEPTION, message: e.message})
+ }
+}
diff --git a/libraries/creativeRender/writer.js b/libraries/creativeRender/writer.js
new file mode 100644
index 00000000000..80bb0592a1f
--- /dev/null
+++ b/libraries/creativeRender/writer.js
@@ -0,0 +1,34 @@
+import {NO_AD} from './constants.js';
+
+const IFRAME_ATTRS = {
+ frameBorder: 0,
+ scrolling: 'no',
+ marginHeight: 0,
+ marginWidth: 0,
+ topMargin: 0,
+ leftMargin: 0,
+ allowTransparency: 'true',
+};
+
+export function mkFrame(doc, attrs) {
+ const frame = doc.createElement('iframe');
+ attrs = Object.assign({}, attrs, IFRAME_ATTRS);
+ Object.entries(attrs).forEach(([k, v]) => frame.setAttribute(k, v));
+ doc.body.appendChild(frame);
+ return frame;
+}
+
+export function writeAd({ad, adUrl, width, height}, cb, doc = document) {
+ if (!ad && !adUrl) {
+ // eslint-disable-next-line standard/no-callback-literal
+ cb({reason: NO_AD, message: 'Missing ad markup or URL'});
+ } else {
+ if (adUrl && !ad) {
+ mkFrame(doc, {width, height, src: adUrl})
+ } else {
+ doc.write(ad);
+ doc.close();
+ }
+ cb();
+ }
+}
diff --git a/modules/.submodules.json b/modules/.submodules.json
index 5699cbfdc87..830d3c9b2f3 100644
--- a/modules/.submodules.json
+++ b/modules/.submodules.json
@@ -57,30 +57,42 @@
"1plusXRtdProvider",
"a1MediaRtdProvider",
"aaxBlockmeterRtdProvider",
+ "adlooxRtdProvider",
+ "adnuntiusRtdProvider",
"airgridRtdProvider",
"akamaiDapRtdProvider",
"arcspanRtdProvider",
"blueconicRtdProvider",
+ "brandmetricsRtdProvider",
"browsiRtdProvider",
"captifyRtdProvider",
+ "mediafilterRtdProvider",
"confiantRtdProvider",
"dgkeywordRtdProvider",
+ "experianRtdProvider",
"geoedgeRtdProvider",
+ "geolocationRtdProvider",
+ "greenbidsRtdProvider",
+ "growthCodeRtdProvider",
"hadronRtdProvider",
- "haloRtdProvider",
"iasRtdProvider",
+ "idWardRtdProvider",
+ "imRtdProvider",
+ "intersectionRtdProvider",
"jwplayerRtdProvider",
"medianetRtdProvider",
"mgidRtdProvider",
+ "neuwoRtdProvider",
"oneKeyRtdProvider",
"optimeraRtdProvider",
+ "oxxionRtdProvider",
"permutiveRtdProvider",
"qortexRtdProvider",
"reconciliationRtdProvider",
+ "relevadRtdProvider",
"sirdataRtdProvider",
"timeoutRtdProvider",
- "weboramaRtdProvider",
- "zeusPrimeRtdProvider"
+ "weboramaRtdProvider"
],
"fpdModule": [
"validationFpdModule",
diff --git a/modules/33acrossAnalyticsAdapter.js b/modules/33acrossAnalyticsAdapter.js
new file mode 100644
index 00000000000..e3539906b13
--- /dev/null
+++ b/modules/33acrossAnalyticsAdapter.js
@@ -0,0 +1,656 @@
+import { deepAccess, logInfo, logWarn, logError, deepClone } from '../src/utils.js';
+import buildAdapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js';
+import adapterManager, { coppaDataHandler, gdprDataHandler, gppDataHandler, uspDataHandler } from '../src/adapterManager.js';
+import CONSTANTS from '../src/constants.json';
+
+/**
+ * @typedef {typeof import('../src/constants.json').EVENTS} EVENTS
+ */
+const { EVENTS } = CONSTANTS;
+
+/** @typedef {'pending'|'available'|'targetingSet'|'rendered'|'timeout'|'rejected'|'noBid'|'error'} BidStatus */
+/**
+ * @type {Object}
+ */
+const BidStatus = {
+ PENDING: 'pending',
+ AVAILABLE: 'available',
+ TARGETING_SET: 'targetingSet',
+ RENDERED: 'rendered',
+ TIMEOUT: 'timeout',
+ REJECTED: 'rejected',
+ NOBID: 'noBid',
+ ERROR: 'error',
+}
+
+const ANALYTICS_VERSION = '1.0.0';
+const PROVIDER_NAME = '33across';
+const GVLID = 58;
+/** Time to wait for all transactions in an auction to complete before sending the report */
+const DEFAULT_TRANSACTION_TIMEOUT = 10000;
+/** Time to wait after all GAM slots have registered before sending the report */
+export const POST_GAM_TIMEOUT = 500;
+export const DEFAULT_ENDPOINT = 'https://analytics.33across.com/api/v1/event';
+
+export const log = getLogger();
+
+/**
+ * @typedef {Object} AnalyticsReport - Sent when all bids are complete (as determined by `bidWon` and `slotRenderEnded` events)
+ * @property {string} analyticsVersion - Version of the Prebid.js 33Across Analytics Adapter
+ * @property {string} pid - Partner ID
+ * @property {string} src - Source of the report ('pbjs')
+ * @property {string} pbjsVersion - Version of Prebid.js
+ * @property {Auction[]} auctions
+ */
+
+/**
+ * @typedef {Object} AnalyticsCache
+ * @property {string} pid Partner ID
+ * @property {Object} auctions
+ * @property {string} [usPrivacy]
+ */
+
+/**
+ * @typedef {Object} Auction - Parsed auction data
+ * @property {AdUnit[]} adUnits
+ * @property {string} auctionId
+ * @property {string[]} userIds
+ */
+
+/**
+ * @typedef {`${number}x${number}`} AdUnitSize
+ */
+
+/**
+ * @typedef {('banner'|'native'|'video')} AdUnitMediaType
+ */
+
+/**
+ * @typedef {Object} BidResponse
+ * @property {number} cpm
+ * @property {string} cur
+ * @property {number} [cpmOrig]
+ * @property {number} cpmFloor
+ * @property {AdUnitMediaType} mediaType
+ * @property {AdUnitSize} size
+ */
+
+/**
+ * @typedef {Object} Bid - Parsed bid data
+ * @property {string} bidder
+ * @property {string} bidId
+ * @property {string} source
+ * @property {string} status
+ * @property {BidResponse} [bidResponse]
+ * @property {1|0} [hasWon]
+ */
+
+/**
+ * @typedef {Object} AdUnit - Parsed adUnit data
+ * @property {string} transactionId - Primary key for *this* auction/adUnit combination
+ * @property {string} adUnitCode
+ * @property {string} slotId - Equivalent to GPID. (Note that
+ * GPID supports adUnits where multiple units have the same `code` values
+ * by appending a `#UNIQUIFIER`. The value of the UNIQUIFIER is likely to be the div-id,
+ * but, if div-id is randomized / unavailable, may be something else like the media size)
+ * @property {Array} mediaTypes
+ * @property {Array} sizes
+ * @property {Array} bids
+ */
+
+/**
+ * After the first transaction begins, wait until all transactions are complete
+ * before calling `onComplete`. If the timeout is reached before all transactions
+ * are complete, send the report anyway.
+ *
+ * Use this to track all transactions per auction, and send the report as soon
+ * as all adUnits have been won (or after timeout) even if other bid/auction
+ * activity is still happening.
+ */
+class TransactionManager {
+ /**
+ * Milliseconds between activity to allow until this collection automatically completes.
+ * @type {number}
+ */
+ #sendTimeout;
+ #sendTimeoutId;
+ #transactionsPending = new Set();
+ #transactionsCompleted = new Set();
+ #onComplete;
+
+ constructor({ timeout, onComplete }) {
+ this.#sendTimeout = timeout;
+ this.#onComplete = onComplete;
+ }
+
+ status() {
+ return {
+ pending: [...this.#transactionsPending],
+ completed: [...this.#transactionsCompleted],
+ };
+ }
+
+ initiate(transactionId) {
+ this.#transactionsPending.add(transactionId);
+ this.#restartSendTimeout();
+ }
+
+ complete(transactionId) {
+ if (!this.#transactionsPending.has(transactionId)) {
+ log.warn(`transactionId "${transactionId}" was not found. No transaction to mark as complete.`);
+ return;
+ }
+
+ this.#transactionsPending.delete(transactionId);
+ this.#transactionsCompleted.add(transactionId);
+
+ if (this.#transactionsPending.size === 0) {
+ this.#flushTransactions();
+ }
+ }
+
+ #flushTransactions() {
+ this.#clearSendTimeout();
+ this.#transactionsPending = new Set();
+ this.#onComplete();
+ }
+
+ // gulp-eslint is using eslint 6, a version that doesn't support private method syntax
+ // eslint-disable-next-line no-dupe-class-members
+ #clearSendTimeout() {
+ return clearTimeout(this.#sendTimeoutId);
+ }
+
+ // eslint-disable-next-line no-dupe-class-members
+ #restartSendTimeout() {
+ this.#clearSendTimeout();
+
+ this.#sendTimeoutId = setTimeout(() => {
+ if (this.#sendTimeout !== 0) {
+ log.warn(`Timed out waiting for ad transactions to complete. Sending report.`);
+ }
+
+ this.#flushTransactions();
+ }, this.#sendTimeout);
+ }
+}
+
+/**
+ * Initialized during `enableAnalytics`. Exported for testing purposes.
+ */
+export const locals = {
+ /** @type {Object} - one manager per auction */
+ transactionManagers: {},
+ /** @type {AnalyticsCache} */
+ cache: {
+ auctions: {},
+ pid: '',
+ },
+ /** @type {Object} */
+ adUnitMap: {},
+ reset() {
+ this.transactionManagers = {};
+ this.cache = {
+ auctions: {},
+ pid: '',
+ };
+ this.adUnitMap = {};
+ }
+}
+
+/**
+ * @typedef {Object} AnalyticsAdapter
+ * @property {function} track
+ * @property {function} enableAnalytics
+ * @property {function} disableAnalytics
+ * @property {function} [originEnableAnalytics]
+ * @property {function} [originDisableAnalytics]
+ * @property {function} [_oldEnable]
+ */
+
+/**
+ * @type {AnalyticsAdapter}
+ */
+const analyticsAdapter = Object.assign(
+ buildAdapter({ analyticsType: 'endpoint' }),
+ { track: analyticEventHandler }
+);
+
+analyticsAdapter.originEnableAnalytics = analyticsAdapter.enableAnalytics;
+analyticsAdapter.enableAnalytics = enableAnalyticsWrapper;
+
+/**
+ * @typedef {Object} AnalyticsConfig
+ * @property {string} provider - set by pbjs at module registration time
+ * @property {Object} options
+ * @property {string} options.pid - Publisher/Partner ID
+ * @property {string} [options.endpoint=DEFAULT_ENDPOINT] - Endpoint to send analytics data
+ * @property {number} [options.timeout=DEFAULT_TRANSACTION_TIMEOUT] - Timeout for sending analytics data
+ */
+
+/**
+ * @param {AnalyticsConfig} config Analytics module configuration
+ */
+function enableAnalyticsWrapper(config) {
+ const { options } = config;
+
+ const pid = options.pid;
+ if (!pid) {
+ log.error('No partnerId provided for "options.pid". No analytics will be sent.');
+
+ return;
+ }
+
+ const endpoint = calculateEndpoint(options.endpoint);
+ this.getUrl = () => endpoint;
+
+ const timeout = calculateTransactionTimeout(options.timeout);
+ this.getTimeout = () => timeout;
+
+ locals.cache = {
+ pid,
+ auctions: {},
+ };
+
+ window.googletag = window.googletag || { cmd: [] };
+ window.googletag.cmd.push(subscribeToGamSlots);
+
+ analyticsAdapter.originEnableAnalytics(config);
+}
+
+/**
+ * @param {string} [endpoint]
+ * @returns {string}
+ */
+function calculateEndpoint(endpoint = DEFAULT_ENDPOINT) {
+ if (typeof endpoint === 'string' && endpoint.startsWith('http')) {
+ return endpoint;
+ }
+
+ log.info(`Invalid endpoint provided for "options.endpoint". Using default endpoint.`);
+
+ return DEFAULT_ENDPOINT;
+}
+/**
+ * @param {number} [configTimeout]
+ * @returns {number} Transaction Timeout
+ */
+function calculateTransactionTimeout(configTimeout = DEFAULT_TRANSACTION_TIMEOUT) {
+ if (typeof configTimeout === 'number' && configTimeout >= 0) {
+ return configTimeout;
+ }
+
+ log.info(`Invalid timeout provided for "options.timeout". Using default timeout of ${DEFAULT_TRANSACTION_TIMEOUT}ms.`);
+
+ return DEFAULT_TRANSACTION_TIMEOUT;
+}
+
+function subscribeToGamSlots() {
+ window.googletag.pubads().addEventListener('slotRenderEnded', event => {
+ setTimeout(() => {
+ const { transactionId, auctionId } =
+ getAdUnitMetadata(event.slot.getAdUnitPath(), event.slot.getSlotElementId());
+ if (!transactionId || !auctionId) {
+ const slotName = `${event.slot.getAdUnitPath()} - ${event.slot.getSlotElementId()}`;
+ log.warn('Could not find configured ad unit matching GAM render of slot:', { slotName });
+ return;
+ }
+
+ locals.transactionManagers[auctionId] &&
+ locals.transactionManagers[auctionId].complete(transactionId);
+ }, POST_GAM_TIMEOUT);
+ });
+}
+
+function getAdUnitMetadata(adUnitPath, adSlotElementId) {
+ const adUnitMeta = locals.adUnitMap[adUnitPath] || locals.adUnitMap[adSlotElementId];
+ if (adUnitMeta && adUnitMeta.length > 0) {
+ return adUnitMeta[adUnitMeta.length - 1];
+ }
+ return {};
+}
+
+/** necessary for testing */
+analyticsAdapter.originDisableAnalytics = analyticsAdapter.disableAnalytics;
+analyticsAdapter.disableAnalytics = function () {
+ analyticsAdapter._oldEnable = enableAnalyticsWrapper;
+ locals.reset();
+ analyticsAdapter.originDisableAnalytics();
+};
+
+adapterManager.registerAnalyticsAdapter({
+ adapter: analyticsAdapter,
+ code: PROVIDER_NAME,
+ gvlid: GVLID,
+});
+
+export default analyticsAdapter;
+
+/**
+ * @param {AnalyticsCache} analyticsCache
+ * @param {string} completedAuctionId value of auctionId
+ * @return {AnalyticsReport} Analytics report
+ */
+function createReportFromCache(analyticsCache, completedAuctionId) {
+ const { pid, auctions } = analyticsCache;
+
+ const report = {
+ pid,
+ src: 'pbjs',
+ analyticsVersion: ANALYTICS_VERSION,
+ pbjsVersion: '$prebid.version$', // Replaced by build script
+ auctions: [ auctions[completedAuctionId] ],
+ }
+ if (uspDataHandler.getConsentData()) {
+ report.usPrivacy = uspDataHandler.getConsentData();
+ }
+
+ if (gdprDataHandler.getConsentData()) {
+ report.gdpr = Number(Boolean(gdprDataHandler.getConsentData().gdprApplies));
+ report.gdprConsent = gdprDataHandler.getConsentData().consentString || '';
+ }
+
+ if (gppDataHandler.getConsentData()) {
+ report.gpp = gppDataHandler.getConsentData().gppString;
+ report.gppSid = gppDataHandler.getConsentData().applicableSections;
+ }
+
+ if (coppaDataHandler.getCoppa()) {
+ report.coppa = Number(coppaDataHandler.getCoppa());
+ }
+
+ return report;
+}
+
+function getCachedBid(auctionId, bidId) {
+ const auction = locals.cache.auctions[auctionId];
+ for (let adUnit of auction.adUnits) {
+ for (let bid of adUnit.bids) {
+ if (bid.bidId === bidId) {
+ return bid;
+ }
+ }
+ }
+ log.error(`Cannot find bid "${bidId}" in auction "${auctionId}".`);
+};
+
+/**
+ * @param {Object} args
+ * @param {Object} args.args Event data
+ * @param {EVENTS[keyof EVENTS]} args.eventType
+ */
+function analyticEventHandler({ eventType, args }) {
+ if (!locals.cache) {
+ log.error('Something went wrong. Analytics cache is not initialized.');
+ return;
+ }
+
+ switch (eventType) {
+ case EVENTS.AUCTION_INIT:
+ onAuctionInit(args);
+ break;
+ case EVENTS.BID_REQUESTED: // BidStatus.PENDING
+ onBidRequested(args);
+ break;
+ case EVENTS.BID_TIMEOUT:
+ for (let bid of args) {
+ setCachedBidStatus(bid.auctionId, bid.bidId, BidStatus.TIMEOUT);
+ }
+ break;
+ case EVENTS.BID_RESPONSE:
+ onBidResponse(args);
+ break;
+ case EVENTS.BID_REJECTED:
+ onBidRejected(args);
+ break;
+ case EVENTS.NO_BID:
+ case EVENTS.SEAT_NON_BID:
+ setCachedBidStatus(args.auctionId, args.bidId, BidStatus.NOBID);
+ break;
+ case EVENTS.BIDDER_ERROR:
+ if (args.bidderRequest && args.bidderRequest.bids) {
+ for (let bid of args.bidderRequest.bids) {
+ setCachedBidStatus(args.bidderRequest.auctionId, bid.bidId, BidStatus.ERROR);
+ }
+ }
+ break;
+ case EVENTS.AUCTION_END:
+ onAuctionEnd(args);
+ break;
+ case EVENTS.BID_WON: // BidStatus.TARGETING_SET | BidStatus.RENDERED | BidStatus.ERROR
+ onBidWon(args);
+ break;
+ default:
+ break;
+ }
+}
+
+/****************
+ * AUCTION_INIT *
+ ***************/
+function onAuctionInit({ adUnits, auctionId, bidderRequests }) {
+ if (typeof auctionId !== 'string' || !Array.isArray(bidderRequests)) {
+ log.error('Analytics adapter failed to parse auction.');
+ return;
+ }
+
+ locals.cache.auctions[auctionId] = {
+ auctionId,
+ adUnits: adUnits.map(au => {
+ setAdUnitMap(au.code, auctionId, au.transactionId);
+
+ return {
+ transactionId: au.transactionId,
+ adUnitCode: au.code,
+ // Note: GPID supports adUnits that have matching `code` values by appending a `#UNIQUIFIER`.
+ // The value of the UNIQUIFIER is likely to be the div-id,
+ // but, if div-id is randomized / unavailable, may be something else like the media size)
+ slotId: deepAccess(au, 'ortb2Imp.ext.gpid') || deepAccess(au, 'ortb2Imp.ext.data.pbadslot', au.code),
+ mediaTypes: Object.keys(au.mediaTypes),
+ sizes: au.sizes.map(size => size.join('x')),
+ bids: [],
+ }
+ }),
+ userIds: Object.keys(deepAccess(bidderRequests, '0.bids.0.userId', {})),
+ };
+
+ locals.transactionManagers[auctionId] ||=
+ new TransactionManager({
+ timeout: analyticsAdapter.getTimeout(),
+ onComplete() {
+ sendReport(
+ createReportFromCache(locals.cache, auctionId),
+ analyticsAdapter.getUrl()
+ );
+ delete locals.transactionManagers[auctionId];
+ }
+ });
+}
+
+function setAdUnitMap(adUnitCode, auctionId, transactionId) {
+ if (!locals.adUnitMap[adUnitCode]) {
+ locals.adUnitMap[adUnitCode] = [];
+ }
+
+ locals.adUnitMap[adUnitCode].push({ auctionId, transactionId });
+}
+
+/*****************
+ * BID_REQUESTED *
+ ****************/
+function onBidRequested({ auctionId, bids }) {
+ for (let { bidder, bidId, transactionId, src } of bids) {
+ const auction = locals.cache.auctions[auctionId];
+ const adUnit = auction.adUnits.find(adUnit => adUnit.transactionId === transactionId);
+ if (!adUnit) return;
+ adUnit.bids.push({
+ bidder,
+ bidId,
+ status: BidStatus.PENDING,
+ hasWon: 0,
+ source: src,
+ });
+
+ // if there is no manager for this auction, then the auction has already been completed
+ locals.transactionManagers[auctionId] &&
+ locals.transactionManagers[auctionId].initiate(transactionId);
+ }
+}
+
+/****************
+ * BID_RESPONSE *
+ ***************/
+function onBidResponse({ requestId, auctionId, cpm, currency, originalCpm, floorData, mediaType, size, status, source }) {
+ const bid = getCachedBid(auctionId, requestId);
+ if (!bid) return;
+
+ setBidStatus(bid, status);
+ Object.assign(bid,
+ {
+ bidResponse: {
+ cpm,
+ cur: currency,
+ cpmOrig: originalCpm,
+ cpmFloor: floorData?.floorValue,
+ mediaType,
+ size
+ },
+ source
+ }
+ );
+}
+
+/****************
+ * BID_REJECTED *
+ ***************/
+function onBidRejected({ requestId, auctionId, cpm, currency, originalCpm, floorData, mediaType, width, height, source }) {
+ const bid = getCachedBid(auctionId, requestId);
+ if (!bid) return;
+
+ setBidStatus(bid, BidStatus.REJECTED);
+ Object.assign(bid,
+ {
+ bidResponse: {
+ cpm,
+ cur: currency,
+ cpmOrig: originalCpm,
+ cpmFloor: floorData?.floorValue,
+ mediaType,
+ size: `${width}x${height}`
+ },
+ source
+ }
+ );
+}
+
+/***************
+ * AUCTION_END *
+ **************/
+/**
+ * @param {Object} args
+ * @param {{requestId: string, status: string}[]} args.bidsReceived
+ * @param {string} args.auctionId
+ * @returns {void}
+ */
+function onAuctionEnd({ bidsReceived, auctionId }) {
+ for (let bid of bidsReceived) {
+ setCachedBidStatus(auctionId, bid.requestId, bid.status);
+ }
+}
+
+/***********
+ * BID_WON *
+ **********/
+function onBidWon(bidWon) {
+ const { auctionId, requestId, transactionId } = bidWon;
+ const bid = getCachedBid(auctionId, requestId);
+ if (!bid) {
+ return;
+ }
+
+ setBidStatus(bid, bidWon.status ?? BidStatus.ERROR);
+
+ locals.transactionManagers[auctionId] &&
+ locals.transactionManagers[auctionId].complete(transactionId);
+}
+
+/**
+ * @param {Bid} bid
+ * @param {BidStatus} [status]
+ * @returns {void}
+ */
+function setBidStatus(bid, status = BidStatus.AVAILABLE) {
+ const statusStates = {
+ pending: {
+ next: [BidStatus.AVAILABLE, BidStatus.TARGETING_SET, BidStatus.RENDERED, BidStatus.TIMEOUT, BidStatus.REJECTED, BidStatus.NOBID, BidStatus.ERROR],
+ },
+ available: {
+ next: [BidStatus.TARGETING_SET, BidStatus.RENDERED, BidStatus.TIMEOUT, BidStatus.REJECTED, BidStatus.NOBID, BidStatus.ERROR],
+ },
+ targetingSet: {
+ next: [BidStatus.RENDERED, BidStatus.ERROR, BidStatus.TIMEOUT],
+ },
+ rendered: {
+ next: [],
+ },
+ timeout: {
+ next: [],
+ },
+ rejected: {
+ next: [],
+ },
+ noBid: {
+ next: [],
+ },
+ error: {
+ next: [BidStatus.TARGETING_SET, BidStatus.RENDERED, BidStatus.TIMEOUT, BidStatus.REJECTED, BidStatus.NOBID, BidStatus.ERROR],
+ },
+ }
+
+ const winningStatuses = [BidStatus.RENDERED];
+
+ if (statusStates[bid.status].next.includes(status)) {
+ bid.status = status;
+ if (winningStatuses.includes(status)) {
+ // occassionally we can detect a bidWon before prebid reports it as such
+ bid.hasWon = 1;
+ }
+ }
+}
+
+function setCachedBidStatus(auctionId, bidId, status) {
+ const bid = getCachedBid(auctionId, bidId);
+ if (!bid) return;
+ setBidStatus(bid, status);
+}
+
+/**
+ * Guarantees sending of data without waiting for response, even after page is left/closed
+ *
+ * @param {AnalyticsReport} report Request payload
+ * @param {string} endpoint URL
+ */
+function sendReport(report, endpoint) {
+ if (navigator.sendBeacon(endpoint, JSON.stringify(report))) {
+ log.info(`Analytics report sent to ${endpoint}`, report);
+
+ return;
+ }
+
+ log.error('Analytics report exceeded User-Agent data limits and was not sent.', report);
+}
+
+/**
+ * Encapsulate certain logger functions and add a prefix to the final messages.
+ *
+ * @return {Object} New logger functions
+ */
+function getLogger() {
+ const LPREFIX = `${PROVIDER_NAME} Analytics: `;
+
+ return {
+ info: (msg, ...args) => logInfo(`${LPREFIX}${msg}`, ...deepClone(args)),
+ warn: (msg, ...args) => logWarn(`${LPREFIX}${msg}`, ...deepClone(args)),
+ error: (msg, ...args) => logError(`${LPREFIX}${msg}`, ...deepClone(args)),
+ }
+}
diff --git a/modules/33acrossAnalyticsAdapter.md b/modules/33acrossAnalyticsAdapter.md
new file mode 100644
index 00000000000..c56059e5526
--- /dev/null
+++ b/modules/33acrossAnalyticsAdapter.md
@@ -0,0 +1,76 @@
+# Overview
+
+```txt
+Module Name: 33Across Analytics Adapter
+Module Type: Analytics Adapter
+Maintainer: analytics_support@33across.com
+```
+
+#### About
+
+This analytics adapter collects data about the performance of your ad slots
+for each auction run on your site. It also provides insight into how identifiers
+from the
+[33Across User ID Sub-module](https://docs.prebid.org/dev-docs/modules/userid-submodules/33across.html)
+and other user ID sub-modules improve your monetization. The data is sent at
+the earliest opportunity for each auction to provide a more complete picture of
+your ad performance.
+
+The analytics adapter is free to use!
+However, the publisher must work with our account management team to obtain a
+Publisher/Partner ID (PID) and enable Analytics for their account.
+To get a PID and to have the publisher account enabled for Analytics,
+you can reach out to our team at the following email - analytics_support@33across.com
+
+If you are an existing publisher and you already use a 33Across PID,
+you can reach out to analytics_support@33across.com
+to have your account enabled for analytics.
+
+The 33Across privacy policy is at .
+
+#### Analytics Options
+
+| Name | Scope | Example | Type | Description |
+|-----------|----------|---------|----------|-------------|
+| `pid` | required | abc123 | `string` | 33Across Publisher ID |
+| `timeout` | optional | 10000 | `int` | Milliseconds to wait after last seen auction transaction before sending report (default 10000). |
+
+#### Configuration
+
+The data is sent at the earliest opportunity for each auction to provide
+a more complete picture of your ad performance, even if the auction is interrupted
+by a page navigation. At the latest, the adapter will always send the report
+when the page is unloaded, at the end of the auction, or after the timeout,
+whichever comes first.
+
+In order to guarantee consistent reports of your ad slot behavior, we recommend
+including the GPT Pre-Auction Module, `gptPreAuction`. This module is included
+by default when Prebid is downloaded. If you are compiling from source,
+this might look something like:
+
+```sh
+gulp bundle --modules=gptPreAuction,consentManagement,consentManagementGpp,consentManagementUsp,enrichmentFpdModule,gdprEnforcement,33acrossBidAdapter,33acrossIdSystem,33acrossAnalyticsAdapter
+```
+
+Enable the 33Across Analytics Adapter in Prebid.js using the analytics provider `33across`
+and options as seen in the example below.
+
+#### Example Configuration
+
+```js
+pbjs.enableAnalytics({
+ provider: '33across',
+ options: {
+ /**
+ * The 33Across Publisher ID.
+ */
+ pid: 'abc123',
+ /**
+ * Timeout in milliseconds after which an auction report
+ * will be sent regardless of auction state.
+ * [optional]
+ */
+ timeout: 10000
+ }
+});
+```
diff --git a/modules/a1MediaBidAdapter.js b/modules/a1MediaBidAdapter.js
index 6a137e621c5..d640bbfe2d7 100644
--- a/modules/a1MediaBidAdapter.js
+++ b/modules/a1MediaBidAdapter.js
@@ -1,6 +1,7 @@
import { ortbConverter } from '../libraries/ortbConverter/converter.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js';
+import { replaceAuctionPrice } from '../src/utils.js';
const BIDDER_CODE = 'a1media';
const END_POINT = 'https://d11.contentsfeed.com/dsp/breq/a1';
@@ -81,7 +82,21 @@ export const spec = {
},
interpretResponse: function (serverResponse, bidRequest) {
- const bids = converter.fromORTB({response: serverResponse.body, request: bidRequest.data}).bids;
+ if (!serverResponse.body) return [];
+ const parsedSeatbid = serverResponse.body.seatbid.map(seatbidItem => {
+ const parsedBid = seatbidItem.bid.map((bidItem) => ({
+ ...bidItem,
+ adm: replaceAuctionPrice(bidItem.adm, bidItem.price),
+ nurl: replaceAuctionPrice(bidItem.nurl, bidItem.price)
+ }));
+ return {...seatbidItem, bid: parsedBid};
+ });
+
+ const responseBody = {...serverResponse.body, seatbid: parsedSeatbid};
+ const bids = converter.fromORTB({
+ response: responseBody,
+ request: bidRequest.data,
+ }).bids;
return bids;
},
diff --git a/modules/adagioAnalyticsAdapter.js b/modules/adagioAnalyticsAdapter.js
index f9b79639073..9c4c0e8fea7 100644
--- a/modules/adagioAnalyticsAdapter.js
+++ b/modules/adagioAnalyticsAdapter.js
@@ -27,6 +27,15 @@ const cache = {
...this.auctions[auctionId][adUnitCode],
...values
};
+ },
+
+ // Map prebid auction id to adagio auction id
+ auctionIdReferences: {},
+ addPrebidAuctionIdRef(auctionId, adagioAuctionId) {
+ this.auctionIdReferences[auctionId] = adagioAuctionId;
+ },
+ getAdagioAuctionId(auctionId) {
+ return this.auctionIdReferences[auctionId];
}
};
const enc = window.encodeURIComponent;
@@ -125,6 +134,10 @@ function sendNewBeacon(auctionId, adUnitCode) {
sendRequest(cache.getAuction(auctionId, adUnitCode));
};
+function getTargetedAuctionId(bid) {
+ return deepAccess(bid, 'latestTargetedAuctionId') || deepAccess(bid, 'auctionId');
+}
+
/**
* END UTILS FUNCTIONS
*/
@@ -196,6 +209,9 @@ function handlerAuctionInit(event) {
// We assume that all Adagio bids for a same adunit have the same params.
const params = adagioAdUnitBids[0].params;
+ const adagioAuctionId = params.adagioAuctionId;
+ cache.addPrebidAuctionIdRef(prebidAuctionId, adagioAuctionId);
+
// Get all media types requested for Adagio.
const adagioMediaTypes = removeDuplicates(
adagioAdUnitBids.map(bid => Object.keys(bid.mediaTypes)).flat(),
@@ -208,7 +224,7 @@ function handlerAuctionInit(event) {
org_id: params.organizationId,
site: params.site,
pv_id: params.pageviewId,
- auct_id: params.adagioAuctionId,
+ auct_id: adagioAuctionId,
adu_code: adUnitCode,
url_dmn: w.location.hostname,
dvc: params.environment,
@@ -247,7 +263,9 @@ function handlerBidResponse(event) {
};
function handlerBidWon(event) {
- if (!guard.bidTracked(event.auctionId, event.adUnitCode)) {
+ let auctionId = getTargetedAuctionId(event);
+
+ if (!guard.bidTracked(auctionId, event.adUnitCode)) {
return;
}
@@ -266,7 +284,12 @@ function handlerBidWon(event) {
logError('Error on Adagio Analytics Adapter - handlerBidWon', error);
}
- cache.updateAuction(event.auctionId, event.adUnitCode, {
+ const adagioAuctionCacheId = (
+ (event.latestTargetedAuctionId && event.latestTargetedAuctionId !== event.auctionId)
+ ? cache.getAdagioAuctionId(event.auctionId)
+ : null);
+
+ cache.updateAuction(auctionId, event.adUnitCode, {
win_bdr: getAdapterNameForAlias(event.bidder),
win_mt: getMediaTypeAlias(event.mediaType),
win_ban_sz: event.mediaType === BANNER ? `${event.width}x${event.height}` : null,
@@ -280,12 +303,17 @@ function handlerBidWon(event) {
og_cpm: event.originalCpm,
og_cur: event.originalCurrency,
og_cur_rate: ogCurRateToUSD,
+
+ // cache bid id
+ auct_id_c: adagioAuctionCacheId,
});
- sendNewBeacon(event.auctionId, event.adUnitCode);
+ sendNewBeacon(auctionId, event.adUnitCode);
};
function handlerAdRender(event, isSuccess) {
- const { auctionId, adUnitCode } = event.bid;
+ const { adUnitCode } = event.bid;
+ let auctionId = getTargetedAuctionId(event.bid);
+
if (!guard.bidTracked(auctionId, adUnitCode)) {
return;
}
diff --git a/modules/adagioBidAdapter.js b/modules/adagioBidAdapter.js
index 3de584a1195..1f3d6040d34 100644
--- a/modules/adagioBidAdapter.js
+++ b/modules/adagioBidAdapter.js
@@ -1,6 +1,5 @@
import {find} from '../src/polyfill.js';
import {
- _map,
cleanObj,
deepAccess,
deepClone,
@@ -54,8 +53,9 @@ const ADAGIO_PUBKEY = 'AL16XT44Sfp+8SHVF1UdC7hydPSMVLMhsYknKDdwqq+0ToDSJrP0+Qh0k
const ADAGIO_PUBKEY_E = 65537;
const CURRENCY = 'USD';
-// This provide a whitelist and a basic validation of OpenRTB 2.6 options used by the Adagio SSP.
-// https://iabtechlab.com/wp-content/uploads/2022/04/OpenRTB-2-6_FINAL.pdf
+// This provide a whitelist and a basic validation of OpenRTB 2.5 options used by the Adagio SSP.
+// Accept all options but 'protocol', 'companionad', 'companiontype', 'ext'
+// https://www.iab.com/wp-content/uploads/2016/03/OpenRTB-API-Specification-Version-2-5-FINAL.pdf
export const ORTB_VIDEO_PARAMS = {
'mimes': (value) => Array.isArray(value) && value.length > 0 && value.every(v => typeof v === 'string'),
'minduration': (value) => isInteger(value),
@@ -569,6 +569,7 @@ function _parseNativeBidResponse(bid) {
bid.native = native
}
+// bidRequest param must be the `bidRequest` object with the original `auctionId` value.
function _getFloors(bidRequest) {
if (!isFn(bidRequest.getFloor)) {
return false;
@@ -995,7 +996,7 @@ export const spec = {
const aucId = generateUUID()
- const adUnits = _map(validBidRequests, (rawBidRequest) => {
+ const adUnits = validBidRequests.map(rawBidRequest => {
const bidRequest = deepClone(rawBidRequest);
// Fix https://github.com/prebid/Prebid.js/issues/9781
@@ -1067,7 +1068,10 @@ export const spec = {
});
// Handle priceFloors module
- const computedFloors = _getFloors(bidRequest);
+ // We need to use `rawBidRequest` as param because:
+ // - adagioBidAdapter generates its own auctionId due to transmitTid activity limitation (see https://github.com/prebid/Prebid.js/pull/10079)
+ // - the priceFloors.getFloor() uses a `_floorDataForAuction` map to store the floors based on the auctionId.
+ const computedFloors = _getFloors(rawBidRequest);
if (isArray(computedFloors) && computedFloors.length) {
bidRequest.floors = computedFloors
@@ -1111,6 +1115,11 @@ export const spec = {
_buildVideoBidRequest(bidRequest);
}
+ const gpid = deepAccess(bidRequest, 'ortb2Imp.ext.gpid') || deepAccess(bidRequest, 'ortb2Imp.ext.data.pbadslot');
+ if (gpid) {
+ bidRequest.gpid = gpid;
+ }
+
storeRequestInAdagioNS(bidRequest);
// Remove these fields at the very end, so we can still use them before.
@@ -1148,7 +1157,7 @@ export const spec = {
});
// Build one request per organizationId
- const requests = _map(Object.keys(groupedAdUnits), organizationId => {
+ const requests = Object.keys(groupedAdUnits).map(organizationId => {
return {
method: 'POST',
url: ENDPOINT,
diff --git a/modules/adagioBidAdapter.md b/modules/adagioBidAdapter.md
index 45f39fc6f2d..19673571982 100644
--- a/modules/adagioBidAdapter.md
+++ b/modules/adagioBidAdapter.md
@@ -107,10 +107,11 @@ var adUnits = [
cpm: 3.00 // default to 1.00
},
video: {
- api: [2, 7], // Required - Your video player must at least support the value 2 and/or 7.
+ api: [2], // Required - Your video player must at least support the value 2
playbackMethod: [6], // Highly recommended
skip: 0
- // OpenRTB video options defined here override ones defined in mediaTypes.
+ // OpenRTB 2.5 video options defined here override ones defined in mediaTypes.
+ // Not supported: 'protocol', 'companionad', 'companiontype', 'ext'
},
native: {
// Optional OpenRTB Native 1.2 request object. Only `context`, `plcmttype` fields are supported.
@@ -193,6 +194,8 @@ If the FPD value is an array, the 1st value of this array will be used.
placement: 'in_article',
adUnitElementId: 'article_outstream',
video: {
+ api: [2],
+ playbackMethod: [6],
skip: 0
},
debug: {
diff --git a/modules/admanBidAdapter.js b/modules/admanBidAdapter.js
index 2ee6ecfcb56..5eac02b7420 100644
--- a/modules/admanBidAdapter.js
+++ b/modules/admanBidAdapter.js
@@ -94,7 +94,9 @@ export const spec = {
request.ccpa = bidderRequest.uspConsent;
}
if (bidderRequest.gdprConsent) {
- request.gdpr = bidderRequest.gdprConsent
+ request.gdpr = {
+ consentString: bidderRequest.gdprConsent.consentString
+ };
}
if (content) {
request.content = content;
diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js
index eeb0cddde89..fc5cf9c8f7b 100644
--- a/modules/admaticBidAdapter.js
+++ b/modules/admaticBidAdapter.js
@@ -1,15 +1,38 @@
import {getValue, logError, isEmpty, deepAccess, isArray, getBidIdParameter} from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
-import { BANNER, VIDEO } from '../src/mediaTypes.js';
+import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js';
+export const OPENRTB = {
+ NATIVE: {
+ IMAGE_TYPE: {
+ ICON: 1,
+ MAIN: 3,
+ },
+ ASSET_ID: {
+ TITLE: 1,
+ IMAGE: 2,
+ ICON: 3,
+ BODY: 4,
+ SPONSORED: 5,
+ CTA: 6
+ },
+ DATA_ASSET_TYPE: {
+ SPONSORED: 1,
+ DESC: 2,
+ CTA_TEXT: 12,
+ },
+ }
+};
+
let SYNC_URL = '';
const BIDDER_CODE = 'admatic';
+
export const spec = {
code: BIDDER_CODE,
aliases: [
{code: 'pixad'}
],
- supportedMediaTypes: [BANNER, VIDEO],
+ supportedMediaTypes: [BANNER, VIDEO, NATIVE],
/** f
* @param {object} bid
* @return {boolean}
@@ -46,10 +69,10 @@ export const spec = {
},
blacklist: [],
site: {
- page: location.href,
- ref: location.origin,
+ page: bidderRequest.refererInfo.page,
+ ref: bidderRequest.refererInfo.page,
publisher: {
- name: location.hostname,
+ name: bidderRequest.refererInfo.domain,
publisherId: networkId
}
},
@@ -122,6 +145,8 @@ export const spec = {
resbid.vastImpUrl = bid.iurl;
} else if (resbid.mediaType === 'banner') {
resbid.ad = bid.party_tag;
+ } else if (resbid.mediaType === 'native') {
+ resbid.native = interpretNativeAd(bid.party_tag)
};
bidResponses.push(resbid);
@@ -157,6 +182,11 @@ function enrichSlotWithFloors(slot, bidRequest) {
videoSizes.forEach(videoSize => slotFloors.video[parseSize(videoSize).toString()] = bidRequest.getFloor({ size: videoSize, mediaType: VIDEO }));
}
+ if (bidRequest.mediaTypes?.native) {
+ slotFloors.native = {};
+ slotFloors.native['*'] = bidRequest.getFloor({ size: '*', mediaType: NATIVE });
+ }
+
if (Object.keys(slotFloors).length > 0) {
if (!slot) {
slot = {}
@@ -196,6 +226,11 @@ function buildRequestObject(bid) {
reqObj.type = 'video';
reqObj.mediatype = bid.mediaTypes.video;
}
+ if (bid.mediaTypes?.native) {
+ reqObj.type = 'native';
+ reqObj.size = [{w: 1, h: 1}];
+ reqObj.mediatype = bid.mediaTypes.native;
+ }
if (deepAccess(bid, 'ortb2Imp.ext')) {
reqObj.ext = bid.ortb2Imp.ext;
@@ -215,10 +250,11 @@ function getSizes(bid) {
function concatSizes(bid) {
let playerSize = deepAccess(bid, 'mediaTypes.video.playerSize');
let videoSizes = deepAccess(bid, 'mediaTypes.video.sizes');
+ let nativeSizes = deepAccess(bid, 'mediaTypes.native.sizes');
let bannerSizes = deepAccess(bid, 'mediaTypes.banner.sizes');
if (isArray(bannerSizes) || isArray(playerSize) || isArray(videoSizes)) {
- let mediaTypesSizes = [bannerSizes, videoSizes, playerSize];
+ let mediaTypesSizes = [bannerSizes, videoSizes, nativeSizes, playerSize];
return mediaTypesSizes
.reduce(function(acc, currSize) {
if (isArray(currSize)) {
@@ -233,6 +269,45 @@ function concatSizes(bid) {
}
}
+function interpretNativeAd(adm) {
+ const native = JSON.parse(adm).native;
+ const result = {
+ clickUrl: encodeURI(native.link.url),
+ impressionTrackers: native.imptrackers
+ };
+ native.assets.forEach(asset => {
+ switch (asset.id) {
+ case OPENRTB.NATIVE.ASSET_ID.TITLE:
+ result.title = asset.title.text;
+ break;
+ case OPENRTB.NATIVE.ASSET_ID.IMAGE:
+ result.image = {
+ url: encodeURI(asset.img.url),
+ width: asset.img.w,
+ height: asset.img.h
+ };
+ break;
+ case OPENRTB.NATIVE.ASSET_ID.ICON:
+ result.icon = {
+ url: encodeURI(asset.img.url),
+ width: asset.img.w,
+ height: asset.img.h
+ };
+ break;
+ case OPENRTB.NATIVE.ASSET_ID.BODY:
+ result.body = asset.data.value;
+ break;
+ case OPENRTB.NATIVE.ASSET_ID.SPONSORED:
+ result.sponsoredBy = asset.data.value;
+ break;
+ case OPENRTB.NATIVE.ASSET_ID.CTA:
+ result.cta = asset.data.value;
+ break;
+ }
+ });
+ return result;
+}
+
function _validateId(id) {
return (parseInt(id) > 0);
}
diff --git a/modules/adnuntiusBidAdapter.js b/modules/adnuntiusBidAdapter.js
index a2b695e55e0..b2653f16daf 100644
--- a/modules/adnuntiusBidAdapter.js
+++ b/modules/adnuntiusBidAdapter.js
@@ -15,39 +15,146 @@ const GVLID = 855;
const DEFAULT_VAST_VERSION = 'vast4'
const MAXIMUM_DEALS_LIMIT = 5;
const VALID_BID_TYPES = ['netBid', 'grossBid'];
+const META_DATA_KEY = 'adn.metaData';
-const checkSegment = function (segment) {
- if (isStr(segment)) return segment;
- if (segment.id) return segment.id
-}
+export const misc = {
+ getUnixTimestamp: function(addDays, asMinutes) {
+ const multiplication = addDays / (asMinutes ? 1440 : 1);
+ return Date.now() + (addDays && addDays > 0 ? (1000 * 60 * 60 * 24 * multiplication) : 0);
+ }
+};
+
+const storageTool = (function() {
+ const storage = getStorageManager({bidderCode: BIDDER_CODE});
+ let metaInternal;
+
+ const getMetaInternal = function() {
+ if (!storage.localStorageIsEnabled()) {
+ return {};
+ }
+
+ let parsedJson;
+ try {
+ parsedJson = JSON.parse(storage.getDataFromLocalStorage(META_DATA_KEY));
+ } catch (e) {
+ return {};
+ }
+
+ let filteredEntries = parsedJson ? parsedJson.filter((datum) => {
+ if (datum.key === 'voidAuIds' && Array.isArray(datum.value)) {
+ return true;
+ }
+ return datum.key && datum.value && datum.exp && datum.exp > misc.getUnixTimestamp();
+ }) : [];
+ const voidAuIdsEntry = filteredEntries.find(entry => entry.key === 'voidAuIds');
+ if (voidAuIdsEntry) {
+ const now = misc.getUnixTimestamp();
+ voidAuIdsEntry.value = voidAuIdsEntry.value.filter(voidAuId => voidAuId.auId && voidAuId.exp > now);
+ if (!voidAuIdsEntry.value.length) {
+ filteredEntries = filteredEntries.filter(entry => entry.key !== 'voidAuIds');
+ }
+ }
+ return filteredEntries;
+ };
+
+ const setMetaInternal = function(apiResponse) {
+ if (!storage.localStorageIsEnabled()) {
+ return;
+ }
+
+ const updateVoidAuIds = function(currentVoidAuIds, auIdsAsString) {
+ const newAuIds = auIdsAsString ? auIdsAsString.split(';') : [];
+ const notNewExistingAuIds = currentVoidAuIds.filter(auIdObj => {
+ return newAuIds.indexOf(auIdObj.value) < -1;
+ }) || [];
+ const oneDayFromNow = misc.getUnixTimestamp(1);
+ const apiIdsArray = newAuIds.map(auId => {
+ return {exp: oneDayFromNow, auId: auId};
+ }) || [];
+ return notNewExistingAuIds.concat(apiIdsArray) || [];
+ }
-const getSegmentsFromOrtb = function (ortb2) {
- const userData = deepAccess(ortb2, 'user.data');
- let segments = [];
- if (userData) {
- userData.forEach(userdat => {
- if (userdat.segment) {
- segments.push(...userdat.segment.filter(checkSegment).map(checkSegment));
+ const metaAsObj = getMetaInternal().reduce((a, entry) => ({...a, [entry.key]: {value: entry.value, exp: entry.exp}}), {});
+ for (const key in apiResponse) {
+ if (key !== 'voidAuIds') {
+ metaAsObj[key] = {
+ value: apiResponse[key],
+ exp: misc.getUnixTimestamp(100)
+ }
+ }
+ }
+ const currentAuIds = updateVoidAuIds(metaAsObj.voidAuIds || [], apiResponse.voidAuIds || []);
+ if (currentAuIds.length > 0) {
+ metaAsObj.voidAuIds = {value: currentAuIds};
+ }
+ const metaDataForSaving = Object.entries(metaAsObj).map((entrySet) => {
+ if (entrySet[0] === 'voidAuIds') {
+ return {
+ key: entrySet[0],
+ value: entrySet[1].value
+ };
+ }
+ return {
+ key: entrySet[0],
+ value: entrySet[1].value,
+ exp: entrySet[1].exp
}
});
+ storage.setDataInLocalStorage(META_DATA_KEY, JSON.stringify(metaDataForSaving));
+ };
+
+ const getUsi = function(meta, ortb2) {
+ let usi = (meta && meta.usi) ? meta.usi : false;
+ if (ortb2 && ortb2.user && ortb2.user.id) {
+ usi = ortb2.user.id
+ }
+ return usi;
}
- return segments
-}
-const handleMeta = function () {
- const storage = getStorageManager({ bidderCode: BIDDER_CODE })
- let adnMeta = null
- if (storage.localStorageIsEnabled()) {
- adnMeta = JSON.parse(storage.getDataFromLocalStorage('adn.metaData'))
+ const getSegmentsFromOrtb = function (ortb2) {
+ const userData = deepAccess(ortb2, 'user.data');
+ let segments = [];
+ if (userData) {
+ userData.forEach(userdat => {
+ if (userdat.segment) {
+ segments.push(...userdat.segment.map((segment) => {
+ if (isStr(segment)) return segment;
+ if (isStr(segment.id)) return segment.id;
+ }).filter((seg) => !!seg));
+ }
+ });
+ }
+ return segments
}
- return (adnMeta !== null) ? adnMeta.reduce((acc, cur) => { return { ...acc, [cur.key]: cur.value } }, {}) : {}
-}
-const getUsi = function (meta, ortb2, bidderRequest) {
- let usi = (meta !== null && meta.usi) ? meta.usi : false;
- if (ortb2 && ortb2.user && ortb2.user.id) { usi = ortb2.user.id }
- return usi
-}
+ return {
+ refreshStorage: function(bidderRequest) {
+ const ortb2 = bidderRequest.ortb2 || {};
+ metaInternal = getMetaInternal().reduce((a, entry) => ({...a, [entry.key]: entry.value}), {});
+ metaInternal.usi = getUsi(metaInternal, ortb2);
+ if (!metaInternal.usi) {
+ delete metaInternal.usi;
+ }
+ if (metaInternal.voidAuIds) {
+ metaInternal.voidAuIdsArray = metaInternal.voidAuIds.map((voidAuId) => {
+ return voidAuId.auId;
+ });
+ }
+ metaInternal.segments = getSegmentsFromOrtb(ortb2);
+ },
+ saveToStorage: function(serverData) {
+ setMetaInternal(serverData);
+ },
+ getUrlRelatedData: function() {
+ const {segments, usi, voidAuIdsArray} = metaInternal;
+ return {segments, usi, voidAuIdsArray};
+ },
+ getPayloadRelatedData: function() {
+ const {segments, usi, userId, voidAuIdsArray, voidAuIds, ...payloadRelatedData} = metaInternal;
+ return payloadRelatedData;
+ }
+ };
+})();
const validateBidType = function(bidTypeOption) {
return VALID_BID_TYPES.indexOf(bidTypeOption || '') > -1 ? bidTypeOption : 'bid';
@@ -67,34 +174,34 @@ export const spec = {
},
buildRequests: function (validBidRequests, bidderRequest) {
- const networks = {};
- const bidRequests = {};
- const requests = [];
- const request = [];
- const ortb2 = bidderRequest.ortb2 || {};
- const bidderConfig = config.getConfig();
+ const queryParamsAndValues = [];
+ queryParamsAndValues.push('tzo=' + new Date().getTimezoneOffset())
+ queryParamsAndValues.push('format=json')
- const adnMeta = handleMeta()
- const usi = getUsi(adnMeta, ortb2, bidderRequest)
- const segments = getSegmentsFromOrtb(ortb2);
- const tzo = new Date().getTimezoneOffset();
const gdprApplies = deepAccess(bidderRequest, 'gdprConsent.gdprApplies');
const consentString = deepAccess(bidderRequest, 'gdprConsent.consentString');
+ if (gdprApplies !== undefined) queryParamsAndValues.push('consentString=' + consentString);
- request.push('tzo=' + tzo)
- request.push('format=json')
+ storageTool.refreshStorage(bidderRequest);
- if (gdprApplies !== undefined) request.push('consentString=' + consentString);
- if (segments.length > 0) request.push('segments=' + segments.join(','));
- if (usi) request.push('userId=' + usi);
- if (bidderConfig.useCookie === false) request.push('noCookies=true');
- if (bidderConfig.maxDeals > 0) request.push('ds=' + Math.min(bidderConfig.maxDeals, MAXIMUM_DEALS_LIMIT));
+ const urlRelatedMetaData = storageTool.getUrlRelatedData();
+ if (urlRelatedMetaData.segments.length > 0) queryParamsAndValues.push('segments=' + urlRelatedMetaData.segments.join(','));
+ if (urlRelatedMetaData.usi) queryParamsAndValues.push('userId=' + urlRelatedMetaData.usi);
+
+ const bidderConfig = config.getConfig();
+ if (bidderConfig.useCookie === false) queryParamsAndValues.push('noCookies=true');
+ if (bidderConfig.maxDeals > 0) queryParamsAndValues.push('ds=' + Math.min(bidderConfig.maxDeals, MAXIMUM_DEALS_LIMIT));
+
+ const bidRequests = {};
+ const networks = {};
for (let i = 0; i < validBidRequests.length; i++) {
- const bid = validBidRequests[i]
- let network = bid.params.network || 'network';
- const maxDeals = Math.max(0, Math.min(bid.params.maxDeals || 0, MAXIMUM_DEALS_LIMIT));
- const targeting = bid.params.targeting || {};
+ const bid = validBidRequests[i];
+ if ((urlRelatedMetaData.voidAuIdsArray && (urlRelatedMetaData.voidAuIdsArray.indexOf(bid.params.auId) > -1 || urlRelatedMetaData.voidAuIdsArray.indexOf(bid.params.auId.padStart(16, '0')) > -1))) {
+ // This auId is void. Do NOT waste time and energy sending a request to the server
+ continue;
+ }
+ let network = bid.params.network || 'network';
if (bid.mediaTypes && bid.mediaTypes.video && bid.mediaTypes.video.context !== 'outstream') {
network += '_video'
}
@@ -105,21 +212,31 @@ export const spec = {
networks[network] = networks[network] || {};
networks[network].adUnits = networks[network].adUnits || [];
if (bidderRequest && bidderRequest.refererInfo) networks[network].context = bidderRequest.refererInfo.page;
- if (adnMeta) networks[network].metaData = adnMeta;
- const adUnit = { ...targeting, auId: bid.params.auId, targetId: bid.bidId, maxDeals: maxDeals }
+
+ const payloadRelatedData = storageTool.getPayloadRelatedData();
+ if (Object.keys(payloadRelatedData).length > 0) {
+ networks[network].metaData = payloadRelatedData;
+ }
+
+ const targeting = bid.params.targeting || {};
+ const adUnit = { ...targeting, auId: bid.params.auId, targetId: bid.params.targetId || bid.bidId };
+ const maxDeals = Math.max(0, Math.min(bid.params.maxDeals || 0, MAXIMUM_DEALS_LIMIT));
+ if (maxDeals > 0) {
+ adUnit.maxDeals = maxDeals;
+ }
if (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) adUnit.dimensions = bid.mediaTypes.banner.sizes
networks[network].adUnits.push(adUnit);
}
+ const requests = [];
const networkKeys = Object.keys(networks)
for (let j = 0; j < networkKeys.length; j++) {
const network = networkKeys[j];
- const networkRequest = [...request]
- if (network.indexOf('_video') > -1) { networkRequest.push('tt=' + DEFAULT_VAST_VERSION) }
+ if (network.indexOf('_video') > -1) { queryParamsAndValues.push('tt=' + DEFAULT_VAST_VERSION) }
const requestURL = gdprApplies ? ENDPOINT_URL_EUROPE : ENDPOINT_URL
requests.push({
method: 'POST',
- url: requestURL + '?' + networkRequest.join('&'),
+ url: requestURL + '?' + queryParamsAndValues.join('&'),
data: JSON.stringify(networks[network]),
bid: bidRequests[network]
});
@@ -129,6 +246,9 @@ export const spec = {
},
interpretResponse: function (serverResponse, bidRequest) {
+ if (serverResponse.body.metaData) {
+ storageTool.saveToStorage(serverResponse.body.metaData);
+ }
const adUnits = serverResponse.body.adUnits;
let validatedBidType = validateBidType(config.getConfig().bidType);
diff --git a/modules/adstirBidAdapter.js b/modules/adstirBidAdapter.js
new file mode 100644
index 00000000000..4b22d568785
--- /dev/null
+++ b/modules/adstirBidAdapter.js
@@ -0,0 +1,91 @@
+import * as utils from '../src/utils.js';
+import { config } from '../src/config.js';
+import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { BANNER } from '../src/mediaTypes.js';
+
+const BIDDER_CODE = 'adstir';
+const ENDPOINT = 'https://ad.ad-stir.com/prebid'
+
+export const spec = {
+ code: BIDDER_CODE,
+ supportedMediaTypes: [BANNER],
+
+ isBidRequestValid: function (bid) {
+ return !!(utils.isStr(bid.params.appId) && !utils.isEmptyStr(bid.params.appId) && utils.isInteger(bid.params.adSpaceNo));
+ },
+
+ buildRequests: function (validBidRequests, bidderRequest) {
+ const sua = utils.deepAccess(validBidRequests[0], 'ortb2.device.sua', null);
+
+ const requests = validBidRequests.map((r) => {
+ return {
+ method: 'POST',
+ url: ENDPOINT,
+ data: JSON.stringify({
+ appId: r.params.appId,
+ adSpaceNo: r.params.adSpaceNo,
+ auctionId: r.auctionId,
+ transactionId: r.transactionId,
+ bidId: r.bidId,
+ mediaTypes: r.mediaTypes,
+ sizes: r.sizes,
+ ref: {
+ page: bidderRequest.refererInfo.page,
+ tloc: bidderRequest.refererInfo.topmostLocation,
+ referrer: bidderRequest.refererInfo.ref,
+ topurl: config.getConfig('pageUrl') ? false : bidderRequest.refererInfo.reachedTop,
+ },
+ sua,
+ gdpr: utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies', false),
+ usp: (bidderRequest.uspConsent || '1---') !== '1---',
+ eids: utils.deepAccess(r, 'userIdAsEids', []),
+ schain: serializeSchain(utils.deepAccess(r, 'schain', null)),
+ pbVersion: '$prebid.version$',
+ }),
+ }
+ });
+
+ return requests;
+ },
+
+ interpretResponse: function (serverResponse, bidRequest) {
+ const seatbid = serverResponse.body.seatbid;
+ if (!utils.isArray(seatbid)) {
+ return [];
+ }
+ const bids = [];
+ seatbid.forEach((b) => {
+ const bid = b.bid || null;
+ if (!bid) {
+ return;
+ }
+ bids.push(bid);
+ });
+ return bids;
+ },
+}
+
+function serializeSchain(schain) {
+ if (!schain) {
+ return null;
+ }
+
+ let serializedSchain = `${schain.ver},${schain.complete}`;
+
+ schain.nodes.map(node => {
+ serializedSchain += `!${encodeURIComponentForRFC3986(node.asi || '')},`;
+ serializedSchain += `${encodeURIComponentForRFC3986(node.sid || '')},`;
+ serializedSchain += `${encodeURIComponentForRFC3986(node.hp || '')},`;
+ serializedSchain += `${encodeURIComponentForRFC3986(node.rid || '')},`;
+ serializedSchain += `${encodeURIComponentForRFC3986(node.name || '')},`;
+ serializedSchain += `${encodeURIComponentForRFC3986(node.domain || '')}`;
+ });
+
+ return serializedSchain;
+}
+
+function encodeURIComponentForRFC3986(str) {
+ return encodeURIComponent(str).replace(/[!'()*]/g, c => `%${c.charCodeAt(0).toString(16)}`);
+}
+
+registerBidder(spec);
diff --git a/modules/adstirBidAdapter.md b/modules/adstirBidAdapter.md
new file mode 100644
index 00000000000..7485375a09d
--- /dev/null
+++ b/modules/adstirBidAdapter.md
@@ -0,0 +1,36 @@
+# Overview
+
+```
+Module Name: adstir Bidder Adapter
+Module Type: Bidder Adapter
+Maintainer: support@ad-stir.com
+```
+
+# Description
+
+Module that connects to adstir's demand sources
+
+# Test Parameters
+
+```
+ var adUnits = [
+ // Banner adUnit
+ {
+ code: 'test-div',
+ mediaTypes: {
+ banner: {
+ sizes: [[300, 250]],
+ }
+ },
+ bids: [
+ {
+ bidder: 'adstir',
+ params: {
+ appId: 'TEST-MEDIA',
+ adSpaceNo: 1,
+ }
+ }
+ ]
+ }
+ ];
+```
diff --git a/modules/adtelligentBidAdapter.js b/modules/adtelligentBidAdapter.js
index 04bca21c60f..8e6aeecdd75 100644
--- a/modules/adtelligentBidAdapter.js
+++ b/modules/adtelligentBidAdapter.js
@@ -21,7 +21,8 @@ const HOST_GETTERS = {
janet: () => 'ghb.bidder.jmgads.com',
ocm: () => 'ghb.cenarius.orangeclickmedia.com',
'9dotsmedia': () => 'ghb.platform.audiodots.com',
- copper6: () => 'ghb.app.copper6.com'
+ copper6: () => 'ghb.app.copper6.com',
+ indicue: () => 'ghb.console.indicue.com',
}
const getUri = function (bidderCode) {
let bidderWithoutSuffix = bidderCode.split('_')[0];
@@ -44,6 +45,7 @@ export const spec = {
{ code: 'ocm', gvlid: 1148 },
'9dotsmedia',
'copper6',
+ 'indicue',
],
supportedMediaTypes: [VIDEO, BANNER],
isBidRequestValid: function (bid) {
diff --git a/modules/adxcgBidAdapter.js b/modules/adxcgBidAdapter.js
index 5930f3adb67..dda88575ff5 100644
--- a/modules/adxcgBidAdapter.js
+++ b/modules/adxcgBidAdapter.js
@@ -1,307 +1,65 @@
// jshint esversion: 6, es3: false, node: true
-'use strict';
-
-import {registerBidder} from '../src/adapters/bidderFactory.js';
-import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
+import { ortbConverter } from '../libraries/ortbConverter/converter.js';
+import { convertTypes } from '../libraries/transformParamsUtils/convertTypes.js';
+import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import {
- _map,
- deepAccess,
- deepSetValue,
- getDNT,
isArray,
- isPlainObject,
- isStr,
- mergeDeep,
- parseSizesInput,
replaceAuctionPrice,
- triggerPixel
+ triggerPixel,
+ logMessage,
+ deepSetValue,
+ getBidIdParameter
} from '../src/utils.js';
-import {config} from '../src/config.js';
-import { convertOrtbRequestToProprietaryNative } from '../src/native.js';
-
-const { getConfig } = config;
+import { config } from '../src/config.js';
const BIDDER_CODE = 'adxcg';
const SECURE_BID_URL = 'https://pbc.adxcg.net/rtb/ortb/pbc?adExchangeId=1';
-const NATIVE_ASSET_IDS = { 0: 'title', 2: 'icon', 3: 'image', 5: 'sponsoredBy', 4: 'body', 1: 'cta' };
-const NATIVE_PARAMS = {
- title: {
- id: 0,
- name: 'title'
- },
- icon: {
- id: 2,
- type: 1,
- name: 'img'
- },
- image: {
- id: 3,
- type: 3,
- name: 'img'
- },
- sponsoredBy: {
- id: 5,
- name: 'data',
- type: 1
- },
- body: {
- id: 4,
- name: 'data',
- type: 2
- },
- cta: {
- id: 1,
- type: 12,
- name: 'data'
- }
-};
+const DEFAULT_CURRENCY = 'EUR';
+const KNOWN_PARAMS = ['cp', 'ct', 'cf', 'battr', 'deals'];
+const DEFAULT_TMAX = 500;
+/**
+ * Adxcg Bid Adapter.
+ *
+ */
export const spec = {
+
code: BIDDER_CODE,
- supportedMediaTypes: [ NATIVE, BANNER, VIDEO ],
+
+ aliases: ['mediaopti'],
+
+ supportedMediaTypes: [BANNER, NATIVE, VIDEO],
+
isBidRequestValid: (bid) => {
+ logMessage('adxcg - validating isBidRequestValid');
const params = bid.params || {};
const { adzoneid } = params;
return !!(adzoneid);
},
- buildRequests: (validBidRequests, bidderRequest) => {
- // convert Native ORTB definition to old-style prebid native definition
- validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);
-
- let app, site;
-
- const commonFpd = bidderRequest.ortb2 || {};
- let { user } = commonFpd;
-
- if (typeof getConfig('app') === 'object') {
- app = getConfig('app') || {};
- if (commonFpd.app) {
- mergeDeep(app, commonFpd.app);
- }
- } else {
- site = getConfig('site') || {};
- if (commonFpd.site) {
- mergeDeep(site, commonFpd.site);
- }
-
- if (!site.page) {
- site.page = bidderRequest.refererInfo.page;
- site.domain = bidderRequest.refererInfo.domain;
- }
- }
-
- const device = getConfig('device') || {};
- device.w = device.w || window.innerWidth;
- device.h = device.h || window.innerHeight;
- device.ua = device.ua || navigator.userAgent;
- device.dnt = getDNT() ? 1 : 0;
- device.language = (navigator && navigator.language) ? navigator.language.split('-')[0] : '';
-
- const tid = bidderRequest.ortb2?.source?.tid;
- const test = setOnAny(validBidRequests, 'params.test');
- const currency = getConfig('currency.adServerCurrency');
- const cur = currency && [ currency ];
- const eids = setOnAny(validBidRequests, 'userIdAsEids');
- const schain = setOnAny(validBidRequests, 'schain');
-
- const imp = validBidRequests.map((bid, id) => {
- const floorInfo = bid.getFloor ? bid.getFloor({
- currency: currency || 'USD'
- }) : {};
- const bidfloor = floorInfo.floor;
- const bidfloorcur = floorInfo.currency;
- const { adzoneid } = bid.params;
-
- const imp = {
- id: id + 1,
- tagid: adzoneid,
- secure: 1,
- bidfloor,
- bidfloorcur,
- ext: {
- }
- };
-
- const assets = _map(bid.nativeParams, (bidParams, key) => {
- const props = NATIVE_PARAMS[key];
- const asset = {
- required: bidParams.required & 1,
- };
- if (props) {
- asset.id = props.id;
- let wmin, hmin, w, h;
- let aRatios = bidParams.aspect_ratios;
-
- if (aRatios && aRatios[0]) {
- aRatios = aRatios[0];
- wmin = aRatios.min_width || 0;
- hmin = aRatios.ratio_height * wmin / aRatios.ratio_width | 0;
- }
-
- if (bidParams.sizes) {
- const sizes = flatten(bidParams.sizes);
- w = sizes[0];
- h = sizes[1];
- }
-
- asset[props.name] = {
- len: bidParams.len,
- type: props.type,
- wmin,
- hmin,
- w,
- h
- };
-
- return asset;
- }
- }).filter(Boolean);
-
- if (assets.length) {
- imp.native = {
- request: JSON.stringify({assets: assets})
- };
- }
-
- const bannerParams = deepAccess(bid, 'mediaTypes.banner');
-
- if (bannerParams && bannerParams.sizes) {
- const sizes = parseSizesInput(bannerParams.sizes);
- const format = sizes.map(size => {
- const [ width, height ] = size.split('x');
- const w = parseInt(width, 10);
- const h = parseInt(height, 10);
- return { w, h };
- });
-
- imp.banner = {
- format
- };
- }
-
- const videoParams = deepAccess(bid, 'mediaTypes.video');
- if (videoParams) {
- imp.video = videoParams;
- }
-
- return imp;
- });
-
- const request = {
- id: bidderRequest.auctionId,
- site,
- app,
- user,
- geo: { utcoffset: new Date().getTimezoneOffset() },
- device,
- source: { tid, fd: 1 },
- ext: {
- prebid: {
- channel: {
- name: 'pbjs',
- version: '$prebid.version$'
- }
- }
- },
- cur,
- imp
- };
-
- if (test) {
- request.is_debug = !!test;
- request.test = 1;
- }
- if (deepAccess(bidderRequest, 'gdprConsent.gdprApplies') !== undefined) {
- deepSetValue(request, 'user.ext.consent', bidderRequest.gdprConsent.consentString);
- deepSetValue(request, 'regs.ext.gdpr', bidderRequest.gdprConsent.gdprApplies & 1);
- }
-
- if (bidderRequest.uspConsent) {
- deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent);
- }
-
- if (eids) {
- deepSetValue(request, 'user.ext.eids', eids);
- }
-
- if (schain) {
- deepSetValue(request, 'source.ext.schain', schain);
- }
+ buildRequests: (bidRequests, bidderRequest) => {
+ const data = converter.toORTB({ bidRequests, bidderRequest });
return {
method: 'POST',
url: SECURE_BID_URL,
- data: JSON.stringify(request),
+ data,
options: {
contentType: 'application/json'
},
- bids: validBidRequests
+ bidderRequest
};
},
- interpretResponse: function(serverResponse, { bids }) {
- if (!serverResponse.body) {
- return;
- }
- const { seatbid, cur } = serverResponse.body;
-
- const bidResponses = flatten(seatbid.map(seat => seat.bid)).reduce((result, bid) => {
- result[bid.impid - 1] = bid;
- return result;
- }, []);
-
- return bids.map((bid, id) => {
- const bidResponse = bidResponses[id];
- if (bidResponse) {
- const mediaType = deepAccess(bidResponse, 'ext.crType');
- const result = {
- requestId: bid.bidId,
- cpm: bidResponse.price,
- creativeId: bidResponse.crid,
- ttl: bidResponse.ttl ? bidResponse.ttl : 300,
- netRevenue: bid.netRevenue === 'net',
- currency: cur,
- burl: bid.burl || '',
- mediaType: mediaType,
- width: bidResponse.w,
- height: bidResponse.h,
- dealId: bidResponse.dealid,
- };
- deepSetValue(result, 'meta.mediaType', mediaType);
- if (isArray(bidResponse.adomain)) {
- deepSetValue(result, 'meta.advertiserDomains', bidResponse.adomain);
- }
-
- if (isPlainObject(bidResponse.ext)) {
- if (isStr(bidResponse.ext.mediaType)) {
- deepSetValue(result, 'meta.mediaType', mediaType);
- }
- if (isStr(bidResponse.ext.advertiser_id)) {
- deepSetValue(result, 'meta.advertiserId', bidResponse.ext.advertiser_id);
- }
- if (isStr(bidResponse.ext.advertiser_name)) {
- deepSetValue(result, 'meta.advertiserName', bidResponse.ext.advertiser_name);
- }
- if (isStr(bidResponse.ext.agency_name)) {
- deepSetValue(result, 'meta.agencyName', bidResponse.ext.agency_name);
- }
- }
- if (mediaType === BANNER) {
- result.ad = bidResponse.adm;
- } else if (mediaType === NATIVE) {
- result.native = parseNative(bidResponse);
- result.width = 0;
- result.height = 0;
- } else if (mediaType === VIDEO) {
- result.vastUrl = bidResponse.nurl;
- result.vastXml = bidResponse.adm;
- }
-
- return result;
- }
- }).filter(Boolean);
+ interpretResponse: (response, request) => {
+ if (response.body) {
+ const bids = converter.fromORTB({ response: response.body, request: request.data }).bids;
+ return bids;
+ }
+ return [];
},
+
getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent) => {
const syncs = [];
let syncUrl = config.getConfig('adxcg.usersyncUrl');
@@ -323,44 +81,95 @@ export const spec = {
}
return syncs;
},
+
onBidWon: (bid) => {
// for native requests we put the nurl as an imp tracker, otherwise if the auction takes place on prebid server
// the server JS adapter puts the nurl in the adm as a tracking pixel and removes the attribute
if (bid.nurl) {
triggerPixel(replaceAuctionPrice(bid.nurl, bid.originalCpm))
}
+ },
+ transformBidParams: function (params) {
+ return convertTypes({
+ 'cf': 'string',
+ 'cp': 'number',
+ 'ct': 'number',
+ 'adzoneid': 'string'
+ }, params);
}
};
-registerBidder(spec);
+const converter = ortbConverter({
+ context: {
+ netRevenue: true,
+ ttl: 300,
+ currency: 'EUR'
+ },
-function parseNative(bid) {
- const { assets, link, imptrackers, jstracker } = JSON.parse(bid.adm);
- const result = {
- clickUrl: link.url,
- clickTrackers: link.clicktrackers || undefined,
- impressionTrackers: imptrackers || undefined,
- javascriptTrackers: jstracker ? [ jstracker ] : undefined
- };
- assets.forEach(asset => {
- const kind = NATIVE_ASSET_IDS[asset.id];
- const content = kind && asset[NATIVE_PARAMS[kind].name];
- if (content) {
- result[kind] = content.text || content.value || { url: content.url, width: content.w, height: content.h };
+ imp(buildImp, bidRequest, context) {
+ const imp = buildImp(bidRequest, context);
+ // tagid
+ imp.tagid = bidRequest.params.adzoneid.toString();
+ // unknown params
+ const unknownParams = slotUnknownParams(bidRequest);
+ if (imp.ext || unknownParams) {
+ imp.ext = Object.assign({}, imp.ext, unknownParams);
+ }
+ // battr
+ if (bidRequest.params.battr) {
+ ['banner', 'video', 'audio', 'native'].forEach(k => {
+ if (imp[k]) {
+ imp[k].battr = bidRequest.params.battr;
+ }
+ });
+ }
+ // deals
+ if (bidRequest.params.deals && isArray(bidRequest.params.deals)) {
+ imp.pmp = {
+ private_auction: 0,
+ deals: bidRequest.params.deals
+ };
}
- });
- return result;
-}
-function setOnAny(collection, key) {
- for (let i = 0, result; i < collection.length; i++) {
- result = deepAccess(collection[i], key);
- if (result) {
- return result;
+ imp.secure = Number(window.location.protocol === 'https:');
+
+ if (!imp.bidfloor && bidRequest.params.bidFloor) {
+ imp.bidfloor = bidRequest.params.bidFloor;
+ imp.bidfloorcur = getBidIdParameter('bidFloorCur', bidRequest.params).toUpperCase() || 'USD'
}
- }
-}
+ return imp;
+ },
+
+ request(buildRequest, imps, bidderRequest, context) {
+ const request = buildRequest(imps, bidderRequest, context);
+ request.tmax = request.tmax || DEFAULT_TMAX;
+ request.test = config.getConfig('debug') ? 1 : 0;
+ request.at = 1;
+ deepSetValue(request, 'ext.prebid.channel.name', 'pbjs');
+ deepSetValue(request, 'ext.prebid.channel.version', '$prebid.version$');
+ return request;
+ },
-function flatten(arr) {
- return [].concat(...arr);
+ bidResponse(buildBidResponse, bid, context) {
+ const bidResponse = buildBidResponse(bid, context);
+ bidResponse.cur = bid.cur || DEFAULT_CURRENCY;
+ return bidResponse;
+ },
+});
+
+/**
+ * Unknown params are captured and sent on ext
+ */
+function slotUnknownParams(slot) {
+ const ext = {};
+ const knownParamsMap = {};
+ KNOWN_PARAMS.forEach(value => knownParamsMap[value] = 1);
+ Object.keys(slot.params).forEach(key => {
+ if (!knownParamsMap[key]) {
+ ext[key] = slot.params[key];
+ }
+ });
+ return Object.keys(ext).length > 0 ? { prebid: ext } : null;
}
+
+registerBidder(spec);
diff --git a/modules/agmaAnalyticsAdapter.js b/modules/agmaAnalyticsAdapter.js
new file mode 100644
index 00000000000..afbc3e771ec
--- /dev/null
+++ b/modules/agmaAnalyticsAdapter.js
@@ -0,0 +1,225 @@
+import { ajax } from '../src/ajax.js';
+import {
+ generateUUID,
+ logInfo,
+ logError,
+ getPerformanceNow,
+ isEmpty,
+ isEmptyStr,
+} from '../src/utils.js';
+import { getGlobal } from '../src/prebidGlobal.js';
+import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js';
+import CONSTANTS from '../src/constants.json';
+import adapterManager, { gdprDataHandler } from '../src/adapterManager.js';
+import { getRefererInfo } from '../src/refererDetection.js';
+import { config } from '../src/config.js';
+
+const GVLID = 1122;
+const ModuleCode = 'agma';
+const analyticsType = 'endpoint';
+const scriptVersion = '1.7.0';
+const batchDelayInMs = 1000;
+const agmaURL = 'https://pbc.agma-analytics.de/v1';
+const pageViewId = generateUUID();
+
+const {
+ EVENTS: { AUCTION_INIT },
+} = CONSTANTS;
+
+// Helper functions
+const getScreen = () => {
+ const w = window;
+ const d = document;
+ const e = d.documentElement;
+ const g = d.getElementsByTagName('body')[0];
+ const x = w.innerWidth || e.clientWidth || g.clientWidth;
+ const y = w.innerHeight || e.clientHeight || g.clientHeight;
+ return { x, y };
+};
+
+const getUserIDs = () => {
+ try {
+ return getGlobal().getUserIdsAsEids();
+ } catch (e) {}
+ return [];
+};
+
+export const getOrtb2Data = (options) => {
+ let site = null;
+ let user = null;
+
+ // check if data is provided via config
+ if (options.ortb2) {
+ if (options.ortb2.user) {
+ user = options.ortb2.user;
+ }
+ if (options.ortb2.site) {
+ site = options.ortb2.site;
+ }
+ if (site && user) {
+ return { site, user };
+ }
+ }
+ try {
+ const configData = config.getConfig('agma');
+ // try to fallback to global config
+ if (configData.ortb2) {
+ site = site || configData.ortb2.site;
+ user = user || configData.ortb2.user;
+ }
+ } catch (e) {}
+
+ return { site, user };
+};
+
+export const getTiming = () => {
+ // Timing API V2
+ let ttfb = 0;
+ try {
+ const entry = performance.getEntriesByType('navigation')[0];
+ ttfb = Math.round(entry.responseStart - entry.startTime);
+ } catch (e) {
+ // Timing API V1
+ try {
+ const entry = performance.timing;
+ ttfb = Math.round(entry.responseStart - entry.fetchStart);
+ } catch (e) {
+ // Timing API not available
+ return null;
+ }
+ }
+ const elapsedTime = getPerformanceNow();
+ ttfb = ttfb >= 0 && ttfb <= elapsedTime ? ttfb : 0;
+ return {
+ ttfb,
+ elapsedTime,
+ };
+};
+
+export const getPayload = (auctionIds, options) => {
+ if (!options || !auctionIds || auctionIds.length === 0) {
+ return false;
+ }
+ const consentData = gdprDataHandler.getConsentData();
+ let gdprApplies = true; // we assume gdpr applies
+ let useExtendedPayload = false;
+ if (consentData) {
+ gdprApplies = consentData.gdprApplies;
+ const consents = consentData.vendorData?.vendor?.consents || {};
+ useExtendedPayload = consents[GVLID];
+ }
+ const ortb2 = getOrtb2Data(options);
+ const ri = getRefererInfo() || {};
+
+ let payload = {
+ auctionIds: auctionIds,
+ triggerEvent: options.triggerEvent,
+ pageViewId,
+ domain: ri.domain,
+ gdprApplies,
+ code: options.code,
+ ortb2: { site: ortb2.site },
+ pageUrl: ri.page,
+ prebidVersion: '$prebid.version$',
+ scriptVersion,
+ debug: options.debug,
+ timing: getTiming(),
+ };
+
+ if (useExtendedPayload) {
+ const { x, y } = getScreen();
+ const userIdsAsEids = getUserIDs();
+ payload = {
+ ...payload,
+ ortb2,
+ extended: true,
+ timestamp: Date.now(),
+ gdprConsentString: consentData.consentString,
+ timezoneOffset: new Date().getTimezoneOffset(),
+ language: window.navigator.language,
+ referrer: ri.topmostLocation,
+ pageUrl: ri.page,
+ screenWidth: x,
+ screenHeight: y,
+ userIdsAsEids,
+ };
+ }
+ return payload;
+};
+
+const agmaAnalytics = Object.assign(adapter({ analyticsType }), {
+ auctionIds: [],
+ timer: null,
+ track(data) {
+ const { eventType, args } = data;
+ if (eventType === this.options.triggerEvent && args && args.auctionId) {
+ this.auctionIds.push(args.auctionId);
+ if (this.timer === null) {
+ this.timer = setTimeout(() => {
+ this.processBatch();
+ }, batchDelayInMs);
+ }
+ }
+ },
+ processBatch() {
+ const currentBatch = [...this.auctionIds];
+ const payload = getPayload(currentBatch, this.options);
+ this.auctionIds = [];
+ if (this.timer) {
+ clearTimeout(this.timer);
+ this.timer = null;
+ }
+ this.send(payload);
+ },
+ send(payload) {
+ if (!payload) {
+ return;
+ }
+ return ajax(
+ agmaURL,
+ () => {
+ logInfo(ModuleCode, 'flushed', payload);
+ },
+ JSON.stringify(payload),
+ {
+ contentType: 'text/plain',
+ method: 'POST',
+ }
+ );
+ },
+});
+
+agmaAnalytics.originEnableAnalytics = agmaAnalytics.enableAnalytics;
+agmaAnalytics.enableAnalytics = function (config = {}) {
+ const { options } = config;
+
+ if (isEmpty(options)) {
+ logError(ModuleCode, 'Please set options');
+ return false;
+ }
+
+ if (options.site && !options.code) {
+ logError(ModuleCode, 'Please set `code` - `site` is deprecated');
+ options.code = options.site;
+ }
+
+ if (!options.code || isEmptyStr(options.code)) {
+ logError(ModuleCode, 'Please set `code` option - agma Analytics is disabled');
+ return false;
+ }
+
+ agmaAnalytics.options = {
+ triggerEvent: AUCTION_INIT,
+ ...options,
+ };
+
+ agmaAnalytics.originEnableAnalytics(config);
+};
+
+adapterManager.registerAnalyticsAdapter({
+ adapter: agmaAnalytics,
+ code: ModuleCode,
+ gvlid: GVLID,
+});
+
+export default agmaAnalytics;
diff --git a/modules/agmaAnalyticsAdapter.md b/modules/agmaAnalyticsAdapter.md
new file mode 100644
index 00000000000..30c88fb92ec
--- /dev/null
+++ b/modules/agmaAnalyticsAdapter.md
@@ -0,0 +1,28 @@
+# Overview
+ Module Name: Agma Analytics
+ Module Type: Analytics Adapter
+ Maintainer: [www.agma-mmc.de](https://www.agma-mmc.de)
+ Technical Support: [info@mllrsohn.com](mailto:info@mllrsohn.com)
+
+# Description
+
+Agma Analytics adapter. Please contact [team-internet@agma-mmc.de](mailto:team-internet@agma-mmc.de) for signup and access to [futher documentation](https://docs.agma-analytics.de).
+
+# Usage
+
+Add the `agmaAnalyticsAdapter` to your build:
+
+```
+gulp build --modules=...,agmaAnalyticsAdapter...
+```
+
+Configure the analytics module:
+
+```javascript
+pbjs.enableAnalytics({
+ provider: 'agma',
+ options: {
+ code: 'provided-by-agma' // change to the code you received from agma
+ }
+});
+```
diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js
index e6b3441b988..c6230d9f1e4 100644
--- a/modules/appnexusBidAdapter.js
+++ b/modules/appnexusBidAdapter.js
@@ -110,6 +110,7 @@ export const spec = {
{ code: 'beintoo', gvlid: 618 },
{ code: 'projectagora', gvlid: 1032 },
{ code: 'uol', gvlid: 32 },
+ { code: 'adzymic', gvlid: 32 },
],
supportedMediaTypes: [BANNER, VIDEO, NATIVE],
diff --git a/modules/asteriobidAnalyticsAdapter.js b/modules/asteriobidAnalyticsAdapter.js
new file mode 100644
index 00000000000..516a3a65667
--- /dev/null
+++ b/modules/asteriobidAnalyticsAdapter.js
@@ -0,0 +1,336 @@
+import { generateUUID, getParameterByName, logError, logInfo, parseUrl } from '../src/utils.js'
+import { ajaxBuilder } from '../src/ajax.js'
+import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'
+import adapterManager from '../src/adapterManager.js'
+import { getStorageManager } from '../src/storageManager.js'
+import CONSTANTS from '../src/constants.json'
+import { MODULE_TYPE_ANALYTICS } from '../src/activities/modules.js'
+import {getRefererInfo} from '../src/refererDetection.js';
+
+/**
+ * asteriobidAnalyticsAdapter.js - analytics adapter for AsterioBid
+ */
+export const storage = getStorageManager({ moduleType: MODULE_TYPE_ANALYTICS, moduleName: 'asteriobid' })
+const DEFAULT_EVENT_URL = 'https://endpt.asteriobid.com/endpoint'
+const analyticsType = 'endpoint'
+const analyticsName = 'AsterioBid Analytics'
+const utmTags = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content']
+const _VERSION = 1
+
+let ajax = ajaxBuilder(20000)
+let initOptions
+let auctionStarts = {}
+let auctionTimeouts = {}
+let sampling
+let pageViewId
+let flushInterval
+let eventQueue = []
+let asteriobidAnalyticsEnabled = false
+
+let asteriobidAnalytics = Object.assign(adapter({ url: DEFAULT_EVENT_URL, analyticsType }), {
+ track({ eventType, args }) {
+ handleEvent(eventType, args)
+ }
+})
+
+asteriobidAnalytics.originEnableAnalytics = asteriobidAnalytics.enableAnalytics
+asteriobidAnalytics.enableAnalytics = function (config) {
+ initOptions = config.options || {}
+
+ pageViewId = initOptions.pageViewId || generateUUID()
+ sampling = initOptions.sampling || 1
+
+ if (Math.floor(Math.random() * sampling) === 0) {
+ asteriobidAnalyticsEnabled = true
+ flushInterval = setInterval(flush, 1000)
+ } else {
+ logInfo(`${analyticsName} isn't enabled because of sampling`)
+ }
+
+ asteriobidAnalytics.originEnableAnalytics(config)
+}
+
+asteriobidAnalytics.originDisableAnalytics = asteriobidAnalytics.disableAnalytics
+asteriobidAnalytics.disableAnalytics = function () {
+ if (!asteriobidAnalyticsEnabled) {
+ return
+ }
+ flush()
+ clearInterval(flushInterval)
+ asteriobidAnalytics.originDisableAnalytics()
+}
+
+function collectUtmTagData() {
+ let newUtm = false
+ let pmUtmTags = {}
+ try {
+ utmTags.forEach(function (utmKey) {
+ let utmValue = getParameterByName(utmKey)
+ if (utmValue !== '') {
+ newUtm = true
+ }
+ pmUtmTags[utmKey] = utmValue
+ })
+ if (newUtm === false) {
+ utmTags.forEach(function (utmKey) {
+ let itemValue = storage.getDataFromLocalStorage(`pm_${utmKey}`)
+ if (itemValue && itemValue.length !== 0) {
+ pmUtmTags[utmKey] = itemValue
+ }
+ })
+ } else {
+ utmTags.forEach(function (utmKey) {
+ storage.setDataInLocalStorage(`pm_${utmKey}`, pmUtmTags[utmKey])
+ })
+ }
+ } catch (e) {
+ logError(`${analyticsName} Error`, e)
+ pmUtmTags['error_utm'] = 1
+ }
+ return pmUtmTags
+}
+
+function collectPageInfo() {
+ const pageInfo = {
+ domain: window.location.hostname,
+ }
+ if (document.referrer) {
+ pageInfo.referrerDomain = parseUrl(document.referrer).hostname
+ }
+
+ const refererInfo = getRefererInfo()
+ pageInfo.page = refererInfo.page
+ pageInfo.ref = refererInfo.ref
+
+ return pageInfo
+}
+
+function flush() {
+ if (!asteriobidAnalyticsEnabled) {
+ return
+ }
+
+ if (eventQueue.length > 0) {
+ const data = {
+ pageViewId: pageViewId,
+ ver: _VERSION,
+ bundleId: initOptions.bundleId,
+ events: eventQueue,
+ utmTags: collectUtmTagData(),
+ pageInfo: collectPageInfo(),
+ sampling: sampling
+ }
+ eventQueue = []
+
+ if ('version' in initOptions) {
+ data.version = initOptions.version
+ }
+ if ('tcf_compliant' in initOptions) {
+ data.tcf_compliant = initOptions.tcf_compliant
+ }
+ if ('adUnitDict' in initOptions) {
+ data.adUnitDict = initOptions.adUnitDict;
+ }
+ if ('customParam' in initOptions) {
+ data.customParam = initOptions.customParam;
+ }
+
+ const url = initOptions.url ? initOptions.url : DEFAULT_EVENT_URL
+ ajax(
+ url,
+ () => logInfo(`${analyticsName} sent events batch`),
+ _VERSION + ':' + JSON.stringify(data),
+ {
+ contentType: 'text/plain',
+ method: 'POST',
+ withCredentials: true
+ }
+ )
+ }
+}
+
+function trimAdUnit(adUnit) {
+ if (!adUnit) return adUnit
+ const res = {}
+ res.code = adUnit.code
+ res.sizes = adUnit.sizes
+ return res
+}
+
+function trimBid(bid) {
+ if (!bid) return bid
+ const res = {}
+ res.auctionId = bid.auctionId
+ res.bidder = bid.bidder
+ res.bidderRequestId = bid.bidderRequestId
+ res.bidId = bid.bidId
+ res.crumbs = bid.crumbs
+ res.cpm = bid.cpm
+ res.currency = bid.currency
+ res.mediaTypes = bid.mediaTypes
+ res.sizes = bid.sizes
+ res.transactionId = bid.transactionId
+ res.adUnitCode = bid.adUnitCode
+ res.bidRequestsCount = bid.bidRequestsCount
+ res.serverResponseTimeMs = bid.serverResponseTimeMs
+ return res
+}
+
+function trimBidderRequest(bidderRequest) {
+ if (!bidderRequest) return bidderRequest
+ const res = {}
+ res.auctionId = bidderRequest.auctionId
+ res.auctionStart = bidderRequest.auctionStart
+ res.bidderRequestId = bidderRequest.bidderRequestId
+ res.bidderCode = bidderRequest.bidderCode
+ res.bids = bidderRequest.bids && bidderRequest.bids.map(trimBid)
+ return res
+}
+
+function handleEvent(eventType, eventArgs) {
+ if (!asteriobidAnalyticsEnabled) {
+ return
+ }
+
+ try {
+ eventArgs = eventArgs ? JSON.parse(JSON.stringify(eventArgs)) : {}
+ } catch (e) {
+ // keep eventArgs as is
+ }
+
+ const pmEvent = {}
+ pmEvent.timestamp = eventArgs.timestamp || Date.now()
+ pmEvent.eventType = eventType
+
+ switch (eventType) {
+ case CONSTANTS.EVENTS.AUCTION_INIT: {
+ pmEvent.auctionId = eventArgs.auctionId
+ pmEvent.timeout = eventArgs.timeout
+ pmEvent.adUnits = eventArgs.adUnits && eventArgs.adUnits.map(trimAdUnit)
+ pmEvent.bidderRequests = eventArgs.bidderRequests && eventArgs.bidderRequests.map(trimBidderRequest)
+ auctionStarts[pmEvent.auctionId] = pmEvent.timestamp
+ auctionTimeouts[pmEvent.auctionId] = pmEvent.timeout
+ break
+ }
+ case CONSTANTS.EVENTS.AUCTION_END: {
+ pmEvent.auctionId = eventArgs.auctionId
+ pmEvent.end = eventArgs.end
+ pmEvent.start = eventArgs.start
+ pmEvent.adUnitCodes = eventArgs.adUnitCodes
+ pmEvent.bidsReceived = eventArgs.bidsReceived && eventArgs.bidsReceived.map(trimBid)
+ pmEvent.start = auctionStarts[pmEvent.auctionId]
+ pmEvent.end = Date.now()
+ break
+ }
+ case CONSTANTS.EVENTS.BID_ADJUSTMENT: {
+ break
+ }
+ case CONSTANTS.EVENTS.BID_TIMEOUT: {
+ pmEvent.bidders = eventArgs && eventArgs.map ? eventArgs.map(trimBid) : eventArgs
+ pmEvent.duration = auctionTimeouts[pmEvent.auctionId]
+ break
+ }
+ case CONSTANTS.EVENTS.BID_REQUESTED: {
+ pmEvent.auctionId = eventArgs.auctionId
+ pmEvent.bidderCode = eventArgs.bidderCode
+ pmEvent.doneCbCallCount = eventArgs.doneCbCallCount
+ pmEvent.start = eventArgs.start
+ pmEvent.bidderRequestId = eventArgs.bidderRequestId
+ pmEvent.bids = eventArgs.bids && eventArgs.bids.map(trimBid)
+ pmEvent.auctionStart = eventArgs.auctionStart
+ pmEvent.timeout = eventArgs.timeout
+ break
+ }
+ case CONSTANTS.EVENTS.BID_RESPONSE: {
+ pmEvent.bidderCode = eventArgs.bidderCode
+ pmEvent.width = eventArgs.width
+ pmEvent.height = eventArgs.height
+ pmEvent.adId = eventArgs.adId
+ pmEvent.mediaType = eventArgs.mediaType
+ pmEvent.cpm = eventArgs.cpm
+ pmEvent.currency = eventArgs.currency
+ pmEvent.requestId = eventArgs.requestId
+ pmEvent.adUnitCode = eventArgs.adUnitCode
+ pmEvent.auctionId = eventArgs.auctionId
+ pmEvent.timeToRespond = eventArgs.timeToRespond
+ pmEvent.requestTimestamp = eventArgs.requestTimestamp
+ pmEvent.responseTimestamp = eventArgs.responseTimestamp
+ pmEvent.netRevenue = eventArgs.netRevenue
+ pmEvent.size = eventArgs.size
+ pmEvent.adserverTargeting = eventArgs.adserverTargeting
+ break
+ }
+ case CONSTANTS.EVENTS.BID_WON: {
+ pmEvent.auctionId = eventArgs.auctionId
+ pmEvent.adId = eventArgs.adId
+ pmEvent.adserverTargeting = eventArgs.adserverTargeting
+ pmEvent.adUnitCode = eventArgs.adUnitCode
+ pmEvent.bidderCode = eventArgs.bidderCode
+ pmEvent.height = eventArgs.height
+ pmEvent.mediaType = eventArgs.mediaType
+ pmEvent.netRevenue = eventArgs.netRevenue
+ pmEvent.cpm = eventArgs.cpm
+ pmEvent.requestTimestamp = eventArgs.requestTimestamp
+ pmEvent.responseTimestamp = eventArgs.responseTimestamp
+ pmEvent.size = eventArgs.size
+ pmEvent.width = eventArgs.width
+ pmEvent.currency = eventArgs.currency
+ pmEvent.bidder = eventArgs.bidder
+ break
+ }
+ case CONSTANTS.EVENTS.BIDDER_DONE: {
+ pmEvent.auctionId = eventArgs.auctionId
+ pmEvent.auctionStart = eventArgs.auctionStart
+ pmEvent.bidderCode = eventArgs.bidderCode
+ pmEvent.bidderRequestId = eventArgs.bidderRequestId
+ pmEvent.bids = eventArgs.bids && eventArgs.bids.map(trimBid)
+ pmEvent.doneCbCallCount = eventArgs.doneCbCallCount
+ pmEvent.start = eventArgs.start
+ pmEvent.timeout = eventArgs.timeout
+ pmEvent.tid = eventArgs.tid
+ pmEvent.src = eventArgs.src
+ break
+ }
+ case CONSTANTS.EVENTS.SET_TARGETING: {
+ break
+ }
+ case CONSTANTS.EVENTS.REQUEST_BIDS: {
+ break
+ }
+ case CONSTANTS.EVENTS.ADD_AD_UNITS: {
+ break
+ }
+ case CONSTANTS.EVENTS.AD_RENDER_FAILED: {
+ pmEvent.bid = eventArgs.bid
+ pmEvent.message = eventArgs.message
+ pmEvent.reason = eventArgs.reason
+ break
+ }
+ default:
+ return
+ }
+
+ sendEvent(pmEvent)
+}
+
+function sendEvent(event) {
+ eventQueue.push(event)
+ logInfo(`${analyticsName} Event ${event.eventType}:`, event)
+
+ if (event.eventType === CONSTANTS.EVENTS.AUCTION_END) {
+ flush()
+ }
+}
+
+adapterManager.registerAnalyticsAdapter({
+ adapter: asteriobidAnalytics,
+ code: 'asteriobid'
+})
+
+asteriobidAnalytics.getOptions = function () {
+ return initOptions
+}
+
+asteriobidAnalytics.flush = flush
+
+export default asteriobidAnalytics
diff --git a/modules/asteriobidAnalyticsAdapter.md b/modules/asteriobidAnalyticsAdapter.md
new file mode 100644
index 00000000000..524cf6e2721
--- /dev/null
+++ b/modules/asteriobidAnalyticsAdapter.md
@@ -0,0 +1,41 @@
+# Overview
+
+Module Name: AsterioBid Analytics Adapter
+Module Type: Analytics Adapter
+Maintainer: admin@asteriobid.com
+
+# Description
+Analytics adapter for AsterioBid. Contact admin@asteriobid.com for information.
+
+# Test Parameters
+
+```
+pbjs.enableAnalytics({
+ provider: 'asteriobid',
+ options: {
+ bundleId: '04bcf17b-9733-4675-9f67-d475f881ab78'
+ }
+});
+
+```
+
+# Advanced Parameters
+
+```
+pbjs.enableAnalytics({
+ provider: 'asteriobid',
+ options: {
+ bundleId: '04bcf17b-9733-4675-9f67-d475f881ab78',
+ version: 'v1', // configuration version for the comparison
+ adUnitDict: { // provide names of the ad units for better reporting
+ adunitid1: 'Top Banner',
+ adunitid2: 'Bottom Banner'
+ },
+ customParam: { // provide custom parameters values that you want to collect and report
+ param1: 'value1',
+ param2: 'value2'
+ }
+ }
+});
+
+```
diff --git a/modules/bliinkBidAdapter.js b/modules/bliinkBidAdapter.js
index 7042dd86cb9..e674c6987c3 100644
--- a/modules/bliinkBidAdapter.js
+++ b/modules/bliinkBidAdapter.js
@@ -4,6 +4,7 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'
import { config } from '../src/config.js'
import { _each, deepAccess, deepSetValue, getWindowSelf, getWindowTop } from '../src/utils.js'
export const BIDDER_CODE = 'bliink'
+export const GVL_ID = 658
export const BLIINK_ENDPOINT_ENGINE = 'https://engine.bliink.io/prebid'
export const BLIINK_ENDPOINT_COOKIE_SYNC_IFRAME = 'https://tag.bliink.io/usersync.html'
@@ -343,6 +344,7 @@ const getUserSyncs = (syncOptions, serverResponses, gdprConsent, uspConsent) =>
*/
export const spec = {
code: BIDDER_CODE,
+ gvlid: GVL_ID,
aliases: aliasBidderCode,
supportedMediaTypes: supportedMediaTypes,
isBidRequestValid,
diff --git a/modules/boldwinBidAdapter.js b/modules/boldwinBidAdapter.js
index 4d97f830d33..c7def383b5e 100644
--- a/modules/boldwinBidAdapter.js
+++ b/modules/boldwinBidAdapter.js
@@ -5,7 +5,7 @@ import { convertOrtbRequestToProprietaryNative } from '../src/native.js';
const BIDDER_CODE = 'boldwin';
const AD_URL = 'https://ssp.videowalldirect.com/pbjs';
-const SYNC_URL = 'https://cs.videowalldirect.com'
+const SYNC_URL = 'https://sync.videowalldirect.com';
function isBidResponseValid(bid) {
if (!bid.requestId || !bid.cpm || !bid.creativeId ||
diff --git a/modules/conceptxBidAdapter.js b/modules/conceptxBidAdapter.js
index 127b049bc99..87ac96f2131 100644
--- a/modules/conceptxBidAdapter.js
+++ b/modules/conceptxBidAdapter.js
@@ -3,23 +3,23 @@ import { BANNER } from '../src/mediaTypes.js';
// import { logError, logInfo, logWarn, parseUrl } from '../src/utils.js';
const BIDDER_CODE = 'conceptx';
-let ENDPOINT_URL = 'https://conceptx.cncpt-central.com/openrtb';
+const ENDPOINT_URL = 'https://conceptx.cncpt-central.com/openrtb';
// const LOG_PREFIX = 'ConceptX: ';
export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER],
isBidRequestValid: function (bid) {
- return !!(bid.bidId);
+ return !!(bid.bidId && bid.params.site && bid.params.adunit);
},
buildRequests: function (validBidRequests, bidderRequest) {
// logWarn(LOG_PREFIX + 'all native assets containing URL should be sent as placeholders with sendId(icon, image, clickUrl, displayUrl, privacyLink, privacyIcon)');
const requests = [];
-
+ let requestUrl = `${ENDPOINT_URL}`
if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) {
- ENDPOINT_URL += '?gdpr_applies=' + bidderRequest.gdprConsent.gdprApplies;
- ENDPOINT_URL += '&consentString=' + bidderRequest.gdprConsent.consentString;
+ requestUrl += '?gdpr_applies=' + bidderRequest.gdprConsent.gdprApplies;
+ requestUrl += '&consentString=' + bidderRequest.gdprConsent.consentString;
}
for (var i = 0; i < validBidRequests.length; i++) {
const requestParent = { adUnits: [], meta: {} };
@@ -33,7 +33,7 @@ export const spec = {
requestParent.adUnits.push(adUnit);
requests.push({
method: 'POST',
- url: ENDPOINT_URL,
+ url: requestUrl,
options: {
withCredentials: false,
},
@@ -51,6 +51,9 @@ export const spec = {
return bidResponses
}
const firstBid = bidResponsesFromServer[0]
+ if (!firstBid) {
+ return bidResponses
+ }
const firstSeat = firstBid.ads[0]
const bidResponse = {
requestId: firstSeat.requestId,
diff --git a/modules/connatixBidAdapter.js b/modules/connatixBidAdapter.js
index df56ad580bc..7524cd4e194 100644
--- a/modules/connatixBidAdapter.js
+++ b/modules/connatixBidAdapter.js
@@ -117,13 +117,12 @@ export const spec = {
interpretResponse: (serverResponse) => {
const responseBody = serverResponse.body;
const bids = responseBody.Bids;
- const playerId = responseBody.PlayerId;
- const customerId = responseBody.CustomerId;
- if (!isArray(bids) || !playerId || !customerId) {
+ if (!isArray(bids)) {
return [];
}
+ const referrer = responseBody.Referrer;
return bids.map(bidResponse => ({
requestId: bidResponse.RequestId,
cpm: bidResponse.Cpm,
@@ -134,8 +133,8 @@ export const spec = {
width: bidResponse.Width,
height: bidResponse.Height,
creativeId: bidResponse.CreativeId,
- referrer: bidResponse.Referrer,
ad: bidResponse.Ad,
+ referrer: referrer,
}));
},
diff --git a/modules/connatixBidAdapter.md b/modules/connatixBidAdapter.md
index 7ac04a64245..595c294e311 100644
--- a/modules/connatixBidAdapter.md
+++ b/modules/connatixBidAdapter.md
@@ -9,7 +9,24 @@ Maintainer: prebid_integration@connatix.com
# Description
Connects to Connatix demand source to fetch bids.
-Please use ```connatix``` as the bidder code.
+Please use ```connatix``` as the bidder code.
+
+# Configuration
+Connatix requires that ```iframe``` is used for user syncing.
+
+Example configuration:
+```
+pbjs.setConfig({
+ userSync: {
+ filterSettings: {
+ iframe: {
+ bidders: '*', // represents all bidders
+ filter: 'include'
+ }
+ }
+ }
+});
+```
# Test Parameters
```
diff --git a/modules/connectIdSystem.js b/modules/connectIdSystem.js
index e1c5b427264..35a77a9d72d 100644
--- a/modules/connectIdSystem.js
+++ b/modules/connectIdSystem.js
@@ -10,7 +10,7 @@ import {submodule} from '../src/hook.js';
import {includes} from '../src/polyfill.js';
import {getRefererInfo} from '../src/refererDetection.js';
import {getStorageManager} from '../src/storageManager.js';
-import {formatQS, isPlainObject, logError, parseUrl} from '../src/utils.js';
+import {formatQS, isNumber, isPlainObject, logError, parseUrl} from '../src/utils.js';
import {uspDataHandler, gppDataHandler} from '../src/adapterManager.js';
import {MODULE_TYPE_UID} from '../src/activities/modules.js';
@@ -26,6 +26,16 @@ const PLACEHOLDER = '__PIXEL_ID__';
const UPS_ENDPOINT = `https://ups.analytics.yahoo.com/ups/${PLACEHOLDER}/fed`;
const OVERRIDE_OPT_OUT_KEY = 'connectIdOptOut';
const INPUT_PARAM_KEYS = ['pixelId', 'he', 'puid'];
+const O_AND_O_DOMAINS = [
+ 'yahoo.com',
+ 'aol.com',
+ 'aol.ca',
+ 'aol.de',
+ 'aol.co.uk',
+ 'engadget.com',
+ 'techcrunch.com',
+ 'autoblog.com',
+];
export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME});
/**
@@ -104,9 +114,11 @@ function syncLocalStorageToCookie() {
}
function isStale(storedIdData) {
- if (isPlainObject(storedIdData) && storedIdData.lastSynced &&
- (storedIdData.lastSynced + VALID_ID_DURATION) <= Date.now()) {
+ if (isOAndOTraffic()) {
return true;
+ } else if (isPlainObject(storedIdData) && storedIdData.lastSynced) {
+ const validTTL = storedIdData.ttl || VALID_ID_DURATION;
+ return storedIdData.lastSynced + validTTL <= Date.now();
}
return false;
}
@@ -127,6 +139,17 @@ function getSiteHostname() {
return pageInfo.hostname;
}
+function isOAndOTraffic() {
+ let referer = getRefererInfo().ref;
+
+ if (referer) {
+ referer = parseUrl(referer).hostname;
+ const subDomains = referer.split('.');
+ referer = subDomains.slice(subDomains.length - 2, subDomains.length).join('.');
+ }
+ return O_AND_O_DOMAINS.indexOf(referer) >= 0;
+}
+
/** @type {Submodule} */
export const connectIdSubmodule = {
/**
@@ -238,6 +261,13 @@ export const connectIdSubmodule = {
responseObj.puid = params.puid || responseObj.puid;
responseObj.lastSynced = Date.now();
responseObj.lastUsed = Date.now();
+ if (isNumber(responseObj.ttl)) {
+ let validTTLMiliseconds = responseObj.ttl * 60 * 60 * 1000;
+ if (validTTLMiliseconds > VALID_ID_DURATION) {
+ validTTLMiliseconds = VALID_ID_DURATION;
+ }
+ responseObj.ttl = validTTLMiliseconds;
+ }
storeObject(responseObj);
} else {
logError(`${MODULE_NAME} module: UPS response returned an invalid payload ${response}`);
diff --git a/modules/consumableBidAdapter.js b/modules/consumableBidAdapter.js
index c78ff7cdf51..696549a67dc 100644
--- a/modules/consumableBidAdapter.js
+++ b/modules/consumableBidAdapter.js
@@ -191,17 +191,20 @@ export const spec = {
if (syncOptions.iframeEnabled) {
if (gdprConsent && gdprConsent.consentString) {
if (typeof gdprConsent.gdprApplies === 'boolean') {
- syncUrl = appendUrlParam(syncUrl, `gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`);
+ syncUrl = appendUrlParam(syncUrl, `gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${encodeURIComponent(gdprConsent.consentString) || ''}`);
} else {
- syncUrl = appendUrlParam(syncUrl, `gdpr=0&gdpr_consent=${gdprConsent.consentString}`);
+ syncUrl = appendUrlParam(syncUrl, `gdpr=0&gdpr_consent=${encodeURIComponent(gdprConsent.consentString) || ''}`);
}
}
if (gppConsent && gppConsent.gppString) {
- syncUrl = appendUrlParam(syncUrl, `gpp=${gppConsent.gppString}&gpp_sid=${gppConsent.applicableSections}`);
+ syncUrl = appendUrlParam(syncUrl, `gpp=${encodeURIComponent(gppConsent.gppString)}`);
+ if (gppConsent.applicableSections && gppConsent.applicableSections.length > 0) {
+ syncUrl = appendUrlParam(syncUrl, `gpp_sid=${encodeURIComponent(gppConsent.applicableSections.join(','))}`);
+ }
}
- if (uspConsent && uspConsent.consentString) {
- syncUrl = appendUrlParam(syncUrl, `us_privacy=${uspConsent.consentString}`);
+ if (uspConsent) {
+ syncUrl = appendUrlParam(syncUrl, `us_privacy=${encodeURIComponent(uspConsent)}`);
}
if (!serverResponses || serverResponses.length === 0 || !serverResponses[0].body.bdr || serverResponses[0].body.bdr !== 'cx') {
diff --git a/modules/criteoBidAdapter.js b/modules/criteoBidAdapter.js
index 9ff6b540467..45769edaf61 100644
--- a/modules/criteoBidAdapter.js
+++ b/modules/criteoBidAdapter.js
@@ -16,6 +16,9 @@ export const ADAPTER_VERSION = 36;
const BIDDER_CODE = 'criteo';
const CDB_ENDPOINT = 'https://bidder.criteo.com/cdb';
const PROFILE_ID_INLINE = 207;
+const FLEDGE_SELLER_DOMAIN = 'https://grid-mercury.criteo.com';
+const FLEDGE_SELLER_TIMEOUT = 500;
+const FLEDGE_DECISION_LOGIC_URL = 'https://grid-mercury.criteo.com/fledge/decision';
export const PROFILE_ID_PUBLISHERTAG = 185;
export const storage = getStorageManager({ bidderCode: BIDDER_CODE });
const LOG_PREFIX = 'Criteo: ';
@@ -28,7 +31,7 @@ const LOG_PREFIX = 'Criteo: ';
Unminified source code can be found in the privately shared repo: https://github.com/Prebid-org/prebid-js-external-js-criteo/blob/master/dist/prod.js
*/
const FAST_BID_VERSION_PLACEHOLDER = '%FAST_BID_VERSION%';
-export const FAST_BID_VERSION_CURRENT = 139;
+export const FAST_BID_VERSION_CURRENT = 144;
const FAST_BID_VERSION_LATEST = 'latest';
const FAST_BID_VERSION_NONE = 'none';
const PUBLISHER_TAG_URL_TEMPLATE = 'https://static.criteo.net/js/ld/publishertag.prebid' + FAST_BID_VERSION_PLACEHOLDER + '.js';
@@ -201,7 +204,7 @@ export const spec = {
/**
* @param {*} response
* @param {ServerRequest} request
- * @return {Bid[]}
+ * @return {Bid[] | {bids: Bid[], fledgeAuctionConfigs: object[]}}
*/
interpretResponse: (response, request) => {
const body = response.body || response;
@@ -215,6 +218,7 @@ export const spec = {
}
const bids = [];
+ const fledgeAuctionConfigs = [];
if (body && body.slots && isArray(body.slots)) {
body.slots.forEach(slot => {
@@ -268,6 +272,45 @@ export const spec = {
});
}
+ if (isArray(body.ext?.igbid)) {
+ const seller = body.ext.seller || FLEDGE_SELLER_DOMAIN;
+ const sellerTimeout = body.ext.sellerTimeout || FLEDGE_SELLER_TIMEOUT;
+ const sellerSignals = body.ext.sellerSignals || {};
+ body.ext.igbid.forEach((igbid) => {
+ const perBuyerSignals = {};
+ igbid.igbuyer.forEach(buyerItem => {
+ perBuyerSignals[buyerItem.origin] = buyerItem.buyerdata;
+ });
+ const bidRequest = request.bidRequests.find(b => b.bidId === igbid.impid);
+ if (!sellerSignals.floor && bidRequest.params.bidFloor) {
+ sellerSignals.floor = bidRequest.params.bidFloor;
+ }
+ if (!sellerSignals.sellerCurrency && bidRequest.params.bidFloorCur) {
+ sellerSignals.sellerCurrency = bidRequest.params.bidFloorCur;
+ }
+ const bidId = bidRequest.bidId;
+ fledgeAuctionConfigs.push({
+ bidId,
+ config: {
+ seller,
+ sellerSignals,
+ sellerTimeout,
+ perBuyerSignals,
+ auctionSignals: {},
+ decisionLogicUrl: FLEDGE_DECISION_LOGIC_URL,
+ interestGroupBuyers: Object.keys(perBuyerSignals),
+ },
+ });
+ });
+ }
+
+ if (fledgeAuctionConfigs.length) {
+ return {
+ bids,
+ fledgeAuctionConfigs,
+ };
+ }
+
return bids;
},
/**
@@ -503,6 +546,7 @@ function buildCdbRequest(context, bidRequests, bidderRequest) {
if (hasVideoMediaType(bidRequest)) {
const video = {
+ context: bidRequest.mediaTypes.video.context,
playersizes: parseSizes(deepAccess(bidRequest, 'mediaTypes.video.playerSize'), parseSize),
mimes: bidRequest.mediaTypes.video.mimes,
protocols: bidRequest.mediaTypes.video.protocols,
@@ -513,7 +557,19 @@ function buildCdbRequest(context, bidRequests, bidderRequest) {
minduration: bidRequest.mediaTypes.video.minduration,
playbackmethod: bidRequest.mediaTypes.video.playbackmethod,
startdelay: bidRequest.mediaTypes.video.startdelay,
- plcmt: bidRequest.mediaTypes.video.plcmt
+ plcmt: bidRequest.mediaTypes.video.plcmt,
+ w: bidRequest.mediaTypes.video.w,
+ h: bidRequest.mediaTypes.video.h,
+ linearity: bidRequest.mediaTypes.video.linearity,
+ skipmin: bidRequest.mediaTypes.video.skipmin,
+ skipafter: bidRequest.mediaTypes.video.skipafter,
+ minbitrate: bidRequest.mediaTypes.video.minbitrate,
+ maxbitrate: bidRequest.mediaTypes.video.maxbitrate,
+ delivery: bidRequest.mediaTypes.video.delivery,
+ pos: bidRequest.mediaTypes.video.pos,
+ playbackend: bidRequest.mediaTypes.video.playbackend,
+ adPodDurationSec: bidRequest.mediaTypes.video.adPodDurationSec,
+ durationRangeSec: bidRequest.mediaTypes.video.durationRangeSec,
};
const paramsVideo = bidRequest.params.video;
if (paramsVideo !== undefined) {
@@ -529,6 +585,10 @@ function buildCdbRequest(context, bidRequests, bidderRequest) {
enrichSlotWithFloors(slot, bidRequest);
+ if (!bidderRequest.fledgeEnabled && slot.ext?.ae) {
+ delete slot.ext.ae;
+ }
+
return slot;
}),
};
diff --git a/modules/criteoIdSystem.js b/modules/criteoIdSystem.js
index ee343d9b16a..6a09ce2c973 100644
--- a/modules/criteoIdSystem.js
+++ b/modules/criteoIdSystem.js
@@ -22,6 +22,9 @@ const bundleStorageKey = 'cto_bundle';
const dnaBundleStorageKey = 'cto_dna_bundle';
const cookiesMaxAge = 13 * 30 * 24 * 60 * 60 * 1000;
+const STORAGE_TYPE_LOCALSTORAGE = 'html5';
+const STORAGE_TYPE_COOKIES = 'cookie';
+
const pastDateString = new Date(0).toString();
const expirationString = new Date(timestamp() + cookiesMaxAge).toString();
@@ -32,14 +35,26 @@ function extractProtocolHost(url, returnOnlyHost = false) {
: `${parsedUrl.protocol}://${parsedUrl.hostname}${parsedUrl.port ? ':' + parsedUrl.port : ''}/`;
}
-function getFromAllStorages(key) {
+function getFromStorage(submoduleConfig, key) {
+ if (submoduleConfig?.storage?.type === STORAGE_TYPE_LOCALSTORAGE) {
+ return storage.getDataFromLocalStorage(key);
+ } else if (submoduleConfig?.storage?.type === STORAGE_TYPE_COOKIES) {
+ return storage.getCookie(key);
+ }
+
return storage.getCookie(key) || storage.getDataFromLocalStorage(key);
}
-function saveOnAllStorages(key, value, hostname) {
+function saveOnStorage(submoduleConfig, key, value, hostname) {
if (key && value) {
- storage.setDataInLocalStorage(key, value);
- setCookieOnAllDomains(key, value, expirationString, hostname, true);
+ if (submoduleConfig?.storage?.type === STORAGE_TYPE_LOCALSTORAGE) {
+ storage.setDataInLocalStorage(key, value);
+ } else if (submoduleConfig?.storage?.type === STORAGE_TYPE_COOKIES) {
+ setCookieOnAllDomains(key, value, expirationString, hostname, true);
+ } else {
+ storage.setDataInLocalStorage(key, value);
+ setCookieOnAllDomains(key, value, expirationString, hostname, true);
+ }
}
}
@@ -70,11 +85,11 @@ function deleteFromAllStorages(key, hostname) {
storage.removeDataFromLocalStorage(key);
}
-function getCriteoDataFromAllStorages() {
+function getCriteoDataFromStorage(submoduleConfig) {
return {
- bundle: getFromAllStorages(bundleStorageKey),
- dnaBundle: getFromAllStorages(dnaBundleStorageKey),
- bidId: getFromAllStorages(bididStorageKey),
+ bundle: getFromStorage(submoduleConfig, bundleStorageKey),
+ dnaBundle: getFromStorage(submoduleConfig, dnaBundleStorageKey),
+ bidId: getFromStorage(submoduleConfig, bididStorageKey),
}
}
@@ -108,7 +123,7 @@ function buildCriteoUsersyncUrl(topUrl, domain, bundle, dnaBundle, areCookiesWri
return url;
}
-function callSyncPixel(domain, pixel) {
+function callSyncPixel(submoduleConfig, domain, pixel) {
if (pixel.writeBundleInStorage && pixel.bundlePropertyName && pixel.storageKeyName) {
ajax(
pixel.pixelUrl,
@@ -117,7 +132,7 @@ function callSyncPixel(domain, pixel) {
if (response) {
const jsonResponse = JSON.parse(response);
if (jsonResponse && jsonResponse[pixel.bundlePropertyName]) {
- saveOnAllStorages(pixel.storageKeyName, jsonResponse[pixel.bundlePropertyName], domain);
+ saveOnStorage(submoduleConfig, pixel.storageKeyName, jsonResponse[pixel.bundlePropertyName], domain);
}
}
},
@@ -133,9 +148,9 @@ function callSyncPixel(domain, pixel) {
}
}
-function callCriteoUserSync(parsedCriteoData, callback) {
- const cw = storage.cookiesAreEnabled();
- const lsw = storage.localStorageIsEnabled();
+function callCriteoUserSync(submoduleConfig, parsedCriteoData, callback) {
+ const cw = (submoduleConfig?.storage?.type === undefined || submoduleConfig?.storage?.type === STORAGE_TYPE_COOKIES) && storage.cookiesAreEnabled();
+ const lsw = (submoduleConfig?.storage?.type === undefined || submoduleConfig?.storage?.type === STORAGE_TYPE_LOCALSTORAGE) && storage.localStorageIsEnabled();
const topUrl = extractProtocolHost(getRefererInfo().page);
// TODO: should domain really be extracted from the current frame?
const domain = extractProtocolHost(document.location.href, true);
@@ -156,18 +171,18 @@ function callCriteoUserSync(parsedCriteoData, callback) {
const jsonResponse = JSON.parse(response);
if (jsonResponse.pixels) {
- jsonResponse.pixels.forEach(pixel => callSyncPixel(domain, pixel));
+ jsonResponse.pixels.forEach(pixel => callSyncPixel(submoduleConfig, domain, pixel));
}
if (jsonResponse.acwsUrl) {
const urlsToCall = typeof jsonResponse.acwsUrl === 'string' ? [jsonResponse.acwsUrl] : jsonResponse.acwsUrl;
urlsToCall.forEach(url => triggerPixel(url));
} else if (jsonResponse.bundle) {
- saveOnAllStorages(bundleStorageKey, jsonResponse.bundle, domain);
+ saveOnStorage(submoduleConfig, bundleStorageKey, jsonResponse.bundle, domain);
}
if (jsonResponse.bidId) {
- saveOnAllStorages(bididStorageKey, jsonResponse.bidId, domain);
+ saveOnStorage(submoduleConfig, bididStorageKey, jsonResponse.bidId, domain);
const criteoId = { criteoId: jsonResponse.bidId };
callback(criteoId);
} else {
@@ -207,10 +222,10 @@ export const criteoIdSubmodule = {
* @param {ConsentData} [consentData]
* @returns {{id: {criteoId: string} | undefined}}}
*/
- getId() {
- let localData = getCriteoDataFromAllStorages();
+ getId(submoduleConfig) {
+ let localData = getCriteoDataFromStorage(submoduleConfig);
- const result = (callback) => callCriteoUserSync(localData, callback);
+ const result = (callback) => callCriteoUserSync(submoduleConfig, localData, callback);
return {
id: localData.bidId ? { criteoId: localData.bidId } : undefined,
diff --git a/modules/currency.js b/modules/currency.js
index 0ae8c8ad0a6..eaed4c50df2 100644
--- a/modules/currency.js
+++ b/modules/currency.js
@@ -7,20 +7,22 @@ import {getHook} from '../src/hook.js';
import {defer} from '../src/utils/promise.js';
import {registerOrtbProcessor, REQUEST} from '../src/pbjsORTB.js';
import {timedBidResponseHook} from '../src/utils/perfMetrics.js';
+import {on as onEvent, off as offEvent} from '../src/events.js';
const DEFAULT_CURRENCY_RATE_URL = 'https://cdn.jsdelivr.net/gh/prebid/currency-file@1/latest.json?date=$$TODAY$$';
const CURRENCY_RATE_PRECISION = 4;
-var bidResponseQueue = [];
-var conversionCache = {};
-var currencyRatesLoaded = false;
-var needToCallForCurrencyFile = true;
-var adServerCurrency = 'USD';
+let ratesURL;
+let bidResponseQueue = [];
+let conversionCache = {};
+let currencyRatesLoaded = false;
+let needToCallForCurrencyFile = true;
+let adServerCurrency = 'USD';
export var currencySupportEnabled = false;
export var currencyRates = {};
-var bidderCurrencyDefault = {};
-var defaultRates;
+let bidderCurrencyDefault = {};
+let defaultRates;
export let responseReady = defer();
@@ -57,7 +59,7 @@ export let responseReady = defer();
* there is an error loading the config.conversionRateFile.
*/
export function setConfig(config) {
- let url = DEFAULT_CURRENCY_RATE_URL;
+ ratesURL = DEFAULT_CURRENCY_RATE_URL;
if (typeof config.rates === 'object') {
currencyRates.conversions = config.rates;
@@ -79,14 +81,14 @@ export function setConfig(config) {
adServerCurrency = config.adServerCurrency;
if (config.conversionRateFile) {
logInfo('currency using override conversionRateFile:', config.conversionRateFile);
- url = config.conversionRateFile;
+ ratesURL = config.conversionRateFile;
}
// see if the url contains a date macro
// this is a workaround to the fact that jsdelivr doesn't currently support setting a 24-hour HTTP cache header
// So this is an approach to let the browser cache a copy of the file each day
// We should remove the macro once the CDN support a day-level HTTP cache setting
- const macroLocation = url.indexOf('$$TODAY$$');
+ const macroLocation = ratesURL.indexOf('$$TODAY$$');
if (macroLocation !== -1) {
// get the date to resolve the macro
const d = new Date();
@@ -97,10 +99,10 @@ export function setConfig(config) {
const todaysDate = `${d.getFullYear()}${month}${day}`;
// replace $$TODAY$$ with todaysDate
- url = `${url.substring(0, macroLocation)}${todaysDate}${url.substring(macroLocation + 9, url.length)}`;
+ ratesURL = `${ratesURL.substring(0, macroLocation)}${todaysDate}${ratesURL.substring(macroLocation + 9, ratesURL.length)}`;
}
- initCurrency(url);
+ initCurrency();
} else {
// currency support is disabled, setting defaults
logInfo('disabling currency support');
@@ -121,21 +123,11 @@ function errorSettingsRates(msg) {
}
}
-function initCurrency(url) {
- conversionCache = {};
- currencySupportEnabled = true;
-
- logInfo('Installing addBidResponse decorator for currency module', arguments);
-
- // Adding conversion function to prebid global for external module and on page use
- getGlobal().convertCurrency = (cpm, fromCurrency, toCurrency) => parseFloat(cpm) * getCurrencyConversion(fromCurrency, toCurrency);
- getHook('addBidResponse').before(addBidResponseHook, 100);
- getHook('responsesReady').before(responsesReadyHook);
-
- // call for the file if we haven't already
+function loadRates() {
if (needToCallForCurrencyFile) {
needToCallForCurrencyFile = false;
- ajax(url,
+ currencyRatesLoaded = false;
+ ajax(ratesURL,
{
success: function (response) {
try {
@@ -150,17 +142,39 @@ function initCurrency(url) {
},
error: function (...args) {
errorSettingsRates(...args);
+ currencyRatesLoaded = true;
+ processBidResponseQueue();
+ needToCallForCurrencyFile = true;
}
}
);
+ } else {
+ processBidResponseQueue();
}
}
+function initCurrency() {
+ conversionCache = {};
+ currencySupportEnabled = true;
+
+ logInfo('Installing addBidResponse decorator for currency module', arguments);
+
+ // Adding conversion function to prebid global for external module and on page use
+ getGlobal().convertCurrency = (cpm, fromCurrency, toCurrency) => parseFloat(cpm) * getCurrencyConversion(fromCurrency, toCurrency);
+ getHook('addBidResponse').before(addBidResponseHook, 100);
+ getHook('responsesReady').before(responsesReadyHook);
+ onEvent(CONSTANTS.EVENTS.AUCTION_TIMEOUT, rejectOnAuctionTimeout);
+ onEvent(CONSTANTS.EVENTS.AUCTION_INIT, loadRates);
+ loadRates();
+}
+
function resetCurrency() {
logInfo('Uninstalling addBidResponse decorator for currency module', arguments);
getHook('addBidResponse').getHooks({hook: addBidResponseHook}).remove();
getHook('responsesReady').getHooks({hook: responsesReadyHook}).remove();
+ offEvent(CONSTANTS.EVENTS.AUCTION_TIMEOUT, rejectOnAuctionTimeout);
+ offEvent(CONSTANTS.EVENTS.AUCTION_INIT, loadRates);
delete getGlobal().convertCurrency;
adServerCurrency = 'USD';
@@ -207,23 +221,25 @@ export const addBidResponseHook = timedBidResponseHook('currency', function addB
if (bid.currency === adServerCurrency) {
return fn.call(this, adUnitCode, bid, reject);
}
-
- bidResponseQueue.push(wrapFunction(fn, this, [adUnitCode, bid, reject]));
+ bidResponseQueue.push([fn, this, adUnitCode, bid, reject]);
if (!currencySupportEnabled || currencyRatesLoaded) {
processBidResponseQueue();
}
});
-function processBidResponseQueue() {
- while (bidResponseQueue.length > 0) {
- (bidResponseQueue.shift())();
- }
- responseReady.resolve()
+function rejectOnAuctionTimeout({auctionId}) {
+ bidResponseQueue = bidResponseQueue.filter(([fn, ctx, adUnitCode, bid, reject]) => {
+ if (bid.auctionId === auctionId) {
+ reject(CONSTANTS.REJECTION_REASON.CANNOT_CONVERT_CURRENCY)
+ } else {
+ return true;
+ }
+ });
}
-function wrapFunction(fn, context, params) {
- return function() {
- let bid = params[1];
+function processBidResponseQueue() {
+ while (bidResponseQueue.length > 0) {
+ const [fn, ctx, adUnitCode, bid, reject] = bidResponseQueue.shift();
if (bid !== undefined && 'currency' in bid && 'cpm' in bid) {
let fromCurrency = bid.currency;
try {
@@ -234,12 +250,13 @@ function wrapFunction(fn, context, params) {
}
} catch (e) {
logWarn('getCurrencyConversion threw error: ', e);
- params[2](CONSTANTS.REJECTION_REASON.CANNOT_CONVERT_CURRENCY);
- return;
+ reject(CONSTANTS.REJECTION_REASON.CANNOT_CONVERT_CURRENCY);
+ continue;
}
}
- return fn.apply(context, params);
- };
+ fn.call(ctx, adUnitCode, bid, reject);
+ }
+ responseReady.resolve();
}
function getCurrencyConversion(fromCurrency, toCurrency = adServerCurrency) {
diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js
index 7ad75f64215..816ec3cbe1f 100644
--- a/modules/discoveryBidAdapter.js
+++ b/modules/discoveryBidAdapter.js
@@ -211,6 +211,64 @@ const popInAdSize = [
{ w: 336, h: 280 },
];
+/**
+ * get screen size
+ *
+ * @returns {Array} eg: "['widthxheight']"
+ */
+function getScreenSize() {
+ return utils.parseSizesInput([window.screen.width, window.screen.height]);
+}
+
+/**
+ * @param {BidRequest} bidRequest
+ * @param bidderRequest
+ * @returns {string}
+ */
+function getReferrer(bidRequest = {}, bidderRequest = {}) {
+ let pageUrl;
+ if (bidRequest.params && bidRequest.params.referrer) {
+ pageUrl = bidRequest.params.referrer;
+ } else {
+ pageUrl = utils.deepAccess(bidderRequest, 'refererInfo.page');
+ }
+ return pageUrl;
+}
+
+/**
+ * format imp ad test ext params
+ *
+ * @param validBidRequest sigleBidRequest
+ * @param bidderRequest
+ */
+function addImpExtParams(bidRequest = {}, bidderRequest = {}) {
+ const { deepAccess } = utils;
+ const { params = {}, adUnitCode, bidId } = bidRequest;
+ const ext = {
+ bidId: bidId || '',
+ adUnitCode: adUnitCode || '',
+ token: params.token || '',
+ siteId: params.siteId || '',
+ zoneId: params.zoneId || '',
+ publisher: params.publisher || '',
+ p_pos: params.position || '',
+ screenSize: getScreenSize(),
+ referrer: getReferrer(bidRequest, bidderRequest),
+ stack: deepAccess(bidRequest, 'refererInfo.stack', []),
+ b_pos: deepAccess(bidRequest, 'mediaTypes.banner.pos', '', ''),
+ ortbUser: deepAccess(bidRequest, 'ortb2.user', {}, {}),
+ ortbSite: deepAccess(bidRequest, 'ortb2.site', {}, {}),
+ tid: deepAccess(bidRequest, 'ortb2Imp.ext.tid', '', ''),
+ browsiViewability: deepAccess(bidRequest, 'ortb2Imp.ext.data.browsi.browsiViewability', '', ''),
+ adserverName: deepAccess(bidRequest, 'ortb2Imp.ext.data.adserver.name', '', ''),
+ adslot: deepAccess(bidRequest, 'ortb2Imp.ext.data.adserver.adslot', '', ''),
+ keywords: deepAccess(bidRequest, 'ortb2Imp.ext.data.keywords', '', ''),
+ gpid: deepAccess(bidRequest, 'ortb2Imp.ext.gpid', '', ''),
+ pbadslot: deepAccess(bidRequest, 'ortb2Imp.ext.data.pbadslot', '', ''),
+ };
+ return ext;
+}
+
/**
* get aditem setting
* @param {Array} validBidRequests an an array of bids
@@ -261,6 +319,11 @@ function getItems(validBidRequests, bidderRequest) {
tagid: req.params && req.params.tagid
};
}
+
+ try {
+ ret.ext = addImpExtParams(req, bidderRequest);
+ } catch (e) {}
+
itemMaps[id] = {
req,
ret,
@@ -323,7 +386,6 @@ function getParam(validBidRequests, bidderRequest) {
buyeruid: getUserID(),
id: sharedid || pubcid,
},
- eids,
tmax: timeout,
site: {
name: domain,
diff --git a/modules/docereeAdManagerBidAdapter.js b/modules/docereeAdManagerBidAdapter.js
new file mode 100644
index 00000000000..d3765f5a130
--- /dev/null
+++ b/modules/docereeAdManagerBidAdapter.js
@@ -0,0 +1,128 @@
+import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { config } from '../src/config.js';
+import { BANNER } from '../src/mediaTypes.js';
+const BIDDER_CODE = 'docereeadmanager';
+const END_POINT = 'https://dai.doceree.com/drs/quest';
+
+export const spec = {
+ code: BIDDER_CODE,
+ url: '',
+ supportedMediaTypes: [BANNER],
+
+ isBidRequestValid: (bid) => {
+ const { placementId } = bid.params;
+ return !!placementId;
+ },
+ isGdprConsentPresent: (bid) => {
+ const { gdpr, gdprconsent } = bid.params;
+ if (gdpr == '1') {
+ return !!gdprconsent;
+ }
+ return true;
+ },
+ buildRequests: (validBidRequests) => {
+ const serverRequests = [];
+ const { data } = config.getConfig('docereeadmanager.user') || {};
+
+ validBidRequests.forEach(function (validBidRequest) {
+ const payload = getPayload(validBidRequest, data);
+
+ if (!payload) {
+ return;
+ }
+
+ serverRequests.push({
+ method: 'POST',
+ url: END_POINT,
+ data: JSON.stringify(payload.data),
+ options: {
+ contentType: 'application/json',
+ withCredentials: true,
+ },
+ });
+ });
+
+ return serverRequests;
+ },
+ interpretResponse: (serverResponse) => {
+ const responseJson = serverResponse ? serverResponse.body : {};
+ const bidResponse = {
+ ad: responseJson.ad,
+ width: Number(responseJson.width),
+ height: Number(responseJson.height),
+ requestId: responseJson.requestId,
+ netRevenue: true,
+ ttl: 30,
+ cpm: responseJson.cpm,
+ currency: responseJson.currency,
+ mediaType: BANNER,
+ creativeId: responseJson.creativeId,
+ meta: {
+ advertiserDomains:
+ Array.isArray(responseJson.meta.advertiserDomains) &&
+ responseJson.meta.advertiserDomains.length > 0
+ ? responseJson.meta.advertiserDomains
+ : [],
+ },
+ };
+
+ return [bidResponse];
+ },
+};
+
+function getPayload(bid, userData) {
+ if (!userData || !bid) {
+ return false;
+ }
+
+ const { bidId, params } = bid;
+ const { placementId } = params;
+ const {
+ userid,
+ email,
+ firstname,
+ lastname,
+ specialization,
+ hcpid,
+ gender,
+ city,
+ state,
+ zipcode,
+ hashedNPI,
+ hashedhcpid,
+ hashedemail,
+ hashedmobile,
+ country,
+ organization,
+ dob,
+ } = userData;
+
+ const data = {
+ userid: userid || '',
+ email: email || '',
+ firstname: firstname || '',
+ lastname: lastname || '',
+ specialization: specialization || '',
+ hcpid: hcpid || '',
+ gender: gender || '',
+ city: city || '',
+ state: state || '',
+ zipcode: zipcode || '',
+ hashedNPI: hashedNPI || '',
+ pb: 1,
+ adunit: placementId || '',
+ requestId: bidId || '',
+ hashedhcpid: hashedhcpid || '',
+ hashedemail: hashedemail || '',
+ hashedmobile: hashedmobile || '',
+ country: country || '',
+ organization: organization || '',
+ dob: dob || '',
+ userconsent: 1,
+ };
+ return {
+ data,
+ };
+}
+
+registerBidder(spec);
diff --git a/modules/docereeAdManagerBidAdapter.md b/modules/docereeAdManagerBidAdapter.md
new file mode 100644
index 00000000000..bedbf57b179
--- /dev/null
+++ b/modules/docereeAdManagerBidAdapter.md
@@ -0,0 +1,68 @@
+# Overview
+
+```
+Module Name: Doceree AdManager Bidder Adapter
+Module Type: Bidder Adapter
+Maintainer: tech.stack@doceree.com
+```
+
+
+
+Connects to Doceree demand source to fetch bids.
+Please use `docereeadmanager` as the bidder code.
+
+# Test Parameters
+
+```
+var adUnits = [
+ {
+ code: 'DOC-397-1',
+ sizes: [
+ [300, 250]
+ ],
+ bids: [
+ {
+ bidder: 'docereeadmanager',
+ params: {
+ placementId: 'DOC-19-1', //required
+ publisherUrl: document.URL || window.location.href, //optional
+ gdpr: '1', //optional
+ gdprconsent:'CPQfU1jPQfU1jG0AAAENAwCAAAAAAAAAAAAAAAAAAAAA.IGLtV_T9fb2vj-_Z99_tkeYwf95y3p-wzhheMs-8NyZeH_B4Wv2MyvBX4JiQKGRgksjLBAQdtHGlcTQgBwIlViTLMYk2MjzNKJrJEilsbO2dYGD9Pn8HT3ZCY70-vv__7v3ff_3g', //optional
+ }
+ }
+ ]
+ }
+];
+```
+
+```javascript
+pbjs.setBidderConfig({
+ bidders: ['docereeadmanager'],
+ config: {
+ docereeadmanager: {
+ user: {
+ data: {
+ email: 'XXX.XXX@GMAIL.COM',
+ firstname: 'DR. XXX',
+ lastname: 'XXX',
+ mobile: '981234XXXX',
+ specialization: 'Internal Medicine',
+ organization: 'Max Lifecare',
+ hcpid: '199291XXXX',
+ dob: '1987-08-27',
+ gender: 'Female',
+ city: 'Oildale',
+ state: 'California',
+ country: 'California',
+ hashedhcpid: '',
+ hashedemail: '',
+ hashedmobile: '',
+ userid: '7d26d8ca-233a-46c2-9d36-7c5d261e151d',
+ zipcode: '',
+ userconsent: '1',
+ },
+ },
+ },
+ },
+});
+```
diff --git a/modules/dxkultureBidAdapter.js b/modules/dxkultureBidAdapter.js
index a8f7b4b86ba..9e4768d12bb 100644
--- a/modules/dxkultureBidAdapter.js
+++ b/modules/dxkultureBidAdapter.js
@@ -1,39 +1,86 @@
import {
- deepSetValue,
logInfo,
- deepAccess,
logError,
- isFn,
- isPlainObject,
- isStr,
- isNumber,
- isArray, logMessage
+ logMessage,
+ deepAccess,
+ deepSetValue,
+ mergeDeep
} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
+import {ortbConverter} from '../libraries/ortbConverter/converter.js'
const BIDDER_CODE = 'dxkulture';
const DEFAULT_BID_TTL = 300;
-const DEFAULT_CURRENCY = 'USD';
const DEFAULT_NET_REVENUE = true;
-const DEFAULT_NETWORK_ID = 1;
-const OPENRTB_VIDEO_PARAMS = [
- 'mimes',
- 'minduration',
- 'maxduration',
- 'placement',
- 'plcmt',
- 'protocols',
- 'startdelay',
- 'skip',
- 'skipafter',
- 'minbitrate',
- 'maxbitrate',
- 'delivery',
- 'playbackmethod',
- 'api',
- 'linearity'
-];
+const DEFAULT_CURRENCY = 'USD';
+const SYNC_URL = 'https://ads.kulture.media/usync';
+
+const converter = ortbConverter({
+ context: {
+ netRevenue: DEFAULT_NET_REVENUE,
+ ttl: DEFAULT_BID_TTL
+ },
+ imp(buildImp, bidRequest, context) {
+ const imp = buildImp(bidRequest, context);
+
+ if (!imp.bidfloor) {
+ imp.bidfloor = bidRequest.params.bidfloor || 0;
+ imp.bidfloorcur = bidRequest.params.currency || DEFAULT_CURRENCY;
+ }
+ return imp;
+ },
+ request(buildRequest, imps, bidderRequest, context) {
+ const req = buildRequest(imps, bidderRequest, context);
+ mergeDeep(req, {
+ ext: {
+ hb: 1,
+ prebidver: '$prebid.version$',
+ adapterver: '1.0.0',
+ }
+ })
+
+ // Attaching GDPR Consent Params
+ if (bidderRequest.gdprConsent) {
+ deepSetValue(req, 'user.ext.consent', bidderRequest.gdprConsent.consentString);
+ deepSetValue(req, 'regs.ext.gdpr', (bidderRequest.gdprConsent.gdprApplies ? 1 : 0));
+ }
+
+ // CCPA
+ if (bidderRequest.uspConsent) {
+ deepSetValue(req, 'regs.ext.us_privacy', bidderRequest.uspConsent);
+ }
+
+ return req;
+ },
+ bidResponse(buildBidResponse, bid, context) {
+ let resMediaType;
+ if (bid.adm?.trim().startsWith(' 0) {
- deepSetValue(openrtbRequest, 'user.ext.eids', eids);
- }
+ const data = converter.toORTB({ bidRequests: validBidRequests, bidderRequest, context: {contextMediaType} });
let publisherId = validBidRequests[0].params.publisherId;
let placementId = validBidRequests[0].params.placementId;
- const networkId = validBidRequests[0].params.networkId || DEFAULT_NETWORK_ID;
if (validBidRequests[0].params.e2etest) {
- logMessage('E2E test mode enabled');
+ logMessage('dxkulture: E2E test mode enabled');
publisherId = 'e2etest'
}
let baseEndpoint = spec.ENDPOINT + '?pid=' + publisherId;
@@ -111,70 +123,46 @@ export const spec = {
if (placementId) {
baseEndpoint += '&placementId=' + placementId
}
- if (networkId) {
- baseEndpoint += '&nId=' + networkId
- }
- const payloadString = JSON.stringify(openrtbRequest);
return {
method: 'POST',
url: baseEndpoint,
- data: payloadString,
+ data: data
};
},
- interpretResponse: function (serverResponse) {
- const bidResponses = [];
- const response = (serverResponse || {}).body;
- // response is always one seat (exchange) with (optional) bids for each impression
- if (response && response.seatbid && response.seatbid.length === 1 && response.seatbid[0].bid && response.seatbid[0].bid.length) {
- response.seatbid[0].bid.forEach(bid => {
- if (bid.adm && bid.price) {
- bidResponses.push(_createBidResponse(bid));
- }
- })
- } else {
- logInfo('dxkulture.interpretResponse :: no valid responses to interpret');
- }
- return bidResponses;
+ interpretResponse: function (serverResponse, bidRequest) {
+ const bids = converter.fromORTB({response: serverResponse.body, request: bidRequest.data}).bids;
+ return bids;
},
- getUserSyncs: function (syncOptions, serverResponses) {
+ getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) {
logInfo('dxkulture.getUserSyncs', 'syncOptions', syncOptions, 'serverResponses', serverResponses);
+
let syncs = [];
if (!syncOptions.iframeEnabled && !syncOptions.pixelEnabled) {
return syncs;
}
- serverResponses.forEach(resp => {
- const userSync = deepAccess(resp, 'body.ext.usersync');
- if (userSync) {
- let syncDetails = [];
- Object.keys(userSync).forEach(key => {
- const value = userSync[key];
- if (value.syncs && value.syncs.length) {
- syncDetails = syncDetails.concat(value.syncs);
- }
- });
- syncDetails.forEach(syncDetails => {
- syncs.push({
- type: syncDetails.type === 'iframe' ? 'iframe' : 'image',
- url: syncDetails.url
- });
- });
-
- if (!syncOptions.iframeEnabled) {
- syncs = syncs.filter(s => s.type !== 'iframe')
- }
- if (!syncOptions.pixelEnabled) {
- syncs = syncs.filter(s => s.type !== 'image')
- }
+ if (syncOptions.iframeEnabled || syncOptions.pixelEnabled) {
+ let pixelType = syncOptions.iframeEnabled ? 'iframe' : 'image';
+ let queryParamStrings = [];
+ let syncUrl = SYNC_URL;
+ if (gdprConsent) {
+ queryParamStrings.push('gdpr=' + (gdprConsent.gdprApplies ? 1 : 0));
+ queryParamStrings.push('gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || ''));
+ }
+ if (uspConsent) {
+ queryParamStrings.push('us_privacy=' + encodeURIComponent(uspConsent));
}
- });
- logInfo('dxkulture.getUserSyncs result=%o', syncs);
- return syncs;
- },
+
+ return [{
+ type: pixelType,
+ url: `${syncUrl}${queryParamStrings.length > 0 ? '?' + queryParamStrings.join('&') : ''}`
+ }];
+ }
+ }
};
@@ -182,16 +170,10 @@ export const spec = {
* Util Functions
*======================================= */
-/**
- * @param {BidRequest} bidRequest bid request
- */
function hasBannerMediaType(bidRequest) {
return !!deepAccess(bidRequest, 'mediaTypes.banner');
}
-/**
- * @param {BidRequest} bidRequest bid request
- */
function hasVideoMediaType(bidRequest) {
return !!deepAccess(bidRequest, 'mediaTypes.video');
}
@@ -206,12 +188,12 @@ function _validateParams(bidRequest) {
}
if (!bidRequest.params.publisherId) {
- logError('Validation failed: publisherId not declared');
+ logError('dxkulture: Validation failed: publisherId not declared');
return false;
}
if (!bidRequest.params.placementId) {
- logError('Validation failed: placementId not declared');
+ logError('dxkulture: Validation failed: placementId not declared');
return false;
}
@@ -266,204 +248,31 @@ function _validateVideo(bidRequest) {
};
if (!Array.isArray(videoParams.mimes) || videoParams.mimes.length === 0) {
- logError('Validation failed: mimes are invalid');
+ logError('dxkulture: Validation failed: mimes are invalid');
return false;
}
if (!Array.isArray(videoParams.protocols) || videoParams.protocols.length === 0) {
- logError('Validation failed: protocols are invalid');
+ logError('dxkulture: Validation failed: protocols are invalid');
return false;
}
if (!videoParams.context) {
- logError('Validation failed: context id not declared');
+ logError('dxkulture: Validation failed: context id not declared');
return false;
}
if (videoParams.context !== 'instream') {
- logError('Validation failed: only context instream is supported ');
+ logError('dxkulture: Validation failed: only context instream is supported ');
return false;
}
if (typeof videoParams.playerSize === 'undefined' || !Array.isArray(videoParams.playerSize) || !Array.isArray(videoParams.playerSize[0])) {
- logError('Validation failed: player size not declared or is not in format [[w,h]]');
+ logError('dxkulture: Validation failed: player size not declared or is not in format [[w,h]]');
return false;
}
return true;
}
-/**
- * Prepares video request data.
- *
- * @param bidRequest
- * @param bidderRequest
- * @returns openrtbRequest
- */
-function buildVideoRequestData(bidRequest, bidderRequest) {
- const {params} = bidRequest;
-
- const videoAdUnit = deepAccess(bidRequest, 'mediaTypes.video', {});
- const videoBidderParams = deepAccess(bidRequest, 'params.video', {});
-
- const videoParams = {
- ...videoAdUnit,
- ...videoBidderParams // Bidder Specific overrides
- };
-
- if (bidRequest.params && bidRequest.params.e2etest) {
- videoParams.playerSize = [[640, 480]]
- videoParams.conext = 'instream'
- }
-
- const video = {
- w: parseInt(videoParams.playerSize[0][0], 10),
- h: parseInt(videoParams.playerSize[0][1], 10),
- }
-
- // Obtain all ORTB params related video from Ad Unit
- OPENRTB_VIDEO_PARAMS.forEach((param) => {
- if (videoParams.hasOwnProperty(param)) {
- video[param] = videoParams[param];
- }
- });
-
- // - If product is instream (for instream context) then override placement to 1
- if (params.context === 'instream') {
- video.startdelay = video.startdelay || 0;
- video.placement = 1;
- }
-
- // bid floor
- const bidFloorRequest = {
- currency: bidRequest.params.cur || 'USD',
- mediaType: 'video',
- size: '*'
- };
- let floorData = bidRequest.params
- if (isFn(bidRequest.getFloor)) {
- floorData = bidRequest.getFloor(bidFloorRequest);
- } else {
- if (params.bidfloor) {
- floorData = {floor: params.bidfloor, currency: params.currency || 'USD'};
- }
- }
-
- const openrtbRequest = {
- id: bidRequest.bidId,
- imp: [
- {
- id: '1',
- video: video,
- secure: isSecure() ? 1 : 0,
- bidfloor: floorData.floor,
- bidfloorcur: floorData.currency
- }
- ],
- site: {
- domain: bidderRequest.refererInfo.domain,
- page: bidderRequest.refererInfo.page,
- ref: bidderRequest.refererInfo.ref,
- },
- ext: {
- hb: 1,
- prebidver: '$prebid.version$',
- adapterver: spec.VERSION,
- },
- };
-
- // content
- if (videoParams.content && isPlainObject(videoParams.content)) {
- openrtbRequest.site.content = {};
- const contentStringKeys = ['id', 'title', 'series', 'season', 'genre', 'contentrating', 'language', 'url'];
- const contentNumberkeys = ['episode', 'prodq', 'context', 'livestream', 'len'];
- const contentArrayKeys = ['cat'];
- const contentObjectKeys = ['ext'];
- for (const contentKey in videoBidderParams.content) {
- if (
- (contentStringKeys.indexOf(contentKey) > -1 && isStr(videoParams.content[contentKey])) ||
- (contentNumberkeys.indexOf(contentKey) > -1 && isNumber(videoParams.content[contentKey])) ||
- (contentObjectKeys.indexOf(contentKey) > -1 && isPlainObject(videoParams.content[contentKey])) ||
- (contentArrayKeys.indexOf(contentKey) > -1 && isArray(videoParams.content[contentKey]) &&
- videoParams.content[contentKey].every(catStr => isStr(catStr)))) {
- openrtbRequest.site.content[contentKey] = videoParams.content[contentKey];
- } else {
- logMessage('DXKulture bid adapter validation error: ', contentKey, ' is either not supported is OpenRTB V2.5 or value is undefined');
- }
- }
- }
-
- return openrtbRequest;
-}
-
-/**
- * Prepares video request data.
- *
- * @param bidRequest
- * @param bidderRequest
- * @returns openrtbRequest
- */
-function buildBannerRequestData(bidRequests, bidderRequest) {
- const impr = bidRequests.map(bidRequest => ({
- id: bidRequest.bidId,
- banner: {
- format: bidRequest.mediaTypes.banner.sizes.map(sizeArr => ({
- w: sizeArr[0],
- h: sizeArr[1]
- }))
- },
- ext: {
- exchange: {
- placementId: bidRequest.params.placementId
- }
- }
- }));
-
- const openrtbRequest = {
- id: bidderRequest.auctionId,
- imp: impr,
- site: {
- domain: bidderRequest.refererInfo?.domain,
- page: bidderRequest.refererInfo?.page,
- ref: bidderRequest.refererInfo?.ref,
- },
- ext: {}
- };
- return openrtbRequest;
-}
-
-function _createBidResponse(bid) {
- const isADomainPresent =
- bid.adomain && bid.adomain.length;
- const bidResponse = {
- requestId: bid.impid,
- bidderCode: spec.code,
- cpm: bid.price,
- width: bid.w,
- height: bid.h,
- ad: bid.adm,
- ttl: typeof bid.exp === 'number' ? bid.exp : DEFAULT_BID_TTL,
- creativeId: bid.crid,
- netRevenue: DEFAULT_NET_REVENUE,
- currency: DEFAULT_CURRENCY,
- mediaType: deepAccess(bid, 'ext.prebid.type', BANNER)
- }
-
- if (isADomainPresent) {
- bidResponse.meta = {
- advertiserDomains: bid.adomain
- };
- }
-
- if (bidResponse.mediaType === VIDEO) {
- bidResponse.vastXml = bid.adm;
- }
-
- return bidResponse;
-}
-
-function isSecure() {
- return document.location.protocol === 'https:';
-}
-
registerBidder(spec);
diff --git a/modules/dxkultureBidAdapter.md b/modules/dxkultureBidAdapter.md
index e934aee3301..e31794ef6c6 100644
--- a/modules/dxkultureBidAdapter.md
+++ b/modules/dxkultureBidAdapter.md
@@ -30,7 +30,8 @@ var adUnits = [
params: {
placementId: 'test',
publisherId: 'test',
- networkId: '123'
+ bidfloor: 2.7,
+ bidfloorcur: 'USD'
}
}]
}
@@ -43,7 +44,7 @@ We support the following OpenRTB params that can be specified in `mediaTypes.vid
- 'mimes',
- 'minduration',
- 'maxduration',
-- 'placement',
+- 'plcmt',
- 'protocols',
- 'startdelay',
- 'skip',
@@ -74,7 +75,7 @@ We support the following OpenRTB params that can be specified in `mediaTypes.vid
delivery: [2],
minduration: 10,
maxduration: 30,
- placement: 1,
+ plcmt: 1,
playbackmethod: [1,5],
}
},
@@ -84,8 +85,7 @@ We support the following OpenRTB params that can be specified in `mediaTypes.vid
params: {
bidfloor: 0.5,
publisherId: '12345',
- placementId: '6789',
- networkId" '123'
+ placementId: '6789'
}
}
]
diff --git a/modules/dynamicAdBoostRtdProvider.js b/modules/dynamicAdBoostRtdProvider.js
new file mode 100644
index 00000000000..fe08795f313
--- /dev/null
+++ b/modules/dynamicAdBoostRtdProvider.js
@@ -0,0 +1,114 @@
+/**
+ * The {@link module:modules/realTimeData} module is required
+ * @module modules/dynamicAdBoost
+ * @requires module:modules/realTimeData
+ */
+
+import { submodule } from '../src/hook.js'
+import { loadExternalScript } from '../src/adloader.js';
+import { getGlobal } from '../src/prebidGlobal.js';
+import { deepAccess, deepSetValue, isEmptyStr } from '../src/utils.js';
+
+const MODULE_NAME = 'dynamicAdBoost';
+const SCRIPT_URL = 'https://adxbid.info';
+const CLIENT_SUPPORTS_IO = window.IntersectionObserver && window.IntersectionObserverEntry && window.IntersectionObserverEntry.prototype &&
+ 'intersectionRatio' in window.IntersectionObserverEntry.prototype;
+// Options for the Intersection Observer
+const dabOptions = {
+ threshold: 0.5 // Trigger callback when 50% of the element is visible
+};
+let observer;
+let dabStartDate;
+let dabStartTime;
+
+// Array of div IDs to track
+let dynamicAdBoostAdUnits = {};
+
+function init(config, userConsent) {
+ dabStartDate = new Date();
+ dabStartTime = dabStartDate.getTime();
+ if (!CLIENT_SUPPORTS_IO) {
+ return false;
+ }
+ // Create an Intersection Observer instance
+ observer = new IntersectionObserver(dabHandleIntersection, dabOptions);
+ if (config.params.keyId) {
+ let keyId = config.params.keyId;
+ if (keyId && !isEmptyStr(keyId)) {
+ let dabDivIdsToTrack = config.params.adUnits;
+ let dabInterval = setInterval(function() {
+ // Observe each div by its ID
+ dabDivIdsToTrack.forEach(divId => {
+ let div = document.getElementById(divId);
+ if (div) {
+ observer.observe(div);
+ }
+ });
+
+ let dabDateNow = new Date();
+ let dabTimeNow = dabDateNow.getTime();
+ let dabElapsedSeconds = Math.floor((dabTimeNow - dabStartTime) / 1000);
+ let elapsedThreshold = 30;
+ if (config.params.threshold) {
+ elapsedThreshold = config.params.threshold;
+ }
+ if (dabElapsedSeconds >= elapsedThreshold) {
+ clearInterval(dabInterval); // Stop
+ loadLmScript(keyId);
+ }
+ }, 1000);
+
+ return true;
+ }
+ }
+ return false;
+}
+
+function loadLmScript(keyId) {
+ let viewableAdUnits = Object.keys(dynamicAdBoostAdUnits);
+ let viewableAdUnitsCSV = viewableAdUnits.join(',');
+ const scriptUrl = `${SCRIPT_URL}/${keyId}.js?viewableAdUnits=${viewableAdUnitsCSV}`;
+ loadExternalScript(scriptUrl, MODULE_NAME);
+ observer.disconnect();
+}
+
+function getBidRequestData(reqBidsConfigObj, callback, config, userConsent) {
+ const reqAdUnits = reqBidsConfigObj.adUnits || getGlobal().adUnits;
+
+ if (Array.isArray(reqAdUnits)) {
+ reqAdUnits.forEach(adunit => {
+ let gptCode = deepAccess(adunit, 'code');
+ if (dynamicAdBoostAdUnits.hasOwnProperty(gptCode)) {
+ // AdUnits has reached target viewablity at some point
+ deepSetValue(adunit, `ortb2Imp.ext.data.${MODULE_NAME}.${gptCode}`, dynamicAdBoostAdUnits[gptCode]);
+ }
+ });
+ }
+ callback();
+}
+
+let markViewed = (entry, observer) => {
+ return () => {
+ observer.unobserve(entry.target);
+ }
+}
+
+// Callback function when an observed element becomes visible
+function dabHandleIntersection(entries) {
+ entries.forEach(entry => {
+ if (entry.isIntersecting && entry.intersectionRatio > 0.5) {
+ dynamicAdBoostAdUnits[entry.target.id] = entry.intersectionRatio;
+ markViewed(entry, observer)
+ }
+ });
+}
+
+/** @type {RtdSubmodule} */
+export const subModuleObj = {
+ name: MODULE_NAME,
+ init,
+ getBidRequestData,
+ markViewed
+};
+
+submodule('realTimeData', subModuleObj);
diff --git a/modules/dynamicAdBoostRtdProvider.md b/modules/dynamicAdBoostRtdProvider.md
new file mode 100644
index 00000000000..93efe3b3f97
--- /dev/null
+++ b/modules/dynamicAdBoostRtdProvider.md
@@ -0,0 +1,40 @@
+# Overview
+
+Module Name: Dynamic Ad Boost
+Module Type: Track when a adunit is viewable
+Maintainer: info@luponmedia.com
+
+# Description
+
+Enhance your revenue with the cutting-edge DynamicAdBoost module! By seamlessly integrating the powerful LuponMedia technology, our module retrieves adunits viewability data, providing publishers with valuable insights to optimize their revenue streams. To unlock the full potential of this technology, we provide a customized LuponMedia module tailored to your specific site requirements. Boost your ad revenue and gain unprecedented visibility into your performance with our advanced solution.
+
+In order to utilize this module, it is essential to collaborate with [LuponMedia](https://www.luponmedia.com/) to create an account and obtain detailed guidelines on configuring your sites. Working hand in hand with LuponMedia will ensure a smooth integration process, enabling you to fully leverage the capabilities of this module on your website. Take the first step towards optimizing your ad revenue and enhancing your site's performance by partnering with LuponMedia for a seamless experience.
+Contact info@luponmedia.com for information.
+
+## Building Prebid with Real-time Data Support
+
+First, make sure to add the Dynamic AdBoost submodule to your Prebid.js package with:
+
+`gulp build --modules=rtdModule,dynamicAdBoostRtdProvider`
+
+The following configuration parameters are available:
+
+```
+pbjs.setConfig(
+ ...
+ realTimeData: {
+ auctionDelay: 2000,
+ dataProviders: [
+ {
+ name: "dynamicAdBoost",
+ params: {
+ keyId: "[PROVIDED_KEY]", // Your provided Dynamic AdBoost keyId
+ adUnits: ["allowedAdUnit1", "allowedAdUnit2"],
+ threshold: 35 // optional
+ }
+ }
+ ]
+ }
+ ...
+}
+```
diff --git a/modules/fledgeForGpt.js b/modules/fledgeForGpt.js
index fd29c41210c..566dd5f40e2 100644
--- a/modules/fledgeForGpt.js
+++ b/modules/fledgeForGpt.js
@@ -96,14 +96,20 @@ function onAuctionEnd({auctionId, bidsReceived, bidderRequests}) {
}
}
-export function addComponentAuctionHook(next, auctionId, adUnitCode, componentAuctionConfig) {
+function setFPDSignals(auctionConfig, fpd) {
+ auctionConfig.auctionSignals = mergeDeep({}, {prebid: fpd}, auctionConfig.auctionSignals);
+}
+
+export function addComponentAuctionHook(next, request, componentAuctionConfig) {
+ const {adUnitCode, auctionId, ortb2, ortb2Imp} = request;
if (PENDING.hasOwnProperty(auctionId)) {
+ setFPDSignals(componentAuctionConfig, {ortb2, ortb2Imp});
!PENDING[auctionId].hasOwnProperty(adUnitCode) && (PENDING[auctionId][adUnitCode] = []);
PENDING[auctionId][adUnitCode].push(componentAuctionConfig);
} else {
logWarn(MODULE, `Received component auction config for auction that has closed (auction '${auctionId}', adUnit '${adUnitCode}')`, componentAuctionConfig)
}
- next(auctionId, adUnitCode, componentAuctionConfig);
+ next(request, componentAuctionConfig);
}
function isFledgeSupported() {
@@ -114,25 +120,21 @@ export function markForFledge(next, bidderRequests) {
if (isFledgeSupported()) {
const globalFledgeConfig = config.getConfig('fledgeForGpt');
const bidders = globalFledgeConfig?.bidders ?? [];
- bidderRequests.forEach((req) => {
- const useGlobalConfig = globalFledgeConfig?.enabled && (bidders.length == 0 || bidders.includes(req.bidderCode));
- Object.assign(req, config.runWithBidder(req.bidderCode, () => {
- return {
- fledgeEnabled: config.getConfig('fledgeEnabled') ?? (useGlobalConfig ? globalFledgeConfig.enabled : undefined),
- defaultForSlots: config.getConfig('defaultForSlots') ?? (useGlobalConfig ? globalFledgeConfig?.defaultForSlots : undefined)
- }
- }));
+ bidderRequests.forEach((bidderReq) => {
+ const useGlobalConfig = globalFledgeConfig?.enabled && (bidders.length === 0 || bidders.includes(bidderReq.bidderCode));
+ config.runWithBidder(bidderReq.bidderCode, () => {
+ const fledgeEnabled = config.getConfig('fledgeEnabled') ?? (useGlobalConfig ? globalFledgeConfig.enabled : undefined);
+ const defaultForSlots = config.getConfig('defaultForSlots') ?? (useGlobalConfig ? globalFledgeConfig?.defaultForSlots : undefined);
+ Object.assign(bidderReq, {fledgeEnabled});
+ bidderReq.bids.forEach(bidReq => { deepSetValue(bidReq, 'ortb2Imp.ext.ae', bidReq.ortb2Imp?.ext?.ae ?? defaultForSlots) })
+ })
});
}
next(bidderRequests);
}
export function setImpExtAe(imp, bidRequest, context) {
- if (context.bidderRequest.fledgeEnabled) {
- imp.ext = Object.assign(imp.ext || {}, {
- ae: imp.ext?.ae ?? context.bidderRequest.defaultForSlots
- })
- } else {
+ if (imp.ext?.ae && !context.bidderRequest.fledgeEnabled) {
delete imp.ext?.ae;
}
}
diff --git a/modules/flippBidAdapter.js b/modules/flippBidAdapter.js
index dfe8141170d..480e414992d 100644
--- a/modules/flippBidAdapter.js
+++ b/modules/flippBidAdapter.js
@@ -25,13 +25,16 @@ export function getUserKey(options = {}) {
}
// If the partner provides the user key use it, otherwise fallback to cookies
- if (options.userKey && isValidUserKey(options.userKey)) {
- userKey = options.userKey;
- return options.userKey;
+ if ('userKey' in options && options.userKey) {
+ if (isValidUserKey(options.userKey)) {
+ userKey = options.userKey;
+ return options.userKey;
+ }
}
+
// Grab from Cookie
- const foundUserKey = storage.cookiesAreEnabled() && storage.getCookie(FLIPP_USER_KEY);
- if (foundUserKey) {
+ const foundUserKey = storage.cookiesAreEnabled(null) && storage.getCookie(FLIPP_USER_KEY, null);
+ if (foundUserKey && isValidUserKey(foundUserKey)) {
return foundUserKey;
}
@@ -47,7 +50,7 @@ export function getUserKey(options = {}) {
}
function isValidUserKey(userKey) {
- return !userKey.startsWith('#');
+ return typeof userKey === 'string' && !userKey.startsWith('#') && userKey.length > 0;
}
const generateUUID = () => {
diff --git a/modules/flippBidAdapter.md b/modules/flippBidAdapter.md
index 810b883e3f9..e823432a60f 100644
--- a/modules/flippBidAdapter.md
+++ b/modules/flippBidAdapter.md
@@ -32,9 +32,10 @@ var adUnits = [
publisherNameIdentifier: 'wishabi-test-publisher', // Required
siteId: 1192075, // Required
zoneIds: [260678], // Optional
- userKey: "", // Optional
+ userKey: ``, // Optional, but recommended for better user experience. Can be a cookie, session id or any other user identifier
options: {
- startCompact: true // Optional, default to true
+ startCompact: true, // Optional. Height of the experience will be reduced. Default to true
+ dwellExpand: true // Optional. Auto expand the experience after a certain time passes. Default to true
}
}
}
diff --git a/modules/freewheel-sspBidAdapter.js b/modules/freewheel-sspBidAdapter.js
index cd4785cdc78..ba819abd687 100644
--- a/modules/freewheel-sspBidAdapter.js
+++ b/modules/freewheel-sspBidAdapter.js
@@ -4,6 +4,7 @@ import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
const BIDDER_CODE = 'freewheel-ssp';
+const GVL_ID = 285;
const PROTOCOL = getProtocol();
const FREEWHEEL_ADSSETUP = PROTOCOL + '://ads.stickyadstv.com/www/delivery/swfIndex.php';
@@ -314,6 +315,7 @@ var getOutstreamScript = function(bid) {
export const spec = {
code: BIDDER_CODE,
+ gvlid: GVL_ID,
supportedMediaTypes: [BANNER, VIDEO],
aliases: ['stickyadstv', 'freewheelssp'], // aliases for freewheel-ssp
/**
@@ -382,6 +384,15 @@ export const spec = {
requestParams.gpp_sid = bidderRequest.ortb2.regs.gpp_sid;
}
+ // Add content object
+ if (bidderRequest && bidderRequest.ortb2 && bidderRequest.ortb2.site && bidderRequest.ortb2.site.content && typeof bidderRequest.ortb2.site.content === 'object') {
+ try {
+ requestParams._fw_prebid_content = JSON.stringify(bidderRequest.ortb2.site.content);
+ } catch (error) {
+ logWarn('PREBID - ' + BIDDER_CODE + ': Unable to stringify the content object: ' + error);
+ }
+ }
+
// Add schain object
var schain = currentBidRequest.schain;
if (schain) {
@@ -532,10 +543,11 @@ export const spec = {
};
if (bidrequest.mediaTypes.video) {
- bidResponse.vastXml = serverResponse;
bidResponse.mediaType = 'video';
}
+ bidResponse.vastXml = serverResponse;
+
bidResponse.ad = formatAdHTML(bidrequest, playerSize);
bidResponses.push(bidResponse);
}
diff --git a/modules/gdprEnforcement.js b/modules/gdprEnforcement.js
index 4e600f71b90..5b73ec19e08 100644
--- a/modules/gdprEnforcement.js
+++ b/modules/gdprEnforcement.js
@@ -7,7 +7,7 @@ import {config} from '../src/config.js';
import adapterManager, {gdprDataHandler} from '../src/adapterManager.js';
import * as events from '../src/events.js';
import CONSTANTS from '../src/constants.json';
-import {GDPR_GVLIDS, VENDORLESS_GVLID} from '../src/consentHandler.js';
+import {GDPR_GVLIDS, VENDORLESS_GVLID, FIRST_PARTY_GVLID} from '../src/consentHandler.js';
import {
MODULE_TYPE_ANALYTICS,
MODULE_TYPE_BIDDER,
@@ -111,7 +111,7 @@ export function getGvlid(moduleType, moduleName, fallbackFn) {
if (gvlMapping && gvlMapping[moduleName]) {
return gvlMapping[moduleName];
} else if (moduleType === MODULE_TYPE_PREBID) {
- return VENDORLESS_GVLID;
+ return moduleName === 'cdep' ? FIRST_PARTY_GVLID : VENDORLESS_GVLID;
} else {
let {gvlid, modules} = GDPR_GVLIDS.get(moduleName);
if (gvlid == null && Object.keys(modules).length > 0) {
@@ -166,6 +166,7 @@ export function shouldEnforce(consentData, purpose, name) {
function getConsent(consentData, type, id, gvlId) {
let purpose = !!deepAccess(consentData, `vendorData.${CONSENT_PATHS[type]}.${id}`);
let vendor = !!deepAccess(consentData, `vendorData.vendor.consents.${gvlId}`);
+
if (type === 'purpose' && LI_PURPOSES.includes(id)) {
purpose ||= !!deepAccess(consentData, `vendorData.purpose.legitimateInterests.${id}`);
vendor ||= !!deepAccess(consentData, `vendorData.vendor.legitimateInterests.${gvlId}`);
@@ -191,13 +192,21 @@ export function validateRules(rule, consentData, currentModule, gvlId) {
}
const vendorConsentRequred = rule.enforceVendor && !((gvlId === VENDORLESS_GVLID || (rule.softVendorExceptions || []).includes(currentModule)));
const {purpose, vendor} = getConsent(consentData, ruleOptions.type, ruleOptions.id, gvlId);
- return (!rule.enforcePurpose || purpose) && (!vendorConsentRequred || vendor);
+
+ let validation = (!rule.enforcePurpose || purpose) && (!vendorConsentRequred || vendor);
+
+ if (gvlId === FIRST_PARTY_GVLID) {
+ validation = (!rule.enforcePurpose || !!deepAccess(consentData, `vendorData.publisher.consents.${ruleOptions.id}`));
+ }
+
+ return validation;
}
function gdprRule(purposeNo, checkConsent, blocked = null, gvlidFallback = () => null) {
return function (params) {
const consentData = gdprDataHandler.getConsentData();
const modName = params[ACTIVITY_PARAM_COMPONENT_NAME];
+
if (shouldEnforce(consentData, purposeNo, modName)) {
const gvlid = getGvlid(params[ACTIVITY_PARAM_COMPONENT_TYPE], modName, gvlidFallback(params));
let allow = !!checkConsent(consentData, modName, gvlid);
diff --git a/modules/genericAnalyticsAdapter.js b/modules/genericAnalyticsAdapter.js
index b52cb7e5464..7f721863912 100644
--- a/modules/genericAnalyticsAdapter.js
+++ b/modules/genericAnalyticsAdapter.js
@@ -1,6 +1,6 @@
import AnalyticsAdapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js';
import {prefixLog, isPlainObject} from '../src/utils.js';
-import * as CONSTANTS from '../src/constants.json';
+import {has as hasEvent} from '../src/events.js';
import adapterManager from '../src/adapterManager.js';
import {ajaxBuilder} from '../src/ajax.js';
@@ -48,12 +48,12 @@ export function GenericAnalytics() {
return false;
}
for (const [event, handler] of Object.entries(options.events)) {
- if (!CONSTANTS.EVENTS.hasOwnProperty(event)) {
+ if (!hasEvent(event)) {
logWarn(`options.events.${event} does not match any known Prebid event`);
- if (typeof handler !== 'function') {
- logError(`options.events.${event} must be a function`);
- return false;
- }
+ }
+ if (typeof handler !== 'function') {
+ logError(`options.events.${event} must be a function`);
+ return false;
}
}
}
diff --git a/modules/goldfishAdsRtdProvider.js b/modules/goldfishAdsRtdProvider.js
new file mode 100755
index 00000000000..c466ac5ec25
--- /dev/null
+++ b/modules/goldfishAdsRtdProvider.js
@@ -0,0 +1,194 @@
+import { ajax } from '../src/ajax.js';
+import { submodule } from '../src/hook.js';
+import { getStorageManager } from '../src/storageManager.js';
+import { deepAccess } from '../src/utils.js';
+
+export const MODULE_NAME = 'goldfishAdsRtd';
+export const MODULE_TYPE = 'realTimeData';
+export const ENDPOINT_URL = 'https://prebid.goldfishads.com/iab-segments';
+export const DATA_STORAGE_KEY = 'goldfishads_data';
+export const DATA_STORAGE_TTL = 1800 * 1000// TTL in seconds
+
+export const ADAPTER_VERSION = '1.0';
+
+export const storage = getStorageManager({
+ gvlid: null,
+ moduleName: MODULE_NAME,
+ moduleType: MODULE_TYPE,
+});
+
+/**
+ *
+ * @param {{response: string[]} } response
+ * @returns
+ */
+export const manageCallbackResponse = (response) => {
+ try {
+ const foo = JSON.parse(response.response);
+ if (!Array.isArray(foo)) throw new Error('Invalid response');
+ const enrichedResponse = {
+ ext: {
+ segtax: 4
+ },
+ segment: foo.map((segment) => { return { id: segment } }),
+ };
+ const output = {
+ name: 'goldfishads.com',
+ ...enrichedResponse,
+ };
+ return output;
+ } catch (e) {
+ throw e;
+ };
+};
+
+/**
+ * @param {string} key
+ * @returns { Promise<{name: 'goldfishads.com', ext: { segtag: 4 }, segment: string[]}> }
+ */
+
+const getTargetingDataFromApi = (key) => {
+ return new Promise((resolve, reject) => {
+ const requestOptions = {
+ customHeaders: {
+ 'Accept': 'application/json'
+ }
+ }
+ const callbacks = {
+ success(responseText, response) {
+ try {
+ const output = manageCallbackResponse(response);
+ resolve(output);
+ } catch (e) {
+ reject(e);
+ }
+ },
+ error(error) {
+ reject(error);
+ }
+ };
+ ajax(`${ENDPOINT_URL}?key=${key}`, callbacks, null, requestOptions)
+ })
+};
+
+/**
+ * @returns {{
+ * name: 'golfishads.com',
+ * ext: { segtax: 4},
+ * segment: string[]
+ * } | null }
+ */
+export const getStorageData = () => {
+ const now = new Date();
+ const data = storage.getDataFromLocalStorage(DATA_STORAGE_KEY);
+ if (data === null) return null;
+ try {
+ const foo = JSON.parse(data);
+ if (now.getTime() > foo.expiry) return null;
+ return foo.targeting;
+ } catch (e) {
+ return null;
+ }
+};
+
+/**
+ * @param { { key: string } } payload
+ * @returns {Promise<{
+ * name: string,
+ * ext: { segtax: 4},
+ * segment: string[]
+ * }> | null
+ * }
+ */
+
+const getTargetingData = (payload) => new Promise((resolve) => {
+ const targeting = getStorageData();
+ if (targeting === null) {
+ getTargetingDataFromApi(payload.key)
+ .then((response) => {
+ const now = new Date()
+ const data = {
+ targeting: response,
+ expiry: now.getTime() + DATA_STORAGE_TTL,
+ };
+ storage.setDataInLocalStorage(DATA_STORAGE_KEY, JSON.stringify(data));
+ resolve(response);
+ })
+ .catch((e) => {
+ resolve(null);
+ });
+ } else {
+ resolve(targeting);
+ }
+})
+
+/**
+ *
+ * @param {*} config
+ * @param {*} userConsent
+ * @returns {boolean}
+ */
+
+const init = (config, userConsent) => {
+ if (!config.params || !config.params.key) return false;
+ // return { type: (typeof config.params.key === 'string') };
+ if (!(typeof config.params.key === 'string')) return false;
+ return true;
+};
+
+/**
+ *
+ * @param {{
+ * name: string,
+* ext: { segtax: 4},
+* segment: {id: string}[]
+* } | null } userData
+ * @param {*} reqBidsConfigObj
+ * @returns
+ */
+export const updateUserData = (userData, reqBidsConfigObj) => {
+ if (userData === null) return;
+ const bidders = ['appnexus', 'rubicon', 'nexx360'];
+ for (let i = 0; i < bidders.length; i++) {
+ const bidderCode = bidders[i];
+ const originalConfig = deepAccess(reqBidsConfigObj, `ortb2Fragments.bidder[${bidderCode}].user.data`) || [];
+ const userConfig = [
+ ...originalConfig,
+ userData,
+ ];
+ reqBidsConfigObj.ortb2Fragments = reqBidsConfigObj.ortb2Fragments || {};
+ reqBidsConfigObj.ortb2Fragments.bidder = reqBidsConfigObj.ortb2Fragments.bidder || {};
+ reqBidsConfigObj.ortb2Fragments.bidder[bidderCode] = reqBidsConfigObj.ortb2Fragments.bidder[bidderCode] || {};
+ reqBidsConfigObj.ortb2Fragments.bidder[bidderCode].user = reqBidsConfigObj.ortb2Fragments.bidder[bidderCode].user = {};
+ reqBidsConfigObj.ortb2Fragments.bidder[bidderCode].user.data = reqBidsConfigObj.ortb2Fragments.bidder[bidderCode].user.data || userConfig;
+ }
+ return reqBidsConfigObj;
+}
+
+/**
+ *
+ * @param {*} reqBidsConfigObj
+ * @param {*} callback
+ * @param {*} moduleConfig
+ * @param {*} userConsent
+ * @returns {void}
+ */
+const getBidRequestData = (reqBidsConfigObj, callback, moduleConfig, userConsent) => {
+ const payload = {
+ key: moduleConfig.params.key,
+ };
+ getTargetingData(payload)
+ .then((userData) => {
+ updateUserData(userData, reqBidsConfigObj);
+ callback();
+ });
+};
+
+/** @type {RtdSubmodule} */
+export const goldfishAdsSubModule = {
+ name: MODULE_NAME,
+ init,
+ getBidRequestData,
+};
+
+submodule(MODULE_TYPE, goldfishAdsSubModule);
diff --git a/modules/goldfishAdsRtdProvider.md b/modules/goldfishAdsRtdProvider.md
new file mode 100755
index 00000000000..4625c9a7988
--- /dev/null
+++ b/modules/goldfishAdsRtdProvider.md
@@ -0,0 +1,48 @@
+# Goldfish Ads Real-time Data Submodule
+
+## Overview
+
+ Module Name: Goldfish Ads Rtd Provider
+ Module Type: Rtd Provider
+ Maintainer: keith@goldfishads.com
+
+## Description
+
+This RTD module provides access to the Goldfish Ads Geograph, which leverages geographic and temporal data on a privcay-first platform. This module works without using cookies, PII, emails, or device IDs across all website traffic, including unauthenticated users, and adds audience data into bid requests to increase scale and yields.
+
+## Usage
+
+### Build
+```
+gulp build --modules="rtdModule,goldfishAdsRtdProvider,appnexusBidAdapter,..."
+```
+
+> Note that the global RTD module, `rtdModule`, is a prerequisite of the Goldfish Ads RTD module.
+
+### Configuration
+
+Use `setConfig` to instruct Prebid.js to initialize the Goldfish Ads RTD module, as specified below.
+
+This module is configured as part of the `realTimeData.dataProviders`
+
+```javascript
+pbjs.setConfig({
+ realTimeData: {
+ auctionDelay: 300,
+ dataProviders: [{
+ name: 'goldfishAds',
+ waitForIt: true,
+ params: {
+ key: 'testkey'
+ }
+ }]
+ }
+})
+```
+
+### Parameters
+| Name | Type | Description | Default |
+|:-----------------|:----------------------------------------|:-----------------------------------------------------------------------------|:-----------------------|
+| name | String | Real time data module name | Always 'goldfishAds' |
+| waitForIt | Boolean | Set to true to maximize chance for bidder enrichment, used with auctionDelay | `false` |
+| params.key | String | Your key id issued by Goldfish Ads | |
diff --git a/modules/gridBidAdapter.js b/modules/gridBidAdapter.js
index aa00a84273c..9673633a0fe 100644
--- a/modules/gridBidAdapter.js
+++ b/modules/gridBidAdapter.js
@@ -18,7 +18,7 @@ import { getStorageManager } from '../src/storageManager.js';
const BIDDER_CODE = 'grid';
const ENDPOINT_URL = 'https://grid.bidswitch.net/hbjson';
-const USP_DELETE_DATA_HANDLER = 'https://media.grid.bidswitch.net/uspapi_delete'
+const USP_DELETE_DATA_HANDLER = 'https://media.grid.bidswitch.net/uspapi_delete_c2s'
const SYNC_URL = 'https://x.bidswitch.net/sync?ssp=themediagrid';
const TIME_TO_LIVE = 360;
@@ -464,16 +464,7 @@ export const spec = {
},
onDataDeletionRequest: function(data) {
- const uids = [];
- const aliases = [spec.code, ...spec.aliases.map((alias) => alias.code || alias)];
- data.forEach(({ bids }) => bids && bids.forEach(({ bidder, params }) => {
- if (aliases.includes(bidder) && params && params.uid) {
- uids.push(params.uid);
- }
- }));
- if (uids.length) {
- spec.ajaxCall(USP_DELETE_DATA_HANDLER, () => {}, JSON.stringify({ uids }), {contentType: 'application/json', method: 'POST'});
- }
+ spec.ajaxCall(USP_DELETE_DATA_HANDLER, null, null, {method: 'GET'});
}
};
diff --git a/modules/growthCodeRtdProvider.js b/modules/growthCodeRtdProvider.js
index ef5c7906ad7..e7dce81f7d0 100644
--- a/modules/growthCodeRtdProvider.js
+++ b/modules/growthCodeRtdProvider.js
@@ -60,7 +60,11 @@ function init(config, userConsent) {
items = tryParse(storage.getDataFromLocalStorage(RTD_CACHE_KEY, null));
- return callServer(configParams, items, expiresAt, userConsent);
+ if (configParams.pid === undefined) {
+ return true; // Die gracefully
+ } else {
+ return callServer(configParams, items, expiresAt, userConsent);
+ }
}
function callServer(configParams, items, expiresAt, userConsent) {
// Expire Cache
diff --git a/modules/gumgumBidAdapter.js b/modules/gumgumBidAdapter.js
index e14dc7433dc..83fd726fde5 100644
--- a/modules/gumgumBidAdapter.js
+++ b/modules/gumgumBidAdapter.js
@@ -176,6 +176,7 @@ function _getVidParams(attributes) {
linearity: li,
startdelay: sd,
placement: pt,
+ plcmt,
protocols = [],
playerSize = []
} = attributes;
@@ -187,7 +188,7 @@ function _getVidParams(attributes) {
pr = protocols.join(',');
}
- return {
+ const result = {
mind,
maxd,
li,
@@ -197,6 +198,11 @@ function _getVidParams(attributes) {
viw,
vih
};
+ // Add vplcmt property to the result object if plcmt is available
+ if (plcmt !== undefined && plcmt !== null) {
+ result.vplcmt = plcmt;
+ }
+ return result;
}
/**
diff --git a/modules/identityLinkIdSystem.js b/modules/identityLinkIdSystem.js
index ba794df1a9c..a57f8d22753 100644
--- a/modules/identityLinkIdSystem.js
+++ b/modules/identityLinkIdSystem.js
@@ -10,6 +10,7 @@ import { ajax } from '../src/ajax.js';
import { submodule } from '../src/hook.js';
import {getStorageManager} from '../src/storageManager.js';
import {MODULE_TYPE_UID} from '../src/activities/modules.js';
+import { gppDataHandler } from '../src/adapterManager.js';
const MODULE_NAME = 'identityLink';
@@ -59,12 +60,16 @@ export const identityLinkSubmodule = {
utils.logInfo('identityLink: Consent string is required to call envelope API.');
return;
}
- const url = `https://api.rlcdn.com/api/identity/envelope?pid=${configParams.pid}${hasGdpr ? (tcfPolicyV2 ? '&ct=4&cv=' : '&ct=1&cv=') + gdprConsentString : ''}`;
+ const gppData = gppDataHandler.getConsentData();
+ const gppString = gppData && gppData.gppString ? gppData.gppString : false;
+ const gppSectionId = gppData && gppData.gppString && gppData.applicableSections.length > 0 && gppData.applicableSections[0] !== -1 ? gppData.applicableSections[0] : false;
+ const hasGpp = gppString && gppSectionId;
+ const url = `https://api.rlcdn.com/api/identity/envelope?pid=${configParams.pid}${hasGdpr ? (tcfPolicyV2 ? '&ct=4&cv=' : '&ct=1&cv=') + gdprConsentString : ''}${hasGpp ? '&gpp=' + gppString + '&gpp_sid=' + gppSectionId : ''}`;
let resp;
resp = function (callback) {
// Check ats during callback so it has a chance to initialise.
// If ats library is available, use it to retrieve envelope. If not use standard third party endpoint
- if (window.ats) {
+ if (window.ats && window.ats.retrieveEnvelope) {
utils.logInfo('identityLink: ATS exists!');
window.ats.retrieveEnvelope(function (envelope) {
if (envelope) {
diff --git a/modules/impactifyBidAdapter.js b/modules/impactifyBidAdapter.js
index f2bf9aaddcb..04a45e64b19 100644
--- a/modules/impactifyBidAdapter.js
+++ b/modules/impactifyBidAdapter.js
@@ -1,7 +1,10 @@
-import {deepAccess, deepSetValue, generateUUID} from '../src/utils.js';
-import {registerBidder} from '../src/adapters/bidderFactory.js';
-import {config} from '../src/config.js';
-import {ajax} from '../src/ajax.js';
+'use strict';
+
+import { deepAccess, deepSetValue, generateUUID } from '../src/utils.js';
+import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { config } from '../src/config.js';
+import { ajax } from '../src/ajax.js';
+import { getStorageManager } from '../src/storageManager.js';
const BIDDER_CODE = 'impactify';
const BIDDER_ALIAS = ['imp'];
@@ -10,58 +13,125 @@ const DEFAULT_VIDEO_WIDTH = 640;
const DEFAULT_VIDEO_HEIGHT = 360;
const ORIGIN = 'https://sonic.impactify.media';
const LOGGER_URI = 'https://logger.impactify.media';
-const AUCTIONURI = '/bidder';
-const COOKIESYNCURI = '/static/cookie_sync.html';
-const GVLID = 606;
-const GETCONFIG = config.getConfig;
-
-const getDeviceType = () => {
- // OpenRTB Device type
- if ((/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase()))) {
- return 5;
- }
- if ((/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(navigator.userAgent.toLowerCase()))) {
- return 4;
- }
- return 2;
-};
+const AUCTION_URI = '/bidder';
+const COOKIE_SYNC_URI = '/static/cookie_sync.html';
+const GVL_ID = 606;
+const GET_CONFIG = config.getConfig;
+export const STORAGE = getStorageManager({ gvlid: GVL_ID, bidderCode: BIDDER_CODE });
+export const STORAGE_KEY = '_im_str'
+
+/**
+ * Helpers object
+ * @type {{getExtParamsFromBid(*): {impactify: {appId}}, createOrtbImpVideoObj(*): {context: string, playerSize: [number,number], id: string, mimes: [string]}, getDeviceType(): (number), createOrtbImpBannerObj(*, *): {format: [], id: string}}}
+ */
+const helpers = {
+ getExtParamsFromBid(bid) {
+ let ext = {
+ impactify: {
+ appId: bid.params.appId
+ },
+ };
-const getFloor = (bid) => {
- const floorInfo = bid.getFloor({
- currency: DEFAULT_CURRENCY,
- mediaType: '*',
- size: '*'
- });
- if (typeof floorInfo === 'object' && floorInfo.currency === DEFAULT_CURRENCY && !isNaN(parseFloat(floorInfo.floor))) {
- return parseFloat(floorInfo.floor);
+ if (typeof bid.params.format == 'string') {
+ ext.impactify.format = bid.params.format;
+ }
+
+ if (typeof bid.params.style == 'string') {
+ ext.impactify.style = bid.params.style;
+ }
+
+ if (typeof bid.params.container == 'string') {
+ ext.impactify.container = bid.params.container;
+ }
+
+ if (typeof bid.params.size == 'string') {
+ ext.impactify.size = bid.params.size;
+ }
+
+ return ext;
+ },
+
+ getDeviceType() {
+ // OpenRTB Device type
+ if ((/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase()))) {
+ return 5;
+ }
+ if ((/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(navigator.userAgent.toLowerCase()))) {
+ return 4;
+ }
+ return 2;
+ },
+
+ createOrtbImpBannerObj(bid, size) {
+ let sizes = size.split('x');
+
+ return {
+ id: 'banner-' + bid.bidId,
+ format: [{
+ w: parseInt(sizes[0]),
+ h: parseInt(sizes[1])
+ }]
+ }
+ },
+
+ createOrtbImpVideoObj(bid) {
+ return {
+ id: 'video-' + bid.bidId,
+ playerSize: [DEFAULT_VIDEO_WIDTH, DEFAULT_VIDEO_HEIGHT],
+ context: 'outstream',
+ mimes: ['video/mp4'],
+ }
+ },
+
+ getFloor(bid) {
+ const floorInfo = bid.getFloor({
+ currency: DEFAULT_CURRENCY,
+ mediaType: '*',
+ size: '*'
+ });
+ if (typeof floorInfo === 'object' && floorInfo.currency === DEFAULT_CURRENCY && !isNaN(parseFloat(floorInfo.floor))) {
+ return parseFloat(floorInfo.floor);
+ }
+ return null;
+ },
+
+ getImStrFromLocalStorage() {
+ return STORAGE.localStorageIsEnabled(false) ? STORAGE.getDataFromLocalStorage(STORAGE_KEY, false) : '';
}
- return null;
+
}
-const createOpenRtbRequest = (validBidRequests, bidderRequest) => {
+/**
+ * Create an OpenRTB formated object from prebid payload
+ * @param validBidRequests
+ * @param bidderRequest
+ * @returns {{cur: string[], validBidRequests, id, source: {tid}, imp: *[]}}
+ */
+function createOpenRtbRequest(validBidRequests, bidderRequest) {
// Create request and set imp bids inside
let request = {
id: bidderRequest.bidderRequestId,
validBidRequests,
cur: [DEFAULT_CURRENCY],
imp: [],
- source: {tid: bidderRequest.ortb2?.source?.tid}
+ source: { tid: bidderRequest.ortb2?.source?.tid }
};
// Get the url parameters
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const checkPrebid = urlParams.get('_checkPrebid');
- // Force impactify debugging parameter
+
+ // Force impactify debugging parameter if present
if (checkPrebid != null) {
request.test = Number(checkPrebid);
}
- // Set Schain in request
+ // Set SChain in request
let schain = deepAccess(validBidRequests, '0.schain');
if (schain) request.source.ext = { schain: schain };
- // Set eids
+ // Set Eids
let eids = deepAccess(validBidRequests, '0.userIdAsEids');
if (eids && eids.length) {
deepSetValue(request, 'user.ext.eids', eids);
@@ -73,13 +143,13 @@ const createOpenRtbRequest = (validBidRequests, bidderRequest) => {
request.device = {
w: window.innerWidth,
h: window.innerHeight,
- devicetype: getDeviceType(),
+ devicetype: helpers.getDeviceType(),
ua: navigator.userAgent,
js: 1,
dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0,
language: ((navigator.language || navigator.userLanguage || '').split('-'))[0] || 'en',
};
- request.site = {page: bidderRequest.refererInfo.page};
+ request.site = { page: bidderRequest.refererInfo.page };
// Handle privacy settings for GDPR/CCPA/COPPA
let gdprApplies = 0;
@@ -91,9 +161,10 @@ const createOpenRtbRequest = (validBidRequests, bidderRequest) => {
if (bidderRequest.uspConsent) {
deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent);
+ this.syncStore.uspConsent = bidderRequest.uspConsent;
}
- if (GETCONFIG('coppa') == true) deepSetValue(request, 'regs.coppa', 1);
+ if (GET_CONFIG('coppa') == true) deepSetValue(request, 'regs.coppa', 1);
if (bidderRequest.uspConsent) {
deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent);
@@ -104,42 +175,47 @@ const createOpenRtbRequest = (validBidRequests, bidderRequest) => {
// Create imps with bids
validBidRequests.forEach((bid) => {
+ let bannerObj = deepAccess(bid.mediaTypes, `banner`);
+
let imp = {
id: bid.bidId,
bidfloor: bid.params.bidfloor ? bid.params.bidfloor : 0,
- ext: {
- impactify: {
- appId: bid.params.appId,
- format: bid.params.format,
- style: bid.params.style
- },
- },
- video: {
- playerSize: [DEFAULT_VIDEO_WIDTH, DEFAULT_VIDEO_HEIGHT],
- context: 'outstream',
- mimes: ['video/mp4'],
- },
+ ext: helpers.getExtParamsFromBid(bid)
};
- if (bid.params.container) {
- imp.ext.impactify.container = bid.params.container;
+
+ if (bannerObj && typeof imp.ext.impactify.size == 'string') {
+ imp.banner = {
+ ...helpers.createOrtbImpBannerObj(bid, imp.ext.impactify.size)
+ }
+ } else {
+ imp.video = {
+ ...helpers.createOrtbImpVideoObj(bid)
+ }
}
+
if (typeof bid.getFloor === 'function') {
- const floor = getFloor(bid);
+ const floor = helpers.getFloor(bid);
if (floor) {
imp.bidfloor = floor;
}
}
+
request.imp.push(imp);
});
return request;
-};
+}
+/**
+ * Export BidderSpec type object and register it to Prebid
+ * @type {{supportedMediaTypes: string[], interpretResponse: ((function(ServerResponse, *): Bid[])|*), code: string, aliases: string[], getUserSyncs: ((function(SyncOptions, ServerResponse[], *, *): UserSync[])|*), buildRequests: (function(*, *): {method: string, data: string, url}), onTimeout: (function(*): boolean), gvlid: number, isBidRequestValid: ((function(BidRequest): (boolean))|*), onBidWon: (function(*): boolean)}}
+ */
export const spec = {
code: BIDDER_CODE,
- gvlid: GVLID,
+ gvlid: GVL_ID,
supportedMediaTypes: ['video', 'banner'],
aliases: BIDDER_ALIAS,
+ storageAllowed: true,
/**
* Determines whether or not the given bid request is valid.
@@ -148,13 +224,16 @@ export const spec = {
* @return boolean True if this is a valid bid, and false otherwise.
*/
isBidRequestValid: function (bid) {
- if (!bid.params.appId || typeof bid.params.appId != 'string' || !bid.params.format || typeof bid.params.format != 'string' || !bid.params.style || typeof bid.params.style != 'string') {
+ if (typeof bid.params.appId != 'string' || !bid.params.appId) {
+ return false;
+ }
+ if (typeof bid.params.format != 'string' || typeof bid.params.style != 'string' || !bid.params.format || !bid.params.style) {
return false;
}
- if (bid.params.format != 'screen' && bid.params.format != 'display') {
+ if (bid.params.format !== 'screen' && bid.params.format !== 'display') {
return false;
}
- if (bid.params.style != 'inline' && bid.params.style != 'impact' && bid.params.style != 'static') {
+ if (bid.params.style !== 'inline' && bid.params.style !== 'impact' && bid.params.style !== 'static') {
return false;
}
@@ -171,11 +250,20 @@ export const spec = {
buildRequests: function (validBidRequests, bidderRequest) {
// Create a clean openRTB request
let request = createOpenRtbRequest(validBidRequests, bidderRequest);
+ const imStr = helpers.getImStrFromLocalStorage();
+ const options = {}
+
+ if (imStr) {
+ options.customHeaders = {
+ 'x-impact': imStr
+ };
+ }
return {
method: 'POST',
- url: ORIGIN + AUCTIONURI,
+ url: ORIGIN + AUCTION_URI,
data: JSON.stringify(request),
+ options
};
},
@@ -265,7 +353,7 @@ export const spec = {
return [{
type: 'iframe',
- url: ORIGIN + COOKIESYNCURI + params
+ url: ORIGIN + COOKIE_SYNC_URI + params
}];
},
@@ -273,8 +361,8 @@ export const spec = {
* Register bidder specific code, which will execute if a bid from this bidder won the auction
* @param {Bid} The bid that won the auction
*/
- onBidWon: function(bid) {
- ajax(`${LOGGER_URI}/log/bidder/won`, null, JSON.stringify(bid), {
+ onBidWon: function (bid) {
+ ajax(`${LOGGER_URI}/prebid/won`, null, JSON.stringify(bid), {
method: 'POST',
contentType: 'application/json'
});
@@ -286,8 +374,8 @@ export const spec = {
* Register bidder specific code, which will execute if bidder timed out after an auction
* @param {data} Containing timeout specific data
*/
- onTimeout: function(data) {
- ajax(`${LOGGER_URI}/log/bidder/timeout`, null, JSON.stringify(data[0]), {
+ onTimeout: function (data) {
+ ajax(`${LOGGER_URI}/prebid/timeout`, null, JSON.stringify(data[0]), {
method: 'POST',
contentType: 'application/json'
});
diff --git a/modules/impactifyBidAdapter.md b/modules/impactifyBidAdapter.md
index 3de9a8cfb84..de3373395dc 100644
--- a/modules/impactifyBidAdapter.md
+++ b/modules/impactifyBidAdapter.md
@@ -10,14 +10,22 @@ Maintainer: thomas.destefano@impactify.io
Module that connects to the Impactify solution.
The impactify bidder need 3 parameters:
- - appId : This is your unique publisher identifier
- - format : This is the ad format needed, can be : screen or display
- - style : This is the ad style needed, can be : inline, impact or static
+- appId : This is your unique publisher identifier
+- format : This is the ad format needed, can be : screen or display (Only for video media type)
+- style : This is the ad style needed, can be : inline, impact or static (Only for video media type)
+
+Note : Impactify adapter need storage access to work properly (Do not forget to set storageAllowed to true).
# Test Parameters
```
- var adUnits = [{
- code: 'your-slot-div-id', // This is your slot div id
+ pbjs.bidderSettings = {
+ impactify: {
+ storageAllowed: true // Mandatory
+ }
+ };
+
+ var adUnitsVideo = [{
+ code: 'your-slot-div-id-video', // This is your slot div id
mediaTypes: {
video: {
context: 'outstream'
@@ -32,4 +40,24 @@ The impactify bidder need 3 parameters:
}
}]
}];
+
+ var adUnitsBanner = [{
+ code: 'your-slot-div-id-banner', // This is your slot div id
+ mediaTypes: {
+ banner: {
+ sizes: [
+ [728, 90]
+ ]
+ }
+ },
+ bids: [{
+ bidder: 'impactify',
+ params: {
+ appId: 'example.com',
+ format: 'display',
+ size: '728x90',
+ style: 'static'
+ }
+ }]
+ }];
```
diff --git a/modules/improvedigitalBidAdapter.js b/modules/improvedigitalBidAdapter.js
index b56cc56a186..b563faf52ac 100644
--- a/modules/improvedigitalBidAdapter.js
+++ b/modules/improvedigitalBidAdapter.js
@@ -182,6 +182,10 @@ export const CONVERTER = ortbConverter({
})();
const bidResponse = buildBidResponse(bid, context);
const idExt = deepAccess(bid, `ext.${BIDDER_CODE}`, {});
+ // Programmatic guaranteed flag
+ if (idExt.pg === 1) {
+ bidResponse.adserverTargeting = { hb_deal_type_improve: 'pg' };
+ }
Object.assign(bidResponse, {
dealId: (typeof idExt.buying_type === 'string' && idExt.buying_type !== 'rtb') ? idExt.line_item_id : undefined,
netRevenue: idExt.is_net || false,
diff --git a/modules/insticatorBidAdapter.js b/modules/insticatorBidAdapter.js
index c770ac69dbe..a18c893b5fc 100644
--- a/modules/insticatorBidAdapter.js
+++ b/modules/insticatorBidAdapter.js
@@ -106,8 +106,10 @@ function buildImpression(bidRequest) {
return imp;
}
-function buildDevice() {
- const deviceConfig = config.getConfig('device');
+function buildDevice(bidRequest) {
+ const ortb2Data = bidRequest?.ortb2 || {};
+ const deviceConfig = ortb2Data?.device || {}
+
const device = {
w: window.innerWidth,
h: window.innerHeight,
@@ -184,7 +186,7 @@ function buildRequest(validBidRequests, bidderRequest) {
page: bidderRequest.refererInfo.page,
ref: bidderRequest.refererInfo.ref,
},
- device: buildDevice(),
+ device: buildDevice(bidderRequest),
regs: buildRegs(bidderRequest),
user: buildUser(validBidRequests[0]),
imp: validBidRequests.map((bidRequest) => buildImpression(bidRequest)),
diff --git a/modules/ipromBidAdapter.js b/modules/ipromBidAdapter.js
index eaf20ad3ad3..1188af471a7 100644
--- a/modules/ipromBidAdapter.js
+++ b/modules/ipromBidAdapter.js
@@ -3,13 +3,15 @@ import { registerBidder } from '../src/adapters/bidderFactory.js';
const BIDDER_CODE = 'iprom';
const ENDPOINT_URL = 'https://core.iprom.net/programmatic';
-const VERSION = 'v1.0.2';
+const VERSION = 'v1.0.3';
const DEFAULT_CURRENCY = 'EUR';
const DEFAULT_NETREVENUE = true;
const DEFAULT_TTL = 360;
+const IAB_GVL_ID = 811;
export const spec = {
code: BIDDER_CODE,
+ gvlid: IAB_GVL_ID,
isBidRequestValid: function ({ bidder, params = {} } = {}) {
// id parameter checks
if (!params.id) {
diff --git a/modules/ixBidAdapter.js b/modules/ixBidAdapter.js
index 8b6b32e83ec..41e0d8e97c5 100644
--- a/modules/ixBidAdapter.js
+++ b/modules/ixBidAdapter.js
@@ -76,6 +76,8 @@ const SOURCE_RTI_MAPPING = {
'audigent.com': '', // Hadron ID from Audigent, hadronId
'pubcid.org': '', // SharedID, pubcid
'utiq.com': '', // Utiq
+ 'criteo.com': '', // Criteo
+ 'euid.eu': '', // EUID
'intimatemerger.com': '',
'33across.com': '',
'liveintent.indexexchange.com': '',
@@ -236,7 +238,10 @@ export function bidToVideoImp(bid) {
imp.video = videoParamRef ? deepClone(bid.params.video) : {};
// populate imp level transactionId
- imp.ext.tid = deepAccess(bid, 'ortb2Imp.ext.tid');
+ let tid = deepAccess(bid, 'ortb2Imp.ext.tid');
+ if (tid) {
+ deepSetValue(imp, 'ext.tid', tid);
+ }
setDisplayManager(imp, bid);
@@ -326,7 +331,10 @@ export function bidToNativeImp(bid) {
};
// populate imp level transactionId
- imp.ext.tid = deepAccess(bid, 'ortb2Imp.ext.tid');
+ let tid = deepAccess(bid, 'ortb2Imp.ext.tid');
+ if (tid) {
+ deepSetValue(imp, 'ext.tid', tid);
+ }
// AdUnit-Specific First Party Data
addAdUnitFPD(imp, bid)
@@ -346,26 +354,30 @@ function bidToImp(bid, mediaType) {
imp.id = bid.bidId;
- imp.ext = {};
+ if (isExchangeIdConfigured() && deepAccess(bid, `params.externalId`)) {
+ deepSetValue(imp, 'ext.externalID', bid.params.externalId);
+ }
if (deepAccess(bid, `params.${mediaType}.siteId`) && !isNaN(Number(bid.params[mediaType].siteId))) {
switch (mediaType) {
case BANNER:
- imp.ext.siteID = bid.params.banner.siteId.toString();
+ deepSetValue(imp, 'ext.siteID', bid.params.banner.siteId.toString());
break;
case VIDEO:
- imp.ext.siteID = bid.params.video.siteId.toString();
+ deepSetValue(imp, 'ext.siteID', bid.params.video.siteId.toString());
break;
case NATIVE:
- imp.ext.siteID = bid.params.native.siteId.toString();
+ deepSetValue(imp, 'ext.siteID', bid.params.native.siteId.toString());
break;
}
} else {
- imp.ext.siteID = bid.params.siteId.toString();
+ if (bid.params.siteId) {
+ deepSetValue(imp, 'ext.siteID', bid.params.siteId.toString());
+ }
}
// populate imp level sid
if (bid.params.hasOwnProperty('id') && (typeof bid.params.id === 'string' || typeof bid.params.id === 'number')) {
- imp.ext.sid = String(bid.params.id);
+ deepSetValue(imp, 'ext.sid', String(bid.params.id));
}
return imp;
@@ -411,12 +423,12 @@ function _applyFloor(bid, imp, mediaType) {
if (moduleFloor) {
imp.bidfloor = moduleFloor.floor;
imp.bidfloorcur = moduleFloor.currency;
- imp.ext.fl = FLOOR_SOURCE.PBJS;
+ deepSetValue(imp, 'ext.fl', FLOOR_SOURCE.PBJS);
setFloor = true;
} else if (adapterFloor) {
imp.bidfloor = adapterFloor.floor;
imp.bidfloorcur = adapterFloor.currency;
- imp.ext.fl = FLOOR_SOURCE.IX;
+ deepSetValue(imp, 'ext.fl', FLOOR_SOURCE.IX);
setFloor = true;
}
@@ -707,8 +719,10 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) {
r = applyRegulations(r, bidderRequest);
let payload = {};
- siteID = validBidRequests[0].params.siteId;
- payload.s = siteID;
+ if (validBidRequests[0].params.siteId) {
+ siteID = validBidRequests[0].params.siteId;
+ payload.s = siteID;
+ }
const impKeys = Object.keys(impressions);
let isFpdAdded = false;
@@ -744,9 +758,19 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) {
r = removeSiteIDs(r);
if (isLastAdUnit) {
+ let exchangeUrl = `${baseUrl}?`;
+
+ if (siteID !== 0) {
+ exchangeUrl += `s=${siteID}`;
+ }
+
+ if (isExchangeIdConfigured()) {
+ exchangeUrl += siteID !== 0 ? '&' : '';
+ exchangeUrl += `p=${config.getConfig('exchangeId')}`;
+ }
requests.push({
method: 'POST',
- url: baseUrl + '?s=' + siteID,
+ url: exchangeUrl,
data: deepClone(r),
option: {
contentType: 'text/plain',
@@ -968,6 +992,7 @@ function addImpressions(impressions, impKeys, r, adUnitIndex) {
for (const impId in bannerImpsKeyed) {
const bannerImps = bannerImpsKeyed[impId];
const { id, banner: { topframe } } = bannerImps[0];
+ let externalID = deepAccess(bannerImps[0], 'ext.externalID');
const _bannerImpression = {
id,
banner: {
@@ -977,15 +1002,24 @@ function addImpressions(impressions, impKeys, r, adUnitIndex) {
};
for (let i = 0; i < _bannerImpression.banner.format.length; i++) {
- // We add sid in imp.ext.sid therefore, remove from banner.format[].ext
- if (_bannerImpression.banner.format[i].ext != null && _bannerImpression.banner.format[i].ext.sid != null) {
- delete _bannerImpression.banner.format[i].ext.sid;
+ // We add sid and externalID in imp.ext therefore, remove from banner.format[].ext
+ if (_bannerImpression.banner.format[i].ext != null) {
+ if (_bannerImpression.banner.format[i].ext.sid != null) {
+ delete _bannerImpression.banner.format[i].ext.sid;
+ }
+ if (_bannerImpression.banner.format[i].ext.externalID != null) {
+ delete _bannerImpression.banner.format[i].ext.externalID;
+ }
}
// add floor per size
if ('bidfloor' in bannerImps[i]) {
_bannerImpression.banner.format[i].ext.bidfloor = bannerImps[i].bidfloor;
}
+
+ if (JSON.stringify(_bannerImpression.banner.format[i].ext) === '{}') {
+ delete _bannerImpression.banner.format[i].ext;
+ }
}
const position = impressions[impKeys[adUnitIndex]].pos;
@@ -993,13 +1027,14 @@ function addImpressions(impressions, impKeys, r, adUnitIndex) {
_bannerImpression.banner.pos = position;
}
- if (dfpAdUnitCode || gpid || tid || sid || auctionEnvironment) {
+ if (dfpAdUnitCode || gpid || tid || sid || auctionEnvironment || externalID) {
_bannerImpression.ext = {};
_bannerImpression.ext.dfp_ad_unit_code = dfpAdUnitCode;
_bannerImpression.ext.gpid = gpid;
_bannerImpression.ext.tid = tid;
_bannerImpression.ext.sid = sid;
+ _bannerImpression.ext.externalID = externalID;
// enable fledge auction
if (auctionEnvironment == 1) {
@@ -1028,7 +1063,9 @@ function addImpressions(impressions, impKeys, r, adUnitIndex) {
// Removes imp.ext.bidfloor
// Sets imp.ext.siteID to one of the other [video/native].ext.siteid if imp.ext.siteID doesnt exist
otherImpressions.forEach(imp => {
- deepSetValue(imp, 'ext.gpid', gpid);
+ if (gpid) {
+ deepSetValue(imp, 'ext.gpid', gpid);
+ }
if (r.imp.length > 0) {
let matchFound = false;
r.imp.forEach((rImp, index) => {
@@ -1626,6 +1663,17 @@ function isIndexRendererPreferred(bid) {
return !isValid || renderer.backupOnly;
}
+function isExchangeIdConfigured() {
+ let exchangeId = config.getConfig('exchangeId');
+ if (typeof exchangeId === 'number' && isFinite(exchangeId)) {
+ return true;
+ }
+ if (typeof exchangeId === 'string' && exchangeId.trim() !== '' && isFinite(Number(exchangeId))) {
+ return true;
+ }
+ return false;
+}
+
export const spec = {
code: BIDDER_CODE,
@@ -1683,14 +1731,21 @@ export const spec = {
}
}
- if (typeof bid.params.siteId !== 'string' && typeof bid.params.siteId !== 'number') {
- logError('IX Bid Adapter: siteId must be string or number type.', { bidder: BIDDER_CODE, code: ERROR_CODES.SITE_ID_INVALID_VALUE });
+ if (!isExchangeIdConfigured() && bid.params.siteId == undefined) {
+ logError('IX Bid Adapter: Invalid configuration - either siteId or exchangeId must be configured.');
return false;
}
- if (typeof bid.params.siteId !== 'string' && isNaN(Number(bid.params.siteId))) {
- logError('IX Bid Adapter: siteId must valid value', { bidder: BIDDER_CODE, code: ERROR_CODES.SITE_ID_INVALID_VALUE });
- return false;
+ if (bid.params.siteId !== undefined) {
+ if (typeof bid.params.siteId !== 'string' && typeof bid.params.siteId !== 'number') {
+ logError('IX Bid Adapter: siteId must be string or number type.', { bidder: BIDDER_CODE, code: ERROR_CODES.SITE_ID_INVALID_VALUE });
+ return false;
+ }
+
+ if (typeof bid.params.siteId !== 'string' && isNaN(Number(bid.params.siteId))) {
+ logError('IX Bid Adapter: siteId must valid value', { bidder: BIDDER_CODE, code: ERROR_CODES.SITE_ID_INVALID_VALUE });
+ return false;
+ }
}
if (hasBidFloor || hasBidFloorCur) {
@@ -1723,6 +1778,11 @@ export const spec = {
return nativeMediaTypeValid(bid);
},
+ // For testing only - resets the siteID to 0 so that it can be set again
+ resetSiteID: function () {
+ siteID = 0;
+ },
+
/**
* Make a server request from the list of BidRequests.
*
@@ -1962,8 +2022,9 @@ function buildImgSyncUrl(syncsPerBidder, index) {
if (gdprConsent && gdprConsent.hasOwnProperty('consentString')) {
consentString = gdprConsent.consentString || '';
}
+ let siteIdParam = siteID !== 0 ? '&site_id=' + siteID.toString() : '';
- return IMG_USER_SYNC_URL + '&site_id=' + siteID.toString() + '&p=' + syncsPerBidder.toString() + '&i=' + index.toString() + '&gdpr=' + gdprApplies + '&gdpr_consent=' + consentString + '&us_privacy=' + (usPrivacy || '');
+ return IMG_USER_SYNC_URL + siteIdParam + '&p=' + syncsPerBidder.toString() + '&i=' + index.toString() + '&gdpr=' + gdprApplies + '&gdpr_consent=' + consentString + '&us_privacy=' + (usPrivacy || '');
}
/**
diff --git a/modules/jixieBidAdapter.js b/modules/jixieBidAdapter.js
index 103c925a2f9..75268e9d168 100644
--- a/modules/jixieBidAdapter.js
+++ b/modules/jixieBidAdapter.js
@@ -1,4 +1,4 @@
-import {deepAccess, getDNT, isArray, logWarn, isFn, isPlainObject} from '../src/utils.js';
+import {deepAccess, getDNT, isArray, logWarn, isFn, isPlainObject, logError, logInfo} from '../src/utils.js';
import {config} from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {getStorageManager} from '../src/storageManager.js';
@@ -7,9 +7,11 @@ import {ajax} from '../src/ajax.js';
import {getRefererInfo} from '../src/refererDetection.js';
import {Renderer} from '../src/Renderer.js';
+const ADAPTER_VERSION = '2.1.0';
+const PREBID_VERSION = '$prebid.version$';
+
const BIDDER_CODE = 'jixie';
export const storage = getStorageManager({bidderCode: BIDDER_CODE});
-const EVENTS_URL = 'https://hbtra.jixie.io/sync/hb?';
const JX_OUTSTREAM_RENDERER_URL = 'https://scripts.jixie.media/jxhbrenderer.1.1.min.js';
const REQUESTS_URL = 'https://hb.jixie.io/v2/hbpost';
const sidTTLMins_ = 30;
@@ -59,7 +61,18 @@ function setIds_(clientId, sessionId) {
} catch (error) {}
}
-function fetchIds_() {
+/**
+ * fetch some ids from cookie, LS.
+ * @returns
+ */
+const defaultGenIds_ = [
+ { id: '_jxtoko' },
+ { id: '_jxifo' },
+ { id: '_jxtdid' },
+ { id: '_jxcomp' }
+];
+
+function fetchIds_(cfg) {
let ret = {
client_id_c: '',
client_id_ls: '',
@@ -77,9 +90,11 @@ function fetchIds_() {
if (tmp) ret.client_id_ls = tmp;
tmp = storage.getDataFromLocalStorage('_jxxs');
if (tmp) ret.session_id_ls = tmp;
- ['_jxtoko', '_jxifo', '_jxtdid', '_jxcomp'].forEach(function(n) {
- tmp = storage.getCookie(n);
- if (tmp) ret.jxeids[n] = tmp;
+
+ let arr = cfg.genids ? cfg.genids : defaultGenIds_;
+ arr.forEach(function(o) {
+ tmp = storage.getCookie(o.ck ? o.ck : o.id);
+ if (tmp) ret.jxeids[o.id] = tmp;
});
} catch (error) {}
return ret;
@@ -97,14 +112,6 @@ function getDevice_() {
return device;
}
-function pingTracking_(endpointOverride, qpobj) {
- internal.ajax((endpointOverride || EVENTS_URL), null, qpobj, {
- withCredentials: true,
- method: 'GET',
- crossOrigin: true
- });
-}
-
function jxOutstreamRender_(bidAd) {
bidAd.renderer.push(() => {
window.JixieOutstreamVideo.init({
@@ -166,7 +173,6 @@ export const internal = {
export const spec = {
code: BIDDER_CODE,
- EVENTS_URL: EVENTS_URL,
supportedMediaTypes: [BANNER, VIDEO],
isBidRequestValid: function(bid) {
if (bid.bidder !== BIDDER_CODE || typeof bid.params === 'undefined') {
@@ -198,29 +204,23 @@ export const spec = {
}
bids.push(tmp);
});
- let jixieCfgBlob = config.getConfig('jixie');
- if (!jixieCfgBlob) {
- jixieCfgBlob = {};
- }
+ let jxCfg = config.getConfig('jixie') || {};
- let ids = fetchIds_();
+ let ids = fetchIds_(jxCfg);
let eids = [];
let miscDims = internal.getMiscDims();
let schain = deepAccess(validBidRequests[0], 'schain');
- let eids1 = validBidRequests[0].userIdAsEids
+ let eids1 = validBidRequests[0].userIdAsEids;
// all available user ids are sent to our backend in the standard array layout:
if (eids1 && eids1.length) {
eids = eids1;
}
// we want to send this blob of info to our backend:
- let pg = config.getConfig('priceGranularity');
- if (!pg) {
- pg = {};
- }
let transformedParams = Object.assign({}, {
// TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
- auctionid: bidderRequest.auctionId,
+ auctionid: bidderRequest.auctionId || '',
+ aid: jxCfg.aid || '',
timeout: bidderRequest.timeout,
currency: currency,
timestamp: (new Date()).getTime(),
@@ -231,8 +231,10 @@ export const spec = {
bids: bids,
eids: eids,
schain: schain,
- pricegranularity: pg,
- cfg: jixieCfgBlob
+ pricegranularity: (config.getConfig('priceGranularity') || {}),
+ ver: ADAPTER_VERSION,
+ pbjsver: PREBID_VERSION,
+ cfg: jxCfg
}, ids);
return Object.assign({}, {
method: 'POST',
@@ -243,48 +245,20 @@ export const spec = {
},
onTimeout: function(timeoutData) {
- let jxCfgBlob = config.getConfig('jixie');
- if (jxCfgBlob && jxCfgBlob.onTimeout == 'off') {
- return;
- }
- let url = null;// default
- if (jxCfgBlob && jxCfgBlob.onTimeoutUrl && typeof jxCfgBlob.onTimeoutUrl == 'string') {
- url = jxCfgBlob.onTimeoutUrl;
- }
- let miscDims = internal.getMiscDims();
- pingTracking_(url, // no overriding ping URL . just use default
- {
- action: 'hbtimeout',
- device: miscDims.device,
- pageurl: encodeURIComponent(miscDims.pageurl),
- domain: encodeURIComponent(miscDims.domain),
- auctionid: deepAccess(timeoutData, '0.auctionId'),
- timeout: deepAccess(timeoutData, '0.timeout'),
- count: timeoutData.length
- });
+ logError('jixie adapter timed out for the auction.', timeoutData);
},
onBidWon: function(bid) {
- if (bid.notrack) {
- return;
- }
if (bid.trackingUrl) {
- pingTracking_(bid.trackingUrl, {});
- } else {
- let miscDims = internal.getMiscDims();
- pingTracking_((bid.trackingUrlBase ? bid.trackingUrlBase : null), {
- action: 'hbbidwon',
- device: miscDims.device,
- pageurl: encodeURIComponent(miscDims.pageurl),
- domain: encodeURIComponent(miscDims.domain),
- cid: bid.cid,
- cpid: bid.cpid,
- jxbidid: bid.jxBidId,
- auctionid: bid.auctionId,
- cpm: bid.cpm,
- requestid: bid.requestId
+ internal.ajax(bid.trackingUrl, null, {}, {
+ withCredentials: true,
+ method: 'GET',
+ crossOrigin: true
});
}
+ logInfo(
+ `jixie adapter won the auction. Bid id: ${bid.bidId}, Ad Unit Id: ${bid.adUnitId}`
+ );
},
interpretResponse: function(response, bidRequest) {
@@ -292,7 +266,6 @@ export const spec = {
const bidResponses = [];
response.body.bids.forEach(function(oneBid) {
let bnd = {};
-
Object.assign(bnd, oneBid);
if (oneBid.osplayer) {
bnd.adResponse = {
diff --git a/modules/kargoBidAdapter.js b/modules/kargoBidAdapter.js
index 01470354755..9d8c7bc06a1 100644
--- a/modules/kargoBidAdapter.js
+++ b/modules/kargoBidAdapter.js
@@ -24,6 +24,7 @@ const CURRENCY = Object.freeze({
});
const REQUEST_KEYS = Object.freeze({
+ USER_DATA: 'ortb2.user.data',
SOCIAL_CANVAS: 'params.socialCanvas',
SUA: 'ortb2.device.sua',
TDID_ADAPTER: 'userId.tdid',
@@ -103,15 +104,20 @@ function buildRequests(validBidRequests, bidderRequest) {
}
}
+ // Add schain
if (firstBidRequest.schain && firstBidRequest.schain.nodes) {
krakenParams.schain = firstBidRequest.schain
}
+ // Add user data object if available
+ krakenParams.user.data = deepAccess(firstBidRequest, REQUEST_KEYS.USER_DATA) || [];
+
const reqCount = getRequestCount()
if (reqCount != null) {
krakenParams.requestCount = reqCount;
}
+ // Add currency if not USD
if (currency != null && currency != CURRENCY.US_DOLLAR) {
krakenParams.cur = currency;
}
@@ -469,8 +475,8 @@ function getImpression(bid) {
imp.bidderWinCount = bid.bidderWinsCount;
}
- const gpid = getGPID(bid)
- if (gpid != null && gpid != '') {
+ const gpid = deepAccess(bid, 'ortb2Imp.ext.gpid') || deepAccess(bid, 'ortb2Imp.ext.data.pbadslot');
+ if (gpid) {
imp.fpd = {
gpid: gpid
}
@@ -493,29 +499,6 @@ function getImpression(bid) {
return imp
}
-function getGPID(bid) {
- if (bid.ortb2Imp != null) {
- if (bid.ortb2Imp.gpid != null && bid.ortb2Imp.gpid != '') {
- return bid.ortb2Imp.gpid;
- }
-
- if (bid.ortb2Imp.ext != null && bid.ortb2Imp.ext.data != null) {
- if (bid.ortb2Imp.ext.data.pbAdSlot != null && bid.ortb2Imp.ext.data.pbAdSlot != '') {
- return bid.ortb2Imp.ext.data.pbAdSlot;
- }
-
- if (bid.ortb2Imp.ext.data.adServer != null && bid.ortb2Imp.ext.data.adServer.adSlot != null && bid.ortb2Imp.ext.data.adServer.adSlot != '') {
- return bid.ortb2Imp.ext.data.adServer.adSlot;
- }
- }
- }
-
- if (bid.adUnitCode != null && bid.adUnitCode != '') {
- return bid.adUnitCode;
- }
- return '';
-}
-
export const spec = {
gvlid: BIDDER.GVLID,
code: BIDDER.CODE,
diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js
index 900b0c41119..cc43f6f6f84 100644
--- a/modules/liveIntentIdSystem.js
+++ b/modules/liveIntentIdSystem.js
@@ -8,7 +8,7 @@ import { triggerPixel, logError } from '../src/utils.js';
import { ajaxBuilder } from '../src/ajax.js';
import { submodule } from '../src/hook.js';
import { LiveConnect } from 'live-connect-js'; // eslint-disable-line prebid/validate-imports
-import { gdprDataHandler, uspDataHandler } from '../src/adapterManager.js';
+import { gdprDataHandler, uspDataHandler, gppDataHandler } from '../src/adapterManager.js';
import {getStorageManager} from '../src/storageManager.js';
import {MODULE_TYPE_UID} from '../src/activities/modules.js';
import {UID2_EIDS} from '../libraries/uid2Eids/uid2Eids.js';
@@ -127,7 +127,11 @@ function initializeLiveConnect(configParams) {
liveConnectConfig.gdprApplies = gdprConsent.gdprApplies;
liveConnectConfig.gdprConsent = gdprConsent.consentString;
}
-
+ const gppConsent = gppDataHandler.getConsentData();
+ if (gppConsent) {
+ liveConnectConfig.gppString = gppConsent.gppString;
+ liveConnectConfig.gppApplicableSections = gppConsent.applicableSections;
+ }
// The second param is the storage object, LS & Cookie manipulation uses PBJS
// The third param is the ajax and pixel object, the ajax and pixel use PBJS
liveConnect = liveIntentIdSubmodule.getInitializer()(liveConnectConfig, storage, calls);
diff --git a/modules/mediabramaBidAdapter.js b/modules/mediabramaBidAdapter.js
new file mode 100644
index 00000000000..caf6854fe03
--- /dev/null
+++ b/modules/mediabramaBidAdapter.js
@@ -0,0 +1,155 @@
+import {
+ isFn,
+ isStr,
+ deepAccess,
+ getWindowTop,
+ triggerPixel
+} from '../src/utils.js';
+import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { BANNER } from '../src/mediaTypes.js';
+import { config } from '../src/config.js';
+
+const BIDDER_CODE = 'mediabrama';
+const AD_URL = 'https://prebid.mediabrama.com/pbjs';
+const SYNC_URL = 'https://prebid.mediabrama.com/sync';
+
+function isBidResponseValid(bid) {
+ if (!bid.requestId || !bid.cpm || !bid.creativeId ||
+ !bid.ttl || !bid.currency || !bid.meta) {
+ return false;
+ }
+
+ switch (bid.mediaType) {
+ case BANNER:
+ return Boolean(bid.width && bid.height && bid.ad);
+ default:
+ return false;
+ }
+}
+
+function getBidFloor(bid) {
+ if (!isFn(bid.getFloor)) {
+ return deepAccess(bid, 'params.bidFloor', 0);
+ }
+
+ try {
+ const bidFloor = bid.getFloor({
+ currency: 'USD',
+ mediaType: '*',
+ size: '*',
+ });
+ return bidFloor.floor;
+ } catch (_) {
+ return 0
+ }
+}
+
+export const spec = {
+ code: BIDDER_CODE,
+ supportedMediaTypes: [BANNER],
+
+ isBidRequestValid: (bid) => {
+ return Boolean(bid.bidId && bid.params && bid.params.placementId);
+ },
+
+ buildRequests: (validBidRequests = [], bidderRequest) => {
+ const winTop = getWindowTop();
+ const location = winTop.location;
+ const placements = [];
+
+ const request = {
+ deviceWidth: winTop.screen.width,
+ deviceHeight: winTop.screen.height,
+ language: (navigator && navigator.language) ? navigator.language.split('-')[0] : '',
+ host: location.host,
+ page: location.pathname,
+ placements: placements
+ };
+
+ if (bidderRequest) {
+ if (bidderRequest.uspConsent) {
+ request.ccpa = bidderRequest.uspConsent;
+ }
+ if (bidderRequest.gdprConsent) {
+ request.gdpr = bidderRequest.gdprConsent;
+ }
+ }
+
+ const len = validBidRequests.length;
+ for (let i = 0; i < len; i++) {
+ const bid = validBidRequests[i];
+ const placement = {
+ placementId: bid.params.placementId,
+ bidId: bid.bidId,
+ schain: bid.schain || {},
+ bidfloor: getBidFloor(bid)
+ };
+
+ if (typeof bid.userId !== 'undefined') {
+ placement.userId = bid.userId;
+ }
+
+ const mediaType = bid.mediaTypes;
+
+ if (mediaType && mediaType[BANNER] && mediaType[BANNER].sizes) {
+ placement.sizes = mediaType[BANNER].sizes;
+ placement.adFormat = BANNER;
+ }
+
+ placements.push(placement);
+ }
+
+ return {
+ method: 'POST',
+ url: AD_URL,
+ data: request
+ };
+ },
+
+ interpretResponse: (serverResponse) => {
+ let response = [];
+ for (let i = 0; i < serverResponse.body.length; i++) {
+ let resItem = serverResponse.body[i];
+ if (isBidResponseValid(resItem)) {
+ const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : [];
+ resItem.meta = { ...resItem.meta, advertiserDomains };
+
+ response.push(resItem);
+ }
+ }
+ return response;
+ },
+
+ getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => {
+ let syncType = syncOptions.iframeEnabled ? 'iframe' : 'image';
+ let syncUrl = SYNC_URL + `/${syncType}?pbjs=1`;
+ if (gdprConsent && gdprConsent.consentString) {
+ if (typeof gdprConsent.gdprApplies === 'boolean') {
+ syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
+ } else {
+ syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`;
+ }
+ }
+ if (uspConsent && uspConsent.consentString) {
+ syncUrl += `&ccpa_consent=${uspConsent.consentString}`;
+ }
+
+ const coppa = config.getConfig('coppa') ? 1 : 0;
+ syncUrl += `&coppa=${coppa}`;
+
+ return [{
+ type: syncType,
+ url: syncUrl
+ }];
+ },
+
+ onBidWon: (bid) => {
+ const cpm = deepAccess(bid, 'adserverTargeting.hb_pb') || '';
+ if (isStr(bid.nurl) && bid.nurl !== '') {
+ bid.nurl = bid.nurl.replace(/\${AUCTION_PRICE}/, cpm);
+ triggerPixel(bid.nurl);
+ }
+ }
+};
+
+registerBidder(spec);
diff --git a/modules/mediabramaBidAdapter.md b/modules/mediabramaBidAdapter.md
new file mode 100644
index 00000000000..fde0a399852
--- /dev/null
+++ b/modules/mediabramaBidAdapter.md
@@ -0,0 +1,33 @@
+# Overview
+
+```
+Module Name: MediaBrama Bidder Adapter
+Module Type: MediaBrama Bidder Adapter
+Maintainer: support@mediabrama.com
+```
+
+# Description
+
+Module that connects to mediabrama demand sources
+
+# Test Parameters
+```
+ var adUnits = [
+ {
+ code: 'div-prebid',
+ mediaTypes:{
+ banner: {
+ sizes: [[300, 250]],
+ }
+ },
+ bids:[
+ {
+ bidder: 'mediabrama',
+ params: {
+ placementId: '24428' //test, please replace after test
+ }
+ }
+ ]
+ },
+ ];
+```
diff --git a/modules/mediafilterRtdProvider.js b/modules/mediafilterRtdProvider.js
new file mode 100644
index 00000000000..277b19c10b2
--- /dev/null
+++ b/modules/mediafilterRtdProvider.js
@@ -0,0 +1,94 @@
+/**
+ * This module adds the Media Filter real-time ad monitoring and protection module.
+ *
+ * The {@link module:modules/realTimeData} module is required
+ *
+ * For more information, visit {@link https://www.themediatrust.com The Media Trust}.
+ *
+ * @author Mirnes Cajlakovic
+ * @module modules/mediafilterRtdProvider
+ * @requires module:modules/realTimeData
+ */
+
+import { submodule } from '../src/hook.js';
+import { logError, generateUUID } from '../src/utils.js';
+import { loadExternalScript } from '../src/adloader.js';
+import * as events from '../src/events.js';
+import CONSTANTS from '../src/constants.json';
+
+/** @const {string} MEDIAFILTER_EVENT_TYPE - The event type for Media Filter. */
+export const MEDIAFILTER_EVENT_TYPE = 'com.mediatrust.pbjs.';
+/** @const {string} MEDIAFILTER_BASE_URL - The base URL for Media Filter scripts. */
+export const MEDIAFILTER_BASE_URL = 'https://scripts.webcontentassessor.com/scripts/';
+
+export const MediaFilter = {
+ /**
+ * Registers the Media Filter as a submodule of real-time data.
+ */
+ register: function() {
+ submodule('realTimeData', {
+ 'name': 'mediafilter',
+ 'init': this.generateInitHandler()
+ });
+ },
+
+ /**
+ * Sets up the Media Filter by initializing event listeners and loading the external script.
+ * @param {object} configuration - The configuration object.
+ */
+ setup: function(configuration) {
+ this.setupEventListener(configuration.configurationHash);
+ this.setupScript(configuration.configurationHash);
+ },
+
+ /**
+ * Sets up an event listener for Media Filter messages.
+ * @param {string} configurationHash - The configuration hash.
+ */
+ setupEventListener: function(configurationHash) {
+ window.addEventListener('message', this.generateEventHandler(configurationHash));
+ },
+
+ /**
+ * Loads the Media Filter script based on the provided configuration hash.
+ * @param {string} configurationHash - The configuration hash.
+ */
+ setupScript: function(configurationHash) {
+ loadExternalScript(MEDIAFILTER_BASE_URL.concat(configurationHash), 'mediafilter', () => {});
+ },
+
+ /**
+ * Generates an event handler for Media Filter messages.
+ * @param {string} configurationHash - The configuration hash.
+ * @returns {function} The generated event handler.
+ */
+ generateEventHandler: function(configurationHash) {
+ return (windowEvent) => {
+ if (windowEvent.data.type === MEDIAFILTER_EVENT_TYPE.concat('.', configurationHash)) {
+ events.emit(CONSTANTS.EVENTS.BILLABLE_EVENT, {
+ 'billingId': generateUUID(),
+ 'configurationHash': configurationHash,
+ 'type': 'impression',
+ 'vendor': 'mediafilter',
+ });
+ }
+ };
+ },
+
+ /**
+ * Generates an initialization handler for Media Filter.
+ * @returns {function} The generated init handler.
+ */
+ generateInitHandler: function() {
+ return (configuration) => {
+ try {
+ this.setup(configuration);
+ } catch (error) {
+ logError(`Error in initialization: ${error.message}`);
+ }
+ };
+ }
+};
+
+// Register the module
+MediaFilter.register();
diff --git a/modules/mediafilterRtdProvider.md b/modules/mediafilterRtdProvider.md
new file mode 100644
index 00000000000..469479f8d0b
--- /dev/null
+++ b/modules/mediafilterRtdProvider.md
@@ -0,0 +1,37 @@
+## Overview
+
+**Module:** The Media Filter
+**Type: **Real Time Data Module
+
+As malvertising, scams, and controversial and offensive ad content proliferate across the digital media ecosystem, publishers need advanced controls to both shield audiences from malware attacks and ensure quality site experience. With the market’s fastest and most comprehensive real-time ad quality tool, The Media Trust empowers publisher Ad/Revenue Operations teams to block a wide range of malware, high-risk ad platforms, heavy ads, ads with sensitive or objectionable content, and custom lists (e.g., competitors). Customizable replacement code calls for a new ad to ensure impressions are still monetized.
+
+[![IMAGE ALT TEXT](http://img.youtube.com/vi/VBHRiirge7s/0.jpg)](http://www.youtube.com/watch?v=VBHRiirge7s "Publishers' Ultimate Avenger: Media Filter")
+
+To start using this module, please contact [The Media Trust](https://mediatrust.com/how-we-help/media-filter/ "The Media Trust") to get a script and configuration hash for module configuration.
+
+## Integration
+
+1. Build Prebid bundle with The Media Filter module included.
+
+```
+gulp build --modules=mediafilterRtdProvider
+```
+
+2. Inlcude the bundled script in your application.
+
+## Configuration
+
+Add configuration entry to `realTimeData.dataProviders` for The Media Filter module.
+
+```
+pbjs.setConfig({
+ realTimeData: {
+ dataProviders: [{
+ name: 'mediafilter',
+ params: {
+ configurationHash: '',
+ }
+ }]
+ }
+});
+```
diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js
index 756e636572d..efd730acace 100644
--- a/modules/mediagoBidAdapter.js
+++ b/modules/mediagoBidAdapter.js
@@ -221,10 +221,10 @@ function getItems(validBidRequests, bidderRequest) {
}
const bidFloor = getBidFloor(req);
- // const gpid =
- // utils.deepAccess(req, 'ortb2Imp.ext.gpid') ||
- // utils.deepAccess(req, 'ortb2Imp.ext.data.pbadslot') ||
- // utils.deepAccess(req, 'params.placementId', 0);
+ const gpid =
+ utils.deepAccess(req, 'ortb2Imp.ext.gpid') ||
+ utils.deepAccess(req, 'ortb2Imp.ext.data.pbadslot') ||
+ utils.deepAccess(req, 'params.placementId', 0);
// if (mediaTypes.native) {}
// banner广告类型
@@ -240,7 +240,8 @@ function getItems(validBidRequests, bidderRequest) {
format: sizes,
},
ext: {
- // gpid: gpid, // 加入后无法返回广告
+ ortb2Imp: utils.deepAccess(req, 'ortb2Imp'), // 传入完整对象,分析日志数据
+ gpid: gpid, // 加入后无法返回广告
},
tagid: req.params && req.params.tagid,
};
diff --git a/modules/missenaBidAdapter.js b/modules/missenaBidAdapter.js
index 33fa6857e85..a06ba1ce29c 100644
--- a/modules/missenaBidAdapter.js
+++ b/modules/missenaBidAdapter.js
@@ -1,12 +1,39 @@
-import { buildUrl, formatQS, logInfo, triggerPixel } from '../src/utils.js';
+import {
+ buildUrl,
+ formatQS,
+ isFn,
+ logInfo,
+ safeJSONParse,
+ triggerPixel,
+} from '../src/utils.js';
+import { config } from '../src/config.js';
import { BANNER } from '../src/mediaTypes.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { getStorageManager } from '../src/storageManager.js';
const BIDDER_CODE = 'missena';
const ENDPOINT_URL = 'https://bid.missena.io/';
const EVENTS_DOMAIN = 'events.missena.io';
const EVENTS_DOMAIN_DEV = 'events.staging.missena.xyz';
+export const storage = getStorageManager({ bidderCode: BIDDER_CODE });
+
+/* Get Floor price information */
+function getFloor(bidRequest) {
+ if (!isFn(bidRequest.getFloor)) {
+ return {};
+ }
+
+ const bidFloors = bidRequest.getFloor({
+ currency: 'USD',
+ mediaType: BANNER,
+ });
+
+ if (!isNaN(bidFloors.floor)) {
+ return bidFloors;
+ }
+}
+
export const spec = {
aliases: ['msna'],
code: BIDDER_CODE,
@@ -30,6 +57,16 @@ export const spec = {
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (validBidRequests, bidderRequest) {
+ const capKey = `missena.missena.capper.remove-bubble.${validBidRequests[0]?.params.apiKey}`;
+ const capping = safeJSONParse(storage.getDataFromLocalStorage(capKey));
+ if (
+ typeof capping?.expiry === 'number' &&
+ new Date().getTime() < capping?.expiry
+ ) {
+ logInfo('Missena - Capped');
+ return [];
+ }
+
return validBidRequests.map((bidRequest) => {
const payload = {
adunit: bidRequest.adUnitCode,
@@ -61,6 +98,12 @@ export const spec = {
payload.is_internal = bidRequest.params.isInternal;
}
payload.userEids = bidRequest.userIdAsEids || [];
+
+ const bidFloor = getFloor(bidRequest);
+ payload.floor = bidFloor?.floor;
+ payload.floor_currency = bidFloor?.currency;
+ payload.currency = config.getConfig('currency.adServerCurrency') || 'EUR';
+
return {
method: 'POST',
url: baseUrl + '?' + formatQS({ t: bidRequest.params.apiKey }),
@@ -89,7 +132,7 @@ export const spec = {
syncOptions,
serverResponses,
gdprConsent,
- uspConsent
+ uspConsent,
) {
if (!syncOptions.iframeEnabled) {
return [];
@@ -128,8 +171,13 @@ export const spec = {
protocol: 'https',
hostname,
pathname: '/v1/bidsuccess',
- search: { t: bid.params[0].apiKey, provider: bid.meta?.networkName, cpm: bid.cpm, currency: bid.currency },
- })
+ search: {
+ t: bid.params[0].apiKey,
+ provider: bid.meta?.networkName,
+ cpm: bid.originalCpm,
+ currency: bid.originalCurrency,
+ },
+ }),
);
logInfo('Missena - Bid won', bid);
},
diff --git a/modules/nobidBidAdapter.js b/modules/nobidBidAdapter.js
index fb052a99695..68010b32b37 100644
--- a/modules/nobidBidAdapter.js
+++ b/modules/nobidBidAdapter.js
@@ -8,17 +8,12 @@ import { hasPurpose1Consent } from '../src/utils/gpdr.js';
const GVLID = 816;
const BIDDER_CODE = 'nobid';
const storage = getStorageManager({bidderCode: BIDDER_CODE});
-window.nobidVersion = '1.4.1';
+window.nobidVersion = '1.3.3';
window.nobid = window.nobid || {};
window.nobid.bidResponses = window.nobid.bidResponses || {};
window.nobid.timeoutTotal = 0;
window.nobid.bidWonTotal = 0;
window.nobid.refreshCount = 0;
-window.nobid.firstPartyIds = null;
-window.nobid.firstPartyIdEnabled = false;
-const FIRST_PARTY_KEY = 'fppcid.nobid.io';
-const FIRST_PARTY_SOURCE_KEY = 'fpid.nobid.io';
-const FIRST_PARTY_DATA_EXPIRY_DAYS = 7 * 24 * 3600 * 1000;
function log(msg, obj) {
logInfo('-NoBid- ' + msg, obj)
}
@@ -140,10 +135,8 @@ function nobidBuildRequests(bids, bidderRequest) {
src.push({source: eid.source, uids: ids});
}
});
- if (window.nobid.firstPartyIds && window.nobid.firstPartyIds) src.push({source: FIRST_PARTY_SOURCE_KEY, uids: [{id: window.nobid.firstPartyIds.ids}]});
return src;
}
- if (window.nobid.firstPartyIds && window.nobid.firstPartyIds.ids) return [{source: FIRST_PARTY_SOURCE_KEY, uids: [{id: window.nobid.firstPartyIds.ids}]}];
}
var state = {};
state['sid'] = siteId;
@@ -293,12 +286,6 @@ function nobidInterpretResponse(response, bidRequest) {
var setRefreshLimit = function(response) {
if (response && typeof response.rlimit !== 'undefined') window.nobid.refreshLimit = response.rlimit;
}
- var setFirstPartyIdEnabled = function(response) {
- if (response && typeof response.fpid !== 'undefined') window.nobid.firstPartyIdEnabled = response.fpid;
- if (window?.nobid?.firstPartyIdEnabled) {
- nobidFirstPartyData.loadOrCreateFirstPartyData();
- }
- }
var setUserBlock = function(response) {
if (response && typeof response.ublock !== 'undefined') {
nobidSetCookie('_ublock', '1', response.ublock);
@@ -306,7 +293,6 @@ function nobidInterpretResponse(response, bidRequest) {
}
setRefreshLimit(response);
setUserBlock(response);
- setFirstPartyIdEnabled(response);
var bidResponses = [];
for (var i = 0; response.bids && i < response.bids.length; i++) {
var bid = response.bids[i];
@@ -373,113 +359,6 @@ window.addEventListener('message', function (event) {
}
}
}, false);
-const nobidFirstPartyData = {
- isJson: function (str) {
- return str && str.startsWith('{') && str.endsWith('}');
- },
- hasLocalStorage: function () {
- try {
- return window.localStorage;
- } catch (error) {
- logWarn('Local storage api disabled', error);
- }
- return false;
- },
- readFirstPartyDataIds: function () {
- try {
- if (this.hasLocalStorage()) {
- const idsStr = window.localStorage.getItem(FIRST_PARTY_SOURCE_KEY);
- if (this.isJson(idsStr)) {
- const idsObj = JSON.parse(idsStr);
- if (idsObj.ts + FIRST_PARTY_DATA_EXPIRY_DAYS < Date.now()) return { pid: idsObj.pid }; // expired?
- return idsObj;
- }
- return null;
- }
- } catch (error) {
- logWarn('Local storage api disabled', error);
- }
- return null;
- },
- loadOrCreateFirstPartyData: function () {
- const storeFirstPartyDataIds = function ({ids: theIds, pid: thePid}) {
- try {
- if (nobidFirstPartyData.hasLocalStorage()) {
- window.localStorage.setItem(FIRST_PARTY_SOURCE_KEY, JSON.stringify({ids: theIds, pid: thePid, ts: Date.now()}));
- }
- } catch (error) {
- logWarn('Local storage api disabled', error);
- }
- };
- const readFirstPartyId = function () {
- try {
- if (nobidFirstPartyData.hasLocalStorage()) {
- const idStr = window.localStorage.getItem(FIRST_PARTY_KEY);
- if (nobidFirstPartyData.isJson(idStr)) {
- return JSON.parse(idStr);
- }
- return null;
- }
- } catch (error) {
- logWarn('Local storage api disabled', error);
- }
- return null;
- };
- const storeFirstPartyId = function (theId) {
- try {
- if (nobidFirstPartyData.hasLocalStorage()) {
- window.localStorage.setItem(FIRST_PARTY_KEY, JSON.stringify(theId));
- }
- } catch (error) {
- logWarn('Local storage api disabled', error);
- }
- };
- const _loadOrCreateFirstPartyData = function () {
- const generateGUID = function () {
- let d = new Date().getTime();
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
- const r = (d + Math.random() * 16) % 16 | 0;
- d = Math.floor(d / 16);
- return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
- });
- };
- const ajaxGet = function (ajaxParams, callback) {
- const ajax = new XMLHttpRequest();
- ajax.withCredentials = false;
- ajax.timeout = ajaxParams.timeout;
- ajax.open('GET', ajaxParams.url, true);
- ajax.onreadystatechange = function () {
- if (this.readyState === XMLHttpRequest.DONE) {
- callback(this.response);
- }
- };
- ajax.send(ajaxParams.data);
- };
- let firstPartyIdObj = readFirstPartyId();
- if (!firstPartyIdObj || !firstPartyIdObj.id || !firstPartyIdObj.ts) {
- const firstPartyId = generateGUID();
- firstPartyIdObj = {id: firstPartyId, ts: Date.now()};
- storeFirstPartyId(firstPartyIdObj);
- }
- let firstPartyIds = nobidFirstPartyData.readFirstPartyDataIds();
- if (firstPartyIdObj?.ts && !firstPartyIds?.ids) {
- const pid = firstPartyIds?.pid || '';
- const pdate = firstPartyIdObj.ts;
- const firstPartyId = firstPartyIdObj.id;
- const url = `https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&pt=17&dpn=1&iiqidtype=2&dpi=430542822&iiqpcid=${firstPartyId}&iiqpciddate=${pdate}&pid=${pid}`;
- if (window.nobid.firstPartyRequestInProgress) return;
- window.nobid.firstPartyRequestInProgress = true;
- ajaxGet({ url: url }, function (response) {
- response = JSON.parse(response);
- if (response?.data) storeFirstPartyDataIds({ ids: response.data, pid: response.pid });
- });
- }
- };
- window.nobid.firstPartyIds = this.readFirstPartyDataIds();
- if (window.nobid.firstPartyIdEnabled && !window.nobid.firstPartyIds?.ids) _loadOrCreateFirstPartyData();
- }
-};
-window.nobid.firstPartyIds = nobidFirstPartyData.readFirstPartyDataIds();
export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
diff --git a/modules/oguryBidAdapter.js b/modules/oguryBidAdapter.js
index c1c8376de87..9937391f6e7 100644
--- a/modules/oguryBidAdapter.js
+++ b/modules/oguryBidAdapter.js
@@ -12,7 +12,7 @@ const DEFAULT_TIMEOUT = 1000;
const BID_HOST = 'https://mweb-hb.presage.io/api/header-bidding-request';
const TIMEOUT_MONITORING_HOST = 'https://ms-ads-monitoring-events.presage.io';
const MS_COOKIE_SYNC_DOMAIN = 'https://ms-cookie-sync.presage.io';
-const ADAPTER_VERSION = '1.5.0';
+const ADAPTER_VERSION = '1.6.0';
function getClientWidth() {
const documentElementClientWidth = window.top.document.documentElement.clientWidth
@@ -122,6 +122,13 @@ function buildRequests(validBidRequests, bidderRequest) {
openRtbBidRequestBanner.site.id = bidRequest.params.assetKey;
const floor = getFloor(bidRequest);
+ if (bidRequest.userId) {
+ openRtbBidRequestBanner.user.ext.uids = bidRequest.userId
+ }
+ if (bidRequest.userIdAsEids) {
+ openRtbBidRequestBanner.user.ext.eids = bidRequest.userIdAsEids
+ }
+
openRtbBidRequestBanner.imp.push({
id: bidRequest.bidId,
tagid: bidRequest.params.adUnitId,
diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js
index 801bb747e34..ee6d2980385 100644
--- a/modules/onetagBidAdapter.js
+++ b/modules/onetagBidAdapter.js
@@ -87,6 +87,7 @@ function buildRequests(validBidRequests, bidderRequest) {
const connection = navigator.connection || navigator.webkitConnection;
payload.networkConnectionType = (connection && connection.type) ? connection.type : null;
payload.networkEffectiveConnectionType = (connection && connection.effectiveType) ? connection.effectiveType : null;
+ payload.fledgeEnabled = Boolean(bidderRequest && bidderRequest.fledgeEnabled)
return {
method: 'POST',
url: ENDPOINT,
@@ -101,10 +102,10 @@ function interpretResponse(serverResponse, bidderRequest) {
if (!body || (body.nobid && body.nobid === true)) {
return bids;
}
- if (!body.bids || !Array.isArray(body.bids) || body.bids.length === 0) {
+ if (!body.fledgeAuctionConfigs && (!body.bids || !Array.isArray(body.bids) || body.bids.length === 0)) {
return bids;
}
- body.bids.forEach(bid => {
+ Array.isArray(body.bids) && body.bids.forEach(bid => {
const responseBid = {
requestId: bid.requestId,
cpm: bid.cpm,
@@ -141,7 +142,16 @@ function interpretResponse(serverResponse, bidderRequest) {
}
bids.push(responseBid);
});
- return bids;
+
+ if (body.fledgeAuctionConfigs && Array.isArray(body.fledgeAuctionConfigs)) {
+ const fledgeAuctionConfigs = body.fledgeAuctionConfigs
+ return {
+ bids,
+ fledgeAuctionConfigs,
+ }
+ } else {
+ return bids;
+ }
}
function createRenderer(bid, rendererOptions = {}) {
@@ -267,9 +277,8 @@ function setGeneralInfo(bidRequest) {
this['adUnitCode'] = bidRequest.adUnitCode;
this['bidId'] = bidRequest.bidId;
this['bidderRequestId'] = bidRequest.bidderRequestId;
- // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
- this['auctionId'] = bidRequest.auctionId;
- this['transactionId'] = bidRequest.ortb2Imp?.ext?.tid;
+ this['auctionId'] = deepAccess(bidRequest, 'ortb2.source.tid');
+ this['transactionId'] = deepAccess(bidRequest, 'ortb2Imp.ext.tid');
this['gpid'] = deepAccess(bidRequest, 'ortb2Imp.ext.gpid') || deepAccess(bidRequest, 'ortb2Imp.ext.data.pbadslot');
this['pubId'] = params.pubId;
this['ext'] = params.ext;
diff --git a/modules/openxBidAdapter.js b/modules/openxBidAdapter.js
index 181a0c70c7e..0f8bee213f7 100644
--- a/modules/openxBidAdapter.js
+++ b/modules/openxBidAdapter.js
@@ -50,7 +50,8 @@ const converter = ortbConverter({
mergeDeep(req, {
at: 1,
ext: {
- bc: `${bidderConfig}_${bidderVersion}`
+ bc: `${bidderConfig}_${bidderVersion}`,
+ pv: '$prebid.version$'
}
})
const bid = context.bidRequests[0];
diff --git a/modules/operaadsBidAdapter.js b/modules/operaadsBidAdapter.js
index b28a24ef57a..131ba0bc1f2 100644
--- a/modules/operaadsBidAdapter.js
+++ b/modules/operaadsBidAdapter.js
@@ -232,13 +232,6 @@ function buildOpenRtbBidRequest(bidRequest, bidderRequest) {
test: config.getConfig('debug') ? 1 : 0,
imp: createImp(bidRequest),
device: getDevice(),
- site: {
- id: String(deepAccess(bidRequest, 'params.publisherId')),
- // TODO: does the fallback make sense here?
- domain: bidderRequest?.refererInfo?.domain || window.location.host,
- page: bidderRequest?.refererInfo?.page,
- ref: bidderRequest?.refererInfo?.ref || '',
- },
at: 1,
bcat: getBcat(bidRequest),
cur: [DEFAULT_CURRENCY],
@@ -250,6 +243,7 @@ function buildOpenRtbBidRequest(bidRequest, bidderRequest) {
buyeruid: getUserId(bidRequest)
}
}
+ fulfillInventoryInfo(payload, bidRequest, bidderRequest);
const gdprConsent = deepAccess(bidderRequest, 'gdprConsent');
if (!!gdprConsent && gdprConsent.gdprApplies) {
@@ -764,6 +758,38 @@ function getDevice() {
return device;
}
+/**
+ * Fulfill inventory info
+ *
+ * @param payload
+ * @param bidRequest
+ * @param bidderRequest
+ */
+function fulfillInventoryInfo(payload, bidRequest, bidderRequest) {
+ let info = deepAccess(bidRequest, 'params.site');
+ // 1.If the inventory info for site specified, use the site object provided in params.
+ let key = 'site';
+ if (!isPlainObject(info)) {
+ info = deepAccess(bidRequest, 'params.app');
+ if (isPlainObject(info)) {
+ // 2.If the inventory info for app specified, use the app object provided in params.
+ key = 'app';
+ } else {
+ // 3.Otherwise, we use site by default.
+ info = {};
+ }
+ }
+ // Fulfill key parameters.
+ info.id = String(deepAccess(bidRequest, 'params.publisherId'));
+ info.domain = info.domain || bidderRequest?.refererInfo?.domain || window.location.host;
+ if (key === 'site') {
+ info.ref = info.ref || bidderRequest?.refererInfo?.ref || '';
+ info.page = info.page || bidderRequest?.refererInfo?.page;
+ }
+
+ payload[key] = info;
+}
+
/**
* Get browser language
*
diff --git a/modules/operaadsBidAdapter.md b/modules/operaadsBidAdapter.md
index 6c5a4646dd0..6f13eebd7d5 100644
--- a/modules/operaadsBidAdapter.md
+++ b/modules/operaadsBidAdapter.md
@@ -14,41 +14,43 @@ Module that connects to OperaAds's demand sources
## Bid Parameters
-| Name | Scope | Type | Description | Example
-| ---- | ----- | ---- | ----------- | -------
-| `placementId` | required | String | The Placement Id provided by Opera Ads. | `s5340077725248`
-| `endpointId` | required | String | The Endpoint Id provided by Opera Ads. | `ep3425464070464`
-| `publisherId` | required | String | The Publisher Id provided by Opera Ads. | `pub3054952966336`
-| `bcat` | optional | String or String[] | The bcat value. | `IAB9-31`
+| Name | Scope | Type | Description | Example |
+|---------------|----------|--------------------|-----------------------------------------|-------------------------------------------------|
+| `placementId` | required | String | The Placement Id provided by Opera Ads. | `s5340077725248` |
+| `endpointId` | required | String | The Endpoint Id provided by Opera Ads. | `ep3425464070464` |
+| `publisherId` | required | String | The Publisher Id provided by Opera Ads. | `pub3054952966336` |
+| `bcat` | optional | String or String[] | The bcat value. | `IAB9-31` |
+| `site` | optional | Object | The site information. | `{"name": "my_site", "domain": "www.test.com"}` |
+| `app` | optional | Object | The app information. | `{"name": "my_app", "ver": "1.1.0"}` |
### Bid Video Parameters
Set these parameters to `bid.mediaTypes.video`.
-| Name | Scope | Type | Description | Example
-| ---- | ----- | ---- | ----------- | -------
-| `context` | optional | String | `instream` or `outstream`. | `instream`
-| `mimes` | optional | String[] | Content MIME types supported. | `['video/mp4']`
-| `playerSize` | optional | Number[] or Number[][] | Video player size in device independent pixels | `[[640, 480]]`
-| `protocols` | optional | Number[] | Array of supported video protocls. | `[1, 2, 3, 4, 5, 6, 7, 8]`
-| `startdelay` | optional | Number | Indicates the start delay in seconds for pre-roll, mid-roll, or post-roll ad placements. | `0`
-| `skip` | optional | Number | Indicates if the player will allow the video to be skipped, where 0 = no, 1 = yes. | `1`
-| `playbackmethod` | optional | Number[] | Playback methods that may be in use. | `[2]`
-| `delivery` | optional | Number[] | Supported delivery methods. | `[1]`
-| `api` | optional | Number[] | List of supported API frameworks for this impression. | `[1, 2, 5]`
+| Name | Scope | Type | Description | Example |
+|------------------|----------|------------------------|------------------------------------------------------------------------------------------|----------------------------|
+| `context` | optional | String | `instream` or `outstream`. | `instream` |
+| `mimes` | optional | String[] | Content MIME types supported. | `['video/mp4']` |
+| `playerSize` | optional | Number[] or Number[][] | Video player size in device independent pixels | `[[640, 480]]` |
+| `protocols` | optional | Number[] | Array of supported video protocls. | `[1, 2, 3, 4, 5, 6, 7, 8]` |
+| `startdelay` | optional | Number | Indicates the start delay in seconds for pre-roll, mid-roll, or post-roll ad placements. | `0` |
+| `skip` | optional | Number | Indicates if the player will allow the video to be skipped, where 0 = no, 1 = yes. | `1` |
+| `playbackmethod` | optional | Number[] | Playback methods that may be in use. | `[2]` |
+| `delivery` | optional | Number[] | Supported delivery methods. | `[1]` |
+| `api` | optional | Number[] | List of supported API frameworks for this impression. | `[1, 2, 5]` |
### Bid Native Parameters
Set these parameters to `bid.nativeParams` or `bid.mediaTypes.native`.
-| Name | Scope | Type | Description | Example
-| ---- | ----- | ---- | ----------- | -------
-| `title` | optional | Object | Config for native asset title. | `{required: true, len: 25}`
-| `image` | optional | Object | Config for native asset image. | `{required: true, sizes: [[300, 250]], aspect_ratios: [{min_width: 300, min_height: 250, ratio_width: 1, ratio_height: 1}]}`
-| `icon` | optional | Object | Config for native asset icon. | `{required: true, sizes: [[60, 60]], aspect_ratios: [{min_width: 60, min_height: 60, ratio_width: 1, ratio_height: 1}]}}`
-| `sponsoredBy` | optional | Object | Config for native asset sponsoredBy. | `{required: true, len: 20}`
-| `body` | optional | Object | Config for native asset body. | `{required: true, len: 200}`
-| `cta` | optional | Object | Config for native asset cta. | `{required: true, len: 20}`
+| Name | Scope | Type | Description | Example |
+|---------------|----------|--------|--------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
+| `title` | optional | Object | Config for native asset title. | `{required: true, len: 25}` |
+| `image` | optional | Object | Config for native asset image. | `{required: true, sizes: [[300, 250]], aspect_ratios: [{min_width: 300, min_height: 250, ratio_width: 1, ratio_height: 1}]}` |
+| `icon` | optional | Object | Config for native asset icon. | `{required: true, sizes: [[60, 60]], aspect_ratios: [{min_width: 60, min_height: 60, ratio_width: 1, ratio_height: 1}]}}` |
+| `sponsoredBy` | optional | Object | Config for native asset sponsoredBy. | `{required: true, len: 20}` |
+| `body` | optional | Object | Config for native asset body. | `{required: true, len: 200}` |
+| `cta` | optional | Object | Config for native asset cta. | `{required: true, len: 20}` |
## Example
@@ -127,7 +129,9 @@ var adUnits = [{
params: {
placementId: 's5340077725248',
endpointId: 'ep3425464070464',
- publisherId: 'pub3054952966336'
+ publisherId: 'pub3054952966336',
+ // You might want to specify some application information here if the bid requests are from an application instead of a browser.
+ app: { 'name': 'my_app', 'bundle': 'test_bundle', 'store_url': 'www.some-store.com', 'ver': '1.1.0' }
}
}]
}];
diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js
index 53fff39047f..efc2effdd62 100644
--- a/modules/orbidderBidAdapter.js
+++ b/modules/orbidderBidAdapter.js
@@ -99,15 +99,7 @@ export const spec = {
data: {
v: getGlobal().version,
pageUrl: referer,
- bidId: bidRequest.bidId,
- auctionId: bidRequest.auctionId,
- // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
- transactionId: bidRequest.ortb2Imp?.ext?.tid,
- adUnitCode: bidRequest.adUnitCode,
- bidRequestCount: bidRequest.bidRequestCount,
- params: bidRequest.params,
- sizes: bidRequest.sizes,
- mediaTypes: bidRequest.mediaTypes
+ ...bidRequest // get all data provided by bid request
}
};
diff --git a/modules/outbrainBidAdapter.js b/modules/outbrainBidAdapter.js
index b4f74872082..6015ff37e08 100644
--- a/modules/outbrainBidAdapter.js
+++ b/modules/outbrainBidAdapter.js
@@ -149,6 +149,13 @@ export const spec = {
if (config.getConfig('coppa') === true) {
deepSetValue(request, 'regs.coppa', config.getConfig('coppa') & 1)
}
+ if (bidderRequest.gppConsent) {
+ deepSetValue(request, 'regs.ext.gpp', bidderRequest.gppConsent.gppString)
+ deepSetValue(request, 'regs.ext.gpp_sid', bidderRequest.gppConsent.applicableSections)
+ } else if (deepAccess(bidderRequest, 'ortb2.regs.gpp')) {
+ deepSetValue(request, 'regs.ext.gpp', bidderRequest.ortb2.regs.gpp)
+ deepSetValue(request, 'regs.ext.gpp_sid', bidderRequest.ortb2.regs.gpp_sid)
+ }
if (eids) {
deepSetValue(request, 'user.ext.eids', eids);
@@ -212,7 +219,7 @@ export const spec = {
}
}).filter(Boolean);
},
- getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent) => {
+ getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent, gppConsent) => {
const syncs = [];
let syncUrl = config.getConfig('outbrain.usersyncUrl');
@@ -225,6 +232,10 @@ export const spec = {
if (uspConsent) {
query.push('us_privacy=' + encodeURIComponent(uspConsent));
}
+ if (gppConsent) {
+ query.push('gpp=' + encodeURIComponent(gppConsent.gppString));
+ query.push('gpp_sid=' + encodeURIComponent(gppConsent.applicableSections.join(',')));
+ }
syncs.push({
type: 'image',
diff --git a/modules/ozoneBidAdapter.js b/modules/ozoneBidAdapter.js
index 970c7d49fb9..0d921f57cda 100644
--- a/modules/ozoneBidAdapter.js
+++ b/modules/ozoneBidAdapter.js
@@ -22,10 +22,10 @@ const AUCTIONURI = '/openrtb2/auction';
const OZONECOOKIESYNC = '/static/load-cookie.html';
const OZONE_RENDERER_URL = 'https://prebid.the-ozone-project.com/ozone-renderer.js';
const ORIGIN_DEV = 'https://test.ozpr.net';
-const OZONEVERSION = '2.9.0';
+const OZONEVERSION = '2.9.1';
export const spec = {
gvlid: 524,
- aliases: [{code: 'lmc', gvlid: 524}],
+ aliases: [{code: 'lmc', gvlid: 524}, {code: 'venatus', gvlid: 524}],
version: OZONEVERSION,
code: BIDDER_CODE,
supportedMediaTypes: [VIDEO, BANNER],
@@ -78,6 +78,9 @@ export const spec = {
if (bidderConfig.hasOwnProperty('batchRequests')) {
this.propertyBag.whitelabel.batchRequests = bidderConfig.batchRequests;
}
+ if (arr.hasOwnProperty('batchRequests')) {
+ this.propertyBag.whitelabel.batchRequests = true;
+ }
try {
if (arr.hasOwnProperty('auction') && arr.auction === 'dev') {
logInfo('GET: auction=dev');
@@ -100,6 +103,7 @@ export const spec = {
return this.propertyBag.whitelabel.rendererUrl;
},
isBatchRequests() {
+ logInfo('isBatchRequests going to return ', this.propertyBag.whitelabel.batchRequests);
return this.propertyBag.whitelabel.batchRequests;
},
isBidRequestValid(bid) {
diff --git a/modules/pangleBidAdapter.js b/modules/pangleBidAdapter.js
index 408a8b24c29..e75a96048b4 100644
--- a/modules/pangleBidAdapter.js
+++ b/modules/pangleBidAdapter.js
@@ -1,14 +1,18 @@
-// ver V1.0.3
-import { BANNER } from '../src/mediaTypes.js';
+// ver V1.0.4
+import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { ortbConverter } from '../libraries/ortbConverter/converter.js'
import { registerBidder } from '../src/adapters/bidderFactory.js';
-import { deepSetValue, generateUUID, timestamp } from '../src/utils.js';
+import { deepSetValue, generateUUID, timestamp, deepAccess } from '../src/utils.js';
import { getStorageManager } from '../src/storageManager.js';
import { MODULE_TYPE_RTD } from '../src/activities/modules.js';
+import { Renderer } from '../src/Renderer.js';
+
const BIDDER_CODE = 'pangle';
const ENDPOINT = 'https://pangle.pangleglobal.com/api/ad/union/web_js/common/get_ads';
+const OUTSTREAM_RENDERER_URL = 'https://sf16-static.i18n-pglstatp.com/obj/ad-pattern-sg/pangle/web/ads/video.js';
+
const DEFAULT_BID_TTL = 30;
const DEFAULT_CURRENCY = 'USD';
const DEFAULT_NET_REVENUE = true;
@@ -25,9 +29,7 @@ export function isValidUuid(uuid) {
function getPangleCookieId() {
let sid = storage.cookiesAreEnabled() && storage.getCookie(PANGLE_COOKIE);
- if (
- !sid || !isValidUuid(sid)
- ) {
+ if (!sid || !isValidUuid(sid)) {
sid = generateUUID();
setPangleCookieId(sid);
}
@@ -37,30 +39,99 @@ function getPangleCookieId() {
function setPangleCookieId(sid) {
if (storage.cookiesAreEnabled()) {
- const expires = (new Date(timestamp() + COOKIE_EXP)).toGMTString();
+ const expires = new Date(timestamp() + COOKIE_EXP).toGMTString();
storage.setCookie(PANGLE_COOKIE, sid, expires);
}
}
+function createRequest(bidRequests, bidderRequest, mediaType) {
+ const data = converter.toORTB({
+ bidRequests,
+ bidderRequest,
+ context: { mediaType },
+ });
+ const devicetype = spec.getDeviceType(navigator.userAgent);
+ deepSetValue(data, 'device.devicetype', devicetype);
+ if (bidderRequest.userId && typeof bidderRequest.userId === 'object') {
+ const pangleId = getPangleCookieId();
+ // add pangle cookie
+ const _eids = data.user?.ext?.eids ?? [];
+ deepSetValue(data, 'user.ext.eids', [
+ ..._eids,
+ {
+ source: document.location.host,
+ uids: [
+ {
+ id: pangleId,
+ atype: 1,
+ },
+ ],
+ },
+ ]);
+ }
+ bidRequests.forEach((item, idx) => {
+ deepSetValue(data.imp[idx], 'ext.networkids', item.params);
+ deepSetValue(data.imp[idx], 'banner.api', [5]);
+ deepSetValue(data, 'test', item.params.test ?? 0)
+ });
+ return {
+ method: 'POST',
+ url: ENDPOINT,
+ data,
+ options: { contentType: 'application/json', withCredentials: true }
+ }
+}
+
+function isVideoBid(bid) {
+ return !!deepAccess(bid, 'mediaTypes.video');
+}
+
+function isBannerBid(bid) {
+ return !!deepAccess(bid, 'mediaTypes.banner');
+}
+
+function renderOutstream(bid) {
+ bid.renderer.push(() => {
+ window.outstreamPlayer({ bid, codeId: bid.adUnitCode });
+ });
+}
+
const converter = ortbConverter({
context: {
netRevenue: DEFAULT_NET_REVENUE,
ttl: DEFAULT_BID_TTL,
currency: DEFAULT_CURRENCY,
- mediaType: BANNER
- }
+ },
+ bidResponse(buildBidResponse, bid, context) {
+ const bidResponse = buildBidResponse(bid, context);
+ const { bidRequest } = context;
+ if (bidRequest.mediaTypes.video?.context === 'outstream') {
+ const renderer = Renderer.install({id: bid.bidId, url: OUTSTREAM_RENDERER_URL, adUnitCode: bid.adUnitCode});
+ renderer.setRender(renderOutstream);
+ bidResponse.renderer = renderer;
+ }
+ return bidResponse;
+ },
});
export const spec = {
code: BIDDER_CODE,
- supportedMediaTypes: [BANNER],
+ supportedMediaTypes: [BANNER, VIDEO],
getDeviceType: function (ua) {
- if ((/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(ua.toLowerCase()))) {
+ if (
+ /ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(
+ ua.toLowerCase()
+ )
+ ) {
return 5; // 'tablet'
}
- if ((/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(ua.toLowerCase()))) {
+ if (
+ /iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(
+ ua.toLowerCase()
+ )
+ ) {
return 4; // 'mobile'
}
return 2; // 'desktop'
@@ -71,38 +142,22 @@ export const spec = {
},
buildRequests(bidRequests, bidderRequest) {
- const data = converter.toORTB({ bidRequests, bidderRequest })
- const devicetype = spec.getDeviceType(navigator.userAgent);
- deepSetValue(data, 'device.devicetype', devicetype);
- if (bidderRequest.userId && typeof bidderRequest.userId === 'object') {
- const pangleId = getPangleCookieId();
- // add pangle cookie
- const _eids = data.user?.ext?.eids ?? []
- deepSetValue(data, 'user.ext.eids', [..._eids, {
- source: document.location.host,
- uids: [
- {
- id: pangleId,
- atype: 1
- }
- ]
- }]);
- }
- bidRequests.forEach((item, idx) => {
- deepSetValue(data.imp[idx], 'ext.networkids', item.params);
- deepSetValue(data.imp[idx], 'banner.api', [5]);
+ const videoBids = bidRequests.filter((bid) => isVideoBid(bid));
+ const bannerBids = bidRequests.filter((bid) => isBannerBid(bid));
+ let requests = bannerBids.length
+ ? [createRequest(bannerBids, bidderRequest, BANNER)]
+ : [];
+ videoBids.forEach((bid) => {
+ requests.push(createRequest([bid], bidderRequest, VIDEO));
});
-
- return [{
- method: 'POST',
- url: ENDPOINT,
- data,
- options: { contentType: 'application/json', withCredentials: true }
- }]
+ return requests;
},
interpretResponse(response, request) {
- const bids = converter.fromORTB({ response: response.body, request: request.data }).bids;
+ const bids = converter.fromORTB({
+ response: response.body,
+ request: request.data,
+ }).bids;
return bids;
},
};
diff --git a/modules/prebidServerBidAdapter/config.js b/modules/prebidServerBidAdapter/config.js
index 29e80dfcc9f..87274504f64 100644
--- a/modules/prebidServerBidAdapter/config.js
+++ b/modules/prebidServerBidAdapter/config.js
@@ -38,5 +38,14 @@ export const S2S_VENDORS = {
noP1Consent: 'https://prebid.openx.net/cookie_sync'
},
timeout: 1000
+ },
+ 'openwrap': {
+ adapter: 'prebidServer',
+ enabled: true,
+ endpoint: {
+ p1Consent: 'https://ow.pubmatic.com/openrtb2/auction?source=pbjs',
+ noP1Consent: 'https://ow.pubmatic.com/openrtb2/auction?source=pbjs'
+ },
+ timeout: 500
}
}
diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js
index 0fff93cdcd1..a530c415839 100644
--- a/modules/prebidServerBidAdapter/index.js
+++ b/modules/prebidServerBidAdapter/index.js
@@ -503,8 +503,8 @@ export function PrebidServer() {
}
}
},
- onFledge: ({adUnitCode, config}) => {
- addComponentAuction(bidRequests[0].auctionId, adUnitCode, config);
+ onFledge: (params) => {
+ addComponentAuction({auctionId: bidRequests[0].auctionId, ...params}, params.config);
}
})
}
diff --git a/modules/prebidServerBidAdapter/ortbConverter.js b/modules/prebidServerBidAdapter/ortbConverter.js
index 54f71c7dc3e..7aeb4302280 100644
--- a/modules/prebidServerBidAdapter/ortbConverter.js
+++ b/modules/prebidServerBidAdapter/ortbConverter.js
@@ -240,7 +240,16 @@ const PBS_CONVERTER = ortbConverter({
},
fledgeAuctionConfigs(orig, response, ortbResponse, context) {
const configs = Object.values(context.impContext)
- .flatMap((impCtx) => (impCtx.fledgeConfigs || []).map(cfg => ({adUnitCode: impCtx.adUnit.code, config: cfg.config})));
+ .flatMap((impCtx) => (impCtx.fledgeConfigs || []).map(cfg => {
+ const bidderReq = impCtx.actualBidderRequests.find(br => br.bidderCode === cfg.bidder);
+ const bidReq = impCtx.actualBidRequests.get(cfg.bidder);
+ return {
+ adUnitCode: impCtx.adUnit.code,
+ ortb2: bidderReq?.ortb2,
+ ortb2Imp: bidReq?.ortb2Imp,
+ config: cfg.config
+ };
+ }));
if (configs.length > 0) {
response.fledgeAuctionConfigs = configs;
}
diff --git a/modules/priceFloors.js b/modules/priceFloors.js
index 07f8fbed45d..4ec8a8e4b7e 100644
--- a/modules/priceFloors.js
+++ b/modules/priceFloors.js
@@ -431,7 +431,7 @@ function validateSchemaFields(fields) {
if (Array.isArray(fields) && fields.length > 0 && fields.every(field => allowedFields.indexOf(field) !== -1)) {
return true;
}
- logError(`${MODULE_NAME}: Fields recieved do not match allowed fields`);
+ logError(`${MODULE_NAME}: Fields received do not match allowed fields`);
return false;
}
@@ -616,7 +616,7 @@ function handleFetchError(status) {
}
/**
- * This function handles sending and recieving the AJAX call for a floors fetch
+ * This function handles sending and receiving the AJAX call for a floors fetch
* @param {object} floorsConfig the floors config coming from setConfig
*/
export function generateAndHandleFetch(floorEndpoint) {
@@ -748,7 +748,7 @@ export const addBidResponseHook = timedBidResponseHook('priceFloors', function a
let floorInfo = getFirstMatchingFloor(floorData.data, matchingBidRequest, {...bid, size: [bid.width, bid.height]});
if (!floorInfo.matchingFloor) {
- logWarn(`${MODULE_NAME}: unable to determine a matching price floor for bidResponse`, bid);
+ if (floorInfo.matchingFloor !== 0) logWarn(`${MODULE_NAME}: unable to determine a matching price floor for bidResponse`, bid);
return fn.call(this, adUnitCode, bid, reject);
}
diff --git a/modules/programmaticaBidAdapter.js b/modules/programmaticaBidAdapter.js
new file mode 100644
index 00000000000..7d52e305189
--- /dev/null
+++ b/modules/programmaticaBidAdapter.js
@@ -0,0 +1,153 @@
+import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { BANNER, VIDEO } from '../src/mediaTypes.js';
+import { hasPurpose1Consent } from '../src/utils/gpdr.js';
+import { deepAccess, parseSizesInput, isArray } from '../src/utils.js';
+
+const BIDDER_CODE = 'programmatica';
+const DEFAULT_ENDPOINT = 'asr.programmatica.com';
+const SYNC_ENDPOINT = 'sync.programmatica.com';
+const ADOMAIN = 'programmatica.com';
+const TIME_TO_LIVE = 360;
+
+export const spec = {
+ code: BIDDER_CODE,
+
+ isBidRequestValid: function(bid) {
+ let valid = bid.params.siteId && bid.params.placementId;
+
+ return !!valid;
+ },
+
+ buildRequests: function(validBidRequests, bidderRequest) {
+ let requests = [];
+ for (const bid of validBidRequests) {
+ let endpoint = bid.params.endpoint || DEFAULT_ENDPOINT;
+
+ requests.push({
+ method: 'GET',
+ url: `https://${endpoint}/get`,
+ data: {
+ site_id: bid.params.siteId,
+ placement_id: bid.params.placementId,
+ prebid: true,
+ },
+ bidRequest: bid,
+ });
+ }
+
+ return requests;
+ },
+
+ interpretResponse: function(serverResponse, request) {
+ if (!serverResponse?.body?.content?.data) {
+ return [];
+ }
+
+ const bidResponses = [];
+ const body = serverResponse.body;
+
+ let mediaType = BANNER;
+ let ad, vastXml;
+ let width;
+ let height;
+
+ let sizes = getSize(body.size);
+ if (isArray(sizes)) {
+ [width, height] = sizes;
+ }
+
+ if (body.type.format != '') {
+ // banner
+ ad = body.content.data;
+ if (body.content.imps?.length) {
+ for (const imp of body.content.imps) {
+ ad += ``;
+ }
+ }
+ } else {
+ // video
+ vastXml = body.content.data;
+ mediaType = VIDEO;
+
+ if (!width || !height) {
+ const pSize = deepAccess(request.bidRequest, 'mediaTypes.video.playerSize');
+ const reqSize = getSize(pSize);
+ if (isArray(reqSize)) {
+ [width, height] = reqSize;
+ }
+ }
+ }
+
+ const bidResponse = {
+ requestId: request.bidRequest.bidId,
+ cpm: body.cpm,
+ currency: body.currency || 'USD',
+ width: parseInt(width),
+ height: parseInt(height),
+ creativeId: body.id,
+ netRevenue: true,
+ ttl: TIME_TO_LIVE,
+ ad: ad,
+ mediaType: mediaType,
+ vastXml: vastXml,
+ meta: {
+ advertiserDomains: [ADOMAIN],
+ }
+ };
+
+ if ((mediaType === VIDEO && request.bidRequest.mediaTypes?.video) || (mediaType === BANNER && request.bidRequest.mediaTypes?.banner)) {
+ bidResponses.push(bidResponse);
+ }
+
+ return bidResponses;
+ },
+
+ getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) {
+ const syncs = []
+
+ if (!hasPurpose1Consent(gdprConsent)) {
+ return syncs;
+ }
+
+ let params = `usp=${uspConsent ?? ''}&consent=${gdprConsent?.consentString ?? ''}`;
+ if (typeof gdprConsent?.gdprApplies === 'boolean') {
+ params += `&gdpr=${Number(gdprConsent.gdprApplies)}`;
+ }
+
+ if (syncOptions.iframeEnabled) {
+ syncs.push({
+ type: 'iframe',
+ url: `//${SYNC_ENDPOINT}/match/sp.ifr?${params}`
+ });
+ }
+
+ if (syncOptions.pixelEnabled) {
+ syncs.push({
+ type: 'image',
+ url: `//${SYNC_ENDPOINT}/match/sp?${params}`
+ });
+ }
+
+ return syncs;
+ },
+
+ onTimeout: function(timeoutData) {},
+ onBidWon: function(bid) {},
+ onSetTargeting: function(bid) {},
+ onBidderError: function() {},
+ supportedMediaTypes: [ BANNER, VIDEO ]
+}
+
+registerBidder(spec);
+
+function getSize(paramSizes) {
+ const parsedSizes = parseSizesInput(paramSizes);
+ const sizes = parsedSizes.map(size => {
+ const [width, height] = size.split('x');
+ const w = parseInt(width, 10);
+ const h = parseInt(height, 10);
+ return [w, h];
+ });
+
+ return sizes[0] || null;
+}
diff --git a/modules/programmaticaBidAdapter.md b/modules/programmaticaBidAdapter.md
new file mode 100644
index 00000000000..5982edf143e
--- /dev/null
+++ b/modules/programmaticaBidAdapter.md
@@ -0,0 +1,46 @@
+# Overview
+
+```
+Module Name: Programmatica Bid Adapter
+Module Type: Bidder Adapter
+Maintainer: tech@programmatica.com
+```
+
+# Description
+Connects to Programmatica server for bids.
+Module supports banner and video mediaType.
+
+# Test Parameters
+
+```
+ var adUnits = [{
+ code: '/test/div',
+ mediaTypes: {
+ banner: {
+ sizes: [[300, 250]]
+ }
+ },
+ bids: [{
+ bidder: 'programmatica',
+ params: {
+ siteId: 'cga9l34ipgja79esubrg',
+ placementId: 'cgim20sipgj0vj1cb510'
+ }
+ }]
+ },
+ {
+ code: '/test/div',
+ mediaTypes: {
+ video: {
+ playerSize: [[640, 360]]
+ }
+ },
+ bids: [{
+ bidder: 'programmatica',
+ params: {
+ siteId: 'cga9l34ipgja79esubrg',
+ placementId: 'cioghpcipgj8r721e9ag'
+ }
+ }]
+ },];
+```
diff --git a/modules/publinkIdSystem.js b/modules/publinkIdSystem.js
index 5b20dbb620a..1a993c99b45 100644
--- a/modules/publinkIdSystem.js
+++ b/modules/publinkIdSystem.js
@@ -16,6 +16,8 @@ const MODULE_NAME = 'publinkId';
const GVLID = 24;
const PUBLINK_COOKIE = '_publink';
const PUBLINK_S2S_COOKIE = '_publink_srv';
+const PUBLINK_REQUEST_PATH = '/cvx/client/sync/publink';
+const PUBLINK_REFRESH_PATH = '/cvx/client/sync/publink/refresh';
export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME});
@@ -23,10 +25,9 @@ function isHex(s) {
return /^[A-F0-9]+$/i.test(s);
}
-function publinkIdUrl(params, consentData) {
- let url = parseUrl('https://proc.ad.cpe.dotomi.com/cvx/client/sync/publink');
+function publinkIdUrl(params, consentData, storedId) {
+ let url = parseUrl('https://proc.ad.cpe.dotomi.com' + PUBLINK_REFRESH_PATH);
url.search = {
- deh: params.e,
mpn: 'Prebid.js',
mpv: '$prebid.version$',
};
@@ -36,9 +37,21 @@ function publinkIdUrl(params, consentData) {
url.search.gdpr_consent = consentData.consentString;
}
- if (params.site_id) { url.search.sid = params.site_id; }
+ if (params) {
+ if (params.e) {
+ // if there's an email parameter call the request path
+ url.search.deh = params.e;
+ url.pathname = PUBLINK_REQUEST_PATH;
+ }
+
+ if (params.site_id) { url.search.sid = params.site_id; }
+
+ if (params.api_key) { url.search.apikey = params.api_key; }
+ }
- if (params.api_key) { url.search.apikey = params.api_key; }
+ if (storedId) {
+ url.search.publink = storedId;
+ }
const usPrivacyString = uspDataHandler.getConsentData();
if (usPrivacyString && typeof usPrivacyString === 'string') {
@@ -48,7 +61,7 @@ function publinkIdUrl(params, consentData) {
return buildUrl(url);
}
-function makeCallback(config = {}, consentData) {
+function makeCallback(config = {}, consentData, storedId) {
return function(prebidCallback) {
const options = {method: 'GET', withCredentials: true};
let handleResponse = function(responseText, xhr) {
@@ -59,15 +72,12 @@ function makeCallback(config = {}, consentData) {
}
}
};
-
- if (config.params && config.params.e) {
- if (isHex(config.params.e)) {
- ajax(publinkIdUrl(config.params, consentData), handleResponse, undefined, options);
- } else {
- logError('params.e must be a hex string');
- }
+ if ((config.params && config.params.e && isHex(config.params.e)) || storedId) {
+ ajax(publinkIdUrl(config.params, consentData, storedId), handleResponse, undefined, options);
+ } else if (config.params.e) {
+ logError('params.e must be a hex string');
}
- };
+ }
}
function getlocalValue() {
@@ -137,9 +147,7 @@ export const publinkIdSubmodule = {
if (localValue) {
return {id: localValue};
}
- if (!storedId) {
- return {callback: makeCallback(config, consentData)};
- }
+ return {callback: makeCallback(config, consentData, storedId)};
},
eids: {
'publinkId': {
diff --git a/modules/pubmaticAnalyticsAdapter.js b/modules/pubmaticAnalyticsAdapter.js
index a636b7340b0..a8f2b8d20ee 100755
--- a/modules/pubmaticAnalyticsAdapter.js
+++ b/modules/pubmaticAnalyticsAdapter.js
@@ -93,7 +93,7 @@ function copyRequiredBidDetails(bid) {
'bidderCode',
'adapterCode',
'bidId',
- 'status', () => NO_BID, // default a bid to NO_BID until response is recieved or bid is timed out
+ 'status', () => NO_BID, // default a bid to NO_BID until response is received or bid is timed out
'finalSource as source',
'params',
'floorData',
diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js
index 16d909c2fea..ee80de03c03 100644
--- a/modules/pubmaticBidAdapter.js
+++ b/modules/pubmaticBidAdapter.js
@@ -758,6 +758,9 @@ function _addImpressionFPD(imp, bid) {
deepSetValue(imp, `ext.data.${prop}`, ortb2[prop]);
}
});
+
+ const gpid = deepAccess(bid, 'ortb2Imp.ext.gpid');
+ gpid && deepSetValue(imp, `ext.gpid`, gpid);
}
function _addFloorFromFloorModule(impObj, bid) {
@@ -1229,6 +1232,10 @@ export const spec = {
payload.device.sua = device?.sua;
}
+ if (device?.ext?.cdep) {
+ deepSetValue(payload, 'device.ext.cdep', device.ext.cdep);
+ }
+
if (user?.geo && device?.geo) {
payload.device.geo = { ...payload.device.geo, ...device.geo };
payload.user.geo = { ...payload.user.geo, ...user.geo };
diff --git a/modules/qortexRtdProvider.js b/modules/qortexRtdProvider.js
index a071436007a..7aa30334756 100644
--- a/modules/qortexRtdProvider.js
+++ b/modules/qortexRtdProvider.js
@@ -83,7 +83,7 @@ export function getContext () {
*/
export function addContextToRequests (reqBidsConfig) {
if (currentSiteContext === null) {
- logWarn('No context data recieved at this time');
+ logWarn('No context data received at this time');
} else {
const fragment = { site: {content: currentSiteContext} }
if (bidderArray?.length > 0) {
@@ -122,17 +122,17 @@ export function loadScriptTag(config) {
case 'qx-impression':
const {uid} = e.detail;
if (!uid || impressionIds.has(uid)) {
- logWarn(`recieved invalid billable event due to ${!uid ? 'missing' : 'duplicate'} uid: qx-impression`)
+ logWarn(`received invalid billable event due to ${!uid ? 'missing' : 'duplicate'} uid: qx-impression`)
return;
} else {
- logMessage('recieved billable event: qx-impression')
+ logMessage('received billable event: qx-impression')
impressionIds.add(uid)
billableEvent.transactionId = e.detail.uid;
events.emit(CONSTANTS.EVENTS.BILLABLE_EVENT, billableEvent);
break;
}
default:
- logWarn(`recieved invalid billable event: ${e.detail?.type}`)
+ logWarn(`received invalid billable event: ${e.detail?.type}`)
}
})
diff --git a/modules/relaidoBidAdapter.js b/modules/relaidoBidAdapter.js
index 1e702d812f0..751e8fa442c 100644
--- a/modules/relaidoBidAdapter.js
+++ b/modules/relaidoBidAdapter.js
@@ -104,7 +104,8 @@ function buildRequests(validBidRequests, bidderRequest) {
width: width,
height: height,
banner_sizes: getBannerSizes(bidRequest),
- media_type: mediaType
+ media_type: mediaType,
+ userIdAsEids: bidRequest.userIdAsEids || {},
});
}
@@ -117,6 +118,7 @@ function buildRequests(validBidRequests, bidderRequest) {
uuid: getUuid(),
pv: '$prebid.version$',
imuid: imuid,
+ canonical_url: bidderRequest.refererInfo?.canonicalUrl || null,
canonical_url_hash: getCanonicalUrlHash(bidderRequest.refererInfo),
ref: bidderRequest.refererInfo.page
});
@@ -142,6 +144,7 @@ function interpretResponse(serverResponse, bidRequest) {
const playerUrl = res.playerUrl || bidRequest.player || body.playerUrl;
let bidResponse = {
requestId: res.bidId,
+ placementId: res.placementId,
width: res.width,
height: res.height,
cpm: res.price,
diff --git a/modules/relevantdigitalBidAdapter.js b/modules/relevantdigitalBidAdapter.js
index ad9ee5e1e14..ef4e1c8e33d 100644
--- a/modules/relevantdigitalBidAdapter.js
+++ b/modules/relevantdigitalBidAdapter.js
@@ -98,7 +98,14 @@ export const spec = {
isBidRequestValid: (bid) => bid.params?.placementId && getBidderConfig([bid]).complete,
/** Trigger impression-pixel */
- onBidWon: ({pbsWurl}) => pbsWurl && triggerPixel(pbsWurl),
+ onBidWon(bid) {
+ if (bid.pbsWurl) {
+ triggerPixel(bid.pbsWurl)
+ }
+ if (bid.burl) {
+ triggerPixel(bid.burl)
+ }
+ },
/** Build BidRequest for PBS */
buildRequests(bidRequests, bidderRequest) {
@@ -193,6 +200,24 @@ export const spec = {
});
return syncs;
},
+
+ /** If server side, transform bid params if needed */
+ transformBidParams(params, isOrtb, adUnit, bidRequests) {
+ if (!params.placementId) {
+ return;
+ }
+ const bid = bidRequests.flatMap(req => req.adUnitsS2SCopy || []).flatMap((adUnit) => adUnit.bids).find((bid) => bid.params?.placementId === params.placementId);
+ if (!bid) {
+ return;
+ }
+ const cfg = getBidderConfig([bid]);
+ FIELDS.forEach(({ name }) => {
+ if (cfg[name] && !params[name]) {
+ params[name] = cfg[name];
+ }
+ });
+ return params;
+ },
};
registerBidder(spec);
diff --git a/modules/resetdigitalBidAdapter.js b/modules/resetdigitalBidAdapter.js
index 8264e0cc9cc..2bac6c6dcba 100644
--- a/modules/resetdigitalBidAdapter.js
+++ b/modules/resetdigitalBidAdapter.js
@@ -1,25 +1,29 @@
import { timestamp, deepAccess, isStr, deepClone } from '../src/utils.js';
import { getOrigin } from '../libraries/getOrigin/index.js';
import { config } from '../src/config.js';
-import {registerBidder} from '../src/adapters/bidderFactory.js';
-import {BANNER} from '../src/mediaTypes.js';
+import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { BANNER } from '../src/mediaTypes.js';
const BIDDER_CODE = 'resetdigital';
const CURRENCY = 'USD';
export const spec = {
code: BIDDER_CODE,
- supportedMediaTypes: [ 'banner', 'video' ],
- isBidRequestValid: function(bid) {
- return (!!(bid.params.pubId || bid.params.zoneId));
+ supportedMediaTypes: ['banner', 'video'],
+ isBidRequestValid: function (bid) {
+ return !!(bid.params.pubId || bid.params.zoneId);
},
- buildRequests: function(validBidRequests, bidderRequest) {
- let stack = (bidderRequest.refererInfo &&
- bidderRequest.refererInfo.stack ? bidderRequest.refererInfo.stack
- : [])
-
- let spb = (config.getConfig('userSync') && config.getConfig('userSync').syncsPerBidder)
- ? config.getConfig('userSync').syncsPerBidder : 5
+ buildRequests: function (validBidRequests, bidderRequest) {
+ let stack =
+ bidderRequest.refererInfo && bidderRequest.refererInfo.stack
+ ? bidderRequest.refererInfo.stack
+ : [];
+
+ let spb =
+ config.getConfig('userSync') &&
+ config.getConfig('userSync').syncsPerBidder
+ ? config.getConfig('userSync').syncsPerBidder
+ : 5;
const payload = {
start_time: timestamp(),
@@ -29,19 +33,19 @@ export const spec = {
iframe: !bidderRequest.refererInfo.reachedTop,
// TODO: the last element in refererInfo.stack is window.location.href, that's unlikely to have been the intent here
url: stack && stack.length > 0 ? [stack.length - 1] : null,
- https: (window.location.protocol === 'https:'),
+ https: window.location.protocol === 'https:',
// TODO: is 'page' the right value here?
- referrer: bidderRequest.refererInfo.page
+ referrer: bidderRequest.refererInfo.page,
},
imps: [],
user_ids: validBidRequests[0].userId,
- sync_limit: spb
+ sync_limit: spb,
};
if (bidderRequest && bidderRequest.gdprConsent) {
payload.gdpr = {
applies: bidderRequest.gdprConsent.gdprApplies,
- consent: bidderRequest.gdprConsent.consentString
+ consent: bidderRequest.gdprConsent.consentString,
};
}
@@ -50,10 +54,16 @@ export const spec = {
}
function getOrtb2Keywords(ortb2Obj) {
- const fields = ['site.keywords', 'site.content.keywords', 'user.keywords', 'app.keywords', 'app.content.keywords'];
+ const fields = [
+ 'site.keywords',
+ 'site.content.keywords',
+ 'user.keywords',
+ 'app.keywords',
+ 'app.content.keywords',
+ ];
let result = [];
- fields.forEach(path => {
+ fields.forEach((path) => {
let keyStr = deepAccess(ortb2Obj, path);
if (isStr(keyStr)) result.push(keyStr);
});
@@ -79,18 +89,26 @@ export const spec = {
const floorInfo = req.getFloor({
currency: CURRENCY,
mediaType: BANNER,
- size: '*'
+ size: '*',
});
- if (typeof floorInfo === 'object' && floorInfo.currency === CURRENCY && !isNaN(parseFloat(floorInfo.floor))) {
+ if (
+ typeof floorInfo === 'object' &&
+ floorInfo.currency === CURRENCY &&
+ !isNaN(parseFloat(floorInfo.floor))
+ ) {
bidFloor = parseFloat(floorInfo.floor);
bidFloorCur = CURRENCY;
}
}
// get param kewords (if it exists)
- let paramsKeywords = req.params.keywords ? req.params.keywords.split(',') : [];
+ let paramsKeywords = req.params.keywords
+ ? req.params.keywords.split(',')
+ : [];
// merge all keywords
- let keywords = ortb2KeywordsList.concat(paramsKeywords).concat(metaKeywords);
+ let keywords = ortb2KeywordsList
+ .concat(paramsKeywords)
+ .concat(metaKeywords);
payload.imps.push({
pub_id: req.params.pubId,
@@ -110,32 +128,32 @@ export const spec = {
sizes: req.sizes,
force_bid: req.params.forceBid,
coppa: config.getConfig('coppa') === true ? 1 : 0,
- media_types: deepAccess(req, 'mediaTypes')
+ media_types: deepAccess(req, 'mediaTypes'),
});
}
- let params = validBidRequests[0].params
- let url = params.endpoint ? params.endpoint : '//ads.resetsrv.com'
+ let params = validBidRequests[0].params;
+ let url = params.endpoint ? params.endpoint : '//ads.resetsrv.com';
return {
method: 'POST',
url: url,
data: JSON.stringify(payload),
- bids: validBidRequests
+ bids: validBidRequests,
};
},
- interpretResponse: function(serverResponse, bidRequest) {
+ interpretResponse: function (serverResponse, bidRequest) {
const bidResponses = [];
if (!serverResponse || !serverResponse.body) {
- return bidResponses
+ return bidResponses;
}
let res = serverResponse.body;
if (!res.bids || !res.bids.length) {
- return []
+ return [];
}
for (let x = 0; x < serverResponse.body.bids.length; x++) {
- let bid = serverResponse.body.bids[x]
+ let bid = serverResponse.body.bids[x];
bidResponses.push({
requestId: bid.bid_id,
@@ -152,47 +170,45 @@ export const spec = {
netRevenue: true,
currency: 'USD',
meta: {
- advertiserDomains: bid.adomain
- }
- })
+ advertiserDomains: bid.adomain,
+ },
+ });
}
return bidResponses;
},
- getUserSyncs: function(syncOptions, serverResponses, gdprConsent) {
- const syncs = []
+ getUserSyncs: function (syncOptions, serverResponses, gdprConsent) {
+ const syncs = [];
if (!serverResponses.length || !serverResponses[0].body) {
- return syncs
+ return syncs;
}
- let pixels = serverResponses[0].body.pixels
+ let pixels = serverResponses[0].body.pixels;
if (!pixels || !pixels.length) {
- return syncs
+ return syncs;
}
- let gdprParams = null
+ let gdprParams = '';
if (gdprConsent) {
if (typeof gdprConsent.gdprApplies === 'boolean') {
- gdprParams = `gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`
+ gdprParams = `gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${
+ gdprConsent.consentString
+ }`;
} else {
- gdprParams = `gdpr_consent=${gdprConsent.consentString}`
+ gdprParams = `gdpr_consent=${gdprConsent.consentString}`;
}
}
- for (let x = 0; x < pixels.length; x++) {
- let pixel = pixels[x]
-
- if ((pixel.type === 'iframe' && syncOptions.iframeEnabled) ||
- (pixel.type === 'image' && syncOptions.pixelEnabled)) {
- if (gdprParams && gdprParams.length) {
- pixel = (pixel.indexOf('?') === -1 ? '?' : '&') + gdprParams
- }
- syncs.push(pixel)
- }
+ if ((syncOptions.iframeEnabled || syncOptions.pixelEnabled)) {
+ return [
+ {
+ type: 'iframe',
+ url: 'https://media.reset-digital.com/prebid/async_usersync.html?' + gdprParams.length ? gdprParams : '',
+ },
+ ];
}
- return syncs;
- }
+ },
};
registerBidder(spec);
diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js
index 4cfd40fb682..bff7661455a 100644
--- a/modules/rubiconBidAdapter.js
+++ b/modules/rubiconBidAdapter.js
@@ -17,7 +17,9 @@ import {
logMessage,
logWarn,
mergeDeep,
- parseSizesInput, _each
+ parseSizesInput,
+ pick,
+ _each
} from '../src/utils.js';
import {getAllOrtbKeywords} from '../libraries/keywords/keywords.js';
import {convertTypes} from '../libraries/transformParamsUtils/convertTypes.js';
@@ -124,6 +126,7 @@ var sizeMap = {
278: '320x500',
282: '320x400',
288: '640x380',
+ 484: '720x1280',
524: '1x2',
548: '500x1000',
550: '980x480',
@@ -407,6 +410,8 @@ export const spec = {
'x_source.tid',
'l_pb_bid_id',
'p_screen_res',
+ 'o_ae',
+ 'o_cdep',
'rp_floor',
'rp_secure',
'tk_user_key'
@@ -480,6 +485,7 @@ export const spec = {
'x_source.tid': bidderRequest.ortb2?.source?.tid,
'x_imp.ext.tid': bidRequest.ortb2Imp?.ext?.tid,
'l_pb_bid_id': bidRequest.bidId,
+ 'o_cdep': bidRequest.ortb2?.device?.ext?.cdep,
'p_screen_res': _getScreenResolution(),
'tk_user_key': params.userId,
'p_geo.latitude': isNaN(parseFloat(latitude)) ? undefined : parseFloat(latitude).toFixed(4),
@@ -519,6 +525,10 @@ export const spec = {
if (configUserId) {
data['ppuid'] = configUserId;
}
+
+ if (bidRequest?.ortb2Imp?.ext?.ae) {
+ data['o_ae'] = 1;
+ }
// loop through userIds and add to request
if (bidRequest.userIdAsEids) {
bidRequest.userIdAsEids.forEach(eid => {
@@ -618,7 +628,7 @@ export const spec = {
* @param {*} responseObj
* @param {BidRequest|Object.} request - if request was SRA the bidRequest argument will be a keyed BidRequest array object,
* non-SRA responses return a plain BidRequest object
- * @return {Bid[]} An array of bids which
+ * @return {{fledgeAuctionConfigs: *, bids: *}} An array of bids which
*/
interpretResponse: function (responseObj, request) {
responseObj = responseObj.body;
@@ -628,7 +638,6 @@ export const spec = {
if (!responseObj || typeof responseObj !== 'object') {
return [];
}
-
// Response from PBS Java openRTB
if (responseObj.seatbid) {
const responseErrors = deepAccess(responseObj, 'ext.errors.rubicon');
@@ -654,7 +663,7 @@ export const spec = {
return [];
}
- return ads.reduce((bids, ad, i) => {
+ let bids = ads.reduce((bids, ad, i) => {
(ad.impression_id && lastImpId === ad.impression_id) ? multibid++ : lastImpId = ad.impression_id;
if (ad.status !== 'ok') {
@@ -715,6 +724,16 @@ export const spec = {
}, []).sort((adA, adB) => {
return (adB.cpm || 0.0) - (adA.cpm || 0.0);
});
+
+ let fledgeAuctionConfigs = responseObj.component_auction_config?.map(config => {
+ return { config, bidId: config.bidId }
+ });
+
+ if (fledgeAuctionConfigs) {
+ return { bids, fledgeAuctionConfigs };
+ } else {
+ return bids;
+ }
},
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) {
if (!hasSynced && syncOptions.iframeEnabled) {
@@ -956,6 +975,33 @@ function applyFPD(bidRequest, mediaType, data) {
if (data['tg_i.pbadslot']) {
delete data['tg_i.dfp_ad_unit_code'];
}
+
+ // High Entropy stuff -> sua object is the ORTB standard (default to pass unless specifically disabled)
+ const clientHints = deepAccess(fpd, 'device.sua');
+ if (clientHints && rubiConf.chEnabled !== false) {
+ // pick out client hints we want to send (any that are undefined or empty will NOT be sent)
+ pick(clientHints, [
+ 'architecture', arch => data.m_ch_arch = arch,
+ 'bitness', bitness => data.m_ch_bitness = bitness,
+ 'browsers', browsers => {
+ if (!Array.isArray(browsers)) return;
+ // reduce down into ua and full version list attributes
+ const [ua, fullVer] = browsers.reduce((accum, browserData) => {
+ accum[0].push(`"${browserData?.brand}"|v="${browserData?.version?.[0]}"`);
+ accum[1].push(`"${browserData?.brand}"|v="${browserData?.version?.join?.('.')}"`);
+ return accum;
+ }, [[], []]);
+ data.m_ch_ua = ua?.join?.(',');
+ data.m_ch_full_ver = fullVer?.join?.(',');
+ },
+ 'mobile', isMobile => data.m_ch_mobile = `?${isMobile}`,
+ 'model', model => data.m_ch_model = model,
+ 'platform', platform => {
+ data.m_ch_platform = platform?.brand;
+ data.m_ch_platform_ver = platform?.version?.join?.('.');
+ }
+ ])
+ }
} else {
if (Object.keys(impExt).length) {
mergeDeep(data.imp[0].ext, impExt);
diff --git a/modules/shinezRtbBidAdapter.js b/modules/shinezRtbBidAdapter.js
new file mode 100644
index 00000000000..d1d9f36a569
--- /dev/null
+++ b/modules/shinezRtbBidAdapter.js
@@ -0,0 +1,336 @@
+import {_each, deepAccess, parseSizesInput, parseUrl, uniques, isFn} from '../src/utils.js';
+import {registerBidder} from '../src/adapters/bidderFactory.js';
+import {BANNER, VIDEO} from '../src/mediaTypes.js';
+import {getStorageManager} from '../src/storageManager.js';
+import {config} from '../src/config.js';
+
+const DEFAULT_SUB_DOMAIN = 'exchange';
+const BIDDER_CODE = 'shinezRtb';
+const BIDDER_VERSION = '1.0.0';
+const CURRENCY = 'USD';
+const TTL_SECONDS = 60 * 5;
+const UNIQUE_DEAL_ID_EXPIRY = 1000 * 60 * 15;
+const storage = getStorageManager({bidderCode: BIDDER_CODE});
+
+function getTopWindowQueryParams() {
+ try {
+ const parsedUrl = parseUrl(window.top.document.URL, {decodeSearchAsString: true});
+ return parsedUrl.search;
+ } catch (e) {
+ return '';
+ }
+}
+
+export function createDomain(subDomain = DEFAULT_SUB_DOMAIN) {
+ return `https://${subDomain}.sweetgum.io`;
+}
+
+export function extractCID(params) {
+ return params.cId || params.CID || params.cID || params.CId || params.cid || params.ciD || params.Cid || params.CiD;
+}
+
+export function extractPID(params) {
+ return params.pId || params.PID || params.pID || params.PId || params.pid || params.piD || params.Pid || params.PiD;
+}
+
+export function extractSubDomain(params) {
+ return params.subDomain || params.SubDomain || params.Subdomain || params.subdomain || params.SUBDOMAIN || params.subDOMAIN;
+}
+
+function isBidRequestValid(bid) {
+ const params = bid.params || {};
+ return !!(extractCID(params) && extractPID(params));
+}
+
+function buildRequest(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout) {
+ const {
+ params,
+ bidId,
+ userId,
+ adUnitCode,
+ schain,
+ mediaTypes,
+ ortb2Imp,
+ bidderRequestId,
+ bidRequestsCount,
+ bidderRequestsCount,
+ bidderWinsCount
+ } = bid;
+ let {bidFloor, ext} = params;
+ const hashUrl = hashCode(topWindowUrl);
+ const uniqueDealId = getUniqueDealId(hashUrl);
+ const cId = extractCID(params);
+ const pId = extractPID(params);
+ const subDomain = extractSubDomain(params);
+
+ const gpid = deepAccess(bid, 'ortb2Imp.ext.gpid', deepAccess(bid, 'ortb2Imp.ext.data.pbadslot', ''));
+
+ if (isFn(bid.getFloor)) {
+ const floorInfo = bid.getFloor({
+ currency: 'USD',
+ mediaType: '*',
+ size: '*'
+ });
+
+ if (floorInfo.currency === 'USD') {
+ bidFloor = floorInfo.floor;
+ }
+ }
+
+ let data = {
+ url: encodeURIComponent(topWindowUrl),
+ uqs: getTopWindowQueryParams(),
+ cb: Date.now(),
+ bidFloor: bidFloor,
+ bidId: bidId,
+ referrer: bidderRequest.refererInfo.ref,
+ adUnitCode: adUnitCode,
+ publisherId: pId,
+ sizes: sizes,
+ uniqueDealId: uniqueDealId,
+ bidderVersion: BIDDER_VERSION,
+ prebidVersion: '$prebid.version$',
+ res: `${screen.width}x${screen.height}`,
+ schain: schain,
+ mediaTypes: mediaTypes,
+ gpid: gpid,
+ transactionId: ortb2Imp?.ext?.tid,
+ bidderRequestId: bidderRequestId,
+ bidRequestsCount: bidRequestsCount,
+ bidderRequestsCount: bidderRequestsCount,
+ bidderWinsCount: bidderWinsCount,
+ bidderTimeout: bidderTimeout
+ };
+
+ appendUserIdsToRequestPayload(data, userId);
+
+ const sua = deepAccess(bidderRequest, 'ortb2.device.sua');
+
+ if (sua) {
+ data.sua = sua;
+ }
+
+ if (bidderRequest.gdprConsent) {
+ if (bidderRequest.gdprConsent.consentString) {
+ data.gdprConsent = bidderRequest.gdprConsent.consentString;
+ }
+ if (bidderRequest.gdprConsent.gdprApplies !== undefined) {
+ data.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0;
+ }
+ }
+ if (bidderRequest.uspConsent) {
+ data.usPrivacy = bidderRequest.uspConsent;
+ }
+
+ if (bidderRequest.gppConsent) {
+ data.gppString = bidderRequest.gppConsent.gppString;
+ data.gppSid = bidderRequest.gppConsent.applicableSections;
+ } else if (bidderRequest.ortb2?.regs?.gpp) {
+ data.gppString = bidderRequest.ortb2.regs.gpp;
+ data.gppSid = bidderRequest.ortb2.regs.gpp_sid;
+ }
+
+ const dto = {
+ method: 'POST',
+ url: `${createDomain(subDomain)}/prebid/multi/${cId}`,
+ data: data
+ };
+
+ _each(ext, (value, key) => {
+ dto.data['ext.' + key] = value;
+ });
+
+ return dto;
+}
+
+function appendUserIdsToRequestPayload(payloadRef, userIds) {
+ let key;
+ _each(userIds, (userId, idSystemProviderName) => {
+ key = `uid.${idSystemProviderName}`;
+
+ switch (idSystemProviderName) {
+ case 'digitrustid':
+ payloadRef[key] = deepAccess(userId, 'data.id');
+ break;
+ case 'lipb':
+ payloadRef[key] = userId.lipbid;
+ break;
+ case 'parrableId':
+ payloadRef[key] = userId.eid;
+ break;
+ case 'id5id':
+ payloadRef[key] = userId.uid;
+ break;
+ default:
+ payloadRef[key] = userId;
+ }
+ });
+}
+
+function buildRequests(validBidRequests, bidderRequest) {
+ const topWindowUrl = bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation;
+ const bidderTimeout = config.getConfig('bidderTimeout');
+ const requests = [];
+ validBidRequests.forEach(validBidRequest => {
+ const sizes = parseSizesInput(validBidRequest.sizes);
+ const request = buildRequest(validBidRequest, topWindowUrl, sizes, bidderRequest, bidderTimeout);
+ requests.push(request);
+ });
+ return requests;
+}
+
+function interpretResponse(serverResponse, request) {
+ if (!serverResponse || !serverResponse.body) {
+ return [];
+ }
+ const {bidId} = request.data;
+ const {results} = serverResponse.body;
+
+ let output = [];
+
+ try {
+ results.forEach(result => {
+ const {
+ creativeId,
+ ad,
+ price,
+ exp,
+ width,
+ height,
+ currency,
+ metaData,
+ advertiserDomains,
+ mediaType = BANNER
+ } = result;
+ if (!ad || !price) {
+ return;
+ }
+
+ const response = {
+ requestId: bidId,
+ cpm: price,
+ width: width,
+ height: height,
+ creativeId: creativeId,
+ currency: currency || CURRENCY,
+ netRevenue: true,
+ ttl: exp || TTL_SECONDS,
+ };
+
+ if (metaData) {
+ Object.assign(response, {
+ meta: metaData
+ })
+ } else {
+ Object.assign(response, {
+ meta: {
+ advertiserDomains: advertiserDomains || []
+ }
+ })
+ }
+
+ if (mediaType === BANNER) {
+ Object.assign(response, {
+ ad: ad,
+ });
+ } else {
+ Object.assign(response, {
+ vastXml: ad,
+ mediaType: VIDEO
+ });
+ }
+ output.push(response);
+ });
+ return output;
+ } catch (e) {
+ return [];
+ }
+}
+
+function getUserSyncs(syncOptions, responses, gdprConsent = {}, uspConsent = '') {
+ let syncs = [];
+ const {iframeEnabled, pixelEnabled} = syncOptions;
+ const {gdprApplies, consentString = ''} = gdprConsent;
+
+ const cidArr = responses.filter(resp => deepAccess(resp, 'body.cid')).map(resp => resp.body.cid).filter(uniques);
+ const params = `?cid=${encodeURIComponent(cidArr.join(','))}&gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${encodeURIComponent(consentString || '')}&us_privacy=${encodeURIComponent(uspConsent || '')}`
+ if (iframeEnabled) {
+ syncs.push({
+ type: 'iframe',
+ url: `https://sync.sweetgum.io/api/sync/iframe/${params}`
+ });
+ }
+ if (pixelEnabled) {
+ syncs.push({
+ type: 'image',
+ url: `https://sync.sweetgum.io/api/sync/image/${params}`
+ });
+ }
+ return syncs;
+}
+
+export function hashCode(s, prefix = '_') {
+ const l = s.length;
+ let h = 0
+ let i = 0;
+ if (l > 0) {
+ while (i < l) {
+ h = (h << 5) - h + s.charCodeAt(i++) | 0;
+ }
+ }
+ return prefix + h;
+}
+
+export function getUniqueDealId(key, expiry = UNIQUE_DEAL_ID_EXPIRY) {
+ const storageKey = `u_${key}`;
+ const now = Date.now();
+ const data = getStorageItem(storageKey);
+ let uniqueId;
+
+ if (!data || !data.value || now - data.created > expiry) {
+ uniqueId = `${key}_${now.toString()}`;
+ setStorageItem(storageKey, uniqueId);
+ } else {
+ uniqueId = data.value;
+ }
+
+ return uniqueId;
+}
+
+export function getStorageItem(key) {
+ try {
+ return tryParseJSON(storage.getDataFromLocalStorage(key));
+ } catch (e) {
+ }
+
+ return null;
+}
+
+export function setStorageItem(key, value, timestamp) {
+ try {
+ const created = timestamp || Date.now();
+ const data = JSON.stringify({value, created});
+ storage.setDataInLocalStorage(key, data);
+ } catch (e) {
+ }
+}
+
+export function tryParseJSON(value) {
+ try {
+ return JSON.parse(value);
+ } catch (e) {
+ return value;
+ }
+}
+
+export const spec = {
+ code: BIDDER_CODE,
+ version: BIDDER_VERSION,
+ supportedMediaTypes: [BANNER, VIDEO],
+ isBidRequestValid,
+ buildRequests,
+ interpretResponse,
+ getUserSyncs
+};
+
+registerBidder(spec);
diff --git a/modules/shinezRtbBidAdapter.md b/modules/shinezRtbBidAdapter.md
new file mode 100644
index 00000000000..e9190c2a9c4
--- /dev/null
+++ b/modules/shinezRtbBidAdapter.md
@@ -0,0 +1,35 @@
+# Overview
+
+**Module Name:** Shinez RTB Bid Adapter
+
+**Module Type:** Bidder Adapter
+
+**Maintainer:** tech-team@shinez.io
+
+# Description
+
+Module that connects to Shinez RTB demand sources.
+
+# Test Parameters
+```js
+var adUnits = [
+ {
+ code: 'test-ad',
+ sizes: [[300, 250]],
+ bids: [
+ {
+ bidder: 'shinezRtb',
+ params: {
+ cId: '562524b21b1c1f08117fc7f9',
+ pId: '59ac17c192832d0011283fe3',
+ bidFloor: 0.0001,
+ ext: {
+ param1: 'loremipsum',
+ param2: 'dolorsitamet'
+ }
+ }
+ }
+ ]
+ }
+];
+```
diff --git a/modules/showheroes-bsBidAdapter.js b/modules/showheroes-bsBidAdapter.js
index a1e7df49d18..bd2706a21d5 100644
--- a/modules/showheroes-bsBidAdapter.js
+++ b/modules/showheroes-bsBidAdapter.js
@@ -28,8 +28,11 @@ function getEnvURLs(isStage) {
}
}
+const GVLID = 111;
+
export const spec = {
code: BIDDER_CODE,
+ gvlid: GVLID,
aliases: ['showheroesBs'],
supportedMediaTypes: [VIDEO, BANNER],
isBidRequestValid: function(bid) {
diff --git a/modules/smartyadsBidAdapter.js b/modules/smartyadsBidAdapter.js
index a7d194e8db4..2409bebbc59 100644
--- a/modules/smartyadsBidAdapter.js
+++ b/modules/smartyadsBidAdapter.js
@@ -6,6 +6,7 @@ import { convertOrtbRequestToProprietaryNative } from '../src/native.js';
import { ajax } from '../src/ajax.js';
const BIDDER_CODE = 'smartyads';
+const GVLID = 534;
const adUrls = {
US_EAST: 'https://n1.smartyads.com/?c=o&m=prebid&secret_key=prebid_js',
EU: 'https://n2.smartyads.com/?c=o&m=prebid&secret_key=prebid_js',
@@ -52,6 +53,7 @@ function getAdUrlByRegion(bid) {
export const spec = {
code: BIDDER_CODE,
+ gvlid: GVLID,
supportedMediaTypes: [BANNER, VIDEO, NATIVE],
isBidRequestValid: (bid) => {
diff --git a/modules/snigelBidAdapter.js b/modules/snigelBidAdapter.js
index 489d0bcdc9e..6d32d8f97a2 100644
--- a/modules/snigelBidAdapter.js
+++ b/modules/snigelBidAdapter.js
@@ -105,7 +105,7 @@ registerBidder(spec);
function getPage(bidderRequest) {
return (
- getConfig(`${BIDDER_CODE}.page`) || deepAccess(bidderRequest, 'refererInfo.canonicalUrl') || window.location.href
+ getConfig(`${BIDDER_CODE}.page`) || deepAccess(bidderRequest, 'refererInfo.page') || window.location.href
);
}
diff --git a/modules/sonobiAnalyticsAdapter.js b/modules/sonobiAnalyticsAdapter.js
index 0057944b201..04a855b5be6 100644
--- a/modules/sonobiAnalyticsAdapter.js
+++ b/modules/sonobiAnalyticsAdapter.js
@@ -6,7 +6,7 @@ import {ajaxBuilder} from '../src/ajax.js';
let ajax = ajaxBuilder(0);
-const DEFAULT_EVENT_URL = 'apex.go.sonobi.com/keymaker';
+export const DEFAULT_EVENT_URL = 'apex.go.sonobi.com/keymaker';
const analyticsType = 'endpoint';
const QUEUE_TIMEOUT_DEFAULT = 200;
const {
diff --git a/modules/sparteoBidAdapter.js b/modules/sparteoBidAdapter.js
new file mode 100644
index 00000000000..ac48ec4089d
--- /dev/null
+++ b/modules/sparteoBidAdapter.js
@@ -0,0 +1,133 @@
+import { deepAccess, deepSetValue, logError, parseSizesInput, triggerPixel } from '../src/utils.js';
+import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { BANNER, VIDEO } from '../src/mediaTypes.js';
+import {ortbConverter} from '../libraries/ortbConverter/converter.js'
+
+const BIDDER_CODE = 'sparteo';
+const GVLID = 1028;
+const TTL = 60;
+const HTTP_METHOD = 'POST';
+const REQUEST_URL = 'https://bid.sparteo.com/auction';
+
+const converter = ortbConverter({
+ context: {
+ // `netRevenue` and `ttl` are required properties of bid responses - provide a default for them
+ netRevenue: true, // or false if your adapter should set bidResponse.netRevenue = false
+ ttl: TTL // default bidResponse.ttl (when not specified in ORTB response.seatbid[].bid[].exp)
+ },
+ request(buildRequest, imps, bidderRequest, context) {
+ const request = buildRequest(imps, bidderRequest, context);
+
+ if (bidderRequest.bids[0].params.networkId) {
+ deepSetValue(request, 'site.publisher.ext.params.networkId', bidderRequest.bids[0].params.networkId);
+ }
+
+ if (bidderRequest.bids[0].params.publisherId) {
+ deepSetValue(request, 'site.publisher.ext.params.publisherId', bidderRequest.bids[0].params.publisherId);
+ }
+
+ return request;
+ },
+ imp(buildImp, bidRequest, context) {
+ const imp = buildImp(bidRequest, context);
+
+ deepSetValue(imp, 'ext.sparteo.params', bidRequest.params);
+
+ return imp;
+ },
+ bidResponse(buildBidResponse, bid, context) {
+ context.mediaType = deepAccess(bid, 'ext.prebid.type');
+
+ return buildBidResponse(bid, context)
+ }
+});
+
+export const spec = {
+ code: BIDDER_CODE,
+ gvlid: GVLID,
+ supportedMediaTypes: [BANNER, VIDEO],
+
+ /**
+ * Determines whether or not the given bid request is valid.
+ *
+ * @param {BidRequest} bid The bid params to validate.
+ * @return boolean True if this is a valid bid, and false otherwise.
+ */
+ isBidRequestValid: function(bid) {
+ let bannerParams = deepAccess(bid, 'mediaTypes.banner');
+ let videoParams = deepAccess(bid, 'mediaTypes.video');
+
+ if (!bid.params) {
+ logError('The bid params are missing');
+ return false;
+ }
+
+ if (!bid.params.networkId && !bid.params.publisherId) {
+ logError('The networkId or publisherId is required');
+ return false;
+ }
+
+ if (!bannerParams && !videoParams) {
+ logError('The placement must be of banner or video type');
+ return false;
+ }
+
+ /**
+ * BANNER checks
+ */
+
+ if (bannerParams) {
+ let sizes = bannerParams.sizes;
+
+ if (!sizes || parseSizesInput(sizes).length == 0) {
+ logError('mediaTypes.banner.sizes must be set for banner placement at the right format.');
+ return false;
+ }
+ }
+
+ /**
+ * VIDEO checks
+ */
+
+ if (videoParams) {
+ if (parseSizesInput(videoParams.playerSize).length == 0) {
+ logError('mediaTypes.video.playerSize must be set for video placement at the right format.');
+ return false;
+ }
+ }
+
+ return true;
+ },
+
+ buildRequests: function(bidRequests, bidderRequest) {
+ const payload = converter.toORTB({bidRequests, bidderRequest})
+
+ return {
+ method: HTTP_METHOD,
+ url: bidRequests[0].params.endpoint ? bidRequests[0].params.endpoint : REQUEST_URL,
+ data: payload
+ };
+ },
+
+ interpretResponse: function(serverResponse, requests) {
+ const bids = converter.fromORTB({response: serverResponse.body, request: requests.data}).bids;
+
+ return bids;
+ },
+
+ getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) {},
+
+ onTimeout: function(timeoutData) {},
+
+ onBidWon: function(bid) {
+ if (bid && bid.nurl && bid.nurl.length > 0) {
+ bid.nurl.forEach(function(winUrl) {
+ triggerPixel(winUrl, null);
+ });
+ }
+ },
+
+ onSetTargeting: function(bid) {}
+};
+
+registerBidder(spec);
diff --git a/modules/sparteoBidAdapter.md b/modules/sparteoBidAdapter.md
new file mode 100644
index 00000000000..774d9211d9d
--- /dev/null
+++ b/modules/sparteoBidAdapter.md
@@ -0,0 +1,35 @@
+# Overview
+
+```
+Module Name: Sparteo Bidder Adapter
+Module Type: Bidder Adapter
+Maintainer: prebid@sparteo.com
+```
+
+# Description
+
+Module that connects to Sparteo's demand sources
+
+# Test Parameters
+```
+ var adUnits = [
+ {
+ code: 'test-div',
+ mediaTypes: {
+ banner: {
+ sizes: [
+ [1, 1]
+ ]
+ }
+ },
+ bids: [
+ {
+ bidder: 'sparteo',
+ params: {
+ networkId: '1234567a-eb1b-1fae-1d23-e1fbaef234cf'
+ }
+ }
+ ]
+ }
+ ];
+```
\ No newline at end of file
diff --git a/modules/sspBCBidAdapter.js b/modules/sspBCBidAdapter.js
index 2b39faa02d8..93aa0973cc7 100644
--- a/modules/sspBCBidAdapter.js
+++ b/modules/sspBCBidAdapter.js
@@ -12,7 +12,7 @@ const SYNC_URL = 'https://ssp.wp.pl/bidder/usersync';
const NOTIFY_URL = 'https://ssp.wp.pl/bidder/notify';
const GVLID = 676;
const TMAX = 450;
-const BIDDER_VERSION = '5.91';
+const BIDDER_VERSION = '5.92';
const DEFAULT_CURRENCY = 'PLN';
const W = window;
const { navigator } = W;
@@ -506,7 +506,7 @@ const mapImpression = slot => {
}
const isVideoAd = bid => {
- const xmlTester = new RegExp(/^<\?xml/);
+ const xmlTester = new RegExp(/^<\?xml| 0 &&
- (typeof bid.mediaTypes.banner.sizes != 'undefined'); // only accepting appropriate sizes
- },
-
- /**
- * @param {BidRequest[]} bidRequests
- * @param {*} bidderRequest
- * @return {ServerRequest}
+ * Register bidder specific code, which will execute if a bid from this bidder won the auction
+ * @param {Bid} bid The bid that won the auction
*/
- buildRequests: (bidRequests, bidderRequest) => {
- if (bidRequests.length === 0) {
- return [];
+ onBidWon: function (bid) {
+ if (bid.burl) {
+ utils.triggerPixel(bid.burl);
}
- const bids = bidRequests.map(bidToRequest);
- const bidderApiUrl = URL;
- const payload = {
- 'bids': [...bids],
- 'site': createSite(bidderRequest.refererInfo)
- };
- return [{
- method: 'POST',
- url: bidderApiUrl,
- data: payload
- }];
+ }
+}
+
+function isBidRequestValid(bid) {
+ return (isValidInventoryId(bid) && (isValidBannerRequest(bid) || isValidVideoRequest(bid)));
+}
+
+function isValidInventoryId(bid) {
+ return 'params' in bid && 'inventoryId' in bid.params && utils.isNumber(bid.params.inventoryId);
+}
+
+function isValidBannerRequest(bid) {
+ const bannerSizes = utils.deepAccess(bid, `mediaTypes.${BANNER}.sizes`);
+ return utils.isArray(bannerSizes) && bannerSizes.length > 0 && bannerSizes.every(size => utils.isNumber(size[0]) && utils.isNumber(size[1]));
+}
+
+function isValidVideoRequest(bid) {
+ const videoSizes = utils.deepAccess(bid, `mediaTypes.${VIDEO}.playerSize`);
+ const videoMimes = utils.deepAccess(bid, `mediaTypes.${VIDEO}.mimes`);
+
+ const isValidVideoSize = utils.isArray(videoSizes) && videoSizes.length > 0 && videoSizes.every(size => utils.isNumber(size[0]) && utils.isNumber(size[1]));
+ const isValidVideoMimes = utils.isArray(videoMimes) && videoMimes.length > 0;
+ return isValidVideoSize && isValidVideoMimes;
+}
+
+function buildRequests(validBidRequests, bidderRequest) {
+ let requests = [];
+ try {
+ if (validBidRequests.length === 0 || !bidderRequest) return [];
+ let bannerBids = validBidRequests.filter(bid => utils.deepAccess(bid, 'mediaTypes.banner'));
+ let videoBids = validBidRequests.filter(bid => utils.deepAccess(bid, 'mediaTypes.video'));
+
+ bannerBids.forEach(bid => {
+ requests.push(createRequest([bid], bidderRequest, BANNER));
+ });
+
+ videoBids.forEach(bid => {
+ requests.push(createRequest([bid], bidderRequest, VIDEO));
+ });
+ } catch (err) {
+ utils.logWarn('buildRequests', err);
+ }
+
+ return requests;
+}
+
+function createRequest(bidRequests, bidderRequest, mediaType) {
+ const rtbData = CONVERTER.toORTB({ bidRequests, bidderRequest, context: { mediaType } })
+
+ const bid = bidRequests.find((b) => b.params.inventoryId)
+
+ if (bid.params.inventoryId) rtbData.ext = {};
+ if (bid.params.inventoryId) rtbData.ext.inventoryId = bid.params.inventoryId
+
+ const ortb2Data = bidderRequest?.ortb2 || {};
+ const bcat = ortb2Data?.bcat || bid.params.bcat || [];
+ const badv = ortb2Data?.badv || bid.params.badv || [];
+ const bapp = ortb2Data?.bapp || bid.params.bapp || [];
+
+ if (bcat.length > 0) {
+ rtbData.bcat = bcat;
+ }
+ if (badv.length > 0) {
+ rtbData.badv = badv;
+ }
+ if (badv.length > 0) {
+ rtbData.bapp = bapp;
+ }
+
+ return {
+ method: 'POST',
+ url: BIDDER_ENDPOINT_URL + '?v=' + ADAPTER_VERSION,
+ data: rtbData
+ }
+}
+
+function interpretResponse(response, request) {
+ return CONVERTER.fromORTB({ request: request.data, response: response.body }).bids;
+}
+
+registerBidder(spec);
+
+const CONVERTER = ortbConverter({
+ context: {
+ netRevenue: true,
+ ttl: DEFAULT_BID_TTL,
+ currency: DEFAULT_CURRENCY
},
- /**
- * Unpack the response from the server into a list of bids.
- *
- * @param {serverResponse} serverResponse A successful response from the server.
- * @return {Bid[]} An array of bids which were nested inside the server.
- */
- interpretResponse: function (serverResponse, serverRequest) {
- if (!Array.isArray(serverResponse.body)) {
- return [];
+ imp(buildImp, bidRequest, context) {
+ let imp = buildImp(bidRequest, context);
+ if (!imp.bidfloor && bidRequest.params.bidFloor) {
+ imp.bidfloor = bidRequest.params.bidFloor;
}
- // server response body is an array of bid results
- const bidResults = serverResponse.body;
- // our server directly returns the format needed by prebid.js so no more
- // transformation is needed here.
- return bidResults;
- },
-
- getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) {
- const syncArr = [];
- if (syncOptions.iframeEnabled) {
- let policyParam = '';
- if (gdprConsent && gdprConsent.consentString) {
- if (typeof gdprConsent.gdprApplies === 'boolean') {
- policyParam += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
- } else {
- policyParam += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`;
+ [VIDEO, BANNER].forEach(namespace => {
+ COMMON_PARAMS.forEach(param => {
+ if (bidRequest.params.hasOwnProperty(param)) {
+ utils.deepSetValue(imp, `${namespace}.${param}`, bidRequest.params[param])
}
+ })
+ })
+ return imp;
+ },
+ bidResponse(buildBidResponse, bid, context) {
+ const {bidRequest} = context;
+ const bidResponse = buildBidResponse(bid, context);
+ if (bidResponse.mediaType === BANNER) {
+ bidResponse.ad = bid.adm;
+ } else if (bidResponse.mediaType === VIDEO) {
+ if (bidRequest.mediaTypes.video.context === 'outstream') {
+ bidResponse.rendererUrl = VIDEO_RENDERER_URL;
+ bidResponse.renderer = createRenderer(bidRequest);
}
- if (uspConsent && uspConsent.consentString) {
- policyParam += `&ccpa_consent=${uspConsent.consentString}`;
- }
- const coppa = config.getConfig('coppa') ? 1 : 0;
- policyParam += `&coppa=${coppa}`;
- syncArr.push({
- type: 'iframe',
- url: IFRAMESYNC + policyParam
- });
- } else {
- syncArr.push({
- type: 'image',
- url: 'https://x.bidswitch.net/sync?ssp=tpmn'
- });
- syncArr.push({
- type: 'image',
- url: 'https://gocm.c.appier.net/tpmn'
- });
- syncArr.push({
- type: 'image',
- url: 'https://info.mmnneo.com/getGuidRedirect.info?url=https%3A%2F%2Fad.tpmn.co.kr%2Fcookiesync.tpmn%3Ftpmn_nid%3Dbf91e8b3b9d3f1af3fc1d657f090b4fb%26tpmn_buid%3D'
- });
- syncArr.push({
- type: 'image',
- url: 'https://sync.aralego.com/idSync?redirect=https%3A%2F%2Fad.tpmn.co.kr%2FpixelCt.tpmn%3Ftpmn_nid%3Dde91e8b3b9d3f1af3fc1d657f090b815%26tpmn_buid%3DSspCookieUserId'
- });
}
- return syncArr;
+ return bidResponse;
},
-};
+ overrides: {
+ imp: {
+ video(orig, imp, bidRequest, context) {
+ let videoParams = bidRequest.mediaTypes[VIDEO];
+ if (videoParams) {
+ videoParams = Object.assign({}, videoParams, bidRequest.params.video);
+ bidRequest = {...bidRequest, mediaTypes: {[VIDEO]: videoParams}}
+ }
+ orig(imp, bidRequest, context);
+ },
+ },
+ }
+});
-registerBidder(spec);
+function createRenderer(bid) {
+ const renderer = Renderer.install({
+ id: bid.bidId,
+ url: VIDEO_RENDERER_URL,
+ config: utils.deepAccess(bid, 'renderer.options'),
+ loaded: false,
+ adUnitCode: bid.adUnitCode
+ });
-/**
- * Creates site description object
- */
-function createSite(refInfo) {
- let url = parseUrl(refInfo.page || '');
- let site = {
- 'domain': url.hostname,
- 'page': url.protocol + '://' + url.hostname + url.pathname
- };
- if (refInfo.ref) {
- site.ref = refInfo.ref
- }
- let keywords = document.getElementsByTagName('meta')['keywords'];
- if (keywords && keywords.content) {
- site.keywords = keywords.content;
+ try {
+ renderer.setRender(outstreamRender);
+ } catch (err) {
+ utils.logWarn('Prebid Error calling setRender on renderer', err);
}
- return site;
+ return renderer;
}
-function parseSize(size) {
- let sizeObj = {}
- sizeObj.width = parseInt(size[0], 10);
- sizeObj.height = parseInt(size[1], 10);
- return sizeObj;
-}
+function outstreamRender(bid, doc) {
+ bid.renderer.push(() => {
+ const win = utils.getWindowFromDocument(doc) || window;
+ win.ANOutstreamVideo.renderAd({
+ sizes: [bid.playerWidth, bid.playerHeight],
+ targetId: bid.adUnitCode,
+ rendererOptions: bid.renderer.getConfig(),
+ adResponse: { content: bid.vastXml }
-function parseSizes(sizes) {
- if (Array.isArray(sizes[0])) { // is there several sizes ? (ie. [[728,90],[200,300]])
- return sizes.map(size => parseSize(size));
- }
- return [parseSize(sizes)]; // or a single one ? (ie. [728,90])
+ }, handleOutstreamRendererEvents.bind(null, bid));
+ });
}
-function getBannerSizes(bidRequest) {
- return parseSizes(deepAccess(bidRequest, 'mediaTypes.banner.sizes') || bidRequest.sizes);
+function handleOutstreamRendererEvents(bid, id, eventName) {
+ bid.renderer.handleVideoEvent({ id, eventName });
}
-function bidToRequest(bid) {
- const bidObj = {};
- bidObj.sizes = getBannerSizes(bid);
-
- bidObj.inventoryId = bid.params.inventoryId;
- bidObj.publisherId = bid.params.publisherId;
- bidObj.bidId = bid.bidId;
- bidObj.adUnitCode = bid.adUnitCode;
- // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
- bidObj.auctionId = bid.auctionId;
-
- return bidObj;
+function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) {
+ const syncArr = [];
+ if (syncOptions.iframeEnabled) {
+ let policyParam = '';
+ if (gdprConsent && gdprConsent.consentString) {
+ if (typeof gdprConsent.gdprApplies === 'boolean') {
+ policyParam += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
+ } else {
+ policyParam += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`;
+ }
+ }
+ if (uspConsent && uspConsent.consentString) {
+ policyParam += `&ccpa_consent=${uspConsent.consentString}`;
+ }
+ const coppa = config.getConfig('coppa') ? 1 : 0;
+ policyParam += `&coppa=${coppa}`;
+ syncArr.push({
+ type: 'iframe',
+ url: IFRAMESYNC + '?' + policyParam
+ });
+ } else {
+ syncArr.push({
+ type: 'image',
+ url: 'https://x.bidswitch.net/sync?ssp=tpmn'
+ });
+ syncArr.push({
+ type: 'image',
+ url: 'https://gocm.c.appier.net/tpmn'
+ });
+ syncArr.push({
+ type: 'image',
+ url: 'https://info.mmnneo.com/getGuidRedirect.info?url=https%3A%2F%2Fad.tpmn.co.kr%2Fcookiesync.tpmn%3Ftpmn_nid%3Dbf91e8b3b9d3f1af3fc1d657f090b4fb%26tpmn_buid%3D'
+ });
+ syncArr.push({
+ type: 'image',
+ url: 'https://sync.aralego.com/idSync?redirect=https%3A%2F%2Fad.tpmn.co.kr%2FpixelCt.tpmn%3Ftpmn_nid%3Dde91e8b3b9d3f1af3fc1d657f090b815%26tpmn_buid%3DSspCookieUserId'
+ });
+ }
+ return syncArr;
}
diff --git a/modules/tpmnBidAdapter.md b/modules/tpmnBidAdapter.md
index 8387528bb0f..3b016d7e5b2 100644
--- a/modules/tpmnBidAdapter.md
+++ b/modules/tpmnBidAdapter.md
@@ -11,10 +11,27 @@ Maintainer: develop@tpmn.co.kr
Connects to TPMN exchange for bids.
NOTE:
-- TPMN bid adapter only supports Banner at the moment.
+- TPMN bid adapter only supports MediaType BANNER, VIDEO.
- Multi-currency is not supported.
+- Please contact the TPMN sales team via email for "inventoryId" issuance.
-# Sample Ad Unit Config
+
+# Bid Parameters
+
+## bids.params (Banner, Video)
+***Pay attention to the case sensitivity.***
+
+{: .table .table-bordered .table-striped }
+| Name | Scope | Description | Example | Type |
+| -------------- | ----------- | ------------------------------------------ | ------------- | ------------ |
+| `inventoryId` | required | Ad Inventory id TPMN | 123 | Number |
+| `bidFloor` | recommended | Minimum price in USD. bidFloor applies to a specific unit. | 1.50 | Number |
+| `bcat` | optional | IAB 5.1 Content Categories | ['IAB7-39'] | [String] |
+| `badv` | optional | IAB Block list of advertisers by their domains | ['example.com'] | [String] |
+| `bapp` | optional | IAB Block list of applications | ['com.blocked'] | [String] |
+
+
+# Banner Ad Unit Config
```
var adUnits = [{
// Banner adUnit
@@ -22,16 +39,77 @@ NOTE:
mediaTypes: {
banner: {
sizes: [[300, 250], [320, 50]], // banner size
+ battr: [1,2,3] // optional
}
},
bids: [
{
bidder: 'tpmn',
params: {
- inventoryId: '1',
- publisherId: 'TPMN'
+ inventoryId: 1, // required
+ bidFloor: 2.0, // recommended
+ ... // bcat, badv, bapp // optional
}
}
]
}];
+```
+
+
+# mediaTypes Parameters
+
+## mediaTypes.banner
+
+The following banner parameters are supported here so publishers may fully declare their banner inventory:
+
+{: .table .table-bordered .table-striped }
+| Name | Scope | Description | Example | Type |
+| --------- | ------------| ----------------------------------------------------------------- | --------- | --------- |
+| `sizes` | required | Avalaible sizes supported for banner ad unit | [ [300, 250], [300, 600] ] | [[Integer, Integer], [Integer, Integer]] |
+| `battr` | optional | IAB 5.3 Creative Attributes | [1,2,3] | [Number] |
+## mediaTypes.video
+
+We support the following OpenRTB params that can be specified in `mediaTypes.video` or in `bids[].params.video`
+
+{: .table .table-bordered .table-striped }
+| Name | Scope | Description | Example | Type |
+| --------- | ------------| ----------------------------------------------------------------- | --------- | --------- |
+| `context` | required | instream or outstream |'outstream' | string |
+| `playerSize` | required | Avalaible sizes supported for video ad unit. | [[300, 250]] | [Integer, Integer] |
+| `mimes` | required | List of content MIME types supported by the player. | ['video/mp4']| [String]|
+| `protocols` | optional | Supported video bid response protocol values. | [2,3,5,6] | [integers]|
+| `api` | optional | Supported API framework values. | [2] | [integers] |
+| `maxduration` | optional | Maximum video ad duration in seconds. | 30 | Integer |
+| `minduration` | optional | Minimum video ad duration in seconds. | 6 | Integer |
+| `startdelay` | optional | Indicates the start delay in seconds for pre-roll, mid-roll, or post-roll ad placements. | 0 | Integer |
+| `placement` | optional | Placement type for the impression. | 1 | Integer |
+| `minbitrate` | optional | Minimum bit rate in Kbps. | 300 | Integer |
+| `maxbitrate` | optional | Maximum bit rate in Kbps. | 9600 | Integer |
+| `playbackmethod` | optional | Playback methods that may be in use. Only one method is typically used in practice. | [2]| [Integers] |
+| `linearity` | optional | OpenRTB2 linearity. in-strea,overlay... | 1 | Integer |
+| `skip` | optional | Indicates if the player will allow the video to be skipped, where 0 = no, 1 = yes . | 1 | Integer |
+| `battr` | optional | IAB 5.3 Creative Attributes | [1,2,3] | [Number] |
+
+
+# Video Ad Unit Config
+```
+ var adUnits = [{
+ code: 'video-div',
+ mediaTypes: {
+ video: {
+ context: 'instream', // required
+ mimes: ['video/mp4'], // required
+ playerSize: [[ 640, 480 ]], // required
+ ... // skippable, startdelay, battr.. // optional
+ }
+ },
+ bids: [{
+ bidder: 'tpmn',
+ params: {
+ inventoryId: 2, // required
+ bidFloor: 2.0, // recommended
+ ... // bcat, badv, bapp // optional
+ }
+ }]
+ }];
```
\ No newline at end of file
diff --git a/modules/uid2IdSystem.js b/modules/uid2IdSystem.js
index d3b35a5a1aa..b9b3dfa2380 100644
--- a/modules/uid2IdSystem.js
+++ b/modules/uid2IdSystem.js
@@ -7,7 +7,7 @@
*/
import { logInfo, logWarn } from '../src/utils.js';
-import {submodule} from '../src/hook.js';
+import { submodule } from '../src/hook.js';
import {getStorageManager} from '../src/storageManager.js';
import {MODULE_TYPE_UID} from '../src/activities/modules.js';
@@ -33,6 +33,19 @@ function createLogger(logger, prefix) {
logger(prefix + ' ', ...strings);
}
}
+
+function extractIdentityFromParams(params) {
+ const keysToCheck = ['emailHash', 'phoneHash', 'email', 'phone'];
+
+ for (let key of keysToCheck) {
+ if (params.hasOwnProperty(key)) {
+ return { [key]: params[key] };
+ }
+ }
+
+ return {};
+}
+
const _logInfo = createLogger(logInfo, LOG_PRE_FIX);
const _logWarn = createLogger(logWarn, LOG_PRE_FIX);
@@ -79,6 +92,14 @@ export const uid2IdSubmodule = {
clientId: UID2_CLIENT_ID,
internalStorage: ADVERTISING_COOKIE
}
+
+ if (FEATURES.UID2_CSTG) {
+ mappedConfig.cstg = {
+ serverPublicKey: config?.params?.serverPublicKey,
+ subscriptionId: config?.params?.subscriptionId,
+ ...extractIdentityFromParams(config?.params ?? {})
+ }
+ }
_logInfo(`UID2 configuration loaded and mapped.`, mappedConfig);
const result = Uid2GetId(mappedConfig, storage, _logInfo, _logWarn);
_logInfo(`UID2 getId returned`, result);
diff --git a/modules/uid2IdSystem.md b/modules/uid2IdSystem.md
index a795d9b1aa1..e546f6eafe1 100644
--- a/modules/uid2IdSystem.md
+++ b/modules/uid2IdSystem.md
@@ -1,11 +1,63 @@
## UID2 User ID Submodule
-UID2 requires initial tokens to be generated server-side. The UID2 module handles storing, providing, and optionally refreshing them. The module can operate in one of two different modes: *Client Refresh* mode or *Server Only* mode.
+The UID2 module handles storing, providing, and optionally refreshing tokens. While initial tokens traditionally required server-side generation, the introduction of the *Client-Side Token Generation (CSTG)* mode offers publishers the flexibility to generate UID2 tokens directly from the module, eliminating this need. Publishers can choose to operate the module in one of three distinct modes: *Client Refresh* mode, *Server Only* mode and *Client-Side Token Generation* mode.
*Server Only* mode was originally referred to as *legacy mode*, but it is a popular mode for new integrations where publishers prefer to handle token refresh server-side.
+*Client-Side Token Generation* mode is included in UID2 module by default. However, it's important to note that this mode is created and made available recently. For publishers who do not intend to use it, you have the option to instruct the build to exclude the code related to this feature:
+
+```
+ $ gulp build --modules=uid2IdSystem --disable UID2_CSTG
+```
+If you do plan to use Client-Side Token Generation (CSTG) mode, please consult the UID2 Team first as they will provide required configuration values for you to use (see the Client-Side Token Generation (CSTG) mode section below for details)
+
**Important information:** UID2 is not designed to be used where GDPR applies. The module checks the passed-in consent data and will not operate if the `gdprApplies` flag is true.
+## Client-Side Token Generation (CSTG) mode
+
+**This mode is created and made available recently. Please consult UID2 Team first as they will provide required configuration values for you to use.**
+
+For publishers seeking a purely client-side integration without the complexities of server-side involvement, the CSTG mode is highly recommended. This mode requires the provision of a public key, subscription ID and [directly identifying information (DII)](https://unifiedid.com/docs/ref-info/glossary-uid#gl-dii) - either emails or phone numbers. In the CSTG mode, the module takes on the responsibility of encrypting the DII, generating the UID2 token, and handling token refreshes when necessary.
+
+To configure the module to use this mode, you must:
+1. Set `parmas.serverPublicKey` and `params.subscriptionId` (please reach out to the UID2 team to obtain these values)
+2. Provide **ONLY ONE DII** by setting **ONLY ONE** of `params.email`/`params.phone`/`params.emailHash`/`params.phoneHash`
+
+Below is a table that provides guidance on when to use each directly identifying information (DII) parameter, along with information on whether normalization and hashing are required by the publisher for each parameter.
+
+| DII param | When to use it | Normalization required by publisher? | Hashing required by publisher? |
+|------------------|-------------------------------------------------------|--------------------------------------|--------------------------------|
+| params.email | When you have users' email address | No | No |
+| params.phone | When you have user's phone number | Yes | No |
+| params.emailHash | When you have user's hashed, normalized email address | Yes | Yes |
+| params.phoneHash | When you have user's hashed, normalized phone number | Yes | Yes |
+
+
+*Note that setting params.email will normalize email addresses, but params.phone requires phone numbers to be normalized.*
+
+Refer to [Normalization and Encoding](#normalization-and-encoding) for details on email address normalization, SHA-256 hashing and Base64 encoding.
+
+### CSTG example
+
+Configuration:
+```
+pbjs.setConfig({
+ userSync: {
+ userIds: [{
+ name: 'uid2',
+ params: {
+ serverPublicKey: '...server public key...',
+ subscriptionId: '...subcription id...',
+ email: 'user@email.com',
+ //phone: '+0000000',
+ //emailHash: '...email hash...',
+ //phoneHash: '...phone hash ...'
+ }
+ }]
+ }
+});
+```
+
## Client Refresh mode
This is the recommended mode for most scenarios. In this mode, the full response body from the UID2 Token Generate or Token Refresh endpoint must be provided to the module. As long as the refresh token remains valid, the module will refresh the advertising token as needed.
@@ -133,3 +185,80 @@ The below parameters apply only to the UID2 User ID Module integration.
| params.uid2Cookie | Optional, Client refresh | String | The name of a cookie which holds the initial UID2 token, set by the server. The cookie should contain JSON in the same format as the uid2Token param. **If uid2Token is supplied, this param is ignored.** | See the sample token above. |
| params.uid2ApiBase | Optional, Client refresh | String | Overrides the default UID2 API endpoint. | `"https://prod.uidapi.com"` _(default)_|
| params.storage | Optional, Client refresh | String | Specify whether to use `cookie` or `localStorage` for module-internal storage. It is recommended to not provide this and allow the module to use the default. | `localStorage` _(default)_ |
+| params.serverPublicKey | Optional, Client-side token generation | String | A public key for encrypting the DII payload for the Operator's CSTG endpoint. **This is required for client-side token generation.** | - |
+| params.subscriptionId | Optional, Client-side token generation | String | A publisher Identifier. **This is required for client-side token generation.** | - |
+| params.email | Optional, Client-side token generation | String | The user's email address. Provide this parameter if using email as the DII. | `"test@example.com"` |
+| params.emailHash | Optional, Client-side token generation | String | A hashed, normalized representation of the user's email. Provide this parameter if using emailHash as the DII. | `"tMmiiTI7IaAcPpQPFQ65uMVCWH8av9jw4cwf/F5HVRQ="` |
+| params.phone | Optional, Client-side token generation | String | The user's phone number. Provide this parameter if using phone as the DII. | `"+15555555555"` |
+| params.phoneHash | Optional, Client-side token generation | String | A hashed, normalized representation of the user's phone number. Provide this parameter if using phoneHash as the DII. | `"tMmiiTI7IaAcPpQPFQ65uMVCWH8av9jw4cwf/F5HVRQ="` |
+
+# Normalization and Encoding
+
+This section provides information about normalizing and encoding [directly Identifying information (DII)](https://unifiedid.com/docs/ref-info/glossary-uid#gl-dii). It's important that, in working with UID2, normalizing and encoding are performed correctly.
+
+## Introduction
+When you're taking user information such as an email address, and following the steps to create a raw UID2 and/or a UID2 advertising token, it's very important that you follow all the required steps. Whether you normalize the information or not, whether you hash it or not, follow the steps exactly. By doing so, you can ensure that the UID2 value you create can be securely and anonymously matched up with other instances of online behavior by the same user.
+
+>Note: Raw UID2s, and their associated UID2 tokens, are case sensitive. When working with UID2, it's important to pass all IDs and tokens without changing the case. Mismatched IDs can cause ID parsing or token decryption errors.
+
+## Types of Directly Identifying Information
+UID2 supports the following types of directly identifying information (DII):
+- Email address
+- Phone number
+
+## Email Address Normalization
+
+If you send unhashed email addresses to the UID2 Operator Service, the service normalizes the email addresses and then hashes them. If you want to hash the email addresses yourself before sending them, you must normalize them before you hash them.
+
+> IMPORTANT: Normalizing before hashing ensures that the generated UID2 value will always be the same, so that the data can be matched. If you do not normalize before hashing, this might result in a different UID2, reducing the effectiveness of targeted advertising.
+
+To normalize an email address, complete the following steps:
+
+1. Remove leading and trailing spaces.
+2. Convert all ASCII characters to lowercase.
+3. In `gmail.com` email addresses, remove the following characters from the username part of the email address:
+ 1. The period (`.` (ASCII code 46)).
For example, normalize `jane.doe@gmail.com` to `janedoe@gmail.com`.
+ 2. The plus sign (`+` (ASCII code 43)) and all subsequent characters.
For example, normalize `janedoe+home@gmail.com` to `janedoe@gmail.com`.
+
+## Email Address Hash Encoding
+
+An email hash is a Base64-encoded SHA-256 hash of a normalized email address. The email address is first normalized, then hashed using the SHA-256 hashing algorithm, and then the resulting bytes of the hash value are encoded using Base64 encoding. Note that the bytes of the hash value are encoded, not the hex-encoded string representation.
+
+| Type | Example | Comments and Usage |
+| :--- | :--- | :--- |
+| Normalized email address | `user@example.com` | Normalization is always the first step. |
+| SHA-256 hash of normalized email address | `b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514` | This 64-character string is a hex-encoded representation of the 32-byte SHA-256.|
+| Hex to Base64 SHA-256 encoding of normalized email address | `tMmiiTI7IaAcPpQPFQ65uMVCWH8av9jw4cwf/F5HVRQ=` | This 44-character string is a Base64-encoded representation of the 32-byte SHA-256.
WARNING: The SHA-256 hash string in the example above is a hex-encoded representation of the hash value. You must Base64-encode the raw bytes of the hash or use a Base64 encoder that takes a hex-encoded value as input.
Use this encoding for `email_hash` values sent in the request body. |
+
+>WARNING: When applying Base64 encoding, be sure to Base64-encode the raw bytes of the hash or use a Base64 encoder that takes a hex-encoded value as input.
+
+## Phone Number Normalization
+
+If you send unhashed phone numbers to the UID2 Operator Service, the service normalizes the phone numbers and then hashes them. If you want to hash the phone numbers yourself before sending them, you must normalize them before you hash them.
+
+> IMPORTANT: Normalization before hashing ensures that the generated UID2 value will always be the same, so that the data can be matched. If you do not normalize before hashing, this might result in a different UID2, reducing the effectiveness of targeted advertising.
+
+Here's what you need to know about phone number normalization rules:
+
+- The UID2 Operator accepts phone numbers in the [E.164](https://en.wikipedia.org/wiki/E.164) format, which is the international phone number format that ensures global uniqueness.
+- E.164 phone numbers can have a maximum of 15 digits.
+- Normalized E.164 phone numbers use the following syntax, with no spaces, hyphens, parentheses, or other special characters:
+ `[+] [country code] [subscriber number including area code]`
+ Examples:
+ - US: `1 (123) 456-7890` is normalized to `+11234567890`.
+ - Singapore: `65 1243 5678` is normalized to `+6512345678`.
+ - Sydney, Australia: `(02) 1234 5678` is normalized to drop the leading zero for the city plus include the country code: `+61212345678`.
+
+## Phone Number Hash Encoding
+
+A phone number hash is a Base64-encoded SHA-256 hash of a normalized phone number. The phone number is first normalized, then hashed using the SHA-256 hashing algorithm, and the resulting hex value is encoded using Base64 encoding.
+
+The example below shows a simple input phone number, and the result as each step is applied to arrive at a secure, opaque, URL-safe value.
+
+| Type | Example | Comments and Usage |
+| :--- | :--- | :--- |
+| Normalized phone number | `+12345678901` | Normalization is always the first step. |
+| SHA-256 hash of normalized phone number | `10e6f0b47054a83359477dcb35231db6de5c69fb1816e1a6b98e192de9e5b9ee` |This 64-character string is a hex-encoded representation of the 32-byte SHA-256. |
+| Hex to Base64 SHA-256 encoding of normalized and hashed phone number | `EObwtHBUqDNZR33LNSMdtt5cafsYFuGmuY4ZLenlue4=` | This 44-character string is a Base64-encoded representation of the 32-byte SHA-256.
NOTE: The SHA-256 hash is a hexadecimal value. You must use a Base64 encoder that takes a hex value as input. Use this encoding for `phone_hash` values sent in the request body. |
+
+>WARNING: When applying Base64 encoding, be sure to use a function that takes a hex value as input. If you use a function that takes text as input, the result is a longer string which is invalid for the purposes of UID2.
diff --git a/modules/uid2IdSystem_shared.js b/modules/uid2IdSystem_shared.js
index 0f6894a9d3e..29837c5f012 100644
--- a/modules/uid2IdSystem_shared.js
+++ b/modules/uid2IdSystem_shared.js
@@ -1,4 +1,7 @@
/* eslint-disable no-console */
+import { ajax } from '../src/ajax.js';
+import { cyrb53Hash } from '../src/utils.js';
+
export const Uid2CodeVersion = '1.1';
function isValidIdentity(identity) {
@@ -13,6 +16,7 @@ export class Uid2ApiClient {
this._logInfo = logInfo;
this._logWarn = logWarn;
}
+
createArrayBuffer(text) {
const arrayBuffer = new Uint8Array(text.length);
for (let i = 0; i < text.length; i++) {
@@ -36,49 +40,58 @@ export class Uid2ApiClient {
}
callRefreshApi(refreshDetails) {
const url = this._baseUrl + '/v2/token/refresh';
- const req = new XMLHttpRequest();
- req.overrideMimeType('text/plain');
- req.open('POST', url, true);
- req.setRequestHeader('X-UID2-Client-Version', this._clientVersion);
let resolvePromise;
let rejectPromise;
const promise = new Promise((resolve, reject) => {
resolvePromise = resolve;
rejectPromise = reject;
});
- req.onreadystatechange = () => {
- if (req.readyState !== req.DONE) { return; }
- try {
- if (!refreshDetails.refresh_response_key || req.status !== 200) {
- this._logInfo('Error status OR no response decryption key available, assuming unencrypted JSON');
- const response = JSON.parse(req.responseText);
+ this._logInfo('Sending refresh request', refreshDetails);
+ ajax(url, {
+ success: (responseText) => {
+ try {
+ if (!refreshDetails.refresh_response_key) {
+ this._logInfo('No response decryption key available, assuming unencrypted JSON');
+ const response = JSON.parse(responseText);
+ const result = this.ResponseToRefreshResult(response);
+ if (typeof result === 'string') { rejectPromise(result); } else { resolvePromise(result); }
+ } else {
+ this._logInfo('Decrypting refresh API response');
+ const encodeResp = this.createArrayBuffer(atob(responseText));
+ window.crypto.subtle.importKey('raw', this.createArrayBuffer(atob(refreshDetails.refresh_response_key)), { name: 'AES-GCM' }, false, ['decrypt']).then((key) => {
+ this._logInfo('Imported decryption key')
+ // returns the symmetric key
+ window.crypto.subtle.decrypt({
+ name: 'AES-GCM',
+ iv: encodeResp.slice(0, 12),
+ tagLength: 128, // The tagLength you used to encrypt (if any)
+ }, key, encodeResp.slice(12)).then((decrypted) => {
+ const decryptedResponse = String.fromCharCode(...new Uint8Array(decrypted));
+ this._logInfo('Decrypted to:', decryptedResponse);
+ const response = JSON.parse(decryptedResponse);
+ const result = this.ResponseToRefreshResult(response);
+ if (typeof result === 'string') { rejectPromise(result); } else { resolvePromise(result); }
+ }, (reason) => this._logWarn(`Call to UID2 API failed`, reason));
+ }, (reason) => this._logWarn(`Call to UID2 API failed`, reason));
+ }
+ } catch (_err) {
+ rejectPromise(responseText);
+ }
+ },
+ error: (error, xhr) => {
+ try {
+ this._logInfo('Error status, assuming unencrypted JSON');
+ const response = JSON.parse(xhr.responseText);
const result = this.ResponseToRefreshResult(response);
if (typeof result === 'string') { rejectPromise(result); } else { resolvePromise(result); }
- } else {
- this._logInfo('Decrypting refresh API response');
- const encodeResp = this.createArrayBuffer(atob(req.responseText));
- window.crypto.subtle.importKey('raw', this.createArrayBuffer(atob(refreshDetails.refresh_response_key)), { name: 'AES-GCM' }, false, ['decrypt']).then((key) => {
- this._logInfo('Imported decryption key')
- // returns the symmetric key
- window.crypto.subtle.decrypt({
- name: 'AES-GCM',
- iv: encodeResp.slice(0, 12),
- tagLength: 128, // The tagLength you used to encrypt (if any)
- }, key, encodeResp.slice(12)).then((decrypted) => {
- const decryptedResponse = String.fromCharCode(...new Uint8Array(decrypted));
- this._logInfo('Decrypted to:', decryptedResponse);
- const response = JSON.parse(decryptedResponse);
- const result = this.ResponseToRefreshResult(response);
- if (typeof result === 'string') { rejectPromise(result); } else { resolvePromise(result); }
- }, (reason) => this._logWarn(`Call to UID2 API failed`, reason));
- }, (reason) => this._logWarn(`Call to UID2 API failed`, reason));
+ } catch (_e) {
+ rejectPromise(error)
}
- } catch (err) {
- rejectPromise(err);
}
- };
- this._logInfo('Sending refresh request', refreshDetails);
- req.send(refreshDetails.refresh_token);
+ }, refreshDetails.refresh_token, { method: 'POST',
+ customHeaders: {
+ 'X-UID2-Client-Version': this._clientVersion
+ } });
return promise;
}
}
@@ -160,18 +173,507 @@ function refreshTokenAndStore(baseUrl, token, clientId, storageManager, _logInfo
originalToken: token,
latestToken: response.identity,
};
+ let storedTokens = storageManager.getStoredValueWithFallback();
+ if (storedTokens?.originalIdentity) tokens.originalIdentity = storedTokens.originalIdentity;
storageManager.storeValue(tokens);
return tokens;
});
}
+let clientSideTokenGenerator;
+if (FEATURES.UID2_CSTG) {
+ const SERVER_PUBLIC_KEY_PREFIX_LENGTH = 9;
+
+ clientSideTokenGenerator = {
+ isCSTGOptionsValid(maybeOpts, _logWarn) {
+ if (typeof maybeOpts !== 'object' || maybeOpts === null) {
+ _logWarn('CSTG opts must be an object');
+ return false;
+ }
+
+ const opts = maybeOpts;
+ if (typeof opts.serverPublicKey !== 'string') {
+ _logWarn('CSTG opts.serverPublicKey must be a string');
+ return false;
+ }
+ const serverPublicKeyPrefix = /^UID2-X-[A-Z]-.+/;
+ if (!serverPublicKeyPrefix.test(opts.serverPublicKey)) {
+ _logWarn(
+ `CSTG opts.serverPublicKey must match the regular expression ${serverPublicKeyPrefix}`
+ );
+ return false;
+ }
+ // We don't do any further validation of the public key, as we will find out
+ // later if it's valid by using importKey.
+
+ if (typeof opts.subscriptionId !== 'string') {
+ _logWarn('CSTG opts.subscriptionId must be a string');
+ return false;
+ }
+ if (opts.subscriptionId.length === 0) {
+ _logWarn('CSTG opts.subscriptionId is empty');
+ return false;
+ }
+ return true;
+ },
+
+ getValidIdentity(opts, _logWarn) {
+ if (opts.emailHash) {
+ if (!UID2DiiNormalization.isBase64Hash(opts.emailHash)) {
+ _logWarn('CSTG opts.emailHash is invalid');
+ return;
+ }
+ return { email_hash: opts.emailHash };
+ }
+
+ if (opts.phoneHash) {
+ if (!UID2DiiNormalization.isBase64Hash(opts.phoneHash)) {
+ _logWarn('CSTG opts.phoneHash is invalid');
+ return;
+ }
+ return { phone_hash: opts.phoneHash };
+ }
+
+ if (opts.email) {
+ const normalizedEmail = UID2DiiNormalization.normalizeEmail(opts.email);
+ if (normalizedEmail === undefined) {
+ _logWarn('CSTG opts.email is invalid');
+ return;
+ }
+ return { email: normalizedEmail };
+ }
+
+ if (opts.phone) {
+ if (!UID2DiiNormalization.isNormalizedPhone(opts.phone)) {
+ _logWarn('CSTG opts.phone is invalid');
+ return;
+ }
+ return { phone: opts.phone };
+ }
+ },
+
+ isStoredTokenInvalid(cstgIdentity, storedTokens, _logInfo, _logWarn) {
+ if (storedTokens) {
+ const identity = Object.values(cstgIdentity)[0];
+ if (!this.isStoredTokenFromSameIdentity(storedTokens, identity)) {
+ _logInfo(
+ 'CSTG supplied new identity - ignoring stored value.',
+ storedTokens.originalIdentity,
+ cstgIdentity
+ );
+ // Stored token wasn't originally sourced from the provided identity - ignore the stored value. A new user has logged in?
+ return true;
+ }
+ }
+ return false;
+ },
+
+ async generateTokenAndStore(
+ baseUrl,
+ cstgOpts,
+ cstgIdentity,
+ storageManager,
+ _logInfo,
+ _logWarn
+ ) {
+ _logInfo('UID2 cstg opts provided: ', JSON.stringify(cstgOpts));
+ const client = new UID2CstgApiClient(
+ { baseUrl, cstg: cstgOpts },
+ _logInfo,
+ _logWarn
+ );
+ const response = await client.generateToken(cstgIdentity);
+ _logInfo('CSTG endpoint responded with:', response);
+ const tokens = {
+ originalIdentity: this.encodeOriginalIdentity(cstgIdentity),
+ latestToken: response.identity,
+ };
+ storageManager.storeValue(tokens);
+ return tokens;
+ },
+
+ isStoredTokenFromSameIdentity(storedTokens, identity) {
+ if (!storedTokens.originalIdentity) return false;
+ return (
+ cyrb53Hash(identity, storedTokens.originalIdentity.salt) ===
+ storedTokens.originalIdentity.identity
+ );
+ },
+
+ encodeOriginalIdentity(identity) {
+ const identityValue = Object.values(identity)[0];
+ const salt = Math.floor(Math.random() * Math.pow(2, 32));
+ return {
+ identity: cyrb53Hash(identityValue, salt),
+ salt,
+ };
+ },
+ };
+
+ class UID2DiiNormalization {
+ static EMAIL_EXTENSION_SYMBOL = '+';
+ static EMAIL_DOT = '.';
+ static GMAIL_DOMAIN = 'gmail.com';
+
+ static isBase64Hash(value) {
+ if (!(value && value.length === 44)) {
+ return false;
+ }
+
+ try {
+ return btoa(atob(value)) === value;
+ } catch (err) {
+ return false;
+ }
+ }
+
+ static isNormalizedPhone(phone) {
+ return /^\+[0-9]{10,15}$/.test(phone);
+ }
+
+ static normalizeEmail(email) {
+ if (!email || !email.length) return;
+
+ const parsedEmail = email.trim().toLowerCase();
+ if (parsedEmail.indexOf(' ') > 0) return;
+
+ const emailParts = this.splitEmailIntoAddressAndDomain(parsedEmail);
+ if (!emailParts) return;
+
+ const { address, domain } = emailParts;
+
+ const emailIsGmail = this.isGmail(domain);
+ const parsedAddress = this.normalizeAddressPart(
+ address,
+ emailIsGmail,
+ emailIsGmail
+ );
+
+ return parsedAddress ? `${parsedAddress}@${domain}` : undefined;
+ }
+
+ static splitEmailIntoAddressAndDomain(email) {
+ const parts = email.split('@');
+ if (
+ parts.length !== 2 ||
+ parts.some((part) => part === '')
+ ) { return; }
+
+ return {
+ address: parts[0],
+ domain: parts[1],
+ };
+ }
+
+ static isGmail(domain) {
+ return domain === this.GMAIL_DOMAIN;
+ }
+
+ static dropExtension(address, extensionSymbol = this.EMAIL_EXTENSION_SYMBOL) {
+ return address.split(extensionSymbol)[0];
+ }
+
+ static normalizeAddressPart(address, shouldRemoveDot, shouldDropExtension) {
+ let parsedAddress = address;
+ if (shouldRemoveDot) { parsedAddress = parsedAddress.replaceAll(this.EMAIL_DOT, ''); }
+ if (shouldDropExtension) parsedAddress = this.dropExtension(parsedAddress);
+ return parsedAddress;
+ }
+ }
+
+ class UID2CstgApiClient {
+ constructor(opts, logInfo, logWarn) {
+ this._baseUrl = opts.baseUrl;
+ this._serverPublicKey = opts.cstg.serverPublicKey;
+ this._subscriptionId = opts.cstg.subscriptionId;
+ this._logInfo = logInfo;
+ this._logWarn = logWarn;
+ }
+
+ hasStatusResponse(response) {
+ return typeof response === 'object' && response && response.status;
+ }
+
+ isCstgApiSuccessResponse(response) {
+ return (
+ this.hasStatusResponse(response) &&
+ response.status === 'success' &&
+ isValidIdentity(response.body)
+ );
+ }
+
+ isCstgApiClientErrorResponse(response) {
+ return (
+ this.hasStatusResponse(response) &&
+ response.status === 'client_error' &&
+ typeof response.message === 'string'
+ );
+ }
+
+ isCstgApiForbiddenResponse(response) {
+ return (
+ this.hasStatusResponse(response) &&
+ response.status === 'invalid_http_origin' &&
+ typeof response.message === 'string'
+ );
+ }
+
+ stripPublicKeyPrefix(serverPublicKey) {
+ return serverPublicKey.substring(SERVER_PUBLIC_KEY_PREFIX_LENGTH);
+ }
+
+ async generateCstgRequest(cstgIdentity) {
+ if ('email_hash' in cstgIdentity || 'phone_hash' in cstgIdentity) {
+ return cstgIdentity;
+ }
+ if ('email' in cstgIdentity) {
+ const emailHash = await UID2CstgCrypto.hash(cstgIdentity.email);
+ return { email_hash: emailHash };
+ }
+ if ('phone' in cstgIdentity) {
+ const phoneHash = await UID2CstgCrypto.hash(cstgIdentity.phone);
+ return { phone_hash: phoneHash };
+ }
+ }
+
+ async generateToken(cstgIdentity) {
+ const request = await this.generateCstgRequest(cstgIdentity);
+ this._logInfo('Building CSTG request for', request);
+ const box = await UID2CstgBox.build(
+ this.stripPublicKeyPrefix(this._serverPublicKey)
+ );
+ const encoder = new TextEncoder();
+ const now = Date.now();
+ const { iv, ciphertext } = await box.encrypt(
+ encoder.encode(JSON.stringify(request)),
+ encoder.encode(JSON.stringify([now]))
+ );
+
+ const exportedPublicKey = await UID2CstgCrypto.exportPublicKey(
+ box.clientPublicKey
+ );
+ const requestBody = {
+ payload: UID2CstgCrypto.bytesToBase64(new Uint8Array(ciphertext)),
+ iv: UID2CstgCrypto.bytesToBase64(new Uint8Array(iv)),
+ public_key: UID2CstgCrypto.bytesToBase64(
+ new Uint8Array(exportedPublicKey)
+ ),
+ timestamp: now,
+ subscription_id: this._subscriptionId,
+ };
+ return this.callCstgApi(requestBody, box);
+ }
+
+ async callCstgApi(requestBody, box) {
+ const url = this._baseUrl + '/v2/token/client-generate';
+ let resolvePromise;
+ let rejectPromise;
+ const promise = new Promise((resolve, reject) => {
+ resolvePromise = resolve;
+ rejectPromise = reject;
+ });
+
+ this._logInfo('Sending CSTG request', requestBody);
+ ajax(
+ url,
+ {
+ success: async (responseText, xhr) => {
+ try {
+ const encodedResp = UID2CstgCrypto.base64ToBytes(responseText);
+ const decrypted = await box.decrypt(
+ encodedResp.slice(0, 12),
+ encodedResp.slice(12)
+ );
+ const decryptedResponse = new TextDecoder().decode(decrypted);
+ const response = JSON.parse(decryptedResponse);
+ if (this.isCstgApiSuccessResponse(response)) {
+ resolvePromise({
+ status: 'success',
+ identity: response.body,
+ });
+ } else {
+ // A 200 should always be a success response.
+ // Something has gone wrong.
+ rejectPromise(
+ `API error: Response body was invalid for HTTP status 200: ${decryptedResponse}`
+ );
+ }
+ } catch (err) {
+ rejectPromise(err);
+ }
+ },
+ error: (error, xhr) => {
+ try {
+ if (xhr.status === 400) {
+ const response = JSON.parse(xhr.responseText);
+ if (this.isCstgApiClientErrorResponse(response)) {
+ rejectPromise(`Client error: ${response.message}`);
+ } else {
+ // A 400 should always be a client error.
+ // Something has gone wrong.
+ rejectPromise(
+ `API error: Response body was invalid for HTTP status 400: ${xhr.responseText}`
+ );
+ }
+ } else if (xhr.status === 403) {
+ const response = JSON.parse(xhr.responseText);
+ if (this.isCstgApiForbiddenResponse(xhr)) {
+ rejectPromise(`Forbidden: ${response.message}`);
+ } else {
+ // A 403 should always be a forbidden response.
+ // Something has gone wrong.
+ rejectPromise(
+ `API error: Response body was invalid for HTTP status 403: ${xhr.responseText}`
+ );
+ }
+ } else {
+ rejectPromise(
+ `API error: Unexpected HTTP status ${xhr.status}: ${error}`
+ );
+ }
+ } catch (_e) {
+ rejectPromise(error);
+ }
+ },
+ },
+ JSON.stringify(requestBody),
+ { method: 'POST' }
+ );
+ return promise;
+ }
+ }
+
+ class UID2CstgBox {
+ static _namedCurve = 'P-256';
+ constructor(clientPublicKey, sharedKey) {
+ this._clientPublicKey = clientPublicKey;
+ this._sharedKey = sharedKey;
+ }
+
+ static async build(serverPublicKey) {
+ const clientKeyPair = await UID2CstgCrypto.generateKeyPair(
+ UID2CstgBox._namedCurve
+ );
+ const importedServerPublicKey = await UID2CstgCrypto.importPublicKey(
+ serverPublicKey,
+ this._namedCurve
+ );
+ const sharedKey = await UID2CstgCrypto.deriveKey(
+ importedServerPublicKey,
+ clientKeyPair.privateKey
+ );
+ return new UID2CstgBox(clientKeyPair.publicKey, sharedKey);
+ }
+
+ async encrypt(plaintext, additionalData) {
+ const iv = window.crypto.getRandomValues(new Uint8Array(12));
+ const ciphertext = await window.crypto.subtle.encrypt(
+ {
+ name: 'AES-GCM',
+ iv,
+ additionalData,
+ },
+ this._sharedKey,
+ plaintext
+ );
+ return { iv, ciphertext };
+ }
+
+ async decrypt(iv, ciphertext) {
+ return window.crypto.subtle.decrypt(
+ {
+ name: 'AES-GCM',
+ iv,
+ },
+ this._sharedKey,
+ ciphertext
+ );
+ }
+
+ get clientPublicKey() {
+ return this._clientPublicKey;
+ }
+ }
+
+ class UID2CstgCrypto {
+ static base64ToBytes(base64) {
+ const binString = atob(base64);
+ return Uint8Array.from(binString, (m) => m.codePointAt(0));
+ }
+
+ static bytesToBase64(bytes) {
+ const binString = Array.from(bytes, (x) => String.fromCodePoint(x)).join(
+ ''
+ );
+ return btoa(binString);
+ }
+
+ static async generateKeyPair(namedCurve) {
+ const params = {
+ name: 'ECDH',
+ namedCurve: namedCurve,
+ };
+ return window.crypto.subtle.generateKey(params, false, ['deriveKey']);
+ }
+
+ static async importPublicKey(publicKey, namedCurve) {
+ const params = {
+ name: 'ECDH',
+ namedCurve: namedCurve,
+ };
+ return window.crypto.subtle.importKey(
+ 'spki',
+ this.base64ToBytes(publicKey),
+ params,
+ false,
+ []
+ );
+ }
+
+ static exportPublicKey(publicKey) {
+ return window.crypto.subtle.exportKey('spki', publicKey);
+ }
+
+ static async deriveKey(serverPublicKey, clientPrivateKey) {
+ return window.crypto.subtle.deriveKey(
+ {
+ name: 'ECDH',
+ public: serverPublicKey,
+ },
+ clientPrivateKey,
+ {
+ name: 'AES-GCM',
+ length: 256,
+ },
+ false,
+ ['encrypt', 'decrypt']
+ );
+ }
+
+ static async hash(value) {
+ const hash = await window.crypto.subtle.digest(
+ 'SHA-256',
+ new TextEncoder().encode(value)
+ );
+ return this.bytesToBase64(new Uint8Array(hash));
+ }
+ }
+}
+
export function Uid2GetId(config, prebidStorageManager, _logInfo, _logWarn) {
let suppliedToken = null;
const preferLocalStorage = (config.storage !== 'cookie');
const storageManager = new Uid2StorageManager(prebidStorageManager, preferLocalStorage, config.internalStorage, _logInfo);
_logInfo(`Module is using ${preferLocalStorage ? 'local storage' : 'cookies'} for internal storage.`);
- if (config.paramToken) {
+ const isCstgEnabled =
+ clientSideTokenGenerator &&
+ clientSideTokenGenerator.isCSTGOptionsValid(config.cstg, _logWarn);
+ if (isCstgEnabled) {
+ _logInfo(`Module is using client-side token generation.`);
+ // Ignores config.paramToken and config.serverCookieName if any is provided
+ suppliedToken = null;
+ } else if (config.paramToken) {
suppliedToken = config.paramToken;
_logInfo('Read token from params', suppliedToken);
} else if (config.serverCookieName) {
@@ -184,7 +686,7 @@ export function Uid2GetId(config, prebidStorageManager, _logInfo, _logWarn) {
if (storedTokens && typeof storedTokens === 'string') {
// Stored value is a plain token - if no token is supplied, just use the stored value.
- if (!suppliedToken) {
+ if (!suppliedToken && !isCstgEnabled) {
_logInfo('Returning legacy cookie value.');
return { id: storedTokens };
}
@@ -200,11 +702,31 @@ export function Uid2GetId(config, prebidStorageManager, _logInfo, _logWarn) {
storedTokens = null;
}
}
- // At this point, any legacy values or superseded stored tokens have been nulled out.
+
+ if (FEATURES.UID2_CSTG && isCstgEnabled) {
+ const cstgIdentity = clientSideTokenGenerator.getValidIdentity(config.cstg, _logWarn);
+ if (cstgIdentity) {
+ if (storedTokens && clientSideTokenGenerator.isStoredTokenInvalid(cstgIdentity, storedTokens, _logInfo, _logWarn)) {
+ storedTokens = null;
+ }
+
+ if (!storedTokens || Date.now() > storedTokens.latestToken.refresh_expires) {
+ const promise = clientSideTokenGenerator.generateTokenAndStore(config.apiBaseUrl, config.cstg, cstgIdentity, storageManager, _logInfo, _logWarn);
+ _logInfo('Generate token using CSTG');
+ return { callback: (cb) => {
+ promise.then((result) => {
+ _logInfo('Token generation responded, passing the new token on.', result);
+ cb(result);
+ });
+ } };
+ }
+ }
+ }
+
const useSuppliedToken = !(storedTokens?.latestToken) || (suppliedToken && suppliedToken.identity_expires > storedTokens.latestToken.identity_expires);
const newestAvailableToken = useSuppliedToken ? suppliedToken : storedTokens.latestToken;
_logInfo('UID2 module selected latest token', useSuppliedToken, newestAvailableToken);
- if (!newestAvailableToken || Date.now() > newestAvailableToken.refresh_expires) {
+ if ((!newestAvailableToken || Date.now() > newestAvailableToken.refresh_expires)) {
_logInfo('Newest available token is expired and not refreshable.');
return { id: null };
}
@@ -227,6 +749,9 @@ export function Uid2GetId(config, prebidStorageManager, _logInfo, _logWarn) {
originalToken: suppliedToken ?? storedTokens?.originalToken,
latestToken: newestAvailableToken,
};
+ if (FEATURES.UID2_CSTG && isCstgEnabled) {
+ tokens.originalIdentity = storedTokens?.originalIdentity;
+ }
storageManager.storeValue(tokens);
return { id: tokens };
}
diff --git a/modules/unrulyBidAdapter.js b/modules/unrulyBidAdapter.js
index d893bfd3038..8fbbcf7d7c5 100644
--- a/modules/unrulyBidAdapter.js
+++ b/modules/unrulyBidAdapter.js
@@ -56,6 +56,12 @@ const RemoveDuplicateSizes = (validBid) => {
}
};
+const ConfigureProtectedAudience = (validBid, protectedAudienceEnabled) => {
+ if (!protectedAudienceEnabled && validBid.ortb2Imp && validBid.ortb2Imp.ext) {
+ delete validBid.ortb2Imp.ext.ae;
+ }
+}
+
const getRequests = (conf, validBidRequests, bidderRequest) => {
const {bids, bidderRequestId, bidderCode, ...bidderRequestData} = bidderRequest;
const invalidBidsCount = bidderRequest.bids.length - validBidRequests.length;
@@ -65,6 +71,7 @@ const getRequests = (conf, validBidRequests, bidderRequest) => {
const currSiteId = validBid.params.siteId;
addBidFloorInfo(validBid);
RemoveDuplicateSizes(validBid);
+ ConfigureProtectedAudience(validBid, conf.protectedAudienceEnabled);
requestBySiteId[currSiteId] = requestBySiteId[currSiteId] || [];
requestBySiteId[currSiteId].push(validBid);
});
@@ -206,21 +213,49 @@ export const adapter = {
endPoint = deepAccess(validBidRequests[0], 'params.endpoint') || endPoint;
}
- const url = endPoint;
- const method = 'POST';
- const options = {contentType: 'application/json'};
- return getRequests({url, method, options}, validBidRequests, bidderRequest);
+ return getRequests({
+ 'url': endPoint,
+ 'method': 'POST',
+ 'options': {
+ 'contentType': 'application/json'
+ },
+ 'protectedAudienceEnabled': bidderRequest.fledgeEnabled
+ }, validBidRequests, bidderRequest);
},
- interpretResponse: function (serverResponse = {}) {
+ interpretResponse: function (serverResponse) {
+ if (!(serverResponse && serverResponse.body && (serverResponse.body.auctionConfigs || serverResponse.body.bids))) {
+ return [];
+ }
+
const serverResponseBody = serverResponse.body;
+ let bids = [];
+ let fledgeAuctionConfigs = null;
+ if (serverResponseBody.bids.length) {
+ bids = handleBidResponseByMediaType(serverResponseBody.bids);
+ }
- const noBidsResponse = [];
- const isInvalidResponse = !serverResponseBody || !serverResponseBody.bids;
+ if (serverResponseBody.auctionConfigs) {
+ let auctionConfigs = serverResponseBody.auctionConfigs;
+ let bidIdList = Object.keys(auctionConfigs);
+ if (bidIdList.length) {
+ bidIdList.forEach((bidId) => {
+ fledgeAuctionConfigs = [{
+ 'bidId': bidId,
+ 'config': auctionConfigs[bidId]
+ }];
+ })
+ }
+ }
- return isInvalidResponse
- ? noBidsResponse
- : handleBidResponseByMediaType(serverResponseBody.bids);
+ if (!fledgeAuctionConfigs) {
+ return bids;
+ }
+
+ return {
+ bids,
+ fledgeAuctionConfigs
+ };
}
};
diff --git a/modules/yieldmoBidAdapter.js b/modules/yieldmoBidAdapter.js
index d2e97f5178e..e72a671ac74 100644
--- a/modules/yieldmoBidAdapter.js
+++ b/modules/yieldmoBidAdapter.js
@@ -78,14 +78,17 @@ export const spec = {
bust: new Date().getTime().toString(),
dnt: getDNT(),
description: getPageDescription(),
+ tmax: bidderRequest.timeout || 400,
userConsent: JSON.stringify({
// case of undefined, stringify will remove param
- gdprApplies: deepAccess(bidderRequest, 'gdprConsent.gdprApplies') || '',
+ gdprApplies:
+ deepAccess(bidderRequest, 'gdprConsent.gdprApplies') || '',
cmp: deepAccess(bidderRequest, 'gdprConsent.consentString') || '',
gpp: deepAccess(bidderRequest, 'gppConsent.gppString') || '',
- gpp_sid: deepAccess(bidderRequest, 'gppConsent.applicableSections') || []
+ gpp_sid:
+ deepAccess(bidderRequest, 'gppConsent.applicableSections') || [],
}),
- us_privacy: deepAccess(bidderRequest, 'uspConsent') || ''
+ us_privacy: deepAccess(bidderRequest, 'uspConsent') || '',
};
if (canAccessTopWindow()) {
diff --git a/modules/zeta_global_sspAnalyticsAdapter.js b/modules/zeta_global_sspAnalyticsAdapter.js
index 3d5466dd906..751b55ec673 100644
--- a/modules/zeta_global_sspAnalyticsAdapter.js
+++ b/modules/zeta_global_sspAnalyticsAdapter.js
@@ -51,28 +51,64 @@ function adRenderSucceededHandler(args) {
let eventType = CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED
logInfo(LOG_PREFIX + 'handle ' + eventType + ' event');
+ const event = {
+ adId: args.adId,
+ bid: {
+ adId: args.bid?.adId,
+ auctionId: args.bid?.auctionId,
+ adUnitCode: args.bid?.adUnitCode,
+ bidId: args.bid?.bidId,
+ requestId: args.bid?.requestId,
+ bidderCode: args.bid?.bidderCode,
+ mediaTypes: args.bid?.mediaTypes,
+ sizes: args.bid?.sizes,
+ adserverTargeting: args.bid?.adserverTargeting,
+ cpm: args.bid?.cpm,
+ creativeId: args.bid?.creativeId,
+ mediaType: args.bid?.mediaType,
+ renderer: args.bid?.renderer,
+ size: args.bid?.size,
+ timeToRespond: args.bid?.timeToRespond,
+ params: args.bid?.params
+ },
+ doc: {
+ location: args.doc?.location
+ }
+ }
+
// set zetaParams from cache
- if (args.bid && args.bid.auctionId) {
- const zetaParams = cache.auctions[args.bid.auctionId];
+ if (event.bid && event.bid.auctionId) {
+ const zetaParams = cache.auctions[event.bid.auctionId];
if (zetaParams) {
- args.bid.params = [ zetaParams ];
+ event.bid.params = [ zetaParams ];
}
}
- sendEvent(eventType, args);
+ sendEvent(eventType, event);
}
function auctionEndHandler(args) {
let eventType = CONSTANTS.EVENTS.AUCTION_END;
logInfo(LOG_PREFIX + 'handle ' + eventType + ' event');
+ const event = {
+ adUnitCodes: args.adUnitCodes,
+ adUnits: args.adUnits,
+ auctionEnd: args.auctionEnd,
+ auctionId: args.auctionId,
+ bidderRequests: args.bidderRequests,
+ bidsReceived: args.bidsReceived,
+ noBids: args.noBids,
+ winningBids: args.winningBids
+ }
+
// save zetaParams to cache
- const zetaParams = getZetaParams(args);
- if (zetaParams && args.auctionId) {
- cache.auctions[args.auctionId] = zetaParams;
+ const zetaParams = getZetaParams(event);
+ if (zetaParams && event.auctionId) {
+ cache.auctions[event.auctionId] = zetaParams;
}
- sendEvent(eventType, args);
+ sendEvent(eventType, event);
}
/// /////////// ADAPTER DEFINITION ///////////////////////////
diff --git a/modules/zeta_global_sspBidAdapter.js b/modules/zeta_global_sspBidAdapter.js
index 687afb6c692..db31791d86f 100644
--- a/modules/zeta_global_sspBidAdapter.js
+++ b/modules/zeta_global_sspBidAdapter.js
@@ -45,7 +45,7 @@ export const spec = {
supportedMediaTypes: [BANNER, VIDEO],
/**
- * Determines whether or not the given bid request is valid.
+ * Determines whether the given bid request is valid.
*
* @param {BidRequest} bid The bid params to validate.
* @return boolean True if this is a valid bid, and false otherwise.
@@ -54,7 +54,8 @@ export const spec = {
// check for all required bid fields
if (!(bid &&
bid.bidId &&
- bid.params)) {
+ bid.params &&
+ bid.params.sid)) {
logWarn('Invalid bid request - missing required bid data');
return false;
}
@@ -162,7 +163,7 @@ export const spec = {
}
provideEids(validBidRequests[0], payload);
- const url = params.shortname ? ENDPOINT_URL.concat('?shortname=', params.shortname) : ENDPOINT_URL;
+ const url = params.sid ? ENDPOINT_URL.concat('?sid=', params.sid) : ENDPOINT_URL;
return {
method: 'POST',
url: url,
diff --git a/package-lock.json b/package-lock.json
index bf4d08f39db..1fbf6ef9aa2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "prebid.js",
- "version": "8.19.0",
+ "version": "8.26.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "prebid.js",
- "version": "8.8.0-pre",
+ "version": "8.24.0-pre",
"license": "Apache-2.0",
"dependencies": {
"@babel/core": "^7.16.7",
@@ -16,13 +16,13 @@
"core-js": "^3.13.0",
"core-js-pure": "^3.13.0",
"criteo-direct-rsa-validate": "^1.1.0",
- "crypto-js": "^3.3.0",
+ "crypto-js": "^4.2.0",
"dlv": "1.1.3",
"dset": "3.1.2",
"express": "^4.15.4",
"fun-hooks": "^0.9.9",
"just-clone": "^1.0.2",
- "live-connect-js": "^6.0.1"
+ "live-connect-js": "^6.3.0"
},
"devDependencies": {
"@babel/eslint-parser": "^7.16.5",
@@ -90,6 +90,7 @@
"lodash": "^4.17.21",
"mocha": "^10.0.0",
"morgan": "^1.10.0",
+ "node-html-parser": "^6.1.5",
"opn": "^5.4.0",
"resolve-from": "^5.0.0",
"sinon": "^4.1.3",
@@ -127,11 +128,12 @@
}
},
"node_modules/@babel/code-frame": {
- "version": "7.18.6",
- "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz",
- "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==",
+ "version": "7.22.13",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz",
+ "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==",
"dependencies": {
- "@babel/highlight": "^7.18.6"
+ "@babel/highlight": "^7.22.13",
+ "chalk": "^2.4.2"
},
"engines": {
"node": ">=6.9.0"
@@ -193,12 +195,13 @@
}
},
"node_modules/@babel/generator": {
- "version": "7.20.1",
- "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.20.1.tgz",
- "integrity": "sha512-u1dMdBUmA7Z0rBB97xh8pIhviK7oItYOkjbsCxTWMknyvbQRBwX7/gn4JXurRdirWMFh+ZtYARqkA6ydogVZpg==",
+ "version": "7.23.0",
+ "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz",
+ "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==",
"dependencies": {
- "@babel/types": "^7.20.0",
+ "@babel/types": "^7.23.0",
"@jridgewell/gen-mapping": "^0.3.2",
+ "@jridgewell/trace-mapping": "^0.3.17",
"jsesc": "^2.5.1"
},
"engines": {
@@ -310,9 +313,9 @@
}
},
"node_modules/@babel/helper-environment-visitor": {
- "version": "7.18.9",
- "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz",
- "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==",
+ "version": "7.22.20",
+ "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz",
+ "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==",
"engines": {
"node": ">=6.9.0"
}
@@ -329,23 +332,23 @@
}
},
"node_modules/@babel/helper-function-name": {
- "version": "7.19.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.19.0.tgz",
- "integrity": "sha512-WAwHBINyrpqywkUH0nTnNgI5ina5TFn85HKS0pbPDfxFfhyR/aNQEn4hGi1P1JyT//I0t4OgXUlofzWILRvS5w==",
+ "version": "7.23.0",
+ "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz",
+ "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==",
"dependencies": {
- "@babel/template": "^7.18.10",
- "@babel/types": "^7.19.0"
+ "@babel/template": "^7.22.15",
+ "@babel/types": "^7.23.0"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-hoist-variables": {
- "version": "7.18.6",
- "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz",
- "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==",
+ "version": "7.22.5",
+ "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz",
+ "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==",
"dependencies": {
- "@babel/types": "^7.18.6"
+ "@babel/types": "^7.22.5"
},
"engines": {
"node": ">=6.9.0"
@@ -465,28 +468,28 @@
}
},
"node_modules/@babel/helper-split-export-declaration": {
- "version": "7.18.6",
- "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz",
- "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==",
+ "version": "7.22.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz",
+ "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==",
"dependencies": {
- "@babel/types": "^7.18.6"
+ "@babel/types": "^7.22.5"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-string-parser": {
- "version": "7.19.4",
- "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz",
- "integrity": "sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==",
+ "version": "7.22.5",
+ "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz",
+ "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-validator-identifier": {
- "version": "7.19.1",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz",
- "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==",
+ "version": "7.22.20",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz",
+ "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==",
"engines": {
"node": ">=6.9.0"
}
@@ -527,12 +530,12 @@
}
},
"node_modules/@babel/highlight": {
- "version": "7.18.6",
- "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz",
- "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==",
+ "version": "7.22.20",
+ "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz",
+ "integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==",
"dependencies": {
- "@babel/helper-validator-identifier": "^7.18.6",
- "chalk": "^2.0.0",
+ "@babel/helper-validator-identifier": "^7.22.20",
+ "chalk": "^2.4.2",
"js-tokens": "^4.0.0"
},
"engines": {
@@ -540,9 +543,9 @@
}
},
"node_modules/@babel/parser": {
- "version": "7.20.1",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.20.1.tgz",
- "integrity": "sha512-hp0AYxaZJhxULfM1zyp7Wgr+pSUKBcP3M+PHnSzWGdXOzg/kHWIgiUWARvubhUKGOEw3xqY4x+lyZ9ytBVcELw==",
+ "version": "7.23.0",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz",
+ "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==",
"bin": {
"parser": "bin/babel-parser.js"
},
@@ -1612,31 +1615,31 @@
}
},
"node_modules/@babel/template": {
- "version": "7.18.10",
- "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.18.10.tgz",
- "integrity": "sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==",
+ "version": "7.22.15",
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz",
+ "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==",
"dependencies": {
- "@babel/code-frame": "^7.18.6",
- "@babel/parser": "^7.18.10",
- "@babel/types": "^7.18.10"
+ "@babel/code-frame": "^7.22.13",
+ "@babel/parser": "^7.22.15",
+ "@babel/types": "^7.22.15"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/traverse": {
- "version": "7.20.1",
- "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.20.1.tgz",
- "integrity": "sha512-d3tN8fkVJwFLkHkBN479SOsw4DMZnz8cdbL/gvuDuzy3TS6Nfw80HuQqhw1pITbIruHyh7d1fMA47kWzmcUEGA==",
- "dependencies": {
- "@babel/code-frame": "^7.18.6",
- "@babel/generator": "^7.20.1",
- "@babel/helper-environment-visitor": "^7.18.9",
- "@babel/helper-function-name": "^7.19.0",
- "@babel/helper-hoist-variables": "^7.18.6",
- "@babel/helper-split-export-declaration": "^7.18.6",
- "@babel/parser": "^7.20.1",
- "@babel/types": "^7.20.0",
+ "version": "7.23.2",
+ "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz",
+ "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==",
+ "dependencies": {
+ "@babel/code-frame": "^7.22.13",
+ "@babel/generator": "^7.23.0",
+ "@babel/helper-environment-visitor": "^7.22.20",
+ "@babel/helper-function-name": "^7.23.0",
+ "@babel/helper-hoist-variables": "^7.22.5",
+ "@babel/helper-split-export-declaration": "^7.22.6",
+ "@babel/parser": "^7.23.0",
+ "@babel/types": "^7.23.0",
"debug": "^4.1.0",
"globals": "^11.1.0"
},
@@ -1645,12 +1648,12 @@
}
},
"node_modules/@babel/types": {
- "version": "7.20.0",
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.20.0.tgz",
- "integrity": "sha512-Jlgt3H0TajCW164wkTOTzHkZb075tMQMULzrLUoUeKmO7eFL96GgDxf7/Axhc5CAuKE3KFyVW1p6ysKsi2oXAg==",
+ "version": "7.23.0",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz",
+ "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==",
"dependencies": {
- "@babel/helper-string-parser": "^7.19.4",
- "@babel/helper-validator-identifier": "^7.19.1",
+ "@babel/helper-string-parser": "^7.22.5",
+ "@babel/helper-validator-identifier": "^7.22.20",
"to-fast-properties": "^2.0.0"
},
"engines": {
@@ -6489,6 +6492,12 @@
"integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==",
"dev": true
},
+ "node_modules/boolbase": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
+ "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==",
+ "dev": true
+ },
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@@ -7838,9 +7847,9 @@
}
},
"node_modules/crypto-js": {
- "version": "3.3.0",
- "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.3.0.tgz",
- "integrity": "sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q=="
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
+ "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
},
"node_modules/css": {
"version": "3.0.0",
@@ -7853,6 +7862,22 @@
"source-map-resolve": "^0.6.0"
}
},
+ "node_modules/css-select": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz",
+ "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==",
+ "dev": true,
+ "dependencies": {
+ "boolbase": "^1.0.0",
+ "css-what": "^6.1.0",
+ "domhandler": "^5.0.2",
+ "domutils": "^3.0.1",
+ "nth-check": "^2.0.1"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/fb55"
+ }
+ },
"node_modules/css-shorthand-properties": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/css-shorthand-properties/-/css-shorthand-properties-1.1.1.tgz",
@@ -7865,6 +7890,18 @@
"integrity": "sha512-FUV3xaJ63buRLgHrLQVlVgQnQdR4yqdLGaDu7g8CQcWjInDfM9plBTPI9FRfpahju1UBSaMckeb2/46ApS/V1Q==",
"dev": true
},
+ "node_modules/css-what": {
+ "version": "6.1.0",
+ "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz",
+ "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==",
+ "dev": true,
+ "engines": {
+ "node": ">= 6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/fb55"
+ }
+ },
"node_modules/css/node_modules/source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
@@ -8691,12 +8728,67 @@
"void-elements": "^2.0.0"
}
},
+ "node_modules/dom-serializer": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
+ "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==",
+ "dev": true,
+ "dependencies": {
+ "domelementtype": "^2.3.0",
+ "domhandler": "^5.0.2",
+ "entities": "^4.2.0"
+ },
+ "funding": {
+ "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"
+ }
+ },
"node_modules/dom-walk": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.2.tgz",
"integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==",
"dev": true
},
+ "node_modules/domelementtype": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz",
+ "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/fb55"
+ }
+ ]
+ },
+ "node_modules/domhandler": {
+ "version": "5.0.3",
+ "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz",
+ "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==",
+ "dev": true,
+ "dependencies": {
+ "domelementtype": "^2.3.0"
+ },
+ "engines": {
+ "node": ">= 4"
+ },
+ "funding": {
+ "url": "https://github.com/fb55/domhandler?sponsor=1"
+ }
+ },
+ "node_modules/domutils": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz",
+ "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==",
+ "dev": true,
+ "dependencies": {
+ "dom-serializer": "^2.0.0",
+ "domelementtype": "^2.3.0",
+ "domhandler": "^5.0.3"
+ },
+ "funding": {
+ "url": "https://github.com/fb55/domutils?sponsor=1"
+ }
+ },
"node_modules/dset": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/dset/-/dset-3.1.2.tgz",
@@ -8957,6 +9049,18 @@
"integrity": "sha512-GHrMyVZQWvTIdDtpiEXdHZnFQKzeO09apj8Cbl4pKWy4i0Oprcq17usfDt5aO63swf0JOeMWjWQE/LzgSRuWpA==",
"dev": true
},
+ "node_modules/entities": {
+ "version": "4.5.0",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
+ "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
+ "dev": true,
+ "engines": {
+ "node": ">=0.12"
+ },
+ "funding": {
+ "url": "https://github.com/fb55/entities?sponsor=1"
+ }
+ },
"node_modules/errno": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz",
@@ -15469,14 +15573,6 @@
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
- "node_modules/js-cookie": {
- "version": "3.0.5",
- "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz",
- "integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==",
- "engines": {
- "node": ">=14"
- }
- },
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@@ -16240,32 +16336,19 @@
"dev": true
},
"node_modules/live-connect-common": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/live-connect-common/-/live-connect-common-3.0.0.tgz",
- "integrity": "sha512-pa1SuzCg8ovsB6OziAQZpDid/OT8k37VgWFQkE8OUmG52Kf9PUtJM8wqaGdMXd/rNAe/NH8m+Kxx9MZuOvn5zg==",
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/live-connect-common/-/live-connect-common-3.0.2.tgz",
+ "integrity": "sha512-K3LNKd9CpREDJbXGdwKqPojjQaxd4G6c7OAD6Yzp3wsCWTH2hV8xNAbUksSOpOcVyyOT9ilteEFXIJQJrbODxQ==",
"engines": {
"node": ">=18"
}
},
- "node_modules/live-connect-handlers": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/live-connect-handlers/-/live-connect-handlers-2.1.0.tgz",
- "integrity": "sha512-uABe9D6yRp7HRgO6vhdIM5j88l17/ROzYGIOHc2Rv1TacLFH6IJ8sbmunY5mIJ9L6ArOVmL4WHY+QgOIkabhxg==",
- "dependencies": {
- "js-cookie": "^3.0.5",
- "live-connect-common": "^3.0.0"
- },
- "engines": {
- "node": ">=8"
- }
- },
"node_modules/live-connect-js": {
- "version": "6.0.1",
- "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-6.0.1.tgz",
- "integrity": "sha512-+TwM7cjgyutqaMNlTQKNY9nJFDPpSWfoazSHmlWxOPlimp10PSZGABIbtulNGGpYbR/Zxgc+C/uW5OxqcNEPXg==",
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-6.3.0.tgz",
+ "integrity": "sha512-1SnXQZq9gxHIb0scXPX1Da1rQ0oY2sloMGgeRreTAwhCtdQEuip/IYwgOh3/ZeZ6yT6iG9FLb7+AjORC4pO46g==",
"dependencies": {
- "live-connect-common": "^3.0.0",
- "live-connect-handlers": "^2.1.0",
+ "live-connect-common": "^v3.0.2",
"tiny-hashes": "1.0.1"
},
"engines": {
@@ -18727,6 +18810,16 @@
}
}
},
+ "node_modules/node-html-parser": {
+ "version": "6.1.6",
+ "resolved": "https://registry.npmjs.org/node-html-parser/-/node-html-parser-6.1.6.tgz",
+ "integrity": "sha512-C/MGDQ2NjdjzUq41bW9kW00MPZecAe/oo89vZEFLDfWoQVDk/DdML1yuxVVKLDMFIFax2VTq6Vpfzyn7z5yYgQ==",
+ "dev": true,
+ "dependencies": {
+ "css-select": "^5.1.0",
+ "he": "1.2.0"
+ }
+ },
"node_modules/node-releases": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz",
@@ -18828,6 +18921,18 @@
"node": ">=4"
}
},
+ "node_modules/nth-check": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz",
+ "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==",
+ "dev": true,
+ "dependencies": {
+ "boolbase": "^1.0.0"
+ },
+ "funding": {
+ "url": "https://github.com/fb55/nth-check?sponsor=1"
+ }
+ },
"node_modules/number-is-nan": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
@@ -25310,11 +25415,12 @@
}
},
"@babel/code-frame": {
- "version": "7.18.6",
- "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz",
- "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==",
+ "version": "7.22.13",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz",
+ "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==",
"requires": {
- "@babel/highlight": "^7.18.6"
+ "@babel/highlight": "^7.22.13",
+ "chalk": "^2.4.2"
}
},
"@babel/compat-data": {
@@ -25356,12 +25462,13 @@
}
},
"@babel/generator": {
- "version": "7.20.1",
- "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.20.1.tgz",
- "integrity": "sha512-u1dMdBUmA7Z0rBB97xh8pIhviK7oItYOkjbsCxTWMknyvbQRBwX7/gn4JXurRdirWMFh+ZtYARqkA6ydogVZpg==",
+ "version": "7.23.0",
+ "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz",
+ "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==",
"requires": {
- "@babel/types": "^7.20.0",
+ "@babel/types": "^7.23.0",
"@jridgewell/gen-mapping": "^0.3.2",
+ "@jridgewell/trace-mapping": "^0.3.17",
"jsesc": "^2.5.1"
},
"dependencies": {
@@ -25442,9 +25549,9 @@
}
},
"@babel/helper-environment-visitor": {
- "version": "7.18.9",
- "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz",
- "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg=="
+ "version": "7.22.20",
+ "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz",
+ "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA=="
},
"@babel/helper-explode-assignable-expression": {
"version": "7.18.6",
@@ -25455,20 +25562,20 @@
}
},
"@babel/helper-function-name": {
- "version": "7.19.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.19.0.tgz",
- "integrity": "sha512-WAwHBINyrpqywkUH0nTnNgI5ina5TFn85HKS0pbPDfxFfhyR/aNQEn4hGi1P1JyT//I0t4OgXUlofzWILRvS5w==",
+ "version": "7.23.0",
+ "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz",
+ "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==",
"requires": {
- "@babel/template": "^7.18.10",
- "@babel/types": "^7.19.0"
+ "@babel/template": "^7.22.15",
+ "@babel/types": "^7.23.0"
}
},
"@babel/helper-hoist-variables": {
- "version": "7.18.6",
- "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz",
- "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==",
+ "version": "7.22.5",
+ "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz",
+ "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==",
"requires": {
- "@babel/types": "^7.18.6"
+ "@babel/types": "^7.22.5"
}
},
"@babel/helper-member-expression-to-functions": {
@@ -25555,22 +25662,22 @@
}
},
"@babel/helper-split-export-declaration": {
- "version": "7.18.6",
- "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz",
- "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==",
+ "version": "7.22.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz",
+ "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==",
"requires": {
- "@babel/types": "^7.18.6"
+ "@babel/types": "^7.22.5"
}
},
"@babel/helper-string-parser": {
- "version": "7.19.4",
- "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz",
- "integrity": "sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw=="
+ "version": "7.22.5",
+ "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz",
+ "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw=="
},
"@babel/helper-validator-identifier": {
- "version": "7.19.1",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz",
- "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w=="
+ "version": "7.22.20",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz",
+ "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A=="
},
"@babel/helper-validator-option": {
"version": "7.18.6",
@@ -25599,19 +25706,19 @@
}
},
"@babel/highlight": {
- "version": "7.18.6",
- "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz",
- "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==",
+ "version": "7.22.20",
+ "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz",
+ "integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==",
"requires": {
- "@babel/helper-validator-identifier": "^7.18.6",
- "chalk": "^2.0.0",
+ "@babel/helper-validator-identifier": "^7.22.20",
+ "chalk": "^2.4.2",
"js-tokens": "^4.0.0"
}
},
"@babel/parser": {
- "version": "7.20.1",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.20.1.tgz",
- "integrity": "sha512-hp0AYxaZJhxULfM1zyp7Wgr+pSUKBcP3M+PHnSzWGdXOzg/kHWIgiUWARvubhUKGOEw3xqY4x+lyZ9ytBVcELw=="
+ "version": "7.23.0",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz",
+ "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw=="
},
"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": {
"version": "7.18.6",
@@ -26303,39 +26410,39 @@
}
},
"@babel/template": {
- "version": "7.18.10",
- "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.18.10.tgz",
- "integrity": "sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==",
+ "version": "7.22.15",
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz",
+ "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==",
"requires": {
- "@babel/code-frame": "^7.18.6",
- "@babel/parser": "^7.18.10",
- "@babel/types": "^7.18.10"
+ "@babel/code-frame": "^7.22.13",
+ "@babel/parser": "^7.22.15",
+ "@babel/types": "^7.22.15"
}
},
"@babel/traverse": {
- "version": "7.20.1",
- "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.20.1.tgz",
- "integrity": "sha512-d3tN8fkVJwFLkHkBN479SOsw4DMZnz8cdbL/gvuDuzy3TS6Nfw80HuQqhw1pITbIruHyh7d1fMA47kWzmcUEGA==",
- "requires": {
- "@babel/code-frame": "^7.18.6",
- "@babel/generator": "^7.20.1",
- "@babel/helper-environment-visitor": "^7.18.9",
- "@babel/helper-function-name": "^7.19.0",
- "@babel/helper-hoist-variables": "^7.18.6",
- "@babel/helper-split-export-declaration": "^7.18.6",
- "@babel/parser": "^7.20.1",
- "@babel/types": "^7.20.0",
+ "version": "7.23.2",
+ "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz",
+ "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==",
+ "requires": {
+ "@babel/code-frame": "^7.22.13",
+ "@babel/generator": "^7.23.0",
+ "@babel/helper-environment-visitor": "^7.22.20",
+ "@babel/helper-function-name": "^7.23.0",
+ "@babel/helper-hoist-variables": "^7.22.5",
+ "@babel/helper-split-export-declaration": "^7.22.6",
+ "@babel/parser": "^7.23.0",
+ "@babel/types": "^7.23.0",
"debug": "^4.1.0",
"globals": "^11.1.0"
}
},
"@babel/types": {
- "version": "7.20.0",
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.20.0.tgz",
- "integrity": "sha512-Jlgt3H0TajCW164wkTOTzHkZb075tMQMULzrLUoUeKmO7eFL96GgDxf7/Axhc5CAuKE3KFyVW1p6ysKsi2oXAg==",
+ "version": "7.23.0",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz",
+ "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==",
"requires": {
- "@babel/helper-string-parser": "^7.19.4",
- "@babel/helper-validator-identifier": "^7.19.1",
+ "@babel/helper-string-parser": "^7.22.5",
+ "@babel/helper-validator-identifier": "^7.22.20",
"to-fast-properties": "^2.0.0"
}
},
@@ -30264,6 +30371,12 @@
}
}
},
+ "boolbase": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
+ "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==",
+ "dev": true
+ },
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@@ -31299,9 +31412,9 @@
}
},
"crypto-js": {
- "version": "3.3.0",
- "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.3.0.tgz",
- "integrity": "sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q=="
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
+ "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
},
"css": {
"version": "3.0.0",
@@ -31322,6 +31435,19 @@
}
}
},
+ "css-select": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz",
+ "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==",
+ "dev": true,
+ "requires": {
+ "boolbase": "^1.0.0",
+ "css-what": "^6.1.0",
+ "domhandler": "^5.0.2",
+ "domutils": "^3.0.1",
+ "nth-check": "^2.0.1"
+ }
+ },
"css-shorthand-properties": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/css-shorthand-properties/-/css-shorthand-properties-1.1.1.tgz",
@@ -31334,6 +31460,12 @@
"integrity": "sha512-FUV3xaJ63buRLgHrLQVlVgQnQdR4yqdLGaDu7g8CQcWjInDfM9plBTPI9FRfpahju1UBSaMckeb2/46ApS/V1Q==",
"dev": true
},
+ "css-what": {
+ "version": "6.1.0",
+ "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz",
+ "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==",
+ "dev": true
+ },
"custom-event": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz",
@@ -31945,12 +32077,49 @@
"void-elements": "^2.0.0"
}
},
+ "dom-serializer": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
+ "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==",
+ "dev": true,
+ "requires": {
+ "domelementtype": "^2.3.0",
+ "domhandler": "^5.0.2",
+ "entities": "^4.2.0"
+ }
+ },
"dom-walk": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.2.tgz",
"integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==",
"dev": true
},
+ "domelementtype": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz",
+ "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==",
+ "dev": true
+ },
+ "domhandler": {
+ "version": "5.0.3",
+ "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz",
+ "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==",
+ "dev": true,
+ "requires": {
+ "domelementtype": "^2.3.0"
+ }
+ },
+ "domutils": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz",
+ "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==",
+ "dev": true,
+ "requires": {
+ "dom-serializer": "^2.0.0",
+ "domelementtype": "^2.3.0",
+ "domhandler": "^5.0.3"
+ }
+ },
"dset": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/dset/-/dset-3.1.2.tgz",
@@ -32181,6 +32350,12 @@
"integrity": "sha512-GHrMyVZQWvTIdDtpiEXdHZnFQKzeO09apj8Cbl4pKWy4i0Oprcq17usfDt5aO63swf0JOeMWjWQE/LzgSRuWpA==",
"dev": true
},
+ "entities": {
+ "version": "4.5.0",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
+ "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
+ "dev": true
+ },
"errno": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz",
@@ -37283,11 +37458,6 @@
}
}
},
- "js-cookie": {
- "version": "3.0.5",
- "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz",
- "integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw=="
- },
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@@ -37909,26 +38079,16 @@
"dev": true
},
"live-connect-common": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/live-connect-common/-/live-connect-common-3.0.0.tgz",
- "integrity": "sha512-pa1SuzCg8ovsB6OziAQZpDid/OT8k37VgWFQkE8OUmG52Kf9PUtJM8wqaGdMXd/rNAe/NH8m+Kxx9MZuOvn5zg=="
- },
- "live-connect-handlers": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/live-connect-handlers/-/live-connect-handlers-2.1.0.tgz",
- "integrity": "sha512-uABe9D6yRp7HRgO6vhdIM5j88l17/ROzYGIOHc2Rv1TacLFH6IJ8sbmunY5mIJ9L6ArOVmL4WHY+QgOIkabhxg==",
- "requires": {
- "js-cookie": "^3.0.5",
- "live-connect-common": "^3.0.0"
- }
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/live-connect-common/-/live-connect-common-3.0.2.tgz",
+ "integrity": "sha512-K3LNKd9CpREDJbXGdwKqPojjQaxd4G6c7OAD6Yzp3wsCWTH2hV8xNAbUksSOpOcVyyOT9ilteEFXIJQJrbODxQ=="
},
"live-connect-js": {
- "version": "6.0.1",
- "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-6.0.1.tgz",
- "integrity": "sha512-+TwM7cjgyutqaMNlTQKNY9nJFDPpSWfoazSHmlWxOPlimp10PSZGABIbtulNGGpYbR/Zxgc+C/uW5OxqcNEPXg==",
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-6.3.0.tgz",
+ "integrity": "sha512-1SnXQZq9gxHIb0scXPX1Da1rQ0oY2sloMGgeRreTAwhCtdQEuip/IYwgOh3/ZeZ6yT6iG9FLb7+AjORC4pO46g==",
"requires": {
- "live-connect-common": "^3.0.0",
- "live-connect-handlers": "^2.1.0",
+ "live-connect-common": "^v3.0.2",
"tiny-hashes": "1.0.1"
}
},
@@ -39770,6 +39930,16 @@
"whatwg-url": "^5.0.0"
}
},
+ "node-html-parser": {
+ "version": "6.1.6",
+ "resolved": "https://registry.npmjs.org/node-html-parser/-/node-html-parser-6.1.6.tgz",
+ "integrity": "sha512-C/MGDQ2NjdjzUq41bW9kW00MPZecAe/oo89vZEFLDfWoQVDk/DdML1yuxVVKLDMFIFax2VTq6Vpfzyn7z5yYgQ==",
+ "dev": true,
+ "requires": {
+ "css-select": "^5.1.0",
+ "he": "1.2.0"
+ }
+ },
"node-releases": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz",
@@ -39845,6 +40015,15 @@
}
}
},
+ "nth-check": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz",
+ "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==",
+ "dev": true,
+ "requires": {
+ "boolbase": "^1.0.0"
+ }
+ },
"number-is-nan": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
diff --git a/package.json b/package.json
index d32ff874668..9470d5cf8c5 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "prebid.js",
- "version": "8.19.0",
+ "version": "8.26.0",
"description": "Header Bidding Management Library",
"main": "src/prebid.js",
"scripts": {
@@ -101,6 +101,7 @@
"lodash": "^4.17.21",
"mocha": "^10.0.0",
"morgan": "^1.10.0",
+ "node-html-parser": "^6.1.5",
"opn": "^5.4.0",
"resolve-from": "^5.0.0",
"sinon": "^4.1.3",
@@ -126,13 +127,13 @@
"core-js": "^3.13.0",
"core-js-pure": "^3.13.0",
"criteo-direct-rsa-validate": "^1.1.0",
- "crypto-js": "^3.3.0",
+ "crypto-js": "^4.2.0",
"dlv": "1.1.3",
"dset": "3.1.2",
"express": "^4.15.4",
"fun-hooks": "^0.9.9",
"just-clone": "^1.0.2",
- "live-connect-js": "^6.0.1"
+ "live-connect-js": "^6.3.0"
},
"optionalDependencies": {
"fsevents": "^2.3.2"
diff --git a/src/activities/redactor.js b/src/activities/redactor.js
index d052c029c13..694a96b2b14 100644
--- a/src/activities/redactor.js
+++ b/src/activities/redactor.js
@@ -18,7 +18,7 @@ export const ORTB_UFPD_PATHS = [
'id',
'buyeruid',
'customdata'
-].map(f => `user.${f}`);
+].map(f => `user.${f}`).concat('device.ext.cdep');
export const ORTB_EIDS_PATHS = ['user.eids', 'user.ext.eids'];
export const ORTB_GEO_PATHS = ['user.geo.lat', 'user.geo.lon', 'device.geo.lat', 'device.geo.lon'];
diff --git a/src/adRendering.js b/src/adRendering.js
index 0a847d7cc25..c3e518eae4d 100644
--- a/src/adRendering.js
+++ b/src/adRendering.js
@@ -1,8 +1,12 @@
-import {logError} from './utils.js';
+import {deepAccess, logError, logWarn, replaceMacros} from './utils.js';
import * as events from './events.js';
-import CONSTANTS from './constants.json';
+import constants from './constants.json';
+import {config} from './config.js';
+import {executeRenderer, isRendererRequired} from './Renderer.js';
+import {VIDEO} from './mediaTypes.js';
+import {auctionManager} from './auctionManager.js';
-const {AD_RENDER_FAILED, AD_RENDER_SUCCEEDED} = CONSTANTS.EVENTS;
+const {AD_RENDER_FAILED, AD_RENDER_SUCCEEDED, STALE_RENDER, BID_WON} = constants.EVENTS;
/**
* Emit the AD_RENDER_FAILED event.
@@ -17,7 +21,7 @@ export function emitAdRenderFail({ reason, message, bid, id }) {
if (bid) data.bid = bid;
if (id) data.adId = id;
- logError(message);
+ logError(`Error rendering ad (id: ${id}): ${message}`);
events.emit(AD_RENDER_FAILED, data);
}
@@ -36,3 +40,61 @@ export function emitAdRenderSucceeded({ doc, bid, id }) {
events.emit(AD_RENDER_SUCCEEDED, data);
}
+
+export function handleRender(renderFn, {adId, options, bidResponse}) {
+ if (bidResponse == null) {
+ emitAdRenderFail({
+ reason: constants.AD_RENDER_FAILED_REASON.CANNOT_FIND_AD,
+ message: `Cannot find ad '${adId}'`,
+ id: adId
+ });
+ return;
+ }
+ if (bidResponse.status === constants.BID_STATUS.RENDERED) {
+ logWarn(`Ad id ${adId} has been rendered before`);
+ events.emit(STALE_RENDER, bidResponse);
+ if (deepAccess(config.getConfig('auctionOptions'), 'suppressStaleRender')) {
+ return;
+ }
+ }
+ try {
+ const {adId, ad, adUrl, width, height, renderer, cpm, originalCpm, mediaType} = bidResponse;
+ // rendering for outstream safeframe
+ if (isRendererRequired(renderer)) {
+ executeRenderer(renderer, bidResponse);
+ } else if (adId) {
+ if (mediaType === VIDEO) {
+ emitAdRenderFail({
+ reason: constants.AD_RENDER_FAILED_REASON.PREVENT_WRITING_ON_MAIN_DOCUMENT,
+ message: 'Cannot render video ad',
+ bid: bidResponse,
+ id: adId
+ });
+ return;
+ }
+ const repl = {
+ AUCTION_PRICE: originalCpm || cpm,
+ CLICKTHROUGH: options?.clickUrl || ''
+ };
+ renderFn({
+ ad: replaceMacros(ad, repl),
+ adUrl: replaceMacros(adUrl, repl),
+ adId,
+ width,
+ height
+ });
+ }
+ } catch (e) {
+ emitAdRenderFail({
+ reason: constants.AD_RENDER_FAILED_REASON.EXCEPTION,
+ message: e.message,
+ id: adId,
+ bid: bidResponse
+ });
+ return;
+ }
+ // save winning bids
+ auctionManager.addWinningBid(bidResponse);
+
+ events.emit(BID_WON, bidResponse);
+}
diff --git a/src/adapters/bidderFactory.js b/src/adapters/bidderFactory.js
index df97d820c96..44775b4e241 100644
--- a/src/adapters/bidderFactory.js
+++ b/src/adapters/bidderFactory.js
@@ -292,7 +292,7 @@ export function newBidder(spec) {
fledgeAuctionConfigs.forEach((fledgeAuctionConfig) => {
const bidRequest = bidRequestMap[fledgeAuctionConfig.bidId];
if (bidRequest) {
- addComponentAuction(bidRequest.auctionId, bidRequest.adUnitCode, fledgeAuctionConfig.config);
+ addComponentAuction(bidRequest, fledgeAuctionConfig.config);
} else {
logWarn('Received fledge auction configuration for an unknown bidId', fledgeAuctionConfig);
}
@@ -457,7 +457,7 @@ export const processBidderRequests = hook('sync', function (spec, bids, bidderRe
return Object.assign(defaults, ro, {
browsingTopics: ro?.hasOwnProperty('browsingTopics') && !ro.browsingTopics
? false
- : isActivityAllowed(ACTIVITY_TRANSMIT_UFPD, activityParams(MODULE_TYPE_BIDDER, spec.code))
+ : (bidderSettings.get(spec.code, 'topicsHeader') ?? true) && isActivityAllowed(ACTIVITY_TRANSMIT_UFPD, activityParams(MODULE_TYPE_BIDDER, spec.code))
})
}
switch (request.method) {
@@ -525,7 +525,7 @@ export const registerSyncInner = hook('async', function(spec, responses, gdprCon
}
}, 'registerSyncs')
-export const addComponentAuction = hook('sync', (adUnitCode, fledgeAuctionConfig) => {
+export const addComponentAuction = hook('sync', (request, fledgeAuctionConfig) => {
}, 'addComponentAuction');
// check that the bid has a width and height set
diff --git a/src/adloader.js b/src/adloader.js
index d69d2032b40..d1dca9627d8 100644
--- a/src/adloader.js
+++ b/src/adloader.js
@@ -27,7 +27,9 @@ const _approvedLoadExternalJSList = [
'clean.io',
'a1Media',
'geoedge',
- 'qortex'
+ 'mediafilter',
+ 'qortex',
+ 'dynamicAdBoost'
]
/**
diff --git a/src/auction.js b/src/auction.js
index df1b2cdef55..0d256bc3cd7 100644
--- a/src/auction.js
+++ b/src/auction.js
@@ -58,6 +58,7 @@
*/
import {
+ callBurl,
deepAccess,
generateUUID,
getValue,
@@ -185,6 +186,8 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels, a
function executeCallback(timedOut) {
if (!timedOut) {
clearTimeout(_timeoutTimer);
+ } else {
+ events.emit(CONSTANTS.EVENTS.AUCTION_TIMEOUT, getProperties());
}
if (_auctionEnd === undefined) {
let timedOutRequests = [];
@@ -360,6 +363,7 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels, a
function addWinningBid(winningBid) {
const winningAd = adUnits.find(adUnit => adUnit.transactionId === winningBid.transactionId);
_winningBids = _winningBids.concat(winningBid);
+ callBurl(winningBid);
adapterManager.callBidWonBidder(winningBid.adapterCode || winningBid.bidder, winningBid, adUnits);
if (winningAd && !winningAd.deferBilling) adapterManager.callBidBillableBidder(winningBid);
}
diff --git a/src/consentHandler.js b/src/consentHandler.js
index 9e3ee5b4c40..5b5d8b805cd 100644
--- a/src/consentHandler.js
+++ b/src/consentHandler.js
@@ -10,6 +10,14 @@ import {config} from './config.js';
*/
export const VENDORLESS_GVLID = Object.freeze({});
+/**
+ * Placeholder gvlid for when device.ext.cdep is present (Privacy Sandbox cookie deprecation label). When this value is used as gvlid, the gdpr
+ * enforcement module will look to see that publisher consent was given.
+ *
+ * see https://github.com/prebid/Prebid.js/issues/10516
+ */
+export const FIRST_PARTY_GVLID = Object.freeze({});
+
export class ConsentHandler {
#enabled;
#data;
diff --git a/src/constants.json b/src/constants.json
index c763090f6d0..ad0f5b3a71b 100644
--- a/src/constants.json
+++ b/src/constants.json
@@ -23,6 +23,7 @@
},
"EVENTS": {
"AUCTION_INIT": "auctionInit",
+ "AUCTION_TIMEOUT": "auctionTimeout",
"AUCTION_END": "auctionEnd",
"BID_ADJUSTMENT": "bidAdjustment",
"BID_TIMEOUT": "bidTimeout",
diff --git a/src/events.js b/src/events.js
index 7a1e25e0e49..6eb7ce49f11 100644
--- a/src/events.js
+++ b/src/events.js
@@ -89,6 +89,8 @@ const _public = (function () {
return allEvents.includes(event)
}
+ _public.has = _checkAvailableEvent;
+
_public.on = function (eventString, handler, id) {
// check whether available event or not
if (_checkAvailableEvent(eventString)) {
@@ -163,7 +165,7 @@ const _public = (function () {
utils._setEventEmitter(_public.emit.bind(_public));
-export const {on, off, get, getEvents, emit, addEvents} = _public;
+export const {on, off, get, getEvents, emit, addEvents, has} = _public;
export function clearEvents() {
eventsFired.clear();
diff --git a/src/fpd/enrichment.js b/src/fpd/enrichment.js
index f812d8435d9..911509455e0 100644
--- a/src/fpd/enrichment.js
+++ b/src/fpd/enrichment.js
@@ -6,6 +6,10 @@ import {config} from '../config.js';
import {getHighEntropySUA, getLowEntropySUA} from './sua.js';
import {GreedyPromise} from '../utils/promise.js';
import {CLIENT_SECTIONS, clientSectionChecker, hasSection} from './oneClient.js';
+import {isActivityAllowed} from '../activities/rules.js';
+import {activityParams} from '../activities/activityParams.js';
+import {ACTIVITY_ACCESS_DEVICE} from '../activities/activities.js';
+import {MODULE_TYPE_PREBID} from '../activities/modules.js';
export const dep = {
getRefererInfo,
@@ -24,8 +28,10 @@ const oneClient = clientSectionChecker('FPD')
* @returns: {Promise[{}]}: a promise to an enriched ortb2 object.
*/
export const enrichFPD = hook('sync', (fpd) => {
- return GreedyPromise.all([fpd, getSUA().catch(() => null)])
- .then(([ortb2, sua]) => {
+ const promArr = [fpd, getSUA().catch(() => null), tryToGetCdepLabel().catch(() => null)];
+
+ return GreedyPromise.all(promArr)
+ .then(([ortb2, sua, cdep]) => {
const ri = dep.getRefererInfo();
mergeLegacySetConfigs(ortb2);
Object.entries(ENRICHMENTS).forEach(([section, getEnrichments]) => {
@@ -34,9 +40,18 @@ export const enrichFPD = hook('sync', (fpd) => {
ortb2[section] = mergeDeep({}, data, ortb2[section]);
}
});
+
if (sua) {
deepSetValue(ortb2, 'device.sua', Object.assign({}, sua, ortb2.device.sua));
}
+
+ if (cdep) {
+ const ext = {
+ cdep
+ }
+ deepSetValue(ortb2, 'device.ext', Object.assign({}, ext, ortb2.device.ext));
+ }
+
ortb2 = oneClient(ortb2);
for (let section of CLIENT_SECTIONS) {
if (hasSection(ortb2, section)) {
@@ -44,6 +59,7 @@ export const enrichFPD = hook('sync', (fpd) => {
break;
}
}
+
return ortb2;
});
});
@@ -78,6 +94,10 @@ function removeUndef(obj) {
return getDefinedParams(obj, Object.keys(obj))
}
+function tryToGetCdepLabel() {
+ return GreedyPromise.resolve('cookieDeprecationLabel' in navigator && isActivityAllowed(ACTIVITY_ACCESS_DEVICE, activityParams(MODULE_TYPE_PREBID, 'cdep')) && navigator.cookieDeprecationLabel.getValue());
+}
+
const ENRICHMENTS = {
site(ortb2, ri) {
if (CLIENT_SECTIONS.filter(p => p !== 'site').some(hasSection.bind(null, ortb2))) {
@@ -93,6 +113,7 @@ const ENRICHMENTS = {
return winFallback((win) => {
const w = win.innerWidth || win.document.documentElement.clientWidth || win.document.body.clientWidth;
const h = win.innerHeight || win.document.documentElement.clientHeight || win.document.body.clientHeight;
+
return {
w,
h,
diff --git a/src/prebid.js b/src/prebid.js
index 6ad5120ce82..df224ab83cf 100644
--- a/src/prebid.js
+++ b/src/prebid.js
@@ -2,15 +2,11 @@
import {getGlobal} from './prebidGlobal.js';
import {
- callBurl,
- createInvisibleIframe,
deepAccess,
deepClone,
deepSetValue,
flatten,
generateUUID,
- inIframe,
- insertElement,
isArray,
isArrayOfNums,
isEmpty,
@@ -22,8 +18,6 @@ import {
logMessage,
logWarn,
mergeDeep,
- replaceAuctionPrice,
- replaceClickThrough,
transformAdServerTargetingObj,
uniques,
unsupportedBidderMessage
@@ -37,10 +31,8 @@ import {hook, wrapHook} from './hook.js';
import {loadSession} from './debugging.js';
import {includes} from './polyfill.js';
import {adunitCounter} from './adUnits.js';
-import {executeRenderer, isRendererRequired} from './Renderer.js';
import {createBid} from './bidfactory.js';
import {storageCallbacks} from './storageManager.js';
-import {emitAdRenderFail, emitAdRenderSucceeded} from './adRendering.js';
import {default as adapterManager, getS2SBidderSet} from './adapterManager.js';
import CONSTANTS from './constants.json';
import * as events from './events.js';
@@ -48,6 +40,7 @@ import {newMetrics, useMetrics} from './utils/perfMetrics.js';
import {defer, GreedyPromise} from './utils/promise.js';
import {enrichFPD} from './fpd/enrichment.js';
import {allConsent} from './consentHandler.js';
+import {renderAdDirect} from '../libraries/creativeRender/direct.js';
import {getHighestCpm} from './utils/reducers.js';
import {fillVideoDefaults} from './video.js';
@@ -55,8 +48,7 @@ const pbjsInstance = getGlobal();
const { triggerUserSyncs } = userSync;
/* private variables */
-const { ADD_AD_UNITS, BID_WON, REQUEST_BIDS, SET_TARGETING, STALE_RENDER } = CONSTANTS.EVENTS;
-const { PREVENT_WRITING_ON_MAIN_DOCUMENT, NO_AD, EXCEPTION, CANNOT_FIND_AD, MISSING_DOC_OR_ADID } = CONSTANTS.AD_RENDER_FAILED_REASON;
+const { ADD_AD_UNITS, REQUEST_BIDS, SET_TARGETING } = CONSTANTS.EVENTS;
const eventValidators = {
bidWon: checkDefinedPlacement
@@ -96,13 +88,6 @@ function checkDefinedPlacement(id) {
return true;
}
-function setRenderSize(doc, width, height) {
- if (doc.defaultView && doc.defaultView.frameElement) {
- doc.defaultView.frameElement.width = width;
- doc.defaultView.frameElement.height = height;
- }
-}
-
function validateSizes(sizes, targLength) {
let cleanSizes = [];
if (isArray(sizes) && ((targLength) ? sizes.length === targLength : sizes.length > 0)) {
@@ -458,19 +443,6 @@ pbjsInstance.setTargetingForAst = function (adUnitCodes) {
events.emit(SET_TARGETING, targeting.getAllTargeting());
};
-/**
- * This function will check for presence of given node in given parent. If not present - will inject it.
- * @param {Node} node node, whose existance is in question
- * @param {Document} doc document element do look in
- * @param {string} tagName tag name to look in
- */
-function reinjectNodeIfRemoved(node, doc, tagName) {
- const injectionNode = doc.querySelector(tagName);
- if (!node.parentNode || node.parentNode !== injectionNode) {
- insertElement(node, doc, tagName);
- }
-}
-
/**
* This function will render the ad (based on params) in the given iframe document passed through.
* Note that doc SHOULD NOT be the parent document page as we can't doc.write() asynchronously
@@ -481,103 +453,7 @@ function reinjectNodeIfRemoved(node, doc, tagName) {
pbjsInstance.renderAd = hook('async', function (doc, id, options) {
logInfo('Invoking $$PREBID_GLOBAL$$.renderAd', arguments);
logMessage('Calling renderAd with adId :' + id);
-
- if (!id) {
- const message = `Error trying to write ad Id :${id} to the page. Missing adId`;
- emitAdRenderFail({ reason: MISSING_DOC_OR_ADID, message, id });
- return;
- }
-
- try {
- // lookup ad by ad Id
- const bid = auctionManager.findBidByAdId(id);
- if (!bid) {
- const message = `Error trying to write ad. Cannot find ad by given id : ${id}`;
- emitAdRenderFail({ reason: CANNOT_FIND_AD, message, id });
- return;
- }
-
- if (bid.status === CONSTANTS.BID_STATUS.RENDERED) {
- logWarn(`Ad id ${bid.adId} has been rendered before`);
- events.emit(STALE_RENDER, bid);
- if (deepAccess(config.getConfig('auctionOptions'), 'suppressStaleRender')) {
- return;
- }
- }
-
- // replace macros according to openRTB with price paid = bid.cpm
- bid.ad = replaceAuctionPrice(bid.ad, bid.originalCpm || bid.cpm);
- bid.adUrl = replaceAuctionPrice(bid.adUrl, bid.originalCpm || bid.cpm);
- // replacing clickthrough if submitted
- if (options && options.clickThrough) {
- const {clickThrough} = options;
- bid.ad = replaceClickThrough(bid.ad, clickThrough);
- bid.adUrl = replaceClickThrough(bid.adUrl, clickThrough);
- }
-
- // save winning bids
- auctionManager.addWinningBid(bid);
-
- // emit 'bid won' event here
- events.emit(BID_WON, bid);
-
- const {height, width, ad, mediaType, adUrl, renderer} = bid;
-
- // video module
- if (FEATURES.VIDEO) {
- const adUnitCode = bid.adUnitCode;
- const adUnit = pbjsInstance.adUnits.filter(adUnit => adUnit.code === adUnitCode);
- const videoModule = pbjsInstance.videoModule;
- if (adUnit.video && videoModule) {
- videoModule.renderBid(adUnit.video.divId, bid);
- return;
- }
- }
-
- if (!doc) {
- const message = `Error trying to write ad Id :${id} to the page. Missing document`;
- emitAdRenderFail({ reason: MISSING_DOC_OR_ADID, message, id });
- return;
- }
-
- const creativeComment = document.createComment(`Creative ${bid.creativeId} served by ${bid.bidder} Prebid.js Header Bidding`);
- insertElement(creativeComment, doc, 'html');
-
- if (isRendererRequired(renderer)) {
- executeRenderer(renderer, bid, doc);
- reinjectNodeIfRemoved(creativeComment, doc, 'html');
- emitAdRenderSucceeded({ doc, bid, id });
- } else if ((doc === document && !inIframe()) || mediaType === 'video') {
- const message = `Error trying to write ad. Ad render call ad id ${id} was prevented from writing to the main document.`;
- emitAdRenderFail({reason: PREVENT_WRITING_ON_MAIN_DOCUMENT, message, bid, id});
- } else if (ad) {
- doc.write(ad);
- doc.close();
- setRenderSize(doc, width, height);
- reinjectNodeIfRemoved(creativeComment, doc, 'html');
- callBurl(bid);
- emitAdRenderSucceeded({ doc, bid, id });
- } else if (adUrl) {
- const iframe = createInvisibleIframe();
- iframe.height = height;
- iframe.width = width;
- iframe.style.display = 'inline';
- iframe.style.overflow = 'hidden';
- iframe.src = adUrl;
-
- insertElement(iframe, doc, 'body');
- setRenderSize(doc, width, height);
- reinjectNodeIfRemoved(creativeComment, doc, 'html');
- callBurl(bid);
- emitAdRenderSucceeded({ doc, bid, id });
- } else {
- const message = `Error trying to write ad. No ad for bid response id: ${id}`;
- emitAdRenderFail({reason: NO_AD, message, bid, id});
- }
- } catch (e) {
- const message = `Error trying to write ad Id :${id} to the page:${e.message}`;
- emitAdRenderFail({ reason: EXCEPTION, message, id });
- }
+ renderAdDirect(doc, id, options);
});
/**
diff --git a/src/secureCreatives.js b/src/secureCreatives.js
index c719bc191f2..0ea93e7e4fb 100644
--- a/src/secureCreatives.js
+++ b/src/secureCreatives.js
@@ -6,26 +6,24 @@
import * as events from './events.js';
import {fireNativeTrackers, getAllAssetsMessage, getAssetMessage} from './native.js';
import constants from './constants.json';
-import {deepAccess, isApnGetTagDefined, isGptPubadsDefined, logError, logWarn, replaceAuctionPrice} from './utils.js';
+import {isApnGetTagDefined, isGptPubadsDefined, logError, logWarn} from './utils.js';
import {auctionManager} from './auctionManager.js';
import {find, includes} from './polyfill.js';
-import {executeRenderer, isRendererRequired} from './Renderer.js';
-import {config} from './config.js';
-import {emitAdRenderFail, emitAdRenderSucceeded} from './adRendering.js';
+import {emitAdRenderFail, emitAdRenderSucceeded, handleRender} from './adRendering.js';
+import {PREBID_EVENT, PREBID_NATIVE, PREBID_REQUEST, PREBID_RESPONSE} from '../libraries/creativeRender/constants.js';
const BID_WON = constants.EVENTS.BID_WON;
-const STALE_RENDER = constants.EVENTS.STALE_RENDER;
const WON_AD_IDS = new WeakSet();
const HANDLER_MAP = {
- 'Prebid Request': handleRenderRequest,
- 'Prebid Event': handleEventRequest,
-}
+ [PREBID_REQUEST]: handleRenderRequest,
+ [PREBID_EVENT]: handleEventRequest,
+};
if (FEATURES.NATIVE) {
Object.assign(HANDLER_MAP, {
- 'Prebid Native': handleNativeRequest,
- })
+ [PREBID_NATIVE]: handleNativeRequest,
+ });
}
export function listenMessagesFromCreative() {
@@ -35,18 +33,18 @@ export function listenMessagesFromCreative() {
export function getReplier(ev) {
if (ev.origin == null && ev.ports.length === 0) {
return function () {
- const msg = 'Cannot post message to a frame with null origin. Please update creatives to use MessageChannel, see https://github.com/prebid/Prebid.js/issues/7870'
- logError(msg)
+ const msg = 'Cannot post message to a frame with null origin. Please update creatives to use MessageChannel, see https://github.com/prebid/Prebid.js/issues/7870';
+ logError(msg);
throw new Error(msg);
- }
+ };
} else if (ev.ports.length > 0) {
return function (message) {
ev.ports[0].postMessage(JSON.stringify(message));
- }
+ };
} else {
return function (message) {
ev.source.postMessage(JSON.stringify(message), ev.origin);
- }
+ };
}
}
@@ -69,39 +67,13 @@ export function receiveMessage(ev) {
}
}
-function handleRenderRequest(reply, data, adObject) {
- if (adObject == null) {
- emitAdRenderFail({
- reason: constants.AD_RENDER_FAILED_REASON.CANNOT_FIND_AD,
- message: `Cannot find ad for cross-origin render request: '${data.adId}'`,
- id: data.adId
- });
- return;
- }
- if (adObject.status === constants.BID_STATUS.RENDERED) {
- logWarn(`Ad id ${adObject.adId} has been rendered before`);
- events.emit(STALE_RENDER, adObject);
- if (deepAccess(config.getConfig('auctionOptions'), 'suppressStaleRender')) {
- return;
- }
- }
-
- try {
- _sendAdToCreative(adObject, reply);
- } catch (e) {
- emitAdRenderFail({
- reason: constants.AD_RENDER_FAILED_REASON.EXCEPTION,
- message: e.message,
- id: data.adId,
- bid: adObject
- });
- return;
- }
-
- // save winning bids
- auctionManager.addWinningBid(adObject);
-
- events.emit(BID_WON, adObject);
+function handleRenderRequest(reply, message, bidResponse) {
+ handleRender(function (adData) {
+ resizeRemoteCreative(bidResponse);
+ reply(Object.assign({
+ message: PREBID_RESPONSE,
+ }, adData));
+ }, {options: message.options, adId: message.adId, bidResponse});
}
function handleNativeRequest(reply, data, adObject) {
@@ -164,29 +136,11 @@ function handleEventRequest(reply, data, adObject) {
});
break;
default:
- logError(`Received x-origin event request for unsupported event: '${data.event}' (adId: '${data.adId}')`)
- }
-}
-
-export function _sendAdToCreative(adObject, reply) {
- const { adId, ad, adUrl, width, height, renderer, cpm, originalCpm } = adObject;
- // rendering for outstream safeframe
- if (isRendererRequired(renderer)) {
- executeRenderer(renderer, adObject);
- } else if (adId) {
- resizeRemoteCreative(adObject);
- reply({
- message: 'Prebid Response',
- ad: replaceAuctionPrice(ad, originalCpm || cpm),
- adUrl: replaceAuctionPrice(adUrl, originalCpm || cpm),
- adId,
- width,
- height
- });
+ logError(`Received x-origin event request for unsupported event: '${data.event}' (adId: '${data.adId}')`);
}
}
-function resizeRemoteCreative({ adId, adUnitCode, width, height }) {
+export function resizeRemoteCreative({adId, adUnitCode, width, height}) {
// resize both container div + iframe
['div', 'iframe'].forEach(elmType => {
// not select element that gets removed after dfp render
@@ -208,9 +162,9 @@ function resizeRemoteCreative({ adId, adUnitCode, width, height }) {
function getElementIdBasedOnAdServer(adId, adUnitCode) {
if (isGptPubadsDefined()) {
- return getDfpElementId(adId)
+ return getDfpElementId(adId);
} else if (isApnGetTagDefined()) {
- return getAstElementId(adUnitCode)
+ return getAstElementId(adUnitCode);
} else {
return adUnitCode;
}
diff --git a/src/utils.js b/src/utils.js
index 256dfb15174..288f0d5da5d 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -599,9 +599,15 @@ export function isSafariBrowser() {
return /^((?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent);
}
-export function replaceAuctionPrice(str, cpm) {
+export function replaceMacros(str, subs) {
if (!str) return;
- return str.replace(/\$\{AUCTION_PRICE\}/g, cpm);
+ return Object.entries(subs).reduce((str, [key, val]) => {
+ return str.replace(new RegExp('\\$\\{' + key + '\\}', 'g'), val || '');
+ }, str);
+}
+
+export function replaceAuctionPrice(str, cpm) {
+ return replaceMacros(str, {AUCTION_PRICE: cpm})
}
export function replaceClickThrough(str, clicktag) {
diff --git a/test/spec/auctionmanager_spec.js b/test/spec/auctionmanager_spec.js
index b43f630752b..137d009bd18 100644
--- a/test/spec/auctionmanager_spec.js
+++ b/test/spec/auctionmanager_spec.js
@@ -1156,7 +1156,7 @@ describe('auctionmanager.js', function () {
return auction.end.then(() => {
expect(auction.getBidsReceived().length).to.eql(1);
})
- })
+ });
})
it('sets bidResponse.ttlBuffer from adUnit.ttlBuffer', () => {
@@ -1200,6 +1200,7 @@ describe('auctionmanager.js', function () {
const spec2 = mockBidder(BIDDER_CODE1, [bids[1]]);
registerBidder(spec2);
auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: () => auctionDone(), cbTimeout: 20});
+ indexAuctions = [auction];
});
afterEach(function () {
@@ -1216,7 +1217,35 @@ describe('auctionmanager.js', function () {
});
respondToRequest(0);
return pm;
- })
+ });
+
+ describe('AUCTION_TIMEOUT event', () => {
+ let handler;
+ beforeEach(() => {
+ handler = sinon.spy();
+ events.on(CONSTANTS.EVENTS.AUCTION_TIMEOUT, handler);
+ })
+ afterEach(() => {
+ events.off(CONSTANTS.EVENTS.AUCTION_TIMEOUT, handler);
+ });
+
+ Object.entries({
+ 'is fired on timeout': [true, [0]],
+ 'is NOT fired otherwise': [false, [0, 1]],
+ }).forEach(([t, [shouldFire, respond]]) => {
+ it(t, () => {
+ const pm = runAuction().then(() => {
+ if (shouldFire) {
+ sinon.assert.calledWith(handler, sinon.match({auctionId: auction.getAuctionId()}))
+ } else {
+ sinon.assert.notCalled(handler);
+ }
+ });
+ respond.forEach(respondToRequest);
+ return pm;
+ })
+ });
+ });
it('should emit BID_TIMEOUT and AUCTION_END for timed out bids', function () {
const pm = runAuction().then(() => {
diff --git a/test/spec/creative/crossDomainCreative_spec.js b/test/spec/creative/crossDomainCreative_spec.js
new file mode 100644
index 00000000000..765d5e5311a
--- /dev/null
+++ b/test/spec/creative/crossDomainCreative_spec.js
@@ -0,0 +1,182 @@
+import {renderer} from '../../../libraries/creativeRender/crossDomain.js';
+import {
+ AD_RENDER_FAILED, AD_RENDER_SUCCEEDED, EXCEPTION, NO_AD,
+ PREBID_EVENT,
+ PREBID_REQUEST,
+ PREBID_RESPONSE
+} from '../../../libraries/creativeRender/constants.js';
+
+describe('cross-domain creative', () => {
+ let win, renderAd, messages, mkIframe, listeners;
+
+ beforeEach(() => {
+ messages = [];
+ listeners = [];
+ mkIframe = sinon.stub();
+ win = {
+ document: {
+ body: {
+ appendChild: sinon.stub(),
+ },
+ createElement: sinon.stub().callsFake(tagname => {
+ switch (tagname.toLowerCase()) {
+ case 'a':
+ return document.createElement('a')
+ case 'iframe': {
+ return mkIframe();
+ }
+ }
+ })
+ },
+ addEventListener: sinon.stub().callsFake((_, listener) => listeners.push(listener)),
+ parent: {
+ postMessage: sinon.stub().callsFake((payload, targetOrigin, transfer) => {
+ messages.push({payload: JSON.parse(payload), targetOrigin, transfer});
+ })
+ }
+ };
+ renderAd = renderer(win);
+ })
+
+ it('derives postMessage target origin from pubUrl ', () => {
+ renderAd({pubUrl: 'https://domain.com:123/path'});
+ expect(messages[0].targetOrigin).to.eql('https://domain.com:123')
+ });
+
+ it('generates request message with adId and clickUrl', () => {
+ renderAd({adId: '123', clickUrl: 'https://click-url.com'});
+ expect(messages[0].payload).to.eql({
+ message: PREBID_REQUEST,
+ adId: '123',
+ options: {
+ clickUrl: 'https://click-url.com'
+ }
+ })
+ })
+
+ Object.entries({
+ 'MessageChannel': (msg) => messages[0].transfer[0].postMessage(msg),
+ 'message listener': (msg) => listeners.forEach((fn) => fn({data: msg}))
+ }).forEach(([t, transport]) => {
+ describe(`when using ${t}`, () => {
+ function reply(msg) {
+ transport(JSON.stringify(msg))
+ };
+
+ it('ignores messages that are not a prebid response message', () => {
+ renderAd({adId: '123'});
+ reply({adId: '123', ad: 'markup'});
+ sinon.assert.notCalled(mkIframe);
+ })
+
+ describe('signals AD_RENDER_FAILED', () => {
+ it('on exception', (done) => {
+ mkIframe.callsFake(() => { throw new Error('error message') });
+ renderAd({adId: '123'});
+ reply({message: PREBID_RESPONSE, adId: '123', ad: 'markup'});
+ setTimeout(() => {
+ expect(messages[1].payload).to.eql({
+ message: PREBID_EVENT,
+ adId: '123',
+ event: AD_RENDER_FAILED,
+ info: {
+ reason: EXCEPTION,
+ message: 'error message'
+ }
+ })
+ done();
+ }, 100)
+ });
+
+ it('on missing ad', (done) => {
+ renderAd({adId: '123'});
+ reply({message: PREBID_RESPONSE, adId: '123'});
+ setTimeout(() => {
+ sinon.assert.match(messages[1].payload, {
+ message: PREBID_EVENT,
+ adId: '123',
+ event: AD_RENDER_FAILED,
+ info: {
+ reason: NO_AD,
+ }
+ })
+ done();
+ }, 100)
+ })
+ });
+
+ describe('rendering', () => {
+ let iframe;
+
+ beforeEach(() => {
+ iframe = {
+ attrs: {},
+ setAttribute: sinon.stub().callsFake((k, v) => iframe.attrs[k.toLowerCase()] = v),
+ contentDocument: {
+ open: sinon.stub(),
+ write: sinon.stub(),
+ close: sinon.stub(),
+ }
+ }
+ mkIframe.callsFake(() => iframe);
+ });
+
+ it('renders adUrl as iframe src', (done) => {
+ renderAd({adId: '123'});
+ reply({message: PREBID_RESPONSE, adId: '123', adUrl: 'some-url'});
+ setTimeout(() => {
+ sinon.assert.calledWith(win.document.body.appendChild, iframe);
+ expect(iframe.attrs.src).to.eql('some-url');
+ done();
+ }, 100)
+ });
+
+ it('renders ad through document.write', (done) => {
+ renderAd({adId: '123'});
+ reply({message: PREBID_RESPONSE, adId: '123', ad: 'some-markup'});
+ setTimeout(() => {
+ sinon.assert.calledWith(win.document.body.appendChild, iframe);
+ sinon.assert.called(iframe.contentDocument.open);
+ sinon.assert.calledWith(iframe.contentDocument.write, 'some-markup');
+ sinon.assert.called(iframe.contentDocument.close);
+ done();
+ }, 100)
+ });
+
+ Object.entries({
+ adUrl: 'mock-ad-url',
+ ad: 'mock-ad-markup'
+ }).forEach(([prop, propValue]) => {
+ describe(`when message has ${prop}`, () => {
+ beforeEach((done) => {
+ renderAd({adId: '123'});
+ reply({
+ message: PREBID_RESPONSE,
+ adId: '123',
+ [prop]: propValue,
+ width: 100,
+ height: 200
+ });
+ setTimeout(done, 100);
+ });
+
+ it('emits AD_RENDER_SUCCEEDED', () => {
+ expect(messages[1].payload).to.eql({
+ message: PREBID_EVENT,
+ adId: '123',
+ event: AD_RENDER_SUCCEEDED
+ })
+ });
+
+ it('sets iframe height / width to ad height / width', () => {
+ sinon.assert.match(iframe.attrs, {
+ width: 100,
+ height: 200
+ })
+ })
+ })
+ })
+ });
+ });
+ });
+});
diff --git a/test/spec/fpd/enrichment_spec.js b/test/spec/fpd/enrichment_spec.js
index 3b3afb15f8c..40692360dca 100644
--- a/test/spec/fpd/enrichment_spec.js
+++ b/test/spec/fpd/enrichment_spec.js
@@ -3,7 +3,10 @@ import {hook} from '../../../src/hook.js';
import {expect} from 'chai/index.mjs';
import {config} from 'src/config.js';
import * as utils from 'src/utils.js';
+import * as activities from 'src/activities/rules.js'
import {CLIENT_SECTIONS} from '../../../src/fpd/oneClient.js';
+import {ACTIVITY_ACCESS_DEVICE} from '../../../src/activities/activities.js';
+import {ACTIVITY_PARAM_COMPONENT} from '../../../src/activities/params.js';
describe('FPD enrichment', () => {
let sandbox;
@@ -213,7 +216,7 @@ describe('FPD enrichment', () => {
ua: 'ua'
})
})
- })
+ });
});
});
@@ -310,6 +313,71 @@ describe('FPD enrichment', () => {
});
});
+ describe('privacy sandbox cookieDeprecationLabel', () => {
+ let isAllowed, cdep, shouldCleanupNav = false;
+
+ before(() => {
+ if (!navigator.cookieDeprecationLabel) {
+ navigator.cookieDeprecationLabel = {};
+ shouldCleanupNav = true;
+ }
+ });
+
+ after(() => {
+ if (shouldCleanupNav) {
+ delete navigator.cookieDeprecationLabel;
+ }
+ });
+
+ beforeEach(() => {
+ isAllowed = true;
+ sandbox.stub(activities, 'isActivityAllowed').callsFake((activity, params) => {
+ if (activity === ACTIVITY_ACCESS_DEVICE && params[ACTIVITY_PARAM_COMPONENT] === 'prebid.cdep') {
+ return isAllowed;
+ } else {
+ throw new Error('Unexpected activity check');
+ }
+ });
+ sandbox.stub(window.navigator, 'cookieDeprecationLabel').value({
+ getValue: sinon.stub().callsFake(() => cdep)
+ })
+ })
+
+ it('enrichment sets device.ext.cdep when allowed and navigator.getCookieDeprecationLabel exists', () => {
+ cdep = Promise.resolve('example-test-label');
+ return fpd().then(ortb2 => {
+ expect(ortb2.device.ext.cdep).to.eql('example-test-label');
+ })
+ });
+
+ Object.entries({
+ 'not allowed'() {
+ isAllowed = false;
+ },
+ 'not supported'() {
+ delete navigator.cookieDeprecationLabel
+ }
+ }).forEach(([t, setup]) => {
+ it(`if ${t}, the navigator API is not called and no enrichment happens`, () => {
+ setup();
+ cdep = Promise.resolve('example-test-label');
+ return fpd().then(ortb2 => {
+ expect(ortb2.device.ext).to.not.exist;
+ if (navigator.cookieDeprecationLabel) {
+ sinon.assert.notCalled(navigator.cookieDeprecationLabel.getValue);
+ }
+ })
+ });
+ })
+
+ it('if the navigator API returns a promise that rejects, the enrichment does not halt forever', () => {
+ cdep = Promise.reject(new Error('oops, something went wrong'));
+ return fpd().then(ortb2 => {
+ expect(ortb2.device.ext).to.not.exist;
+ })
+ });
+ });
+
it('leaves only one of app, site, dooh', () => {
return fpd({
app: {p: 'val'},
diff --git a/test/spec/modules/33acrossAnalyticsAdapter_spec.js b/test/spec/modules/33acrossAnalyticsAdapter_spec.js
new file mode 100644
index 00000000000..9e0d928cd97
--- /dev/null
+++ b/test/spec/modules/33acrossAnalyticsAdapter_spec.js
@@ -0,0 +1,1163 @@
+// @ts-nocheck
+import analyticsAdapter from 'modules/33acrossAnalyticsAdapter.js';
+import { log } from 'modules/33acrossAnalyticsAdapter.js';
+import * as mockGpt from 'test/spec/integration/faker/googletag.js';
+import * as events from 'src/events.js';
+import * as faker from 'faker';
+import CONSTANTS from 'src/constants.json';
+import { gdprDataHandler, gppDataHandler, uspDataHandler } from '../../../src/adapterManager';
+import { DEFAULT_ENDPOINT, POST_GAM_TIMEOUT, locals } from '../../../modules/33acrossAnalyticsAdapter';
+const { EVENTS, BID_STATUS } = CONSTANTS;
+
+describe('33acrossAnalyticsAdapter:', function () {
+ let sandbox;
+ let assert = getLocalAssert();
+
+ beforeEach(function () {
+ mockGpt.reset();
+
+ sandbox = sinon.createSandbox({
+ useFakeTimers: {
+ now: new Date(2023, 3, 3, 0, 1, 33, 425),
+ },
+ });
+
+ sandbox.stub(events, 'getEvents').returns([]);
+
+ sandbox.spy(log, 'info');
+ sandbox.spy(log, 'warn');
+ sandbox.spy(log, 'error');
+
+ sandbox.stub(navigator, 'sendBeacon').callsFake(function (url, data) {
+ const json = JSON.parse(data);
+ assert.isValidAnalyticsReport(json);
+
+ return true;
+ });
+ });
+
+ afterEach(function () {
+ analyticsAdapter.disableAnalytics();
+ mockGpt.enable();
+ sandbox.restore();
+ });
+
+ describe('enableAnalytics:', function () {
+ context('When pid is given', function () {
+ context('but endpoint is not', function () {
+ it('uses the default endpoint', function () {
+ analyticsAdapter.enableAnalytics({
+ options: {
+ pid: 'test-pid',
+ },
+ });
+
+ assert.equal(analyticsAdapter.getUrl(), DEFAULT_ENDPOINT);
+ });
+ });
+
+ context('but the endpoint is invalid', function () {
+ it('logs an info message', function () {
+ analyticsAdapter.enableAnalytics({
+ options: {
+ pid: 'test-pid',
+ endpoint: 'foo'
+ },
+ });
+
+ assert.calledWithExactly(log.info, 'Invalid endpoint provided for "options.endpoint". Using default endpoint.');
+ });
+ });
+ });
+
+ context('When endpoint is given', function () {
+ context('but pid is not', function () {
+ it('logs an error message', function () {
+ analyticsAdapter.enableAnalytics({
+ options: {
+ endpoint: faker.internet.url()
+ },
+ });
+
+ assert.calledWithExactly(log.error, 'No partnerId provided for "options.pid". No analytics will be sent.');
+ });
+ });
+ });
+
+ context('When pid and endpoint are given', function () {
+ context('and an invalid timeout config value is given', function () {
+ it('logs an info message', function () {
+ [null, 'foo', -1].forEach(timeout => {
+ analyticsAdapter.enableAnalytics({
+ options: {
+ pid: 'test-pid',
+ endpoint: 'http://test-endpoint',
+ timeout
+ },
+ });
+ analyticsAdapter.disableAnalytics();
+
+ assert.calledWithExactly(log.info, 'Invalid timeout provided for "options.timeout". Using default timeout of 10000ms.');
+ log.info.resetHistory();
+ });
+ });
+ });
+ });
+ });
+
+ // check that upcoming tests are derived from a valid report
+ describe('Report Mocks', function () {
+ it('the report should have the correct format', function () {
+ assert.isValidAnalyticsReport(createReportWithThreeBidWonEvents());
+ });
+ });
+
+ describe('Event Handling', function () {
+ beforeEach(function () {
+ this.defaultTimeout = 10000;
+ this.enableAnalytics = (options) => {
+ analyticsAdapter.enableAnalytics({
+ options: {
+ endpoint: 'http://test-endpoint',
+ pid: 'test-pid',
+ timeout: this.defaultTimeout,
+ ...options
+ },
+ });
+ window.googletag.cmd.forEach(cmd => cmd());
+ }
+ });
+
+ context('when an auction is complete', function () {
+ context('and the AnalyticsReport is sent successfully to the given endpoint', function () {
+ it('calls "sendBeacon" with all won bids', function () {
+ const endpoint = faker.internet.url();
+ this.enableAnalytics({ endpoint });
+
+ navigator.sendBeacon
+ .withArgs(endpoint, JSON.stringify(createReportWithThreeBidWonEvents()));
+
+ performStandardAuction();
+ sandbox.clock.tick(this.defaultTimeout + 1000);
+
+ const [url, jsonString] = navigator.sendBeacon.firstCall.args;
+ const { auctions } = JSON.parse(jsonString);
+
+ assert.lengthOf(mapToBids(auctions).filter(bid => bid.hasWon), 3);
+ });
+
+ it('calls "sendBeacon" with the correct report string', function () {
+ const endpoint = faker.internet.url();
+ this.enableAnalytics({ endpoint });
+
+ navigator.sendBeacon
+ .withArgs(endpoint, JSON.stringify(createReportWithThreeBidWonEvents()));
+
+ performStandardAuction();
+ sandbox.clock.tick(this.defaultTimeout + 1000);
+
+ assert.calledOnceWithStringJsonEquivalent(navigator.sendBeacon, endpoint, createReportWithThreeBidWonEvents());
+ });
+
+ it('logs an info message containing the report', function () {
+ const endpoint = faker.internet.url();
+ this.enableAnalytics({ endpoint });
+
+ navigator.sendBeacon
+ .withArgs(endpoint, JSON.stringify(createReportWithThreeBidWonEvents()))
+ .returns(true);
+
+ performStandardAuction();
+ sandbox.clock.tick(this.defaultTimeout + 1000);
+
+ assert.calledWithExactly(log.info, `Analytics report sent to ${endpoint}`, createReportWithThreeBidWonEvents());
+ });
+
+ it('calls "sendBeacon" as soon as all values are available (before timeout)', function () {
+ const endpoint = faker.internet.url();
+ this.enableAnalytics({ endpoint });
+
+ navigator.sendBeacon
+ .withArgs(endpoint, JSON.stringify(createReportWithThreeBidWonEvents()));
+
+ performStandardAuction();
+ sandbox.clock.tick(1);
+
+ assert.calledOnceWithStringJsonEquivalent(navigator.sendBeacon, endpoint, createReportWithThreeBidWonEvents());
+ });
+ });
+
+ context('and a valid US Privacy configuration is present', function () {
+ ['1YNY', '1---', '1NY-', '1Y--', '1--Y', '1N--', '1--N', '1NNN'].forEach(consent => {
+ it(`calls "sendBeacon" with a report containing the "${consent}" privacy string`, function () {
+ sandbox.stub(uspDataHandler, 'getConsentData').returns(consent);
+ this.enableAnalytics();
+
+ const reportWithConsent = {
+ ...createReportWithThreeBidWonEvents(),
+ usPrivacy: consent
+ };
+ navigator.sendBeacon
+ .withArgs('http://test-endpoint', reportWithConsent);
+
+ performStandardAuction();
+ sandbox.clock.tick(this.defaultTimeout + 1000);
+
+ assert.calledOnceWithStringJsonEquivalent(navigator.sendBeacon, 'http://test-endpoint', reportWithConsent);
+ });
+ });
+ });
+
+ context('and a GDPR Privacy configuration is present', function () {
+ it('it calls "sendBeacon" with a report containing the GDPR consent string', function () {
+ sandbox.stub(gdprDataHandler, 'getConsentData').returns({
+ consentString: 'foo',
+ gdprApplies: true
+ });
+ this.enableAnalytics();
+
+ const reportWithConsent = {
+ ...createReportWithThreeBidWonEvents(),
+ gdpr: 1,
+ gdprConsent: 'foo'
+ };
+ navigator.sendBeacon
+ .withArgs('http://test-endpoint', reportWithConsent);
+
+ performStandardAuction();
+ sandbox.clock.tick(this.defaultTimeout + 1);
+
+ assert.calledOnceWithStringJsonEquivalent(navigator.sendBeacon, 'http://test-endpoint', reportWithConsent);
+ });
+ });
+ });
+
+ context('when an auction is complete and a GPP configuration is present', function () {
+ it('it calls "sendBeacon" with a report containing the GPP consent string', function () {
+ sandbox.stub(gppDataHandler, 'getConsentData').returns({
+ gppString: 'gppString',
+ applicableSections: [7]
+ });
+ this.enableAnalytics();
+
+ const reportWithConsent = {
+ ...createReportWithThreeBidWonEvents(),
+ gpp: 'gppString',
+ gppSid: [7]
+ };
+ navigator.sendBeacon
+ .withArgs('http://test-endpoint', reportWithConsent);
+
+ performStandardAuction();
+ sandbox.clock.tick(this.defaultTimeout + 1);
+
+ assert.calledOnceWithStringJsonEquivalent(navigator.sendBeacon, 'http://test-endpoint', reportWithConsent);
+ });
+ });
+
+ context('when an error occurs while sending the AnalyticsReport', function () {
+ it('logs an error', function () {
+ this.enableAnalytics();
+ navigator.sendBeacon.returns(false);
+
+ performStandardAuction();
+ sandbox.clock.tick(this.defaultTimeout + 1000);
+
+ assert.calledWithExactly(log.error, 'Analytics report exceeded User-Agent data limits and was not sent.', createReportWithThreeBidWonEvents());
+ });
+ });
+
+ context('when an auction report was already sent', function () {
+ context('and a new bid won event is returned after the report completes', function () {
+ it('finishes the auction without error', function () {
+ const incompleteAnalyticsReport = createReportWithThreeBidWonEvents();
+ incompleteAnalyticsReport.auctions.forEach(auction => {
+ auction.adUnits.forEach(adUnit => {
+ adUnit.bids.forEach(bid => {
+ delete bid.bidResponse;
+ bid.hasWon = 0;
+ bid.status = 'pending';
+ });
+ });
+ });
+
+ this.enableAnalytics();
+ const { prebid: [auction] } = getMockEvents();
+
+ events.emit(EVENTS.AUCTION_INIT, auction.AUCTION_INIT);
+ for (let bidRequestedEvent of auction.BID_REQUESTED) {
+ events.emit(EVENTS.BID_REQUESTED, bidRequestedEvent);
+ };
+
+ sandbox.clock.tick(this.defaultTimeout + 1000);
+
+ for (let bidResponseEvent of auction.BID_RESPONSE) {
+ events.emit(EVENTS.BID_RESPONSE, bidResponseEvent);
+ };
+ for (let bidWonEvent of auction.BID_WON) {
+ events.emit(EVENTS.BID_WON, bidWonEvent);
+ };
+
+ events.emit(EVENTS.AUCTION_END, auction.AUCTION_END);
+
+ sandbox.clock.tick(1);
+
+ assert.calledOnceWithStringJsonEquivalent(navigator.sendBeacon, 'http://test-endpoint', incompleteAnalyticsReport);
+ });
+ });
+
+ context('and another auction completes after that', function () {
+ it('sends the new report', function () {
+ const endpoint = faker.internet.url();
+ this.enableAnalytics({ endpoint });
+
+ navigator.sendBeacon
+ .withArgs(endpoint, JSON.stringify(createReportWithThreeBidWonEvents()));
+
+ performStandardAuction();
+ sandbox.clock.tick(this.defaultTimeout + 1000);
+
+ performStandardAuction();
+ sandbox.clock.tick(this.defaultTimeout + 1000);
+
+ assert.calledTwice(navigator.sendBeacon);
+ });
+ });
+ });
+
+ context('when two auctions overlap', function() {
+ it('sends a report for each auction', function () {
+ const endpoint = faker.internet.url();
+ this.enableAnalytics({ endpoint });
+
+ navigator.sendBeacon
+ .withArgs(endpoint, JSON.stringify(createReportWithThreeBidWonEvents()));
+
+ performStandardAuction();
+ performStandardAuction();
+ sandbox.clock.tick(this.defaultTimeout + 1000);
+
+ assert.calledTwice(navigator.sendBeacon);
+ });
+ });
+
+ context('when an AUCTION_END event is received before BID_WON events', function () {
+ it('sends a report with the bids that have won after all bids are won', function () {
+ const endpoint = faker.internet.url();
+ this.enableAnalytics({ endpoint });
+
+ navigator.sendBeacon
+ .withArgs(endpoint, JSON.stringify(createReportWithThreeBidWonEvents()));
+
+ const { prebid: [auction] } = getMockEvents();
+
+ performStandardAuction({ exclude: [EVENTS.BID_WON] });
+
+ assert.notCalled(navigator.sendBeacon);
+ for (let bidWon of auction.BID_WON) {
+ events.emit(EVENTS.BID_WON, bidWon);
+ }
+ assert.calledOnceWithStringJsonEquivalent(navigator.sendBeacon, endpoint, createReportWithThreeBidWonEvents());
+ });
+ });
+
+ context('when a BID_WON event is received', function () {
+ context('and there is no record of that bid being requested', function () {
+ it('logs a warning message', function () {
+ this.enableAnalytics();
+
+ const mockEvents = getMockEvents();
+ const { prebid } = mockEvents;
+ const [auction] = prebid;
+
+ events.emit(EVENTS.AUCTION_INIT, auction.AUCTION_INIT);
+
+ const fakeBidWonEvent = Object.assign(auction.BID_WON[0], {
+ transactionId: 'foo'
+ })
+
+ events.emit(EVENTS.BID_WON, fakeBidWonEvent);
+
+ const { auctionId, requestId } = fakeBidWonEvent;
+ assert.calledWithExactly(log.error, `Cannot find bid "${requestId}" in auction "${auctionId}".`);
+ });
+ });
+ });
+
+ context('when a BID_REJECTED event is received', function () {
+ it(`marks the rejected bid as "rejected"`, function () {
+ this.enableAnalytics();
+
+ const auction = getMockEvents().prebid[0];
+
+ // Start the auction
+ events.emit(EVENTS.AUCTION_INIT, auction.AUCTION_INIT);
+ for (let bidRequestedEvent of auction.BID_REQUESTED) {
+ events.emit(EVENTS.BID_REQUESTED, bidRequestedEvent);
+ };
+
+ // Reject first bid
+ const bidToReject = auction.BID_REQUESTED[0].bids[0];
+ events.emit(EVENTS.BID_REJECTED, auction.BID_REJECTED[0]);
+
+ // Accept remaining bids
+ for (let i = 1; i < auction.BID_RESPONSE.length; ++i) {
+ events.emit(EVENTS.BID_RESPONSE, auction.BID_RESPONSE[i]);
+ };
+
+ // Complete the auction
+ events.emit(EVENTS.AUCTION_END, auction.AUCTION_END);
+
+ sandbox.clock.tick(this.defaultTimeout + 1);
+
+ // Verify that we detected that the first bid was rejected
+ const expectedRejectedBid = JSON.parse(navigator.sendBeacon.firstCall.args[1]).auctions[0].adUnits[0].bids[0];
+ assert.strictEqual(expectedRejectedBid.status, 'rejected');
+ });
+ });
+
+ context('when a transaction does not reach its complete state', function () {
+ context('and a timeout config value has been given', function () {
+ context('and the timeout value has elapsed', function () {
+ it('logs a warning', function () {
+ const timeout = 2000;
+ this.enableAnalytics({ timeout });
+
+ performStandardAuction({exclude: ['bidWon', 'slotRenderEnded', 'auctionEnd']});
+
+ sandbox.clock.tick(timeout + 1000);
+
+ assert.calledWithExactly(log.warn, 'Timed out waiting for ad transactions to complete. Sending report.');
+ });
+
+ it(`marks timed out bids as "timeout"`, function () {
+ const timeout = 2000;
+ this.enableAnalytics({ timeout });
+ const request = getMockEvents().prebid[0].BID_REQUESTED[0];
+ const bidToTimeout = request.bids[0];
+
+ performStandardAuction({exclude: ['bidWon', 'slotRenderEnded', 'auctionEnd']});
+ sandbox.clock.tick(1);
+ events.emit(EVENTS.BID_TIMEOUT, [{
+ auctionId: request.auctionId,
+ bidId: bidToTimeout.bidId,
+ transactionId: bidToTimeout.transactionId,
+ }]);
+ sandbox.clock.tick(timeout + 1000);
+
+ const timeoutBid = JSON.parse(navigator.sendBeacon.firstCall.args[1]).auctions[0].adUnits[0].bids[0];
+ assert.strictEqual(timeoutBid.status, 'timeout');
+ });
+ });
+ });
+
+ context('and a timeout config value has not been given', function () {
+ context('and the default timeout has elapsed', function () {
+ it('logs an error', function () {
+ this.enableAnalytics();
+
+ performStandardAuction({exclude: ['bidWon', 'slotRenderEnded', 'auctionEnd']});
+
+ sandbox.clock.tick(this.defaultTimeout + 1000);
+
+ assert.calledWithExactly(log.warn, 'Timed out waiting for ad transactions to complete. Sending report.');
+ });
+ })
+ });
+
+ context('and the `slotRenderEnded` event fired for all bids, but not all bids have won', function () {
+ context('and the GAM slot IDs are configured as the ad unit codes', function () {
+ it('sends a report after the all `slotRenderEnded` events have fired and timed out', function () {
+ const timeout = POST_GAM_TIMEOUT + 2000;
+ this.enableAnalytics({ timeout });
+
+ performStandardAuction({exclude: ['bidWon', 'auctionEnd']});
+ sandbox.clock.tick(POST_GAM_TIMEOUT + 1);
+
+ assert.strictEqual(navigator.sendBeacon.callCount, 1);
+ });
+ });
+
+ context('and the slot element IDs are configured as the ad unit codes', function () {
+ it('sends a report after the all `slotRenderEnded` events have fired and timed out', function () {
+ const timeout = POST_GAM_TIMEOUT + 2000;
+ this.enableAnalytics({ timeout });
+
+ performStandardAuction({exclude: ['bidWon', 'auctionEnd'], useSlotElementIds: true});
+ sandbox.clock.tick(POST_GAM_TIMEOUT + 1);
+
+ assert.strictEqual(navigator.sendBeacon.callCount, 1);
+ });
+ });
+
+ it('does NOT send a report if not all `slotRenderEnded` events have timed out', function () {
+ const timeout = POST_GAM_TIMEOUT + 2000;
+ this.enableAnalytics({ timeout });
+
+ performStandardAuction({exclude: ['bidWon', 'auctionEnd']});
+ sandbox.clock.tick(POST_GAM_TIMEOUT - 1);
+
+ assert.strictEqual(navigator.sendBeacon.callCount, 0);
+ });
+ });
+
+ context('and the `slotRenderEnded` event has fired for an unknown slot code', function () {
+ it('logs a warning message', function () {
+ this.enableAnalytics();
+
+ const { prebid: [auction], gam } = getMockEvents();
+ auction.AUCTION_INIT.adUnits[0].code = 'INVALID_AD_UNIT_CODE';
+
+ const slotRenderEnded = gam.slotRenderEnded[0];
+ events.emit(EVENTS.AUCTION_INIT, auction.AUCTION_INIT);
+ events.emit(EVENTS.BID_REQUESTED, auction.BID_REQUESTED[0]);
+ mockGpt.emitEvent('slotRenderEnded', slotRenderEnded);
+
+ sandbox.clock.tick(POST_GAM_TIMEOUT + 1);
+
+ assert.calledWithExactly(log.warn,
+ 'Could not find configured ad unit matching GAM render of slot:',
+ { slotName: `${adUnitCodes[0]} - ${adSlotElementIds[0]}` });
+ });
+ });
+
+ context('and the incomplete report has been sent successfully', function () {
+ it('sends a report string with any bids with rendered status set to hasWon: 1', function () {
+ navigator.sendBeacon.returns(true);
+
+ this.enableAnalytics();
+
+ performStandardAuction({exclude: ['auctionEnd']});
+ sandbox.clock.tick(this.defaultTimeout + 1000);
+
+ const incompleteSentBid = JSON.parse(navigator.sendBeacon.firstCall.args[1]).auctions[0].adUnits[1].bids[0];
+ assert.strictEqual(incompleteSentBid.hasWon, 1);
+ });
+
+ it('reports bids with only targetingSet status as hasWon: 0', function () {
+ navigator.sendBeacon.returns(true);
+
+ this.enableAnalytics();
+
+ performStandardAuction({exclude: ['bidWon', 'auctionEnd']});
+ sandbox.clock.tick(this.defaultTimeout + 1000);
+
+ const incompleteSentBid = JSON.parse(navigator.sendBeacon.firstCall.args[1]).auctions[0].adUnits[1].bids[0];
+ assert.strictEqual(incompleteSentBid.hasWon, 0);
+ });
+
+ it('logs an info message', function () {
+ navigator.sendBeacon.returns(true);
+
+ const endpoint = faker.internet.url();
+ this.enableAnalytics({ endpoint });
+
+ performStandardAuction({exclude: ['bidWon', 'auctionEnd']});
+ sandbox.clock.tick(this.defaultTimeout + 1000);
+
+ assert.calledWith(log.info, `Analytics report sent to ${endpoint}`);
+ });
+ });
+ });
+
+ context('when the transaction manager has open transactions', function () {
+ it('reports those transactions as pending', function () {
+ this.enableAnalytics();
+
+ const { prebid: [auction] } = getMockEvents();
+ events.emit(EVENTS.AUCTION_INIT, auction.AUCTION_INIT);
+ events.emit(EVENTS.BID_REQUESTED, auction.BID_REQUESTED[0]);
+
+ const manager = locals.transactionManagers[auction.AUCTION_INIT.auctionId];
+ assert.equal(manager.status().pending.length, auction.BID_REQUESTED[0].bids.length);
+ });
+
+ context('and a single bidWon event has triggered', function () {
+ it('completes the transaction', function () {
+ this.enableAnalytics();
+
+ const { prebid: [auction] } = getMockEvents();
+ events.emit(EVENTS.AUCTION_INIT, auction.AUCTION_INIT);
+ events.emit(EVENTS.BID_REQUESTED, auction.BID_REQUESTED[0]);
+ events.emit(EVENTS.BID_WON, auction.BID_WON[0]);
+
+ const manager = locals.transactionManagers[auction.AUCTION_INIT.auctionId];
+ assert.deepEqual({
+ completed: manager.status().completed.length,
+ pending: manager.status().pending.length
+ }, {
+ completed: 1,
+ pending: auction.BID_REQUESTED[0].bids.length - 1
+ });
+ });
+ });
+
+ context('and a single slotRenderEnded event has triggered', function () {
+ context('and the Google Ad Manager timeout has not elapsed', function () {
+ it('does NOT complete the transaction', function () {
+ this.enableAnalytics();
+
+ const { prebid: [auction], gam } = getMockEvents();
+ const slotRenderEnded = gam.slotRenderEnded[0];
+ events.emit(EVENTS.AUCTION_INIT, auction.AUCTION_INIT);
+ events.emit(EVENTS.BID_REQUESTED, auction.BID_REQUESTED[0]);
+ mockGpt.emitEvent('slotRenderEnded', slotRenderEnded);
+
+ const manager = locals.transactionManagers[auction.AUCTION_INIT.auctionId];
+ assert.deepEqual({
+ completed: manager.status().completed.length,
+ pending: manager.status().pending.length
+ }, {
+ completed: 0,
+ pending: auction.BID_REQUESTED[0].bids.length
+ });
+ });
+ });
+
+ context('and the Google Ad Manager timeout has elapsed', function () {
+ it('completes the transaction', function () {
+ const timeout = POST_GAM_TIMEOUT + 2000;
+ this.enableAnalytics({timeout});
+
+ const { prebid: [auction], gam } = getMockEvents();
+ const slotRenderEnded = gam.slotRenderEnded[0];
+ events.emit(EVENTS.AUCTION_INIT, auction.AUCTION_INIT);
+ events.emit(EVENTS.BID_REQUESTED, auction.BID_REQUESTED[0]);
+ mockGpt.emitEvent('slotRenderEnded', slotRenderEnded);
+
+ sandbox.clock.tick(POST_GAM_TIMEOUT + 1);
+ const manager = locals.transactionManagers[auction.AUCTION_INIT.auctionId];
+ assert.deepEqual({
+ completed: manager.status().completed.length,
+ pending: manager.status().pending.length
+ }, {
+ completed: 1,
+ pending: auction.BID_REQUESTED[0].bids.length - 1
+ });
+ });
+ });
+ });
+ });
+ });
+});
+
+const adUnitCodes = ['/19968336/header-bid-tag-0', '/19968336/header-bid-tag-1', '/17118521/header-bid-tag-2'];
+const adSlotElementIds = ['ad-slot-div-0', 'ad-slot-div-1', 'ad-slot-div-2'];
+
+function performStandardAuction({ exclude = [], useSlotElementIds = false } = {}) {
+ const mockEvents = getMockEvents();
+ const { prebid, gam } = mockEvents;
+ const [auction] = prebid;
+
+ if (!exclude.includes(EVENTS.AUCTION_INIT)) {
+ if (useSlotElementIds) {
+ // With this option, identify the ad units by slot element IDs instead of GAM paths
+ auction.AUCTION_INIT.adUnits.forEach((adUnit, i) => {
+ adUnit.code = adSlotElementIds[i];
+ });
+ }
+ events.emit(EVENTS.AUCTION_INIT, auction.AUCTION_INIT);
+ }
+
+ if (!exclude.includes(EVENTS.BID_REQUESTED)) {
+ for (let bidRequestedEvent of auction.BID_REQUESTED) {
+ events.emit(EVENTS.BID_REQUESTED, bidRequestedEvent);
+ };
+ }
+
+ if (!exclude.includes(EVENTS.BID_RESPONSE)) {
+ for (let bidResponseEvent of auction.BID_RESPONSE) {
+ events.emit(EVENTS.BID_RESPONSE, bidResponseEvent);
+ };
+ }
+
+ if (!exclude.includes(EVENTS.AUCTION_END)) {
+ events.emit(EVENTS.AUCTION_END, auction.AUCTION_END);
+ }
+
+ if (!exclude.includes('slotRenderEnded')) {
+ for (let gEvent of gam.slotRenderEnded) {
+ mockGpt.emitEvent('slotRenderEnded', gEvent);
+ }
+ }
+
+ if (!exclude.includes(EVENTS.BID_WON)) {
+ for (let bidWonEvent of auction.BID_WON) {
+ events.emit(EVENTS.BID_WON, bidWonEvent);
+ };
+ }
+}
+
+function mapToBids(auctions) {
+ return auctions.flatMap(
+ auction => auction.adUnits.flatMap(
+ au => au.bids
+ )
+ );
+}
+
+function getLocalAssert() {
+ function isValidAnalyticsReport(report) {
+ assert.containsAllKeys(report, ['analyticsVersion', 'pid', 'src', 'pbjsVersion', 'auctions']);
+ if ('usPrivacy' in report) {
+ assert.match(report.usPrivacy, /[0|1][Y|N|-]{3}/);
+ }
+ if ('gdpr' in report) {
+ assert.oneOf(report.gdpr, [0, 1]);
+ }
+ if (report.gdpr === 1) {
+ assert.isString(report.gdprConsent);
+ }
+ if ('gpp' in report) {
+ assert.isString(report.gpp);
+ assert.isArray(report.gppSid);
+ }
+ if ('coppa' in report) {
+ assert.oneOf(report.coppa, [0, 1]);
+ }
+
+ assert.equal(report.analyticsVersion, '1.0.0');
+ assert.isString(report.pid);
+ assert.isString(report.src);
+ assert.equal(report.pbjsVersion, '$prebid.version$');
+ assert.isArray(report.auctions);
+ assert.isAbove(report.auctions.length, 0);
+ report.auctions.forEach(isValidAuction);
+ }
+ function isValidAuction(auction) {
+ assert.hasAllKeys(auction, ['adUnits', 'auctionId', 'userIds']);
+ assert.isArray(auction.adUnits);
+ assert.isString(auction.auctionId);
+ assert.isArray(auction.userIds);
+ auction.adUnits.forEach(isValidAdUnit);
+ }
+ function isValidAdUnit(adUnit) {
+ assert.hasAllKeys(adUnit, ['transactionId', 'adUnitCode', 'slotId', 'mediaTypes', 'sizes', 'bids']);
+ assert.isString(adUnit.transactionId);
+ assert.isString(adUnit.adUnitCode);
+ assert.isString(adUnit.slotId);
+ assert.isArray(adUnit.mediaTypes);
+ assert.isArray(adUnit.sizes);
+ assert.isArray(adUnit.bids);
+ adUnit.mediaTypes.forEach(isValidMediaType);
+ adUnit.sizes.forEach(isValidSizeString);
+ adUnit.bids.forEach(isValidBid);
+ }
+ function isValidBid(bid) {
+ assert.containsAllKeys(bid, ['bidder', 'bidId', 'source', 'status', 'hasWon']);
+ if ('bidResponse' in bid) {
+ isValidBidResponse(bid.bidResponse);
+ }
+ assert.isString(bid.bidder);
+ assert.isString(bid.bidId);
+ assert.isString(bid.source);
+ assert.oneOf(bid.status, ['pending', 'timeout', 'targetingSet', 'rendered', 'success', 'rejected', 'no-bid', 'error']);
+ assert.oneOf(bid.hasWon, [0, 1]);
+ }
+ function isValidBidResponse(bidResponse) {
+ assert.containsAllKeys(bidResponse, ['mediaType', 'size', 'cur', 'cpm', 'cpmFloor']);
+ if ('cpmOrig' in bidResponse) {
+ assert.isNumber(bidResponse.cpmOrig);
+ }
+ isValidMediaType(bidResponse.mediaType);
+ isValidSizeString(bidResponse.size);
+ assert.isString(bidResponse.cur);
+ assert.isNumber(bidResponse.cpm);
+ assert.isNumber(bidResponse.cpmFloor);
+ }
+ function isValidMediaType(mediaType) {
+ assert.oneOf(mediaType, ['banner', 'video', 'native']);
+ }
+ function isValidSizeString(size) {
+ assert.match(size, /[0-9]+x[0-9]+/);
+ }
+
+ function calledOnceWithStringJsonEquivalent(sinonSpy, ...args) {
+ sinon.assert.calledOnce(sinonSpy);
+ args.forEach((arg, i) => {
+ const stubCallArgs = sinonSpy.firstCall.args[i]
+
+ if (typeof arg === 'object') {
+ assert.deepEqual(JSON.parse(stubCallArgs), arg);
+ } else {
+ assert.strictEqual(stubCallArgs, arg);
+ }
+ });
+ }
+
+ sinon.assert.expose(assert, { prefix: '' });
+ return {
+ ...assert,
+ calledOnceWithStringJsonEquivalent,
+ isValidAnalyticsReport,
+ isValidAuction,
+ isValidAdUnit,
+ isValidBid,
+ isValidBidResponse,
+ isValidMediaType,
+ isValidSizeString,
+ }
+};
+
+function createReportWithThreeBidWonEvents() {
+ return {
+ pid: 'test-pid',
+ src: 'pbjs',
+ analyticsVersion: '1.0.0',
+ pbjsVersion: '$prebid.version$',
+ auctions: [{
+ adUnits: [{
+ transactionId: 'ef947609-7b55-4420-8407-599760d0e373',
+ adUnitCode: adUnitCodes[0],
+ slotId: adUnitCodes[0],
+ mediaTypes: ['banner'],
+ sizes: ['300x250', '300x600'],
+ bids: [{
+ bidder: 'bidder0',
+ bidId: '20661fc5fbb5d9b',
+ source: 'client',
+ status: 'rendered',
+ bidResponse: {
+ cpm: 1.5,
+ cur: 'USD',
+ cpmOrig: 1.5,
+ cpmFloor: 1,
+ mediaType: 'banner',
+ size: '300x250'
+ },
+ hasWon: 1
+ }]
+ }, {
+ transactionId: 'abab4423-d962-41aa-adc7-0681f686c330',
+ adUnitCode: adUnitCodes[1],
+ slotId: adUnitCodes[1],
+ mediaTypes: ['banner'],
+ sizes: ['728x90', '970x250'],
+ bids: [{
+ bidder: 'bidder0',
+ bidId: '21ad295f40dd7ab',
+ source: 'client',
+ status: 'rendered',
+ bidResponse: {
+ cpm: 1.5,
+ cur: 'USD',
+ cpmOrig: 1.5,
+ cpmFloor: 1,
+ mediaType: 'banner',
+ size: '728x90'
+ },
+ hasWon: 1
+ }]
+ }, {
+ transactionId: 'b43e7487-0a52-4689-a0f7-d139d08b1f9f',
+ adUnitCode: adUnitCodes[2],
+ slotId: adUnitCodes[2],
+ mediaTypes: ['banner'],
+ sizes: ['300x250'],
+ bids: [{
+ bidder: 'bidder0',
+ bidId: '22108ac7b778717',
+ source: 'client',
+ status: 'rendered',
+ bidResponse: {
+ cpm: 1.5,
+ cur: 'USD',
+ cpmOrig: 1.5,
+ cpmFloor: 1,
+ mediaType: 'banner',
+ size: '728x90'
+ },
+ hasWon: 1
+ }]
+ }],
+ auctionId: 'auction-000',
+ userIds: ['33acrossId']
+ }],
+ };
+}
+
+function getMockEvents() {
+ const auctionId = 'auction-000';
+ const userId = {
+ '33acrossId': {
+ envelope: 'v1.0014',
+ },
+ };
+
+ return {
+ gam: {
+ slotRenderEnded: [
+ {
+ serviceName: 'publisher_ads',
+ slot: mockGpt.makeSlot({ code: adUnitCodes[0], divId: adSlotElementIds[0] }),
+ isEmpty: true,
+ slotContentChanged: true,
+ size: null,
+ advertiserId: null,
+ campaignId: null,
+ creativeId: null,
+ creativeTemplateId: null,
+ labelIds: null,
+ lineItemId: null,
+ isBackfill: false,
+ },
+ {
+ serviceName: 'publisher_ads',
+ slot: mockGpt.makeSlot({ code: adUnitCodes[1], divId: adSlotElementIds[1] }),
+ isEmpty: false,
+ slotContentChanged: true,
+ size: [1, 1],
+ advertiserId: 12345,
+ campaignId: 400000001,
+ creativeId: 6789,
+ creativeTemplateId: null,
+ labelIds: null,
+ lineItemId: 1011,
+ isBackfill: false,
+ yieldGroupIds: null,
+ companyIds: null,
+ },
+ {
+ serviceName: 'publisher_ads',
+ slot: mockGpt.makeSlot({ code: adUnitCodes[2], divId: adSlotElementIds[2] }),
+ isEmpty: false,
+ slotContentChanged: true,
+ size: [728, 90],
+ advertiserId: 12346,
+ campaignId: 299999000,
+ creativeId: 6790,
+ creativeTemplateId: null,
+ labelIds: null,
+ lineItemId: 1012,
+ isBackfill: false,
+ yieldGroupIds: null,
+ companyIds: null,
+ },
+ ],
+ },
+ prebid: [{
+ AUCTION_INIT: {
+ auctionId,
+ adUnits: [
+ {
+ code: adUnitCodes[0],
+ mediaTypes: {
+ banner: {
+ sizes: [
+ [300, 250],
+ [300, 600],
+ ],
+ },
+ },
+ bids: [
+ {
+ bidder: 'bidder0',
+ userId,
+ },
+ ],
+ sizes: [
+ [300, 250],
+ [300, 600],
+ ],
+ transactionId: 'ef947609-7b55-4420-8407-599760d0e373',
+ ortb2Imp: {
+ ext: {
+ gpid: adUnitCodes[0],
+ },
+ },
+ },
+ {
+ code: adUnitCodes[1],
+ mediaTypes: {
+ banner: {
+ sizes: [
+ [728, 90],
+ [970, 250],
+ ],
+ },
+ },
+ bids: [
+ {
+ bidder: 'bidder0',
+ userId,
+ },
+ ],
+ sizes: [
+ [728, 90],
+ [970, 250],
+ ],
+ transactionId: 'abab4423-d962-41aa-adc7-0681f686c330',
+ ortb2Imp: {
+ ext: {
+ gpid: adUnitCodes[1],
+ },
+ },
+ },
+ {
+ code: adUnitCodes[2],
+ mediaTypes: {
+ banner: {
+ sizes: [[300, 250]],
+ },
+ },
+ bids: [
+ {
+ bidder: '33across',
+ userId,
+ },
+ {
+ bidder: 'bidder0',
+ userId,
+ },
+ ],
+ sizes: [[300, 250]],
+ transactionId: 'b43e7487-0a52-4689-a0f7-d139d08b1f9f',
+ ortb2Imp: {
+ ext: {
+ gpid: adUnitCodes[2],
+ },
+ },
+ },
+ ],
+ bidderRequests: [
+ {
+ bids: [
+ { userId },
+ ],
+ }
+ ],
+ },
+ BID_REQUESTED: [
+ {
+ auctionId,
+ bids: [
+ {
+ bidder: 'bidder0',
+ transactionId: 'ef947609-7b55-4420-8407-599760d0e373',
+ bidId: '20661fc5fbb5d9b',
+ src: 'client',
+ },
+ {
+ bidder: 'bidder0',
+ transactionId: 'abab4423-d962-41aa-adc7-0681f686c330',
+ bidId: '21ad295f40dd7ab',
+ src: 'client',
+ },
+ {
+ bidder: 'bidder0',
+ transactionId: 'b43e7487-0a52-4689-a0f7-d139d08b1f9f',
+ bidId: '22108ac7b778717',
+ src: 'client',
+ },
+ ],
+ }],
+ BID_RESPONSE: [{
+ auctionId,
+ cpm: 1.5,
+ currency: 'USD',
+ floorData: {
+ floorValue: 1
+ },
+ mediaType: 'banner',
+ originalCpm: 1.5,
+ requestId: '20661fc5fbb5d9b',
+ size: '300x250',
+ source: 'client',
+ status: 'targetingSet'
+ },
+ {
+ auctionId,
+ cpm: 1.5,
+ currency: 'USD',
+ floorData: {
+ floorValue: 1
+ },
+ mediaType: 'banner',
+ originalCpm: 1.5,
+ requestId: '21ad295f40dd7ab',
+ size: '728x90',
+ source: 'client',
+ status: 'targetingSet',
+ },
+ {
+ auctionId,
+ cpm: 1.5,
+ currency: 'USD',
+ floorData: {
+ floorValue: 1
+ },
+ mediaType: 'banner',
+ originalCpm: 1.5,
+ requestId: '22108ac7b778717',
+ size: '728x90',
+ source: 'client',
+ status: 'targetingSet',
+ }],
+ BID_WON: [{
+ auctionId,
+ cpm: 1.5,
+ currency: 'USD',
+ floorData: {
+ floorValue: 1
+ },
+ mediaType: 'banner',
+ originalCpm: 1.5,
+ requestId: '20661fc5fbb5d9b',
+ size: '300x250',
+ source: 'client',
+ status: 'rendered',
+ transactionId: 'ef947609-7b55-4420-8407-599760d0e373',
+ },
+ {
+ auctionId,
+ cpm: 1.5,
+ currency: 'USD',
+ floorData: {
+ floorValue: 1
+ },
+ mediaType: 'banner',
+ originalCpm: 1.5,
+ requestId: '21ad295f40dd7ab',
+ size: '728x90',
+ source: 'client',
+ status: 'rendered',
+ transactionId: 'abab4423-d962-41aa-adc7-0681f686c330',
+ },
+ {
+ auctionId,
+ cpm: 1.5,
+ currency: 'USD',
+ floorData: {
+ floorValue: 1
+ },
+ mediaType: 'banner',
+ originalCpm: 1.5,
+ requestId: '22108ac7b778717',
+ size: '728x90',
+ source: 'client',
+ status: 'rendered',
+ transactionId: 'b43e7487-0a52-4689-a0f7-d139d08b1f9f',
+ }],
+ BID_REJECTED: [{
+ auctionId,
+ cpm: 1.5,
+ currency: 'USD',
+ floorData: {
+ floorValue: 2
+ },
+ mediaType: 'banner',
+ originalCpm: 1.5,
+ requestId: '20661fc5fbb5d9b',
+ width: 300,
+ height: 250,
+ source: 'client',
+ transactionId: 'ef947609-7b55-4420-8407-599760d0e373',
+ statusMessage: 'Bid available',
+ rejectionReason: 'Bid does not meet price floor',
+ }],
+ AUCTION_END: {
+ auctionId,
+ },
+ }],
+ };
+}
diff --git a/test/spec/modules/a1MediaBidAdapter_spec.js b/test/spec/modules/a1MediaBidAdapter_spec.js
index 060fe3b5a65..e1db2b9ad8d 100644
--- a/test/spec/modules/a1MediaBidAdapter_spec.js
+++ b/test/spec/modules/a1MediaBidAdapter_spec.js
@@ -3,6 +3,7 @@ import { config } from 'src/config.js';
import { BANNER, VIDEO, NATIVE } from 'src/mediaTypes.js';
import 'modules/currency.js';
import 'modules/priceFloors.js';
+import { replaceAuctionPrice } from '../../../src/utils';
const ortbBlockParams = {
battr: [ 13 ],
@@ -102,6 +103,9 @@ const getBidderResponse = () => {
const bannerAdm = '';
const videoAdm = 'testvast1';
const nativeAdm = '{"ver":"1.2","link":{"url":"test_url"},"assets":[{"id":1,"required":1,"title":{"text":"native_title"}}]}';
+const macroAdm = '';
+const macroNurl = 'https://d11.contentsfeed.com/dsp/win/example.com/SITE/a1/${AUCTION_PRICE}';
+const interpretedNurl = ``;
describe('a1MediaBidAdapter', function() {
describe('isValidRequest', function() {
@@ -216,5 +220,29 @@ describe('a1MediaBidAdapter', function() {
expect(interpretedRes[0].mediaType).equal(BANNER);
});
});
+
+ describe('resolve the AUCTION_PRICE macro', function() {
+ let bidRequest;
+ beforeEach(function() {
+ const bidderRequest = getBidderRequest(true);
+ bidRequest = spec.buildRequests(bidderRequest.bids, bidderRequest);
+ });
+ it('should return empty array when bid response has not contents', function() {
+ const emptyResponse = { body: '' };
+ const interpretedRes = spec.interpretResponse(emptyResponse, bidRequest);
+ expect(interpretedRes.length).equal(0);
+ });
+ it('should replace macro keyword if is exist', function() {
+ const bidderResponse = getBidderResponse();
+ bidderResponse.body.seatbid[0].bid[0].adm = macroAdm;
+ bidderResponse.body.seatbid[0].bid[0].nurl = macroNurl;
+ const interpretedRes = spec.interpretResponse(bidderResponse, bidRequest);
+
+ const expectedResPrice = 9;
+ const expectedAd = replaceAuctionPrice(macroAdm, expectedResPrice) + replaceAuctionPrice(interpretedNurl, expectedResPrice);
+
+ expect(interpretedRes[0].ad).equal(expectedAd);
+ });
+ });
});
})
diff --git a/test/spec/modules/adagioAnalyticsAdapter_spec.js b/test/spec/modules/adagioAnalyticsAdapter_spec.js
index 39fb5d2d068..8359a34baa0 100644
--- a/test/spec/modules/adagioAnalyticsAdapter_spec.js
+++ b/test/spec/modules/adagioAnalyticsAdapter_spec.js
@@ -178,6 +178,9 @@ describe('adagio analytics adapter - adagio.js', () => {
});
const AUCTION_ID = '25c6d7f5-699a-4bfc-87c9-996f915341fa';
+const AUCTION_ID_ADAGIO = '6fc53663-bde5-427b-ab63-baa9ed296f47'
+const AUCTION_ID_CACHE = 'b43d24a0-13d4-406d-8176-3181402bafc4';
+const AUCTION_ID_CACHE_ADAGIO = 'a9cae98f-efb5-477e-9259-27350044f8db';
const BID_ADAGIO = Object.assign({}, BID_ADAGIO, {
bidder: 'adagio',
@@ -242,6 +245,11 @@ const BID_ANOTHER = Object.assign({}, BID_ANOTHER, {
}
});
+const BID_CACHED = Object.assign({}, BID_ADAGIO, {
+ auctionId: AUCTION_ID_CACHE,
+ latestTargetedAuctionId: BID_ADAGIO.auctionId,
+});
+
const PARAMS_ADG = {
organizationId: '1001',
site: 'test-com',
@@ -251,146 +259,288 @@ const PARAMS_ADG = {
placement: 'pave_top'
};
-const MOCK = {
- SET_TARGETING: {
- [BID_ADAGIO.adUnitCode]: BID_ADAGIO.adserverTargeting,
- [BID_ANOTHER.adUnitCode]: BID_ANOTHER.adserverTargeting
- },
- AUCTION_INIT: {
+const AUCTION_INIT_ANOTHER = {
+ 'auctionId': AUCTION_ID,
+ 'timestamp': 1519767010567,
+ 'auctionStatus': 'inProgress',
+ 'adUnits': [ {
+ 'code': '/19968336/header-bid-tag-1',
+ 'mediaTypes': {
+ 'banner': {
+ 'sizes': [
+ [
+ 640,
+ 480
+ ],
+ [
+ 640,
+ 100
+ ]
+ ]
+ }
+ },
+ 'sizes': [[640, 480]],
+ 'bids': [ {
+ 'bidder': 'another',
+ 'params': {
+ 'publisherId': '1001'
+ },
+ }, {
+ 'bidder': 'adagio',
+ 'params': {
+ ...PARAMS_ADG
+ },
+ }, ],
+ 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014'
+ }, {
+ 'code': '/19968336/footer-bid-tag-1',
+ 'mediaTypes': {
+ 'banner': {
+ 'sizes': [
+ [
+ 640,
+ 480
+ ]
+ ]
+ }
+ },
+ 'sizes': [[640, 480]],
+ 'bids': [ {
+ 'bidder': 'another',
+ 'params': {
+ 'publisherId': '1001'
+ },
+ } ],
+ 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014'
+ } ],
+ 'adUnitCodes': ['/19968336/header-bid-tag-1', '/19968336/footer-bid-tag-1'],
+ 'bidderRequests': [ {
+ 'bidderCode': 'another',
'auctionId': AUCTION_ID,
- 'timestamp': 1519767010567,
- 'auctionStatus': 'inProgress',
- 'adUnits': [ {
- 'code': '/19968336/header-bid-tag-1',
+ 'bidderRequestId': '1be65d7958826a',
+ 'bids': [ {
+ 'bidder': 'another',
+ 'params': {
+ 'publisherId': '1001',
+ },
'mediaTypes': {
'banner': {
- 'sizes': [
- [
- 640,
- 480
- ],
- [
- 640,
- 100
- ]
- ]
+ 'sizes': [[640, 480]]
}
},
+ 'adUnitCode': '/19968336/header-bid-tag-1',
+ 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
'sizes': [[640, 480]],
- 'bids': [ {
- 'bidder': 'another',
- 'params': {
- 'publisherId': '1001'
- },
- }, {
- 'bidder': 'adagio',
- 'params': {
- ...PARAMS_ADG
- },
- }, ],
- 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014'
+ 'bidId': '2ecff0db240757',
+ 'bidderRequestId': '1be65d7958826a',
+ 'auctionId': AUCTION_ID,
+ 'src': 'client',
+ 'bidRequestsCount': 1
}, {
- 'code': '/19968336/footer-bid-tag-1',
+ 'bidder': 'another',
+ 'params': {
+ 'publisherId': '1001'
+ },
'mediaTypes': {
'banner': {
- 'sizes': [
- [
- 640,
- 480
- ]
- ]
+ 'sizes': [[640, 480]]
}
},
+ 'adUnitCode': '/19968336/footer-bid-tag-1',
+ 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
'sizes': [[640, 480]],
- 'bids': [ {
- 'bidder': 'another',
- 'params': {
- 'publisherId': '1001'
- },
- } ],
- 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014'
- } ],
- 'adUnitCodes': ['/19968336/header-bid-tag-1', '/19968336/footer-bid-tag-1'],
- 'bidderRequests': [ {
- 'bidderCode': 'another',
+ 'bidId': '2ecff0db240757',
+ 'bidderRequestId': '1be65d7958826a',
'auctionId': AUCTION_ID,
+ 'src': 'client',
+ 'bidRequestsCount': 1
+ }
+ ],
+ 'timeout': 3000,
+ 'refererInfo': {
+ 'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html']
+ }
+ }, {
+ 'bidderCode': 'adagio',
+ 'auctionId': AUCTION_ID,
+ 'bidderRequestId': '1be65d7958826a',
+ 'bids': [ {
+ 'bidder': 'adagio',
+ 'params': {
+ ...PARAMS_ADG,
+ adagioAuctionId: AUCTION_ID_ADAGIO
+ },
+ 'mediaTypes': {
+ 'banner': {
+ 'sizes': [[640, 480]]
+ }
+ },
+ 'adUnitCode': '/19968336/header-bid-tag-1',
+ 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
+ 'sizes': [[640, 480]],
+ 'bidId': '2ecff0db240757',
'bidderRequestId': '1be65d7958826a',
- 'bids': [ {
- 'bidder': 'another',
- 'params': {
- 'publisherId': '1001',
- },
- 'mediaTypes': {
- 'banner': {
- 'sizes': [[640, 480]]
- }
- },
- 'adUnitCode': '/19968336/header-bid-tag-1',
- 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
- 'sizes': [[640, 480]],
- 'bidId': '2ecff0db240757',
- 'bidderRequestId': '1be65d7958826a',
- 'auctionId': AUCTION_ID,
- 'src': 'client',
- 'bidRequestsCount': 1
- }, {
- 'bidder': 'another',
- 'params': {
- 'publisherId': '1001'
- },
- 'mediaTypes': {
- 'banner': {
- 'sizes': [[640, 480]]
- }
- },
- 'adUnitCode': '/19968336/footer-bid-tag-1',
- 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
- 'sizes': [[640, 480]],
- 'bidId': '2ecff0db240757',
- 'bidderRequestId': '1be65d7958826a',
- 'auctionId': AUCTION_ID,
- 'src': 'client',
- 'bidRequestsCount': 1
+ 'auctionId': AUCTION_ID,
+ 'src': 'client',
+ 'bidRequestsCount': 1
+ }
+ ],
+ 'timeout': 3000,
+ 'refererInfo': {
+ 'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html']
+ }
+ }
+ ],
+ 'bidsReceived': [],
+ 'winningBids': [],
+ 'timeout': 3000
+};
+
+const AUCTION_INIT_CACHE = {
+ 'auctionId': AUCTION_ID_CACHE,
+ 'timestamp': 1519767010567,
+ 'auctionStatus': 'inProgress',
+ 'adUnits': [ {
+ 'code': '/19968336/header-bid-tag-1',
+ 'mediaTypes': {
+ 'banner': {
+ 'sizes': [
+ [
+ 640,
+ 480
+ ],
+ [
+ 640,
+ 100
+ ]
+ ]
}
- ],
- 'timeout': 3000,
- 'refererInfo': {
- 'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html']
+ },
+ 'sizes': [[640, 480]],
+ 'bids': [ {
+ 'bidder': 'another',
+ 'params': {
+ 'publisherId': '1001'
+ },
+ }, {
+ 'bidder': 'adagio',
+ 'params': {
+ ...PARAMS_ADG
+ },
+ }, ],
+ 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014'
+ }, {
+ 'code': '/19968336/footer-bid-tag-1',
+ 'mediaTypes': {
+ 'banner': {
+ 'sizes': [
+ [
+ 640,
+ 480
+ ]
+ ]
}
+ },
+ 'sizes': [[640, 480]],
+ 'bids': [ {
+ 'bidder': 'another',
+ 'params': {
+ 'publisherId': '1001'
+ },
+ } ],
+ 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014'
+ } ],
+ 'adUnitCodes': ['/19968336/header-bid-tag-1', '/19968336/footer-bid-tag-1'],
+ 'bidderRequests': [ {
+ 'bidderCode': 'another',
+ 'auctionId': AUCTION_ID_CACHE,
+ 'bidderRequestId': '1be65d7958826a',
+ 'bids': [ {
+ 'bidder': 'another',
+ 'params': {
+ 'publisherId': '1001',
+ },
+ 'mediaTypes': {
+ 'banner': {
+ 'sizes': [[640, 480]]
+ }
+ },
+ 'adUnitCode': '/19968336/header-bid-tag-1',
+ 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
+ 'sizes': [[640, 480]],
+ 'bidId': '2ecff0db240757',
+ 'bidderRequestId': '1be65d7958826a',
+ 'auctionId': AUCTION_ID_CACHE,
+ 'src': 'client',
+ 'bidRequestsCount': 1
}, {
- 'bidderCode': 'adagio',
- 'auctionId': AUCTION_ID,
+ 'bidder': 'another',
+ 'params': {
+ 'publisherId': '1001'
+ },
+ 'mediaTypes': {
+ 'banner': {
+ 'sizes': [[640, 480]]
+ }
+ },
+ 'adUnitCode': '/19968336/footer-bid-tag-1',
+ 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
+ 'sizes': [[640, 480]],
+ 'bidId': '2ecff0db240757',
'bidderRequestId': '1be65d7958826a',
- 'bids': [ {
- 'bidder': 'adagio',
- 'params': {
- ...PARAMS_ADG,
- adagioAuctionId: '6fc53663-bde5-427b-ab63-baa9ed296f47'
- },
- 'mediaTypes': {
- 'banner': {
- 'sizes': [[640, 480]]
- }
- },
- 'adUnitCode': '/19968336/header-bid-tag-1',
- 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
- 'sizes': [[640, 480]],
- 'bidId': '2ecff0db240757',
- 'bidderRequestId': '1be65d7958826a',
- 'auctionId': AUCTION_ID,
- 'src': 'client',
- 'bidRequestsCount': 1
- }
- ],
- 'timeout': 3000,
- 'refererInfo': {
- 'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html']
- }
+ 'auctionId': AUCTION_ID_CACHE,
+ 'src': 'client',
+ 'bidRequestsCount': 1
}
],
- 'bidsReceived': [],
- 'winningBids': [],
- 'timeout': 3000
+ 'timeout': 3000,
+ 'refererInfo': {
+ 'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html']
+ }
+ }, {
+ 'bidderCode': 'adagio',
+ 'auctionId': AUCTION_ID_CACHE,
+ 'bidderRequestId': '1be65d7958826a',
+ 'bids': [ {
+ 'bidder': 'adagio',
+ 'params': {
+ ...PARAMS_ADG,
+ adagioAuctionId: AUCTION_ID_CACHE_ADAGIO
+ },
+ 'mediaTypes': {
+ 'banner': {
+ 'sizes': [[640, 480]]
+ }
+ },
+ 'adUnitCode': '/19968336/header-bid-tag-1',
+ 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
+ 'sizes': [[640, 480]],
+ 'bidId': '2ecff0db240757',
+ 'bidderRequestId': '1be65d7958826a',
+ 'auctionId': AUCTION_ID_CACHE,
+ 'src': 'client',
+ 'bidRequestsCount': 1
+ }
+ ],
+ 'timeout': 3000,
+ 'refererInfo': {
+ 'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html']
+ }
+ }
+ ],
+ 'bidsReceived': [],
+ 'winningBids': [],
+ 'timeout': 3000
+};
+
+const MOCK = {
+ SET_TARGETING: {
+ [BID_ADAGIO.adUnitCode]: BID_ADAGIO.adserverTargeting,
+ [BID_ANOTHER.adUnitCode]: BID_ANOTHER.adserverTargeting
+ },
+ AUCTION_INIT: {
+ another: AUCTION_INIT_ANOTHER,
+ bidcached: AUCTION_INIT_CACHE
},
BID_RESPONSE: {
adagio: BID_ADAGIO,
@@ -402,12 +552,22 @@ const MOCK = {
}),
another: Object.assign({}, BID_ANOTHER, {
'status': 'rendered'
- })
+ }),
+ bidcached: Object.assign({}, BID_CACHED, {
+ 'status': 'rendered'
+ }),
},
AD_RENDER_SUCCEEDED: {
- ad: 'ad
',
- adId: 'fake_ad_id_2',
- bid: BID_ANOTHER
+ another: {
+ ad: 'ad
',
+ adId: 'fake_ad_id_2',
+ bid: BID_ANOTHER
+ },
+ bidcached: {
+ ad: 'ad
',
+ adId: 'fake_ad_id_2',
+ bid: BID_CACHED
+ }
},
};
@@ -453,11 +613,11 @@ describe('adagio analytics adapter', () => {
return cpm * (convKeys[`${from}-${to}`] || 1);
};
- events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT);
+ events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT.another);
events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE.adagio);
events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE.another);
events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON.another);
- events.emit(constants.EVENTS.AD_RENDER_SUCCEEDED, MOCK.AD_RENDER_SUCCEEDED);
+ events.emit(constants.EVENTS.AD_RENDER_SUCCEEDED, MOCK.AD_RENDER_SUCCEEDED.another);
expect(server.requests.length).to.equal(3);
{
@@ -467,7 +627,7 @@ describe('adagio analytics adapter', () => {
expect(pathname).to.equal('/pba.gif');
expect(search.v).to.equal('1');
expect(search.pbjsv).to.equal('$prebid.version$');
- expect(search.auct_id).to.equal('6fc53663-bde5-427b-ab63-baa9ed296f47');
+ expect(search.auct_id).to.equal(AUCTION_ID_ADAGIO);
expect(search.adu_code).to.equal('/19968336/header-bid-tag-1');
expect(search.org_id).to.equal('1001');
expect(search.site).to.equal('test-com');
@@ -488,7 +648,7 @@ describe('adagio analytics adapter', () => {
expect(hostname).to.equal('c.4dex.io');
expect(pathname).to.equal('/pba.gif');
expect(search.v).to.equal('2');
- expect(search.auct_id).to.equal('6fc53663-bde5-427b-ab63-baa9ed296f47');
+ expect(search.auct_id).to.equal(AUCTION_ID_ADAGIO);
expect(search.adu_code).to.equal('/19968336/header-bid-tag-1');
expect(search.adg_sid).to.equal('42');
expect(search.win_bdr).to.equal('another');
@@ -508,7 +668,106 @@ describe('adagio analytics adapter', () => {
expect(hostname).to.equal('c.4dex.io');
expect(pathname).to.equal('/pba.gif');
expect(search.v).to.equal('3');
- expect(search.auct_id).to.equal('6fc53663-bde5-427b-ab63-baa9ed296f47');
+ expect(search.auct_id).to.equal(AUCTION_ID_ADAGIO);
+ expect(search.adu_code).to.equal('/19968336/header-bid-tag-1');
+ expect(search.rndr).to.equal('1');
+ }
+ });
+
+ it('builds and sends auction data with a cached bid win', () => {
+ getGlobal().convertCurrency = (cpm, from, to) => {
+ const convKeys = {
+ 'GBP-EUR': 0.7,
+ 'EUR-GBP': 1.3,
+ 'USD-EUR': 0.8,
+ 'EUR-USD': 1.2,
+ 'USD-GBP': 0.6,
+ 'GBP-USD': 1.6,
+ };
+ return cpm * (convKeys[`${from}-${to}`] || 1);
+ };
+
+ events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT.bidcached);
+ events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT.another);
+ events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE.adagio);
+ events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE.another);
+ events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON.bidcached);
+ events.emit(constants.EVENTS.AD_RENDER_SUCCEEDED, MOCK.AD_RENDER_SUCCEEDED.bidcached);
+
+ expect(server.requests.length).to.equal(4);
+ {
+ const { protocol, hostname, pathname, search } = utils.parseUrl(server.requests[0].url);
+ expect(protocol).to.equal('https');
+ expect(hostname).to.equal('c.4dex.io');
+ expect(pathname).to.equal('/pba.gif');
+ expect(search.v).to.equal('1');
+ expect(search.pbjsv).to.equal('$prebid.version$');
+ expect(search.auct_id).to.equal(AUCTION_ID_CACHE_ADAGIO);
+ expect(search.adu_code).to.equal('/19968336/header-bid-tag-1');
+ expect(search.org_id).to.equal('1001');
+ expect(search.site).to.equal('test-com');
+ expect(search.pv_id).to.equal('a68e6d70-213b-496c-be0a-c468ff387106');
+ expect(search.url_dmn).to.equal(window.location.hostname);
+ expect(search.dvc).to.equal('desktop');
+ expect(search.pgtyp).to.equal('article');
+ expect(search.plcmt).to.equal('pave_top');
+ expect(search.mts).to.equal('ban');
+ expect(search.ban_szs).to.equal('640x100,640x480');
+ expect(search.bdrs).to.equal('adagio,another');
+ expect(search.adg_mts).to.equal('ban');
+ }
+
+ {
+ const { protocol, hostname, pathname, search } = utils.parseUrl(server.requests[1].url);
+ expect(protocol).to.equal('https');
+ expect(hostname).to.equal('c.4dex.io');
+ expect(pathname).to.equal('/pba.gif');
+ expect(search.v).to.equal('1');
+ expect(search.pbjsv).to.equal('$prebid.version$');
+ expect(search.auct_id).to.equal(AUCTION_ID_ADAGIO);
+ expect(search.adu_code).to.equal('/19968336/header-bid-tag-1');
+ expect(search.org_id).to.equal('1001');
+ expect(search.site).to.equal('test-com');
+ expect(search.pv_id).to.equal('a68e6d70-213b-496c-be0a-c468ff387106');
+ expect(search.url_dmn).to.equal(window.location.hostname);
+ expect(search.dvc).to.equal('desktop');
+ expect(search.pgtyp).to.equal('article');
+ expect(search.plcmt).to.equal('pave_top');
+ expect(search.mts).to.equal('ban');
+ expect(search.ban_szs).to.equal('640x100,640x480');
+ expect(search.bdrs).to.equal('adagio,another');
+ expect(search.adg_mts).to.equal('ban');
+ }
+
+ {
+ const { protocol, hostname, pathname, search } = utils.parseUrl(server.requests[2].url);
+ expect(protocol).to.equal('https');
+ expect(hostname).to.equal('c.4dex.io');
+ expect(pathname).to.equal('/pba.gif');
+ expect(search.v).to.equal('2');
+ expect(search.auct_id).to.equal(AUCTION_ID_ADAGIO);
+ expect(search.auct_id_c).to.equal(AUCTION_ID_CACHE_ADAGIO);
+ expect(search.adu_code).to.equal('/19968336/header-bid-tag-1');
+ expect(search.adg_sid).to.equal('42');
+ expect(search.win_bdr).to.equal('adagio');
+ expect(search.win_mt).to.equal('ban');
+ expect(search.win_ban_sz).to.equal('728x90');
+ expect(search.win_cpm).to.equal('1.42');
+ expect(search.cur).to.equal('USD');
+ expect(search.cur_rate).to.equal('1');
+ expect(search.og_cpm).to.equal('1.42');
+ expect(search.og_cur).to.equal('USD');
+ expect(search.og_cur_rate).to.equal('1');
+ }
+
+ {
+ const { protocol, hostname, pathname, search } = utils.parseUrl(server.requests[3].url);
+ expect(protocol).to.equal('https');
+ expect(hostname).to.equal('c.4dex.io');
+ expect(pathname).to.equal('/pba.gif');
+ expect(search.v).to.equal('3');
+ expect(search.auct_id).to.equal(AUCTION_ID_ADAGIO);
+ expect(search.auct_id_c).to.equal(AUCTION_ID_CACHE_ADAGIO);
expect(search.adu_code).to.equal('/19968336/header-bid-tag-1');
expect(search.rndr).to.equal('1');
}
diff --git a/test/spec/modules/adagioBidAdapter_spec.js b/test/spec/modules/adagioBidAdapter_spec.js
index 1f734a6a7fc..7f0b31b9680 100644
--- a/test/spec/modules/adagioBidAdapter_spec.js
+++ b/test/spec/modules/adagioBidAdapter_spec.js
@@ -958,6 +958,34 @@ describe('Adagio bid adapter', () => {
expect(requests[0].data.usIfr).to.equal(false);
});
});
+
+ describe('with GPID', function () {
+ const gpid = '/12345/my-gpt-tag-0';
+
+ it('should add preferred gpid to the request', function () {
+ const bid01 = new BidRequestBuilder().withParams().build();
+ bid01.ortb2Imp = {
+ ext: {
+ gpid: gpid
+ }
+ };
+ const bidderRequest = new BidderRequestBuilder().build();
+ const requests = spec.buildRequests([bid01], bidderRequest);
+ expect(requests[0].data.adUnits[0].gpid).to.exist.and.equal(gpid);
+ });
+
+ it('should add backup gpid to the request', function () {
+ const bid01 = new BidRequestBuilder().withParams().build();
+ bid01.ortb2Imp = {
+ ext: {
+ data: { pbadslot: gpid }
+ }
+ };
+ const bidderRequest = new BidderRequestBuilder().build();
+ const requests = spec.buildRequests([bid01], bidderRequest);
+ expect(requests[0].data.adUnits[0].gpid).to.exist.and.equal(gpid);
+ });
+ });
});
describe('interpretResponse()', function() {
diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js
index b378ec2d2a4..bd409958b1a 100644
--- a/test/spec/modules/admaticBidAdapter_spec.js
+++ b/test/spec/modules/admaticBidAdapter_spec.js
@@ -16,6 +16,10 @@ describe('admaticBidAdapter', () => {
describe('isBidRequestValid', function() {
let bid = {
+ 'refererInfo': {
+ 'page': 'https://www.admatic.com.tr',
+ 'domain': 'https://www.admatic.com.tr',
+ },
'bidder': 'admatic',
'params': {
'networkId': 10433394,
@@ -48,6 +52,10 @@ describe('admaticBidAdapter', () => {
describe('buildRequests', function () {
it('sends bid request to ENDPOINT via POST', function () {
let validRequest = [ {
+ 'refererInfo': {
+ 'page': 'https://www.admatic.com.tr',
+ 'domain': 'https://www.admatic.com.tr',
+ },
'bidder': 'admatic',
'params': {
'networkId': 10433394,
@@ -151,6 +159,51 @@ describe('admaticBidAdapter', () => {
'placement': 2
},
'id': '45e86fc7ce7fc93'
+ },
+ {
+ 'size': [
+ {
+ 'w': 1,
+ 'h': 1
+ }
+ ],
+ 'type': 'native',
+ 'mediatype': {
+ 'title': {
+ 'required': true,
+ 'len': 120
+ },
+ 'image': {
+ 'required': true
+ },
+ 'icon': {
+ 'required': false,
+ 'sizes': [
+ 640,
+ 480
+ ]
+ },
+ 'sponsoredBy': {
+ 'required': false
+ },
+ 'body': {
+ 'required': false
+ },
+ 'clickUrl': {
+ 'required': false
+ },
+ 'displayUrl': {
+ 'required': false
+ }
+ },
+ 'ext': {
+ 'instl': 0,
+ 'gpid': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a',
+ 'data': {
+ 'pbadslot': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a'
+ }
+ },
+ 'id': '16e0c8982318f91'
}
],
'ext': {
@@ -159,6 +212,10 @@ describe('admaticBidAdapter', () => {
}
} ];
let bidderRequest = {
+ 'refererInfo': {
+ 'page': 'https://www.admatic.com.tr',
+ 'domain': 'https://www.admatic.com.tr',
+ },
'bidder': 'admatic',
'params': {
'networkId': 10433394,
@@ -262,6 +319,51 @@ describe('admaticBidAdapter', () => {
'placement': 2
},
'id': '45e86fc7ce7fc93'
+ },
+ {
+ 'size': [
+ {
+ 'w': 1,
+ 'h': 1
+ }
+ ],
+ 'type': 'native',
+ 'mediatype': {
+ 'title': {
+ 'required': true,
+ 'len': 120
+ },
+ 'image': {
+ 'required': true
+ },
+ 'icon': {
+ 'required': false,
+ 'sizes': [
+ 640,
+ 480
+ ]
+ },
+ 'sponsoredBy': {
+ 'required': false
+ },
+ 'body': {
+ 'required': false
+ },
+ 'clickUrl': {
+ 'required': false
+ },
+ 'displayUrl': {
+ 'required': false
+ }
+ },
+ 'ext': {
+ 'instl': 0,
+ 'gpid': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a',
+ 'data': {
+ 'pbadslot': 'native-INS_b1b1269f-9570-fe3c-9bf4-f187827ec94a'
+ }
+ },
+ 'id': '16e0c8982318f91'
}
],
'ext': {
@@ -307,6 +409,10 @@ describe('admaticBidAdapter', () => {
},
];
let bidderRequest = {
+ 'refererInfo': {
+ 'page': 'https://www.admatic.com.tr',
+ 'domain': 'https://www.admatic.com.tr',
+ },
'bidder': 'admatic',
'params': {
'networkId': 10433394,
@@ -378,6 +484,19 @@ describe('admaticBidAdapter', () => {
'adomain': ['admatic.com.tr'],
'party_tag': 'https://www.admatic.com.tr',
'iurl': 'https://www.admatic.com.tr'
+ },
+ {
+ 'id': 4,
+ 'creative_id': '3742',
+ 'width': 1,
+ 'height': 1,
+ 'price': 0.01,
+ 'type': 'native',
+ 'mime_type': 'iframe',
+ 'bidder': 'admatic',
+ 'adomain': ['admatic.com.tr'],
+ 'party_tag': '{"native":{"ver":"1.1","assets":[{"id":1,"title":{"text":"title"}},{"id":4,"data":{"value":"body"}},{"id":5,"data":{"value":"sponsored"}},{"id":2,"img":{"url":"https://www.admatic.com.tr","w":1200,"h":628}},{"id":3,"img":{"url":"https://www.admatic.com.tr","w":640,"h":480}}],"link":{"url":"https://www.admatic.com.tr"},"imptrackers":["https://www.admatic.com.tr"]}}',
+ 'iurl': 'https://www.admatic.com.tr'
}
],
'queryId': 'cdnbh24rlv0hhkpfpln0',
@@ -437,6 +556,39 @@ describe('admaticBidAdapter', () => {
},
ttl: 60,
bidder: 'admatic'
+ },
+ {
+ requestId: 4,
+ cpm: 0.01,
+ width: 1,
+ height: 1,
+ currency: 'TRY',
+ mediaType: 'native',
+ netRevenue: true,
+ native: {
+ 'clickUrl': 'https://www.admatic.com.tr',
+ 'impressionTrackers': ['https://www.admatic.com.tr'],
+ 'title': 'title',
+ 'body': 'body',
+ 'sponsoredBy': 'sponsored',
+ 'image': {
+ 'url': 'https://www.admatic.com.tr',
+ 'width': 1200,
+ 'height': 628
+ },
+ 'icon': {
+ 'url': 'https://www.admatic.com.tr',
+ 'width': 640,
+ 'height': 480
+ }
+ },
+ creativeId: '3742',
+ meta: {
+ model: 'iframe',
+ advertiserDomains: ['admatic.com.tr']
+ },
+ ttl: 60,
+ bidder: 'admatic'
}
];
const request = {
diff --git a/test/spec/modules/adnuntiusBidAdapter_spec.js b/test/spec/modules/adnuntiusBidAdapter_spec.js
index 6a77c9205ca..8fa719f7af6 100644
--- a/test/spec/modules/adnuntiusBidAdapter_spec.js
+++ b/test/spec/modules/adnuntiusBidAdapter_spec.js
@@ -10,9 +10,10 @@ import {getGlobal} from '../../../src/prebidGlobal';
describe('adnuntiusBidAdapter', function() {
const URL = 'https://ads.adnuntius.delivery/i?tzo=';
const EURO_URL = 'https://europe.delivery.adnuntius.com/i?tzo=';
- const GVLID = 855;
const usi = utils.generateUUID()
- const meta = [{key: 'usi', value: usi}]
+
+ const meta = [{key: 'valueless'}, {value: 'keyless'}, {key: 'voidAuIds'}, {key: 'voidAuIds', value: [{auId: '11118b6bc', exp: misc.getUnixTimestamp()}, {exp: misc.getUnixTimestamp(1)}]}, {key: 'valid', value: 'also-valid', exp: misc.getUnixTimestamp(1)}, {key: 'expired', value: 'fwefew', exp: misc.getUnixTimestamp()}, {key: 'usi', value: 'should be skipped because timestamp', exp: misc.getUnixTimestamp()}, {key: 'usi', value: usi, exp: misc.getUnixTimestamp(100)}, {key: 'usi', value: 'should be skipped because timestamp', exp: misc.getUnixTimestamp()}]
+ let storage;
before(() => {
getGlobal().bidderSettings = {
@@ -20,8 +21,11 @@ describe('adnuntiusBidAdapter', function() {
storageAllowed: true
}
};
- const storage = getStorageManager({bidderCode: 'adnuntius'})
- storage.setDataInLocalStorage('adn.metaData', JSON.stringify(meta))
+ storage = getStorageManager({bidderCode: 'adnuntius'});
+ });
+
+ beforeEach(() => {
+ storage.setDataInLocalStorage('adn.metaData', JSON.stringify(meta));
});
after(() => {
@@ -47,6 +51,7 @@ describe('adnuntiusBidAdapter', function() {
bidder: 'adnuntius',
params: {
auId: '000000000008b6bc',
+ targetId: '123',
network: 'adnuntius',
maxDeals: 1
},
@@ -459,7 +464,78 @@ describe('adnuntiusBidAdapter', function() {
expect(request[0]).to.have.property('url');
expect(request[0].url).to.equal(ENDPOINT_URL);
expect(request[0]).to.have.property('data');
- expect(request[0].data).to.equal('{"adUnits":[{"auId":"000000000008b6bc","targetId":"adn-000000000008b6bc","maxDeals":1,"dimensions":[[640,480],[600,400]]},{"auId":"0000000000000551","targetId":"adn-0000000000000551","maxDeals":0,"dimensions":[[1640,1480],[1600,1400]]}],"metaData":{"usi":"' + usi + '"}}');
+ expect(request[0].data).to.equal('{"adUnits":[{"auId":"000000000008b6bc","targetId":"123","maxDeals":1,"dimensions":[[640,480],[600,400]]},{"auId":"0000000000000551","targetId":"adn-0000000000000551","dimensions":[[1640,1480],[1600,1400]]}],"metaData":{"valid":"also-valid"}}');
+ });
+
+ it('Test requests with no local storage', function() {
+ storage.setDataInLocalStorage('adn.metaData', JSON.stringify([{}]));
+ const request = spec.buildRequests(bidderRequests, {});
+ expect(request.length).to.equal(1);
+ expect(request[0]).to.have.property('bid');
+ const bid = request[0].bid[0]
+ expect(bid).to.have.property('bidId');
+ expect(request[0]).to.have.property('url');
+ expect(request[0].url).to.equal(ENDPOINT_URL_BASE);
+ expect(request[0]).to.have.property('data');
+ expect(request[0].data).to.equal('{"adUnits":[{"auId":"000000000008b6bc","targetId":"123","maxDeals":1,"dimensions":[[640,480],[600,400]]},{"auId":"0000000000000551","targetId":"adn-0000000000000551","dimensions":[[1640,1480],[1600,1400]]}]}');
+
+ localStorage.removeItem('adn.metaData');
+ const request2 = spec.buildRequests(bidderRequests, {});
+ expect(request2.length).to.equal(1);
+ expect(request2[0]).to.have.property('url');
+ expect(request2[0].url).to.equal(ENDPOINT_URL_BASE);
+ });
+
+ it('Test request changes for voided au ids', function() {
+ storage.setDataInLocalStorage('adn.metaData', JSON.stringify([{key: 'voidAuIds', value: [{auId: '11118b6bc', exp: misc.getUnixTimestamp(1)}, {auId: '0000000000000023', exp: misc.getUnixTimestamp(1)}]}]));
+ const bRequests = bidderRequests.concat([{
+ bidId: 'adn-11118b6bc',
+ bidder: 'adnuntius',
+ params: {
+ auId: '11118b6bc',
+ network: 'adnuntius',
+ },
+ mediaTypes: {
+ banner: {
+ sizes: [[1640, 1480], [1600, 1400]],
+ }
+ },
+ }]);
+ bRequests.push({
+ bidId: 'adn-23',
+ bidder: 'adnuntius',
+ params: {
+ auId: '23',
+ network: 'adnuntius',
+ },
+ mediaTypes: {
+ banner: {
+ sizes: [[1640, 1480], [1600, 1400]],
+ }
+ },
+ });
+ bRequests.push({
+ bidId: 'adn-13',
+ bidder: 'adnuntius',
+ params: {
+ auId: '13',
+ network: 'adnuntius',
+ },
+ mediaTypes: {
+ banner: {
+ sizes: [[164, 140], [10, 1400]],
+ }
+ },
+ });
+ const request = spec.buildRequests(bRequests, {});
+ expect(request.length).to.equal(1);
+ expect(request[0]).to.have.property('bid');
+ const bid = request[0].bid[0]
+ expect(bid).to.have.property('bidId');
+ expect(request[0]).to.have.property('url');
+ expect(request[0].url).to.equal(ENDPOINT_URL_BASE);
+ expect(request[0]).to.have.property('data');
+ expect(request[0].data).to.equal('{"adUnits":[{"auId":"000000000008b6bc","targetId":"123","maxDeals":1,"dimensions":[[640,480],[600,400]]},{"auId":"0000000000000551","targetId":"adn-0000000000000551","dimensions":[[1640,1480],[1600,1400]]},{"auId":"13","targetId":"adn-13","dimensions":[[164,140],[10,1400]]}]}');
});
it('Test Video requests', function() {
@@ -477,7 +553,7 @@ describe('adnuntiusBidAdapter', function() {
user: {
data: [{
name: 'adnuntius',
- segment: [{id: 'segment1'}, {id: 'segment2'}]
+ segment: [{id: 'segment1'}, {id: 'segment2'}, {invalidSegment: 'invalid'}, {id: 123}, {id: ['3332']}]
},
{
name: 'other',
@@ -660,7 +736,7 @@ describe('adnuntiusBidAdapter', function() {
expect(bidderRequests[0].params.maxDeals).to.equal(1);
expect(data.adUnits[0].maxDeals).to.equal(bidderRequests[0].params.maxDeals);
expect(bidderRequests[1].params).to.not.have.property('maxBids');
- expect(data.adUnits[1].maxDeals).to.equal(0);
+ expect(data.adUnits[1].maxDeals).to.equal(undefined);
});
it('Should allow a maximum of 5 deals.', function() {
config.setBidderConfig({
@@ -706,7 +782,7 @@ describe('adnuntiusBidAdapter', function() {
expect(request[0]).to.have.property('data');
const data = JSON.parse(request[0].data);
expect(data.adUnits.length).to.equal(1);
- expect(data.adUnits[0].maxDeals).to.equal(0);
+ expect(data.adUnits[0].maxDeals).to.equal(undefined);
});
it('Should set max deals using bidder config.', function() {
config.setBidderConfig({
@@ -794,6 +870,33 @@ describe('adnuntiusBidAdapter', function() {
expect(interpretedResponse[1].ttl).to.equal(360);
expect(interpretedResponse[1].dealId).to.equal('not-in-deal-array-here');
expect(interpretedResponse[1].dealCount).to.equal(0);
+
+ const results = JSON.parse(storage.getDataFromLocalStorage('adn.metaData'));
+ const usiEntry = results.find(entry => entry.key === 'usi');
+ expect(usiEntry.key).to.equal('usi');
+ expect(usiEntry.value).to.equal('from-api-server dude');
+ expect(usiEntry.exp).to.be.greaterThan(misc.getUnixTimestamp(90));
+
+ const voidAuIdsEntry = results.find(entry => entry.key === 'voidAuIds');
+ expect(voidAuIdsEntry.key).to.equal('voidAuIds');
+ expect(voidAuIdsEntry.exp).to.equal(undefined);
+ expect(voidAuIdsEntry.value[0].auId).to.equal('00000000000abcde');
+ expect(voidAuIdsEntry.value[0].exp).to.be.greaterThan(misc.getUnixTimestamp());
+ expect(voidAuIdsEntry.value[0].exp).to.be.lessThan(misc.getUnixTimestamp(2));
+ expect(voidAuIdsEntry.value[1].auId).to.equal('00000000000fffff');
+ expect(voidAuIdsEntry.value[1].exp).to.be.greaterThan(misc.getUnixTimestamp());
+ expect(voidAuIdsEntry.value[1].exp).to.be.lessThan(misc.getUnixTimestamp(2));
+
+ const validEntry = results.find(entry => entry.key === 'valid');
+ expect(validEntry.key).to.equal('valid');
+ expect(validEntry.value).to.equal('also-valid');
+ expect(validEntry.exp).to.be.greaterThan(misc.getUnixTimestamp());
+ expect(validEntry.exp).to.be.lessThan(misc.getUnixTimestamp(2));
+
+ const randomApiEntry = results.find(entry => entry.key === 'randomApiKey');
+ expect(randomApiEntry.key).to.equal('randomApiKey');
+ expect(randomApiEntry.value).to.equal('randomApiValue');
+ expect(randomApiEntry.exp).to.be.greaterThan(misc.getUnixTimestamp(90));
});
it('should not process valid response when passed alt bidder that is an adndeal', function() {
diff --git a/test/spec/modules/adstirBidAdapter_spec.js b/test/spec/modules/adstirBidAdapter_spec.js
new file mode 100644
index 00000000000..290a6822f69
--- /dev/null
+++ b/test/spec/modules/adstirBidAdapter_spec.js
@@ -0,0 +1,412 @@
+import { expect } from 'chai';
+import { spec } from '../../../modules/adstirBidAdapter.js';
+import * as utils from 'src/utils.js';
+import { config } from 'src/config.js';
+
+describe('AdstirAdapter', function () {
+ describe('isBidRequestValid', function () {
+ it('should return true if appId is non-empty string and adSpaceNo is integer', function () {
+ const bid = {
+ params: {
+ appId: 'MEDIA-XXXXXX',
+ adSpaceNo: 6,
+ }
+ }
+ expect(spec.isBidRequestValid(bid)).to.equal(true);
+ });
+ it('should return false if appId is non-empty string, but adSpaceNo is not integer', function () {
+ const bid = {
+ params: {
+ appId: 'MEDIA-XXXXXX',
+ adSpaceNo: 'a',
+ }
+ }
+ expect(spec.isBidRequestValid(bid)).to.equal(false);
+ });
+ it('should return false if appId is non-empty string, but adSpaceNo is null', function () {
+ const bid = {
+ params: {
+ appId: 'MEDIA-XXXXXX',
+ adSpaceNo: null,
+ }
+ }
+ expect(spec.isBidRequestValid(bid)).to.equal(false);
+ });
+ it('should return false if appId is non-empty string, but adSpaceNo is undefined', function () {
+ const bid = {
+ params: {
+ appId: 'MEDIA-XXXXXX'
+ }
+ }
+ expect(spec.isBidRequestValid(bid)).to.equal(false);
+ });
+ it('should return false if adSpaceNo is integer, but appId is empty string', function () {
+ const bid = {
+ params: {
+ appId: '',
+ adSpaceNo: 6,
+ }
+ }
+ expect(spec.isBidRequestValid(bid)).to.equal(false);
+ });
+ it('should return false if adSpaceNo is integer, but appId is not string', function () {
+ const bid = {
+ params: {
+ appId: 123,
+ adSpaceNo: 6,
+ }
+ }
+ expect(spec.isBidRequestValid(bid)).to.equal(false);
+ });
+ it('should return false if adSpaceNo is integer, but appId is null', function () {
+ const bid = {
+ params: {
+ appId: null,
+ adSpaceNo: 6,
+ }
+ }
+ expect(spec.isBidRequestValid(bid)).to.equal(false);
+ });
+ it('should return false if adSpaceNo is integer, but appId is undefined', function () {
+ const bid = {
+ params: {
+ adSpaceNo: 6,
+ }
+ }
+ expect(spec.isBidRequestValid(bid)).to.equal(false);
+ });
+ it('should return false if params is empty', function () {
+ const bid = {
+ params: {}
+ }
+ expect(spec.isBidRequestValid(bid)).to.equal(false);
+ });
+ });
+
+ describe('buildRequests', function () {
+ const validBidRequests = [
+ {
+ auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
+ bidder: 'adstir',
+ bidId: 'bidid1111',
+ params: {
+ appId: 'MEDIA-XXXXXX',
+ adSpaceNo: 1,
+ },
+ transactionId: 'transactionid-1111',
+ mediaTypes: {
+ banner: {
+ sizes: [
+ [300, 250],
+ [336, 280],
+ ],
+ }
+ },
+ sizes: [
+ [300, 250],
+ [336, 280],
+ ],
+ },
+ {
+ auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
+ bidder: 'adstir',
+ bidId: 'bidid2222',
+ params: {
+ appId: 'MEDIA-XXXXXX',
+ adSpaceNo: 2,
+ },
+ transactionId: 'transactionid-2222',
+ mediaTypes: {
+ banner: {
+ sizes: [
+ [320, 50],
+ [320, 100],
+ ],
+ }
+ },
+ sizes: [
+ [320, 50],
+ [320, 100],
+ ],
+ },
+ ];
+
+ const bidderRequest = {
+ auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
+ refererInfo: {
+ page: 'https://ad-stir.com/contact',
+ topmostLocation: 'https://ad-stir.com/contact',
+ reachedTop: true,
+ ref: 'https://test.example/q=adstir',
+ isAmp: false,
+ numIframes: 0,
+ stack: [
+ 'https://ad-stir.com/contact',
+ ],
+ },
+ };
+
+ it('one entry in validBidRequests corresponds to one server request object.', function () {
+ const requests = spec.buildRequests(validBidRequests, bidderRequest);
+ expect(requests.length).to.equal(validBidRequests.length);
+ requests.forEach(function (r, i) {
+ expect(r.method).to.equal('POST');
+ expect(r.url).to.equal('https://ad.ad-stir.com/prebid');
+ const d = JSON.parse(r.data);
+ expect(d.auctionId).to.equal('b06c5141-fe8f-4cdf-9d7d-54415490a917');
+
+ const v = validBidRequests[i];
+ expect(d.appId).to.equal(v.params.appId);
+ expect(d.adSpaceNo).to.equal(v.params.adSpaceNo);
+ expect(d.bidId).to.equal(v.bidId);
+ expect(d.transactionId).to.equal(v.transactionId);
+ expect(d.mediaTypes).to.deep.equal(v.mediaTypes);
+ expect(d.sizes).to.deep.equal(v.sizes);
+ expect(d.ref.page).to.equal(bidderRequest.refererInfo.page);
+ expect(d.ref.tloc).to.equal(bidderRequest.refererInfo.topmostLocation);
+ expect(d.ref.referrer).to.equal(bidderRequest.refererInfo.ref);
+ expect(d.sua).to.equal(null);
+ expect(d.gdpr).to.equal(false);
+ expect(d.usp).to.equal(false);
+ expect(d.schain).to.equal(null);
+ expect(d.eids).to.deep.equal([]);
+ });
+ });
+
+ it('ref.page, ref.tloc and ref.referrer correspond to refererInfo', function () {
+ const [ request ] = spec.buildRequests([validBidRequests[0]], {
+ auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
+ refererInfo: {
+ page: null,
+ topmostLocation: 'https://adserver.example/iframe1.html',
+ reachedTop: false,
+ ref: null,
+ isAmp: false,
+ numIframes: 2,
+ stack: [
+ null,
+ 'https://adserver.example/iframe1.html',
+ 'https://adserver.example/iframe2.html'
+ ],
+ },
+ });
+
+ const { ref } = JSON.parse(request.data);
+ expect(ref.page).to.equal(null);
+ expect(ref.tloc).to.equal('https://adserver.example/iframe1.html');
+ expect(ref.referrer).to.equal(null);
+ });
+
+ it('when config.pageUrl is not set, ref.topurl equals to refererInfo.reachedTop', function () {
+ let bidderRequestClone = utils.deepClone(bidderRequest);
+ [true, false].forEach(function (reachedTop) {
+ bidderRequestClone.refererInfo.reachedTop = reachedTop;
+ const requests = spec.buildRequests(validBidRequests, bidderRequestClone);
+ const d = JSON.parse(requests[0].data);
+ expect(d.ref.topurl).to.equal(reachedTop);
+ });
+ });
+
+ describe('when config.pageUrl is set, ref.topurl is always false', function () {
+ before(function () {
+ config.setConfig({ pageUrl: 'https://ad-stir.com/register' });
+ });
+ after(function () {
+ config.resetConfig();
+ });
+
+ it('ref.topurl should be false', function () {
+ let bidderRequestClone = utils.deepClone(bidderRequest);
+ [true, false].forEach(function (reachedTop) {
+ bidderRequestClone.refererInfo.reachedTop = reachedTop;
+ const requests = spec.buildRequests(validBidRequests, bidderRequestClone);
+ const d = JSON.parse(requests[0].data);
+ expect(d.ref.topurl).to.equal(false);
+ });
+ });
+ });
+
+ it('gdprConsent.gdprApplies is sent', function () {
+ let bidderRequestClone = utils.deepClone(bidderRequest);
+ [true, false].forEach(function (gdprApplies) {
+ bidderRequestClone.gdprConsent = { gdprApplies };
+ const requests = spec.buildRequests(validBidRequests, bidderRequestClone);
+ const d = JSON.parse(requests[0].data);
+ expect(d.gdpr).to.equal(gdprApplies);
+ });
+ });
+
+ it('includes in the request parameters whether CCPA applies', function () {
+ let bidderRequestClone = utils.deepClone(bidderRequest);
+ const cases = [
+ { uspConsent: '1---', expected: false },
+ { uspConsent: '1YYY', expected: true },
+ { uspConsent: '1YNN', expected: true },
+ { uspConsent: '1NYN', expected: true },
+ { uspConsent: '1-Y-', expected: true },
+ ];
+ cases.forEach(function ({ uspConsent, expected }) {
+ bidderRequestClone.uspConsent = uspConsent;
+ const requests = spec.buildRequests(validBidRequests, bidderRequestClone);
+ const d = JSON.parse(requests[0].data);
+ expect(d.usp).to.equal(expected);
+ });
+ });
+
+ it('should add schain if available', function() {
+ const schain = {
+ 'ver': '1.0',
+ 'complete': 1,
+ 'nodes': [
+ {
+ 'asi': 'exchange1.example',
+ 'sid': '1234!abcd',
+ 'hp': 1,
+ 'rid': 'bid-request-1',
+ 'name': 'publisher, Inc.',
+ 'domain': 'publisher.example'
+ },
+ {
+ 'asi': 'exchange2.example',
+ 'sid': 'abcd',
+ 'hp': 1,
+ 'rid': 'bid-request-2',
+ 'name': 'intermediary',
+ 'domain': 'intermediary.example'
+ }
+ ]
+ };
+ const serializedSchain = '1.0,1!exchange1.example,1234%21abcd,1,bid-request-1,publisher%2C%20Inc.,publisher.example!exchange2.example,abcd,1,bid-request-2,intermediary,intermediary.example';
+
+ const [ request ] = spec.buildRequests([utils.mergeDeep(utils.deepClone(validBidRequests[0]), { schain })], bidderRequest);
+ const d = JSON.parse(request.data);
+ expect(d.schain).to.deep.equal(serializedSchain);
+ });
+
+ it('should add schain even if some nodes params are blank', function() {
+ const schain = {
+ 'ver': '1.0',
+ 'complete': 1,
+ 'nodes': [
+ {
+ 'asi': 'exchange1.example',
+ 'sid': '1234!abcd',
+ 'hp': 1,
+ },
+ {
+ },
+ {
+ 'asi': 'exchange2.example',
+ 'sid': 'abcd',
+ 'hp': 1,
+ },
+ ]
+ };
+ const serializedSchain = '1.0,1!exchange1.example,1234%21abcd,1,,,!,,,,,!exchange2.example,abcd,1,,,';
+
+ const [ request ] = spec.buildRequests([utils.mergeDeep(utils.deepClone(validBidRequests[0]), { schain })], bidderRequest);
+ const d = JSON.parse(request.data);
+ expect(d.schain).to.deep.equal(serializedSchain);
+ });
+
+ it('should add UA client hints to payload if available', function () {
+ const sua = {
+ browsers: [
+ {
+ brand: 'Not?A_Brand',
+ version: [
+ '8',
+ '0',
+ '0',
+ '0'
+ ]
+ },
+ {
+ version: [
+ '108',
+ '0',
+ '5359',
+ '40'
+ ]
+ },
+ {
+ brand: 'Google Chrome',
+ version: [
+ '108',
+ '0',
+ '5359',
+ '40'
+ ]
+ }
+ ],
+ platform: {
+ brand: 'Android',
+ version: [
+ '11'
+ ]
+ },
+ mobile: 1,
+ architecture: '',
+ bitness: '64',
+ model: 'Pixel 5',
+ source: 2
+ }
+
+ const validBidRequestsClone = utils.deepClone(validBidRequests);
+ validBidRequestsClone[0] = utils.mergeDeep(validBidRequestsClone[0], {
+ ortb2: {
+ device: { sua },
+ }
+ });
+
+ const requests = spec.buildRequests(validBidRequestsClone, bidderRequest);
+ requests.forEach(function (r) {
+ const d = JSON.parse(r.data);
+ expect(d.sua).to.deep.equal(sua);
+ });
+ });
+ });
+
+ describe('interpretResponse', function () {
+ it('return empty array when no content', function () {
+ const bids = spec.interpretResponse({ body: '' });
+ expect(bids).to.deep.equal([]);
+ });
+ it('return empty array when seatbid empty', function () {
+ const bids = spec.interpretResponse({ body: { seatbid: [] } });
+ expect(bids).to.deep.equal([]);
+ });
+ it('return valid bids when serverResponse is valid', function () {
+ const serverResponse = {
+ 'body': {
+ 'seatbid': [
+ {
+ 'bid': {
+ 'ad': 'test response
',
+ 'cpm': 5250,
+ 'creativeId': '5_1234ABCD',
+ 'currency': 'JPY',
+ 'height': 250,
+ 'meta': {
+ 'advertiserDomains': [
+ 'adv.example'
+ ],
+ 'mediaType': 'banner',
+ 'networkId': 5
+ },
+ 'netRevenue': true,
+ 'requestId': '22a9457aed98a4',
+ 'transactionId': 'f18c078e-4d2a-4ecb-a886-2a0c52187213',
+ 'ttl': 60,
+ 'width': 300,
+ }
+ }
+ ]
+ },
+ 'headers': {}
+ };
+ const bids = spec.interpretResponse(serverResponse);
+ expect(bids[0]).to.deep.equal(serverResponse.body.seatbid[0].bid);
+ });
+ });
+});
diff --git a/test/spec/modules/adtelligentBidAdapter_spec.js b/test/spec/modules/adtelligentBidAdapter_spec.js
index f271f638e98..0acbaa06f5b 100644
--- a/test/spec/modules/adtelligentBidAdapter_spec.js
+++ b/test/spec/modules/adtelligentBidAdapter_spec.js
@@ -17,6 +17,7 @@ const aliasEP = {
'ocm': 'https://ghb.cenarius.orangeclickmedia.com/v2/auction/',
'9dotsmedia': 'https://ghb.platform.audiodots.com/v2/auction/',
'copper6': 'https://ghb.app.copper6.com/v2/auction/',
+ 'indicue': 'https://ghb.console.indicue.com/v2/auction/',
};
const DEFAULT_ADATPER_REQ = { bidderCode: 'adtelligent' };
diff --git a/test/spec/modules/adxcgBidAdapter_spec.js b/test/spec/modules/adxcgBidAdapter_spec.js
index 65c7584b428..e07e3a6e5d4 100644
--- a/test/spec/modules/adxcgBidAdapter_spec.js
+++ b/test/spec/modules/adxcgBidAdapter_spec.js
@@ -1,835 +1,19 @@
// jshint esversion: 6, es3: false, node: true
-import {assert} from 'chai';
-import {spec} from 'modules/adxcgBidAdapter.js';
-import {config} from 'src/config.js';
-import {createEidsArray} from 'modules/userId/eids.js';
+import { assert } from 'chai';
+import { spec } from 'modules/adxcgBidAdapter.js';
+import { config } from 'src/config.js';
+import { createEidsArray } from 'modules/userId/eids.js';
+/* eslint dot-notation:0, quote-props:0 */
+import { expect } from 'chai';
+
+import { syncAddFPDToBidderRequest } from '../../helpers/fpd.js';
+import { deepClone } from '../../../src/utils';
+
const utils = require('src/utils');
describe('Adxcg adapter', function () {
let bids = [];
- describe('isBidRequestValid', function () {
- let bid = {
- 'bidder': 'adxcg',
- 'params': {
- 'adzoneid': '19910113'
- }
- };
-
- it('should return true when required params found', function () {
- assert(spec.isBidRequestValid(bid));
-
- bid.params = {
- adzoneid: 4332,
- };
- assert(spec.isBidRequestValid(bid));
- });
-
- it('should return false when required params are missing', function () {
- bid.params = {};
- assert.isFalse(spec.isBidRequestValid(bid));
-
- bid.params = {
- mname: 'some-placement'
- };
- assert.isFalse(spec.isBidRequestValid(bid));
-
- bid.params = {
- inv: 1234
- };
- assert.isFalse(spec.isBidRequestValid(bid));
- });
- });
-
- describe('buildRequests', function () {
- beforeEach(function () {
- config.resetConfig();
- });
- it('should send request with correct structure', function () {
- let validBidRequests = [{
- bidId: 'bidId',
- params: {
- adzoneid: '19910113'
- }
- }];
- let request = spec.buildRequests(validBidRequests, {refererInfo: {page: 'page', domain: 'localhost'}});
-
- assert.equal(request.method, 'POST');
- assert.equal(request.url, 'https://pbc.adxcg.net/rtb/ortb/pbc?adExchangeId=1');
- assert.deepEqual(request.options, {contentType: 'application/json'});
- assert.ok(request.data);
- });
-
- describe('user privacy', function () {
- it('should send GDPR Consent data to exchange if gdprApplies', function () {
- let validBidRequests = [{bidId: 'bidId', params: {test: 1}}];
- let bidderRequest = {
- gdprConsent: {gdprApplies: true, consentString: 'consentDataString'},
- refererInfo: {referer: 'page'}
- };
- let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data);
-
- assert.equal(request.user.ext.consent, bidderRequest.gdprConsent.consentString);
- assert.equal(request.regs.ext.gdpr, bidderRequest.gdprConsent.gdprApplies);
- assert.equal(typeof request.regs.ext.gdpr, 'number');
- });
-
- it('should send gdpr as number', function () {
- let validBidRequests = [{bidId: 'bidId', params: {test: 1}}];
- let bidderRequest = {
- gdprConsent: {gdprApplies: true, consentString: 'consentDataString'},
- refererInfo: {referer: 'page'}
- };
- let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data);
-
- assert.equal(typeof request.regs.ext.gdpr, 'number');
- assert.equal(request.regs.ext.gdpr, 1);
- });
-
- it('should send CCPA Consent data to exchange', function () {
- let validBidRequests = [{bidId: 'bidId', params: {test: 1}}];
- let bidderRequest = {uspConsent: '1YA-', refererInfo: {referer: 'page'}};
- let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data);
-
- assert.equal(request.regs.ext.us_privacy, '1YA-');
-
- bidderRequest = {
- uspConsent: '1YA-',
- gdprConsent: {gdprApplies: true, consentString: 'consentDataString'},
- refererInfo: {referer: 'page'}
- };
- request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data);
-
- assert.equal(request.regs.ext.us_privacy, '1YA-');
- assert.equal(request.user.ext.consent, 'consentDataString');
- assert.equal(request.regs.ext.gdpr, 1);
- });
-
- it('should not send GDPR Consent data to adxcg if gdprApplies is undefined', function () {
- let validBidRequests = [{
- bidId: 'bidId',
- params: {siteId: 'siteId'}
- }];
- let bidderRequest = {
- gdprConsent: {gdprApplies: false, consentString: 'consentDataString'},
- refererInfo: {referer: 'page'}
- };
- let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data);
-
- assert.equal(request.user.ext.consent, 'consentDataString');
- assert.equal(request.regs.ext.gdpr, 0);
-
- bidderRequest = {gdprConsent: {consentString: 'consentDataString'}, refererInfo: {referer: 'page'}};
- request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data);
-
- assert.equal(request.user, undefined);
- assert.equal(request.regs, undefined);
- });
- it('should send default GDPR Consent data to exchange', function () {
- let validBidRequests = [{
- bidId: 'bidId',
- params: {siteId: 'siteId'}
- }];
- let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data);
-
- assert.equal(request.user, undefined);
- assert.equal(request.regs, undefined);
- });
- });
-
- it('should add test and is_debug to request, if test is set in parameters', function () {
- let validBidRequests = [{
- bidId: 'bidId',
- params: {test: 1}
- }];
- let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data);
-
- assert.ok(request.is_debug);
- assert.equal(request.test, 1);
- });
-
- it('should have default request structure', function () {
- let keys = 'site,geo,device,source,ext,imp'.split(',');
- let validBidRequests = [{
- bidId: 'bidId',
- params: {siteId: 'siteId'}
- }];
- let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data);
- let data = Object.keys(request);
-
- assert.deepEqual(keys, data);
- });
-
- it('should set request keys correct values', function () {
- let validBidRequests = [{
- bidId: 'bidId',
- params: {siteId: 'siteId'},
- }];
- let request = JSON.parse(spec.buildRequests(validBidRequests, {
- refererInfo: {referer: 'page'},
- ortb2: {source: {tid: 'tid'}}
- }).data);
-
- assert.equal(request.source.tid, 'tid');
- assert.equal(request.source.fd, 1);
- });
-
- it('should send info about device', function () {
- config.setConfig({
- device: {w: 100, h: 100}
- });
- let validBidRequests = [{
- bidId: 'bidId',
- params: {adzoneid: '1000'}
- }];
- let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {page: 'page', domain: 'localhost'}}).data);
-
- assert.equal(request.device.ua, navigator.userAgent);
- assert.equal(request.device.w, 100);
- assert.equal(request.device.h, 100);
- });
-
- it('should send app info', function () {
- config.setConfig({
- app: {id: 'appid'},
- });
- const ortb2 = {app: {name: 'appname'}}
- let validBidRequests = [{
- bidId: 'bidId',
- params: {adzoneid: '1000'},
- ortb2
- }];
- let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}, ortb2}).data);
-
- assert.equal(request.app.id, 'appid');
- assert.equal(request.app.name, 'appname');
- assert.equal(request.site, undefined);
- });
-
- it('should send info about the site', function () {
- config.setConfig({
- site: {
- id: '123123',
- publisher: {
- domain: 'publisher.domain.com'
- }
- },
- });
- const ortb2 = {
- site: {
- publisher: {
- id: 4441,
- name: 'publisher\'s name'
- }
- }
- };
-
- let validBidRequests = [{
- bidId: 'bidId',
- params: {adzoneid: '1000'},
- ortb2
- }];
- let refererInfo = {page: 'page', domain: 'localhost'};
- let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo, ortb2}).data);
-
- assert.deepEqual(request.site, {
- domain: 'localhost',
- id: '123123',
- page: refererInfo.page,
- publisher: {
- domain: 'publisher.domain.com',
- id: 4441,
- name: 'publisher\'s name'
- }
- });
- });
-
- it('should pass extended ids', function () {
- let validBidRequests = [{
- bidId: 'bidId',
- params: {},
- userIdAsEids: createEidsArray({
- tdid: 'TTD_ID_FROM_USER_ID_MODULE',
- pubcid: 'pubCommonId_FROM_USER_ID_MODULE'
- })
- }];
-
- let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data);
- assert.deepEqual(request.user.ext.eids, [
- {source: 'adserver.org', uids: [{id: 'TTD_ID_FROM_USER_ID_MODULE', atype: 1, ext: {rtiPartner: 'TDID'}}]},
- {source: 'pubcid.org', uids: [{id: 'pubCommonId_FROM_USER_ID_MODULE', atype: 1}]}
- ]);
- });
-
- it('should send currency if defined', function () {
- config.setConfig({currency: {adServerCurrency: 'EUR'}});
- let validBidRequests = [{params: {}}];
- let refererInfo = {referer: 'page'};
- let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo}).data);
-
- assert.deepEqual(request.cur, ['EUR']);
- });
-
- it('should pass supply chain object', function () {
- let validBidRequests = [{
- bidId: 'bidId',
- params: {},
- schain: {
- validation: 'strict',
- config: {
- ver: '1.0'
- }
- }
- }];
-
- let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data);
- assert.deepEqual(request.source.ext.schain, {
- validation: 'strict',
- config: {
- ver: '1.0'
- }
- });
- });
-
- describe('bids', function () {
- it('should add more than one bid to the request', function () {
- let validBidRequests = [{
- bidId: 'bidId',
- params: {siteId: 'siteId'}
- }, {
- bidId: 'bidId2',
- params: {siteId: 'siteId'}
- }];
- let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data);
-
- assert.equal(request.imp.length, 2);
- });
- it('should add incrementing values of id', function () {
- let validBidRequests = [{
- bidId: 'bidId',
- params: {adzoneid: '1000'},
- mediaTypes: {video: {}}
- }, {
- bidId: 'bidId2',
- params: {adzoneid: '1000'},
- mediaTypes: {video: {}}
- }, {
- bidId: 'bidId3',
- params: {adzoneid: '1000'},
- mediaTypes: {video: {}}
- }];
- let imps = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data).imp;
-
- for (let i = 0; i < 3; i++) {
- assert.equal(imps[i].id, i + 1);
- }
- });
-
- it('should add adzoneid', function () {
- let validBidRequests = [{bidId: 'bidId', params: {adzoneid: 1000}, mediaTypes: {video: {}}},
- {bidId: 'bidId2', params: {adzoneid: 1001}, mediaTypes: {video: {}}},
- {bidId: 'bidId3', params: {adzoneid: 1002}, mediaTypes: {video: {}}}];
- let imps = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data).imp;
- for (let i = 0; i < 3; i++) {
- assert.equal(imps[i].tagid, validBidRequests[i].params.adzoneid);
- }
- });
-
- describe('price floors', function () {
- it('should not add if floors module not configured', function () {
- const validBidRequests = [{bidId: 'bidId', params: {adzoneid: 1000}, mediaTypes: {video: {}}}];
- let imp = getRequestImps(validBidRequests)[0];
-
- assert.equal(imp.bidfloor, undefined);
- assert.equal(imp.bidfloorcur, undefined);
- });
-
- it('should not add if floor price not defined', function () {
- const validBidRequests = [getBidWithFloor()];
- let imp = getRequestImps(validBidRequests)[0];
-
- assert.equal(imp.bidfloor, undefined);
- assert.equal(imp.bidfloorcur, 'USD');
- });
-
- it('should request floor price in adserver currency', function () {
- config.setConfig({currency: {adServerCurrency: 'DKK'}});
- const validBidRequests = [getBidWithFloor()];
- let imp = getRequestImps(validBidRequests)[0];
-
- assert.equal(imp.bidfloor, undefined);
- assert.equal(imp.bidfloorcur, 'DKK');
- });
-
- it('should add correct floor values', function () {
- const expectedFloors = [1, 1.3, 0.5];
- const validBidRequests = expectedFloors.map(getBidWithFloor);
- let imps = getRequestImps(validBidRequests);
-
- expectedFloors.forEach((floor, index) => {
- assert.equal(imps[index].bidfloor, floor);
- assert.equal(imps[index].bidfloorcur, 'USD');
- });
- });
-
- function getBidWithFloor(floor) {
- return {
- params: {adzoneid: 1},
- mediaTypes: {video: {}},
- getFloor: ({currency}) => {
- return {
- currency: currency,
- floor
- };
- }
- };
- }
- });
-
- describe('multiple media types', function () {
- it('should use all configured media types for bidding', function () {
- let validBidRequests = [{
- bidId: 'bidId',
- params: {adzoneid: 1000},
- mediaTypes: {
- banner: {
- sizes: [[100, 100], [200, 300]]
- },
- video: {}
- }
- }, {
- bidId: 'bidId1',
- params: {adzoneid: 1000},
- mediaTypes: {
- video: {},
- native: {}
- }
- }, {
- bidId: 'bidId2',
- params: {adzoneid: 1000},
- nativeParams: {
- title: {required: true, len: 140}
- },
- mediaTypes: {
- banner: {
- sizes: [[100, 100], [200, 300]]
- },
- native: {},
- video: {}
- }
- }];
- let [first, second, third] = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data).imp;
-
- assert.ok(first.banner);
- assert.ok(first.video);
- assert.equal(first.native, undefined);
-
- assert.ok(second.video);
- assert.equal(second.banner, undefined);
- assert.equal(second.native, undefined);
-
- assert.ok(third.native);
- assert.ok(third.video);
- assert.ok(third.banner);
- });
- });
-
- describe('banner', function () {
- it('should convert sizes to openrtb format', function () {
- let validBidRequests = [{
- bidId: 'bidId',
- params: {adzoneid: 1000},
- mediaTypes: {
- banner: {
- sizes: [[100, 100], [200, 300]]
- }
- }
- }];
- let {banner} = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data).imp[0];
- assert.deepEqual(banner, {
- format: [{w: 100, h: 100}, {w: 200, h: 300}]
- });
- });
- });
-
- describe('video', function () {
- it('should pass video mediatype config', function () {
- let validBidRequests = [{
- bidId: 'bidId',
- params: {adzoneid: 1000},
- mediaTypes: {
- video: {
- playerSize: [640, 480],
- context: 'outstream',
- mimes: ['video/mp4']
- }
- }
- }];
- let {video} = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data).imp[0];
- assert.deepEqual(video, {
- playerSize: [640, 480],
- context: 'outstream',
- mimes: ['video/mp4']
- });
- });
- });
-
- describe('native', function () {
- describe('assets', function () {
- it('should set correct asset id', function () {
- let validBidRequests = [{
- bidId: 'bidId',
- params: {adzoneid: 1000},
- nativeParams: {
- title: {required: true, len: 140},
- image: {required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif']},
- body: {len: 140}
- }
- }];
- let nativeRequest = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data).imp[0].native.request;
- let assets = JSON.parse(nativeRequest).assets;
-
- assert.equal(assets[0].id, 0);
- assert.equal(assets[1].id, 3);
- assert.equal(assets[2].id, 4);
- });
- it('should add required key if it is necessary', function () {
- let validBidRequests = [{
- bidId: 'bidId',
- params: {adzoneid: 1000},
- nativeParams: {
- title: {required: true, len: 140},
- image: {required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif']},
- body: {len: 140},
- sponsoredBy: {required: true, len: 140}
- }
- }];
-
- let nativeRequest = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data).imp[0].native.request;
- let assets = JSON.parse(nativeRequest).assets;
-
- assert.equal(assets[0].required, 1);
- assert.ok(!assets[1].required);
- assert.ok(!assets[2].required);
- assert.equal(assets[3].required, 1);
- });
-
- it('should map img and data assets', function () {
- let validBidRequests = [{
- bidId: 'bidId',
- params: {adzoneid: 1000},
- nativeParams: {
- title: {required: true, len: 140},
- image: {required: true, sizes: [150, 50]},
- icon: {required: false, sizes: [50, 50]},
- body: {required: false, len: 140},
- sponsoredBy: {required: true},
- cta: {required: false},
- clickUrl: {required: false}
- }
- }];
-
- let nativeRequest = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data).imp[0].native.request;
- let assets = JSON.parse(nativeRequest).assets;
- assert.ok(assets[0].title);
- assert.equal(assets[0].title.len, 140);
- assert.deepEqual(assets[1].img, {type: 3, w: 150, h: 50});
- assert.deepEqual(assets[2].img, {type: 1, w: 50, h: 50});
- assert.deepEqual(assets[3].data, {type: 2, len: 140});
- assert.deepEqual(assets[4].data, {type: 1});
- assert.deepEqual(assets[5].data, {type: 12});
- assert.ok(!assets[6]);
- });
-
- describe('icon/image sizing', function () {
- it('should flatten sizes and utilise first pair', function () {
- const validBidRequests = [{
- bidId: 'bidId',
- params: {adzoneid: 1000},
- nativeParams: {
- image: {
- sizes: [[200, 300], [100, 200]]
- },
- }
- }];
-
- let nativeRequest = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data).imp[0].native.request;
- let assets = JSON.parse(nativeRequest).assets;
- assert.ok(assets[0].img);
- assert.equal(assets[0].img.w, 200);
- assert.equal(assets[0].img.h, 300);
- });
- });
-
- it('should utilise aspect_ratios', function () {
- const validBidRequests = [{
- bidId: 'bidId',
- params: {adzoneid: 1000},
- nativeParams: {
- image: {
- aspect_ratios: [{
- min_width: 100,
- ratio_height: 3,
- ratio_width: 1
- }]
- },
- icon: {
- aspect_ratios: [{
- min_width: 10,
- ratio_height: 5,
- ratio_width: 2
- }]
- }
- }
- }];
-
- let nativeRequest = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data).imp[0].native.request;
- let assets = JSON.parse(nativeRequest).assets;
- assert.ok(assets[0].img);
- assert.equal(assets[0].img.wmin, 100);
- assert.equal(assets[0].img.hmin, 300);
-
- assert.ok(assets[1].img);
- assert.equal(assets[1].img.wmin, 10);
- assert.equal(assets[1].img.hmin, 25);
- });
-
- it('should not throw error if aspect_ratios config is not defined', function () {
- const validBidRequests = [{
- bidId: 'bidId',
- params: {adzoneid: 1000},
- nativeParams: {
- image: {
- aspect_ratios: []
- },
- icon: {
- aspect_ratios: []
- }
- }
- }];
-
- assert.doesNotThrow(() => spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}));
- });
- });
-
- it('should expect any dimensions if min_width not passed', function () {
- const validBidRequests = [{
- bidId: 'bidId',
- params: {adzoneid: 1000},
- nativeParams: {
- image: {
- aspect_ratios: [{
- ratio_height: 3,
- ratio_width: 1
- }]
- }
- }
- }];
-
- let nativeRequest = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data).imp[0].native.request;
- let assets = JSON.parse(nativeRequest).assets;
- assert.ok(assets[0].img);
- assert.equal(assets[0].img.wmin, 0);
- assert.equal(assets[0].img.hmin, 0);
- assert.ok(!assets[1]);
- });
- });
- });
-
- function getRequestImps(validBidRequests) {
- return JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data).imp;
- }
- });
-
- describe('interpretResponse', function () {
- it('should return if no body in response', function () {
- let serverResponse = {};
- let bidRequest = {};
-
- assert.ok(!spec.interpretResponse(serverResponse, bidRequest));
- });
- it('should return more than one bids', function () {
- let serverResponse = {
- body: {
- seatbid: [{
- bid: [{
- impid: '1',
- native: {ver: '1.1', link: {url: 'link'}, assets: [{id: 1, title: {text: 'Asset title text'}}]}
- }]
- }, {
- bid: [{
- impid: '2',
- native: {ver: '1.1', link: {url: 'link'}, assets: [{id: 1, data: {value: 'Asset title text'}}]}
- }]
- }]
- }
- };
- let bidRequest = {
- data: {},
- bids: [
- {
- bidId: 'bidId1',
- params: {adzoneid: 1000},
- nativeParams: {
- title: {required: true, len: 140},
- image: {required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif']},
- body: {len: 140}
- }
- },
- {
- bidId: 'bidId2',
- params: {adzoneid: 1000},
- nativeParams: {
- title: {required: true, len: 140},
- image: {required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif']},
- body: {len: 140}
- }
- }
- ]
- };
-
- bids = spec.interpretResponse(serverResponse, bidRequest);
- assert.equal(spec.interpretResponse(serverResponse, bidRequest).length, 2);
- });
-
- it('should set correct values to bid', function () {
- let nativeExample1 = {
- assets: [],
- link: {url: 'link'},
- imptrackers: ['imptrackers url1', 'imptrackers url2']
- }
-
- let serverResponse = {
- body: {
- id: null,
- bidid: null,
- seatbid: [{
- bid: [
- {
- impid: '1',
- price: 93.1231,
- crid: '12312312',
- adm: JSON.stringify(nativeExample1),
- dealid: 'deal-id',
- adomain: ['demo.com'],
- ext: {
- crType: 'native',
- advertiser_id: 'adv1',
- advertiser_name: 'advname',
- agency_name: 'agname',
- mediaType: 'native'
- }
- }
- ]
- }],
- cur: 'EUR'
- }
- };
- let bidRequest = {
- data: {},
- bids: [
- {
- bidId: 'bidId1',
- params: {adzoneid: 1000},
- nativeParams: {
- title: {required: true, len: 140},
- image: {required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif']},
- body: {len: 140}
- }
- }
- ]
- };
-
- const bids = spec.interpretResponse(serverResponse, bidRequest);
- const bid = serverResponse.body.seatbid[0].bid[0];
- assert.deepEqual(bids[0].requestId, bidRequest.bids[0].bidId);
- assert.deepEqual(bids[0].cpm, bid.price);
- assert.deepEqual(bids[0].creativeId, bid.crid);
- assert.deepEqual(bids[0].ttl, 300);
- assert.deepEqual(bids[0].netRevenue, false);
- assert.deepEqual(bids[0].currency, serverResponse.body.cur);
- assert.deepEqual(bids[0].mediaType, 'native');
- assert.deepEqual(bids[0].meta.mediaType, 'native');
- assert.deepEqual(bids[0].meta.advertiserDomains, ['demo.com']);
-
- assert.deepEqual(bids[0].meta.advertiserName, 'advname');
- assert.deepEqual(bids[0].meta.agencyName, 'agname');
-
- assert.deepEqual(bids[0].dealId, 'deal-id');
- });
-
- it('should return empty when there is no bids in response', function () {
- const serverResponse = {
- body: {
- id: null,
- bidid: null,
- seatbid: [{bid: []}],
- cur: 'EUR'
- }
- };
- let bidRequest = {
- data: {},
- bids: [{bidId: 'bidId1'}]
- };
- const result = spec.interpretResponse(serverResponse, bidRequest)[0];
- assert.ok(!result);
- });
-
- describe('banner', function () {
- it('should set ad content on response', function () {
- let serverResponse = {
- body: {
- seatbid: [{
- bid: [{impid: '1', adm: '', ext: {crType: 'banner'}}]
- }]
- }
- };
- let bidRequest = {
- data: {},
- bids: [
- {
- bidId: 'bidId1',
- params: {adzoneid: 1000}
- }
- ]
- };
-
- bids = spec.interpretResponse(serverResponse, bidRequest);
- assert.equal(bids.length, 1);
- assert.equal(bids[0].ad, '');
- assert.equal(bids[0].mediaType, 'banner');
- assert.equal(bids[0].meta.mediaType, 'banner');
- });
- });
-
- describe('video', function () {
- it('should set vastXml on response', function () {
- let serverResponse = {
- body: {
- seatbid: [{
- bid: [{impid: '1', adm: '', ext: {crType: 'video'}}]
- }]
- }
- };
- let bidRequest = {
- data: {},
- bids: [
- {
- bidId: 'bidId1',
- params: {adzoneid: 1000}
- }
- ]
- };
-
- bids = spec.interpretResponse(serverResponse, bidRequest);
- assert.equal(bids.length, 1);
- assert.equal(bids[0].vastXml, '');
- assert.equal(bids[0].mediaType, 'video');
- assert.equal(bids[0].meta.mediaType, 'video');
- });
- });
- });
-
describe('getUserSyncs', function () {
const usersyncUrl = 'https://usersync-url.com';
beforeEach(() => {
@@ -846,55 +30,55 @@ describe('Adxcg adapter', function () {
})
it('should return user sync if pixel enabled with adxcg config', function () {
- const ret = spec.getUserSyncs({pixelEnabled: true})
- expect(ret).to.deep.equal([{type: 'image', url: usersyncUrl}])
+ const ret = spec.getUserSyncs({ pixelEnabled: true })
+ expect(ret).to.deep.equal([{ type: 'image', url: usersyncUrl }])
})
it('should not return user sync if pixel disabled', function () {
- const ret = spec.getUserSyncs({pixelEnabled: false})
+ const ret = spec.getUserSyncs({ pixelEnabled: false })
expect(ret).to.be.an('array').that.is.empty
})
it('should not return user sync if url is not set', function () {
config.resetConfig()
- const ret = spec.getUserSyncs({pixelEnabled: true})
+ const ret = spec.getUserSyncs({ pixelEnabled: true })
expect(ret).to.be.an('array').that.is.empty
})
- it('should pass GDPR consent', function() {
- expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, undefined)).to.deep.equal([{
+ it('should pass GDPR consent', function () {
+ expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { gdprApplies: true, consentString: 'foo' }, undefined)).to.deep.equal([{
type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=foo`
}]);
- expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: false, consentString: 'foo'}, undefined)).to.deep.equal([{
+ expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { gdprApplies: false, consentString: 'foo' }, undefined)).to.deep.equal([{
type: 'image', url: `${usersyncUrl}?gdpr=0&gdpr_consent=foo`
}]);
- expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: undefined}, undefined)).to.deep.equal([{
+ expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { gdprApplies: true, consentString: undefined }, undefined)).to.deep.equal([{
type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=`
}]);
});
- it('should pass US consent', function() {
+ it('should pass US consent', function () {
expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined, '1NYN')).to.deep.equal([{
type: 'image', url: `${usersyncUrl}?us_privacy=1NYN`
}]);
});
- it('should pass GDPR and US consent', function() {
- expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, '1NYN')).to.deep.equal([{
+ it('should pass GDPR and US consent', function () {
+ expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { gdprApplies: true, consentString: 'foo' }, '1NYN')).to.deep.equal([{
type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=foo&us_privacy=1NYN`
}]);
});
});
- describe('onBidWon', function() {
- beforeEach(function() {
+ describe('onBidWon', function () {
+ beforeEach(function () {
sinon.stub(utils, 'triggerPixel');
});
- afterEach(function() {
+ afterEach(function () {
utils.triggerPixel.restore();
});
- it('Should trigger pixel if bid nurl', function() {
+ it('Should trigger pixel if bid nurl', function () {
const bid = {
nurl: 'http://example.com/win/${AUCTION_PRICE}',
cpm: 2.1,
@@ -904,4 +88,510 @@ describe('Adxcg adapter', function () {
expect(utils.triggerPixel.callCount).to.equal(1)
})
})
+
+ it('should return just to have at least 1 karma test ok', function () {
+ assert(true);
+ });
+});
+
+describe('adxcg v8 oRtbConverter Adapter Tests', function () {
+ const slotConfigs = [{
+ placementCode: '/DfpAccount1/slot1',
+ mediaTypes: {
+ banner: {
+ sizes: [[728, 90], [160, 600]]
+ }
+ },
+ bidId: 'bid12345',
+ params: {
+ cp: 'p10000',
+ ct: 't10000',
+ cf: '300x250',
+ adzoneid: '77'
+ }
+ }, {
+ placementCode: '/DfpAccount2/slot2',
+ mediaTypes: {
+ banner: {
+ sizes: [[728, 90]]
+ }
+ },
+ bidId: 'bid23456',
+ params: {
+ cp: 'p10000',
+ ct: 't20000',
+ cf: '728x90',
+ adzoneid: '77'
+ }
+ }];
+ const nativeOrtbRequest = {
+ assets: [{
+ id: 1,
+ required: 1,
+ img: {
+ type: 3,
+ w: 150,
+ h: 50,
+ }
+ },
+ {
+ id: 2,
+ required: 1,
+ title: {
+ len: 80
+ }
+ },
+ {
+ id: 3,
+ required: 0,
+ data: {
+ type: 1
+ }
+ }]
+ };
+ const nativeSlotConfig = [{
+ placementCode: '/DfpAccount1/slot3',
+ bidId: 'bid12345',
+ mediaTypes: {
+ native: {
+ sendTargetingKeys: false,
+ ortb: nativeOrtbRequest
+ }
+ },
+ nativeOrtbRequest,
+ params: {
+ cp: 'p10000',
+ ct: 't10000',
+ adzoneid: '77'
+ }
+ }];
+ const videoSlotConfig = [{
+ placementCode: '/DfpAccount1/slotVideo',
+ bidId: 'bid12345',
+ mediaTypes: {
+ video: {
+ playerSize: [400, 300],
+ w: 400,
+ h: 300,
+ minduration: 5,
+ maxduration: 10,
+ startdelay: 0,
+ skip: 1,
+ minbitrate: 200,
+ protocols: [1, 2, 4]
+ }
+ },
+ params: {
+ cp: 'p10000',
+ ct: 't10000',
+ adzoneid: '77'
+ }
+ }];
+ const additionalParamsConfig = [{
+ placementCode: '/DfpAccount1/slot1',
+ mediaTypes: {
+ banner: {
+ sizes: [[1, 1]]
+ }
+ },
+ bidId: 'bid12345',
+ params: {
+ cp: 'p10000',
+ ct: 't10000',
+ cf: '1x1',
+ adzoneid: '77',
+ extra_key1: 'extra_val1',
+ extra_key2: 12345,
+ extra_key3: {
+ key1: 'val1',
+ key2: 23456,
+ },
+ extra_key4: [1, 2, 3]
+ }
+ }];
+
+ const schainParamsSlotConfig = [{
+ placementCode: '/DfpAccount1/slot1',
+ mediaTypes: {
+ banner: {
+ sizes: [[1, 1]]
+ }
+ },
+ bidId: 'bid12345',
+ params: {
+ cp: 'p10000',
+ ct: 't10000',
+ cf: '1x1',
+ adzoneid: '77',
+ bcat: ['IAB-1', 'IAB-20'],
+ battr: [1, 2, 3],
+ bidfloor: 1.5,
+ badv: ['cocacola.com', 'lays.com']
+ },
+ schain: {
+ 'ver': '1.0',
+ 'complete': 1,
+ 'nodes': [
+ {
+ 'asi': 'exchange1.com',
+ 'sid': '1234',
+ 'hp': 1,
+ 'rid': 'bid-request-1',
+ 'name': 'publisher',
+ 'domain': 'publisher.com'
+ }
+ ]
+ },
+ }];
+
+ const bidderRequest = {
+ refererInfo: {
+ page: 'https://publisher.com/home',
+ ref: 'https://referrer'
+ }
+ };
+
+ it('Verify build request', function () {
+ const request = spec.buildRequests(slotConfigs, syncAddFPDToBidderRequest(bidderRequest));
+ expect(request.url).to.equal('https://pbc.adxcg.net/rtb/ortb/pbc?adExchangeId=1');
+ expect(request.method).to.equal('POST');
+ const ortbRequest = request.data;
+ // site object
+ expect(ortbRequest.site).to.not.equal(null);
+ expect(ortbRequest.site.publisher).to.not.equal(null);
+ // expect(ortbRequest.site.publisher.id).to.equal('p10000');
+ expect(ortbRequest.site.page).to.equal('https://publisher.com/home');
+ expect(ortbRequest.imp).to.have.lengthOf(2);
+ // device object
+ expect(ortbRequest.device).to.not.equal(null);
+ expect(ortbRequest.device.ua).to.equal(navigator.userAgent);
+ // slot 1
+ // expect(ortbRequest.imp[0].tagid).to.equal('t10000');
+ expect(ortbRequest.imp[0].banner).to.not.equal(null);
+ expect(ortbRequest.imp[0].banner.format).to.deep.eq([{ 'w': 728, 'h': 90 }, { 'w': 160, 'h': 600 }]);
+ // slot 2
+ // expect(ortbRequest.imp[1].tagid).to.equal('t20000');
+ expect(ortbRequest.imp[1].banner).to.not.equal(null);
+ expect(ortbRequest.imp[1].banner.format).to.deep.eq([{ 'w': 728, 'h': 90 }]);
+ });
+
+ it('Verify parse response', function () {
+ const request = spec.buildRequests(slotConfigs, syncAddFPDToBidderRequest(bidderRequest));
+ const ortbRequest = request.data;
+ const ortbResponse = {
+ seatbid: [{
+ bid: [{
+ impid: ortbRequest.imp[0].id,
+ price: 1.25,
+ adm: 'This is an Ad',
+ crid: 'Creative#123',
+ mtype: 1,
+ w: 300,
+ h: 250,
+ exp: 20,
+ adomain: ['advertiser.com']
+ }]
+ }]
+ };
+ const bids = spec.interpretResponse({ body: ortbResponse }, request);
+ expect(bids).to.have.lengthOf(1);
+ // verify first bid
+ const bid = bids[0];
+ expect(bid.cpm).to.equal(1.25);
+ expect(bid.ad).to.equal('This is an Ad');
+ expect(bid.width).to.equal(300);
+ expect(bid.height).to.equal(250);
+ expect(bid.creative_id).to.equal('Creative#123');
+ expect(bid.creativeId).to.equal('Creative#123');
+ expect(bid.netRevenue).to.equal(true);
+ expect(bid.currency).to.equal('EUR');
+ expect(bid.ttl).to.equal(20);
+ expect(bid.meta).to.not.be.null;
+ expect(bid.meta.advertiserDomains).to.eql(['advertiser.com']);
+ });
+
+ it('Verify full passback', function () {
+ const request = spec.buildRequests(slotConfigs, bidderRequest);
+ const bids = spec.interpretResponse({ body: null }, request)
+ expect(bids).to.have.lengthOf(0);
+ });
+
+ if (FEATURES.NATIVE) {
+ it('Verify Native request', function () {
+ const request = spec.buildRequests(nativeSlotConfig, syncAddFPDToBidderRequest(bidderRequest));
+ expect(request.url).to.equal('https://pbc.adxcg.net/rtb/ortb/pbc?adExchangeId=1');
+ expect(request.method).to.equal('POST');
+ const ortbRequest = request.data;
+ // native impression
+ expect(ortbRequest.imp[0].tagid).to.equal('77');
+ expect(ortbRequest.imp[0].banner).to.be.undefined;
+ const nativePart = ortbRequest.imp[0]['native'];
+ expect(nativePart).to.not.equal(null);
+ expect(nativePart.request).to.not.equal(null);
+ // native request assets
+ const nativeRequest = JSON.parse(ortbRequest.imp[0]['native'].request);
+ expect(nativeRequest).to.not.equal(null);
+ expect(nativeRequest.assets).to.have.lengthOf(3);
+ // image asset
+ expect(nativeRequest.assets[0].id).to.equal(1);
+ expect(nativeRequest.assets[0].required).to.equal(1);
+ expect(nativeRequest.assets[0].title).to.be.undefined;
+ expect(nativeRequest.assets[0].img).to.not.equal(null);
+ expect(nativeRequest.assets[0].img.w).to.equal(150);
+ expect(nativeRequest.assets[0].img.h).to.equal(50);
+ expect(nativeRequest.assets[0].img.type).to.equal(3);
+ // title asset
+ expect(nativeRequest.assets[1].id).to.equal(2);
+ expect(nativeRequest.assets[1].required).to.equal(1);
+ expect(nativeRequest.assets[1].title).to.not.equal(null);
+ expect(nativeRequest.assets[1].title.len).to.equal(80);
+ // data asset
+ expect(nativeRequest.assets[2].id).to.equal(3);
+ expect(nativeRequest.assets[2].required).to.equal(0);
+ expect(nativeRequest.assets[2].title).to.be.undefined;
+ expect(nativeRequest.assets[2].data).to.not.equal(null);
+ expect(nativeRequest.assets[2].data.type).to.equal(1);
+ });
+
+ it('Verify Native response', function () {
+ const request = spec.buildRequests(nativeSlotConfig, syncAddFPDToBidderRequest(bidderRequest));
+ expect(request.url).to.equal('https://pbc.adxcg.net/rtb/ortb/pbc?adExchangeId=1');
+ expect(request.method).to.equal('POST');
+ const ortbRequest = request.data;
+ const nativeResponse = {
+ assets: [
+ { id: 1, img: { type: 3, url: 'https://images.cdn.brand.com/123' } },
+ { id: 2, title: { text: 'Ad Title' } },
+ { id: 3, data: { type: 1, value: 'Sponsored By: Brand' } }
+ ],
+ link: { url: 'https://brand.clickme.com/' },
+ imptrackers: ['https://imp1.trackme.com/', 'https://imp1.contextweb.com/']
+
+ };
+ const ortbResponse = {
+ seatbid: [{
+ bid: [{
+ impid: ortbRequest.imp[0].id,
+ price: 1.25,
+ adm: JSON.stringify(nativeResponse),
+ mtype: 4
+ }]
+ }]
+ };
+ const bids = spec.interpretResponse({ body: ortbResponse }, request);
+ // verify bid
+ const bid = bids[0];
+ expect(bid.cpm).to.equal(1.25);
+ expect(bid.requestId).to.equal('bid12345');
+ expect(bid.ad).to.be.undefined;
+ expect(bid.mediaType).to.equal('native');
+ expect(bid['native']).to.not.be.null;
+ expect(bid['native'].ortb).to.not.be.null;
+ const nativeBid = bid['native'].ortb;
+ expect(nativeBid.assets).to.have.lengthOf(3);
+ expect(nativeBid.assets[0].id).to.equal(1);
+ expect(nativeBid.assets[0].img).to.not.be.null;
+ expect(nativeBid.assets[0].img.type).to.equal(3);
+ expect(nativeBid.assets[0].img.url).to.equal('https://images.cdn.brand.com/123');
+ expect(nativeBid.assets[1].id).to.equal(2);
+ expect(nativeBid.assets[1].title).to.not.be.null;
+ expect(nativeBid.assets[1].title.text).to.equal('Ad Title');
+ expect(nativeBid.assets[2].id).to.equal(3);
+ expect(nativeBid.assets[2].data).to.not.be.null;
+ expect(nativeBid.assets[2].data.type).to.equal(1);
+ expect(nativeBid.assets[2].data.value).to.equal('Sponsored By: Brand');
+ expect(nativeBid.link).to.not.be.null;
+ expect(nativeBid.link.url).to.equal('https://brand.clickme.com/');
+ expect(nativeBid.imptrackers).to.have.lengthOf(2);
+ expect(nativeBid.imptrackers[0]).to.equal('https://imp1.trackme.com/');
+ expect(nativeBid.imptrackers[1]).to.equal('https://imp1.contextweb.com/');
+ });
+ }
+
+ it('Verifies bidder code', function () {
+ expect(spec.code).to.equal('adxcg');
+ });
+
+ it('Verifies bidder aliases', function () {
+ expect(spec.aliases).to.have.lengthOf(1);
+ expect(spec.aliases[0]).to.equal('mediaopti');
+ });
+
+ it('Verifies supported media types', function () {
+ expect(spec.supportedMediaTypes).to.have.lengthOf(3);
+ expect(spec.supportedMediaTypes[0]).to.equal('banner');
+ expect(spec.supportedMediaTypes[1]).to.equal('native');
+ expect(spec.supportedMediaTypes[2]).to.equal('video');
+ });
+
+ if (FEATURES.VIDEO) {
+ it('Verify Video request', function () {
+ const request = spec.buildRequests(videoSlotConfig, syncAddFPDToBidderRequest(bidderRequest));
+ expect(request.url).to.equal('https://pbc.adxcg.net/rtb/ortb/pbc?adExchangeId=1');
+ expect(request.method).to.equal('POST');
+ const ortbRequest = request.data;
+ expect(ortbRequest).to.not.equal(null);
+ expect(ortbRequest.imp).to.have.lengthOf(1);
+ expect(ortbRequest.imp[0].video).to.not.be.null;
+ expect(ortbRequest.imp[0].native).to.be.undefined;
+ expect(ortbRequest.imp[0].banner).to.be.undefined;
+ expect(ortbRequest.imp[0].video.w).to.equal(400);
+ expect(ortbRequest.imp[0].video.h).to.equal(300);
+ expect(ortbRequest.imp[0].video.minduration).to.equal(5);
+ expect(ortbRequest.imp[0].video.maxduration).to.equal(10);
+ expect(ortbRequest.imp[0].video.startdelay).to.equal(0);
+ expect(ortbRequest.imp[0].video.skip).to.equal(1);
+ expect(ortbRequest.imp[0].video.minbitrate).to.equal(200);
+ expect(ortbRequest.imp[0].video.protocols).to.eql([1, 2, 4]);
+ });
+ }
+
+ it('Verify extra parameters', function () {
+ let request = spec.buildRequests(additionalParamsConfig, syncAddFPDToBidderRequest(bidderRequest));
+ let ortbRequest = request.data;
+ expect(ortbRequest).to.not.equal(null);
+ expect(ortbRequest.imp).to.have.lengthOf(1);
+ expect(ortbRequest.imp[0].ext).to.not.equal(null);
+ expect(ortbRequest.imp[0].ext.prebid).to.not.equal(null);
+ expect(ortbRequest.imp[0].ext.prebid).to.not.be.null;
+ expect(ortbRequest.imp[0].ext.prebid.extra_key1).to.equal('extra_val1');
+ expect(ortbRequest.imp[0].ext.prebid.extra_key2).to.equal(12345);
+ expect(ortbRequest.imp[0].ext.prebid.extra_key3).to.not.be.null;
+ expect(ortbRequest.imp[0].ext.prebid.extra_key3.key1).to.equal('val1');
+ expect(ortbRequest.imp[0].ext.prebid.extra_key3.key2).to.equal(23456);
+ expect(ortbRequest.imp[0].ext.prebid.extra_key4).to.eql([1, 2, 3]);
+ expect(Object.keys(ortbRequest.imp[0].ext.prebid)).to.eql(['adzoneid', 'extra_key1', 'extra_key2', 'extra_key3', 'extra_key4']);
+ // attempting with a configuration with no unknown params.
+ request = spec.buildRequests(videoSlotConfig, bidderRequest);
+ ortbRequest = request.data;
+ expect(ortbRequest).to.not.equal(null);
+ expect(ortbRequest.imp).to.have.lengthOf(1);
+ // expect(ortbRequest.imp[0].ext).to.be.undefined;
+ });
+
+ it('Verify user level first party data', function () {
+ const bidderRequest = {
+ refererInfo: {
+ page: 'https://publisher.com/home',
+ ref: 'https://referrer'
+ },
+ gdprConsent: {
+ gdprApplies: true,
+ consentString: 'serialized_gpdr_data'
+ },
+ ortb2: {
+ user: {
+ yob: 1985,
+ gender: 'm',
+ ext: {
+ data: {
+ registered: true,
+ interests: ['cars']
+ }
+ }
+ }
+ }
+ };
+ let request = spec.buildRequests(slotConfigs, syncAddFPDToBidderRequest(bidderRequest));
+ let ortbRequest = request.data;
+ expect(ortbRequest).to.not.equal(null);
+ expect(ortbRequest.user).to.not.equal(null);
+ });
+
+ it('Verify site level first party data', function () {
+ const bidderRequest = {
+ ortb2: {
+ site: {
+ content: {
+ data: [{
+ name: 'www.iris.com',
+ ext: {
+ segtax: 500,
+ cids: ['iris_c73g5jq96mwso4d8']
+ }
+ }]
+ },
+ page: 'http://pub.com/news',
+ ref: 'http://google.com',
+ publisher: {
+ domain: 'pub.com'
+ }
+ }
+ }
+ };
+ let request = spec.buildRequests(slotConfigs, syncAddFPDToBidderRequest(bidderRequest));
+ let ortbRequest = request.data;
+ expect(ortbRequest).to.not.equal(null);
+ expect(ortbRequest.site).to.not.equal(null);
+ expect(ortbRequest.site).to.deep.equal({
+ content: {
+ data: [{
+ name: 'www.iris.com',
+ ext: {
+ segtax: 500,
+ cids: ['iris_c73g5jq96mwso4d8']
+ }
+ }]
+ },
+ page: 'http://pub.com/news',
+ ref: 'http://google.com',
+ publisher: {
+ // id: 'p10000',
+ domain: 'pub.com'
+ }
+ });
+ });
+
+ it('Verify impression/slot level first party data', function () {
+ const bidderRequests = [{
+ placementCode: '/DfpAccount1/slot1',
+ mediaTypes: {
+ banner: {
+ sizes: [[1, 1]]
+ }
+ },
+ bidId: 'bid12345',
+ params: {
+ cp: 'p10000',
+ ct: 't10000',
+ adzoneid: '77',
+ extra_key1: 'extra_val1',
+ extra_key2: 12345
+ },
+ ortb2Imp: {
+ ext: {
+ data: {
+ pbadslot: 'homepage-top-rect',
+ adUnitSpecificAttribute: '123'
+ }
+ }
+ }
+ }];
+ let request = spec.buildRequests(bidderRequests, bidderRequest);
+ let ortbRequest = request.data;
+ expect(ortbRequest).to.not.equal(null);
+ expect(ortbRequest.imp).to.not.equal(null);
+ expect(ortbRequest.imp).to.have.lengthOf(1);
+ expect(ortbRequest.imp[0].ext).to.not.equal(null);
+ expect(ortbRequest.imp[0].ext).to.deep.equal({
+ prebid: {
+ adzoneid: '77',
+ extra_key1: 'extra_val1',
+ extra_key2: 12345
+ },
+ data: {
+ pbadslot: 'homepage-top-rect',
+ adUnitSpecificAttribute: '123'
+ }
+ });
+ });
+
+ it('Verify bid request timeouts', function () {
+ const mkRequest = (bidderRequest) => spec.buildRequests(slotConfigs, bidderRequest).data;
+ // assert default is used when no bidderRequest.timeout value is available
+ expect(mkRequest(bidderRequest).tmax).to.equal(500)
+
+ // assert bidderRequest value is used when available
+ expect(mkRequest(Object.assign({}, { timeout: 6000 }, bidderRequest)).tmax).to.equal(6000)
+ });
});
diff --git a/test/spec/modules/agmaAnalyticsAdapter_spec.js b/test/spec/modules/agmaAnalyticsAdapter_spec.js
new file mode 100644
index 00000000000..ba71624e3b3
--- /dev/null
+++ b/test/spec/modules/agmaAnalyticsAdapter_spec.js
@@ -0,0 +1,388 @@
+import adapterManager from '../../../src/adapterManager.js';
+import agmaAnalyticsAdapter, {
+ getTiming,
+ getOrtb2Data,
+ getPayload,
+} from '../../../modules/agmaAnalyticsAdapter.js';
+import { gdprDataHandler } from '../../../src/adapterManager.js';
+import { expect } from 'chai';
+import * as events from '../../../src/events.js';
+import constants from '../../../src/constants.json';
+import { generateUUID } from '../../../src/utils.js';
+import { server } from '../../mocks/xhr.js';
+import { config } from 'src/config.js';
+
+const INGEST_URL = 'https://pbc.agma-analytics.de/v1';
+const extendedKey = [
+ 'auctionIds',
+ 'code',
+ 'domain',
+ 'extended',
+ 'gdprApplies',
+ 'gdprConsentString',
+ 'language',
+ 'ortb2',
+ 'pageUrl',
+ 'pageViewId',
+ 'prebidVersion',
+ 'referrer',
+ 'screenHeight',
+ 'screenWidth',
+ 'scriptVersion',
+ 'timestamp',
+ 'timezoneOffset',
+ 'timing',
+ 'triggerEvent',
+ 'userIdsAsEids',
+];
+const nonExtendedKey = [
+ 'auctionIds',
+ 'code',
+ 'domain',
+ 'gdprApplies',
+ 'ortb2',
+ 'pageUrl',
+ 'pageViewId',
+ 'prebidVersion',
+ 'scriptVersion',
+ 'timing',
+ 'triggerEvent',
+];
+
+describe('AGMA Analytics Adapter', () => {
+ let agmaConfig, sandbox, clock;
+
+ beforeEach(() => {
+ sandbox = sinon.sandbox.create();
+ clock = sandbox.useFakeTimers();
+ sandbox.stub(events, 'getEvents').returns([]);
+ agmaConfig = {
+ options: {
+ code: 'test',
+ },
+ };
+ });
+
+ afterEach(() => {
+ sandbox.restore();
+ });
+
+ describe('configuration', () => {
+ it('registers itself with the adapter manager', () => {
+ const adapter = adapterManager.getAnalyticsAdapter('agma');
+ expect(adapter).to.exist;
+ expect(adapter.gvlid).to.equal(1122);
+ });
+ });
+
+ describe('getPayload', () => {
+ it('should use non extended payload with no consent info', () => {
+ sandbox.stub(gdprDataHandler, 'getConsentData').callsFake(() => null)
+ const payload = getPayload([generateUUID()], {
+ code: 'test',
+ });
+
+ expect(payload).to.have.all.keys([...nonExtendedKey, 'debug']);
+ });
+
+ it('should use non extended payload when agma is not in the TC String', () => {
+ sandbox.stub(gdprDataHandler, 'getConsentData').callsFake(() => ({
+ vendorData: {
+ vendor: {
+ consents: {
+ 1122: false,
+ },
+ },
+ },
+ }));
+ const payload = getPayload([generateUUID()], {
+ code: 'test',
+ });
+ expect(payload).to.have.all.keys([...nonExtendedKey, 'debug']);
+ });
+
+ it('should use extended payload when agma is in the TC String', () => {
+ sandbox.stub(gdprDataHandler, 'getConsentData').callsFake(() => ({
+ vendorData: {
+ vendor: {
+ consents: {
+ 1122: true,
+ },
+ },
+ },
+ }));
+ const payload = getPayload([generateUUID()], {
+ code: 'test',
+ });
+ expect(payload).to.have.all.keys([...extendedKey, 'debug']);
+ });
+ });
+
+ describe('getTiming', () => {
+ let originalPerformance;
+ let originalWindowPerformanceNow;
+
+ beforeEach(() => {
+ originalPerformance = global.performance;
+ originalWindowPerformanceNow = window.performance.now;
+ });
+
+ afterEach(() => {
+ global.performance = originalPerformance;
+ window.performance.now = originalWindowPerformanceNow;
+ });
+
+ it('returns TTFB using Timing API V2', () => {
+ global.performance = {
+ getEntriesByType: sinon
+ .stub()
+ .returns([{ responseStart: 100, startTime: 50 }]),
+ now: sinon.stub().returns(150),
+ };
+
+ const result = getTiming();
+
+ expect(result).to.deep.equal({ ttfb: 50, elapsedTime: 150 });
+ });
+
+ it('returns TTFB using Timing API V1 when V2 is not available', () => {
+ global.performance = {
+ getEntriesByType: sinon.stub().throws(),
+ timing: { responseStart: 150, fetchStart: 50 },
+ now: sinon.stub().returns(200),
+ };
+
+ const result = getTiming();
+
+ expect(result).to.deep.equal({ ttfb: 100, elapsedTime: 200 });
+ });
+
+ it('returns null when Timing API is not available', () => {
+ global.performance = {
+ getEntriesByType: sinon.stub().throws(),
+ timing: undefined,
+ };
+
+ const result = getTiming();
+
+ expect(result).to.be.null;
+ });
+
+ it('returns ttfb as 0 if calculated value is negative', () => {
+ global.performance = {
+ getEntriesByType: sinon
+ .stub()
+ .returns([{ responseStart: 50, startTime: 150 }]),
+ now: sinon.stub().returns(200),
+ };
+
+ const result = getTiming();
+
+ expect(result).to.deep.equal({ ttfb: 0, elapsedTime: 200 });
+ });
+
+ it('returns ttfb as 0 if calculated value exceeds performance.now()', () => {
+ global.performance = {
+ getEntriesByType: sinon
+ .stub()
+ .returns([{ responseStart: 50, startTime: 0 }]),
+ now: sinon.stub().returns(40),
+ };
+
+ const result = getTiming();
+
+ expect(result).to.deep.equal({ ttfb: 0, elapsedTime: 40 });
+ });
+ });
+
+ describe('getOrtb2Data', () => {
+ it('returns site and user from options when available', () => {
+ sandbox.stub(config, 'getConfig').callsFake((key) => {
+ return {};
+ });
+
+ const ortb2 = {
+ user: 'user',
+ site: 'site',
+ };
+
+ const result = getOrtb2Data({
+ ortb2,
+ });
+
+ expect(result).to.deep.equal(ortb2);
+ });
+
+ it('returns a combination of data from options and pGlobal.readConfig', () => {
+ sandbox.stub(config, 'getConfig').callsFake((key) => {
+ return {
+ ortb2: {
+ site: {
+ foo: 'bar',
+ },
+ },
+ };
+ });
+
+ const ortb2 = {
+ user: 'user',
+ };
+ const result = getOrtb2Data({
+ ortb2,
+ });
+
+ expect(result).to.deep.equal({
+ site: {
+ foo: 'bar',
+ },
+ user: 'user',
+ });
+ });
+ });
+
+ describe('Event Payload', () => {
+ beforeEach(() => {
+ agmaAnalyticsAdapter.enableAnalytics({
+ ...agmaConfig,
+ });
+ server.respondWith('POST', INGEST_URL, [
+ 200,
+ {
+ 'Content-Type': 'application/json',
+ 'Access-Control-Allow-Origin': '*',
+ },
+ '',
+ ]);
+ });
+
+ afterEach(() => {
+ agmaAnalyticsAdapter.auctionIds = [];
+ if (agmaAnalyticsAdapter.timer) {
+ clearTimeout(agmaAnalyticsAdapter.timer);
+ }
+ agmaAnalyticsAdapter.disableAnalytics();
+ });
+
+ it('should only send once per minute', () => {
+ sandbox.stub(gdprDataHandler, 'getConsentData').callsFake(() => ({
+ gdprApplies: true,
+ consentString: 'consentDataString',
+ vendorData: {
+ vendor: {
+ consents: {
+ 1122: true,
+ },
+ },
+ },
+ }));
+ const auction = {
+ auctionId: generateUUID(),
+ };
+
+ events.emit(constants.EVENTS.AUCTION_INIT, {
+ auctionId: generateUUID('1'),
+ auction,
+ });
+
+ clock.tick(200);
+
+ events.emit(constants.EVENTS.AUCTION_INIT, {
+ auctionId: generateUUID('2'),
+ auction,
+ });
+ events.emit(constants.EVENTS.AUCTION_INIT, {
+ auctionId: generateUUID('3'),
+ auction,
+ });
+ events.emit(constants.EVENTS.AUCTION_INIT, {
+ auctionId: generateUUID('4'),
+ auction,
+ });
+
+ clock.tick(900);
+
+ const [request] = server.requests;
+ const requestBody = JSON.parse(request.requestBody);
+ expect(request.url).to.equal(INGEST_URL);
+ expect(requestBody).to.have.all.keys(extendedKey);
+ expect(requestBody.triggerEvent).to.equal(constants.EVENTS.AUCTION_INIT);
+ expect(server.requests).to.have.length(1);
+ });
+
+ it('should send the extended payload with consent', () => {
+ sandbox.stub(gdprDataHandler, 'getConsentData').callsFake(() => ({
+ gdprApplies: true,
+ consentString: 'consentDataString',
+ vendorData: {
+ vendor: {
+ consents: {
+ 1122: true,
+ },
+ },
+ },
+ }));
+ const auction = {
+ auctionId: generateUUID(),
+ };
+
+ events.emit(constants.EVENTS.AUCTION_INIT, auction);
+ clock.tick(1100);
+
+ const [request] = server.requests;
+ const requestBody = JSON.parse(request.requestBody);
+ expect(request.url).to.equal(INGEST_URL);
+ expect(requestBody).to.have.all.keys(extendedKey);
+ expect(requestBody.triggerEvent).to.equal(constants.EVENTS.AUCTION_INIT);
+ expect(server.requests).to.have.length(1);
+ expect(agmaAnalyticsAdapter.auctionIds).to.have.length(0);
+ });
+
+ it('should send the non extended payload with no explicit consent', () => {
+ sandbox.stub(gdprDataHandler, 'getConsentData').callsFake(() => ({
+ gdprApplies: true,
+ consentString: 'consentDataString',
+ }));
+
+ const auction = {
+ auctionId: generateUUID(),
+ };
+
+ events.emit(constants.EVENTS.AUCTION_INIT, auction);
+ clock.tick(1000);
+
+ const [request] = server.requests;
+ const requestBody = JSON.parse(request.requestBody);
+ expect(request.url).to.equal(INGEST_URL);
+ expect(requestBody.triggerEvent).to.equal(constants.EVENTS.AUCTION_INIT);
+ expect(server.requests).to.have.length(1);
+ expect(agmaAnalyticsAdapter.auctionIds).to.have.length(0);
+ });
+
+ it('should set the trigger Event', () => {
+ sandbox.stub(gdprDataHandler, 'getConsentData').callsFake(() => null);
+ agmaAnalyticsAdapter.disableAnalytics();
+ agmaAnalyticsAdapter.enableAnalytics({
+ provider: 'agma',
+ options: {
+ code: 'test',
+ triggerEvent: constants.EVENTS.AUCTION_END
+ },
+ });
+ const auction = {
+ auctionId: generateUUID(),
+ };
+
+ events.emit(constants.EVENTS.AUCTION_INIT, auction);
+ events.emit(constants.EVENTS.AUCTION_END, auction);
+ clock.tick(1000);
+
+ const [request] = server.requests;
+ const requestBody = JSON.parse(request.requestBody);
+ expect(request.url).to.equal(INGEST_URL);
+ expect(requestBody.auctionIds).to.have.length(1);
+ expect(requestBody.triggerEvent).to.equal(constants.EVENTS.AUCTION_END);
+ expect(server.requests).to.have.length(1);
+ expect(agmaAnalyticsAdapter.auctionIds).to.have.length(0);
+ });
+ });
+});
diff --git a/test/spec/modules/asteriobidAnalyticsAdapter_spec.js b/test/spec/modules/asteriobidAnalyticsAdapter_spec.js
new file mode 100644
index 00000000000..9be6c1dedac
--- /dev/null
+++ b/test/spec/modules/asteriobidAnalyticsAdapter_spec.js
@@ -0,0 +1,151 @@
+import asteriobidAnalytics, {storage} from 'modules/asteriobidAnalyticsAdapter.js';
+import {expect} from 'chai';
+import {server} from 'test/mocks/xhr.js';
+import * as utils from 'src/utils.js';
+import {expectEvents} from '../../helpers/analytics.js';
+
+let events = require('src/events');
+let constants = require('src/constants.json');
+
+describe('AsterioBid Analytics Adapter', function () {
+ let bidWonEvent = {
+ 'bidderCode': 'appnexus',
+ 'width': 300,
+ 'height': 250,
+ 'adId': '1ebb82ec35375e',
+ 'mediaType': 'banner',
+ 'cpm': 0.5,
+ 'requestId': '1582271863760569973',
+ 'creative_id': '96846035',
+ 'creativeId': '96846035',
+ 'ttl': 60,
+ 'currency': 'USD',
+ 'netRevenue': true,
+ 'auctionId': '9c7b70b9-b6ab-4439-9e71-b7b382797c18',
+ 'responseTimestamp': 1537521629657,
+ 'requestTimestamp': 1537521629331,
+ 'bidder': 'appnexus',
+ 'adUnitCode': 'div-gpt-ad-1460505748561-0',
+ 'timeToRespond': 326,
+ 'size': '300x250',
+ 'status': 'rendered',
+ 'eventType': 'bidWon',
+ 'ad': 'some ad',
+ 'adUrl': 'ad url'
+ };
+
+ describe('AsterioBid Analytic tests', function () {
+ beforeEach(function () {
+ sinon.stub(events, 'getEvents').returns([]);
+ });
+
+ afterEach(function () {
+ asteriobidAnalytics.disableAnalytics();
+ events.getEvents.restore();
+ });
+
+ it('support custom endpoint', function () {
+ let custom_url = 'custom url';
+ asteriobidAnalytics.enableAnalytics({
+ provider: 'asteriobid',
+ options: {
+ url: custom_url,
+ bundleId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
+ }
+ });
+
+ expect(asteriobidAnalytics.getOptions().url).to.equal(custom_url);
+ });
+
+ it('bid won event', function() {
+ let bundleId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
+ asteriobidAnalytics.enableAnalytics({
+ provider: 'asteriobid',
+ options: {
+ bundleId: bundleId
+ }
+ });
+
+ events.emit(constants.EVENTS.BID_WON, bidWonEvent);
+ asteriobidAnalytics.flush();
+
+ expect(server.requests.length).to.equal(1);
+ expect(server.requests[0].url).to.equal('https://endpt.asteriobid.com/endpoint');
+ expect(server.requests[0].requestBody.substring(0, 2)).to.equal('1:');
+
+ const pmEvents = JSON.parse(server.requests[0].requestBody.substring(2));
+ expect(pmEvents.pageViewId).to.exist;
+ expect(pmEvents.bundleId).to.equal(bundleId);
+ expect(pmEvents.ver).to.equal(1);
+ expect(pmEvents.events.length).to.equal(1);
+ expect(pmEvents.events[0].eventType).to.equal('bidWon');
+ expect(pmEvents.events[0].ad).to.be.undefined;
+ expect(pmEvents.events[0].adUrl).to.be.undefined;
+ });
+
+ it('track event without errors', function () {
+ sinon.spy(asteriobidAnalytics, 'track');
+
+ asteriobidAnalytics.enableAnalytics({
+ provider: 'asteriobid',
+ options: {
+ bundleId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
+ }
+ });
+
+ expectEvents().to.beTrackedBy(asteriobidAnalytics.track);
+ });
+ });
+
+ describe('build utm tag data', function () {
+ let getDataFromLocalStorageStub;
+ this.timeout(4000)
+ beforeEach(function () {
+ getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage');
+ getDataFromLocalStorageStub.withArgs('pm_utm_source').returns('utm_source');
+ getDataFromLocalStorageStub.withArgs('pm_utm_medium').returns('utm_medium');
+ getDataFromLocalStorageStub.withArgs('pm_utm_campaign').returns('utm_camp');
+ getDataFromLocalStorageStub.withArgs('pm_utm_term').returns('');
+ getDataFromLocalStorageStub.withArgs('pm_utm_content').returns('');
+ });
+ afterEach(function () {
+ getDataFromLocalStorageStub.restore();
+ asteriobidAnalytics.disableAnalytics()
+ });
+ it('should build utm data from local storage', function () {
+ asteriobidAnalytics.enableAnalytics({
+ provider: 'asteriobid',
+ options: {
+ bundleId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
+ }
+ });
+
+ const pmEvents = JSON.parse(server.requests[0].requestBody.substring(2));
+
+ expect(pmEvents.utmTags.utm_source).to.equal('utm_source');
+ expect(pmEvents.utmTags.utm_medium).to.equal('utm_medium');
+ expect(pmEvents.utmTags.utm_campaign).to.equal('utm_camp');
+ expect(pmEvents.utmTags.utm_term).to.equal('');
+ expect(pmEvents.utmTags.utm_content).to.equal('');
+ });
+ });
+
+ describe('build page info', function () {
+ afterEach(function () {
+ asteriobidAnalytics.disableAnalytics()
+ });
+ it('should build page info', function () {
+ asteriobidAnalytics.enableAnalytics({
+ provider: 'asteriobid',
+ options: {
+ bundleId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
+ }
+ });
+
+ const pmEvents = JSON.parse(server.requests[0].requestBody.substring(2));
+
+ expect(pmEvents.pageInfo.domain).to.equal(window.location.hostname);
+ expect(pmEvents.pageInfo.referrerDomain).to.equal(utils.parseUrl(document.referrer).hostname);
+ });
+ });
+});
diff --git a/test/spec/modules/bliinkBidAdapter_spec.js b/test/spec/modules/bliinkBidAdapter_spec.js
index cd1dcf4a20a..3db97a17d88 100644
--- a/test/spec/modules/bliinkBidAdapter_spec.js
+++ b/test/spec/modules/bliinkBidAdapter_spec.js
@@ -8,6 +8,7 @@ import {
getEffectiveConnectionType,
getUserIds,
getDomLoadingDuration,
+ GVL_ID,
} from 'modules/bliinkBidAdapter.js';
import { config } from 'src/config.js';
@@ -1168,3 +1169,7 @@ describe('getEffectiveConnectionType', () => {
});
}
});
+
+it('should expose gvlid', function () {
+ expect(spec.gvlid).to.equal(GVL_ID);
+});
diff --git a/test/spec/modules/boldwinBidAdapter_spec.js b/test/spec/modules/boldwinBidAdapter_spec.js
index 52a6ec03757..9a7b16c0914 100644
--- a/test/spec/modules/boldwinBidAdapter_spec.js
+++ b/test/spec/modules/boldwinBidAdapter_spec.js
@@ -314,7 +314,7 @@ describe('BoldwinBidAdapter', function () {
expect(userSync[0].type).to.exist;
expect(userSync[0].url).to.exist;
expect(userSync[0].type).to.be.equal('image');
- expect(userSync[0].url).to.be.equal('https://cs.videowalldirect.com');
+ expect(userSync[0].url).to.be.equal('https://sync.videowalldirect.com');
});
});
});
diff --git a/test/spec/modules/concertBidAdapter_spec.js b/test/spec/modules/concertBidAdapter_spec.js
index 40294deb26d..0a76ed3e62d 100644
--- a/test/spec/modules/concertBidAdapter_spec.js
+++ b/test/spec/modules/concertBidAdapter_spec.js
@@ -94,7 +94,7 @@ describe('ConcertAdapter', function () {
});
describe('spec.isBidRequestValid', function() {
- it('should return when it recieved all the required params', function() {
+ it('should return when it received all the required params', function() {
const bid = bidRequests[0];
expect(spec.isBidRequestValid(bid)).to.equal(true);
});
diff --git a/test/spec/modules/connatixBidAdapter_spec.js b/test/spec/modules/connatixBidAdapter_spec.js
index 16ead9f9458..78f6a9d410d 100644
--- a/test/spec/modules/connatixBidAdapter_spec.js
+++ b/test/spec/modules/connatixBidAdapter_spec.js
@@ -135,14 +135,12 @@ describe('connatixBidAdapter', function () {
describe('interpretResponse', function () {
const CustomerId = '99f20d18-c4b4-4a28-3d8e-d43e2c8cb4ac';
const PlayerId = 'e4984e88-9ff4-45a3-8b9d-33aabcad634f';
- const Bid = {Cpm: 0.1, LineItems: [], RequestId: '2f897340c4eaa3', Ttl: 86400};
+ const Bid = {Cpm: 0.1, RequestId: '2f897340c4eaa3', Ttl: 86400, CustomerId, PlayerId};
let serverResponse;
this.beforeEach(function () {
serverResponse = {
body: {
- CustomerId,
- PlayerId,
Bids: [ Bid ]
},
headers: function() { }
@@ -162,18 +160,6 @@ describe('connatixBidAdapter', function () {
expect(response).to.be.an('array').that.is.empty;
});
- it('Should return an empty array if CustomerId is null', function () {
- serverResponse.body.CustomerId = null;
- const response = spec.interpretResponse(serverResponse);
- expect(response).to.be.an('array').that.is.empty;
- });
-
- it('Should return an empty array if PlayerId is null', function () {
- serverResponse.body.PlayerId = null;
- const response = spec.interpretResponse(serverResponse);
- expect(response).to.be.an('array').that.is.empty;
- });
-
it('Should return one bid response for one bid', function() {
const bidResponses = spec.interpretResponse(serverResponse);
expect(bidResponses.length).to.equal(1);
@@ -212,12 +198,10 @@ describe('connatixBidAdapter', function () {
const CustomerId = '99f20d18-c4b4-4a28-3d8e-d43e2c8cb4ac';
const PlayerId = 'e4984e88-9ff4-45a3-8b9d-33aabcad634f';
const UserSyncEndpoint = 'https://connatix.com/sync'
- const Bid = {Cpm: 0.1, LineItems: [], RequestId: '2f897340c4eaa3', Ttl: 86400};
+ const Bid = {Cpm: 0.1, RequestId: '2f897340c4eaa3', Ttl: 86400, CustomerId, PlayerId};
const serverResponse = {
body: {
- CustomerId,
- PlayerId,
UserSyncEndpoint,
Bids: [ Bid ]
},
diff --git a/test/spec/modules/connectIdSystem_spec.js b/test/spec/modules/connectIdSystem_spec.js
index 5376ba60886..686c3d63a63 100644
--- a/test/spec/modules/connectIdSystem_spec.js
+++ b/test/spec/modules/connectIdSystem_spec.js
@@ -3,6 +3,7 @@ import {connectIdSubmodule, storage} from 'modules/connectIdSystem.js';
import {server} from '../../mocks/xhr';
import {parseQS, parseUrl} from 'src/utils.js';
import {uspDataHandler, gppDataHandler} from 'src/adapterManager.js';
+import * as refererDetection from '../../../src/refererDetection';
const TEST_SERVER_URL = 'http://localhost:9876/';
@@ -288,6 +289,79 @@ describe('Yahoo ConnectID Submodule', () => {
expect(setCookieStub.firstCall.args[2]).to.equal(expiryDelta.toUTCString());
});
+ it('returns an object with the stored ID from cookies and syncs because of expired TTL', () => {
+ const last2Days = Date.now() - (60 * 60 * 24 * 1000 * 2);
+ const last21Days = Date.now() - (60 * 60 * 24 * 1000 * 21);
+ const ttl = 10000;
+ const cookieData = {connectId: 'foo', he: 'email', lastSynced: last2Days, puid: '9', lastUsed: last21Days, ttl};
+ getCookieStub.withArgs(STORAGE_KEY).returns(JSON.stringify(cookieData));
+
+ let result = invokeGetIdAPI({
+ he: HASHED_EMAIL,
+ pixelId: PIXEL_ID
+ }, consentData);
+
+ expect(result).to.be.an('object').that.has.all.keys('id', 'callback');
+ expect(result.id).to.deep.equal(cookieData);
+ expect(typeof result.callback).to.equal('function');
+ });
+
+ it('returns an object with the stored ID from cookies and not syncs because of valid TTL', () => {
+ const last2Days = Date.now() - (60 * 60 * 24 * 1000 * 2);
+ const last21Days = Date.now() - (60 * 60 * 24 * 1000 * 21);
+ const ttl = 60 * 60 * 24 * 1000 * 3;
+ const cookieData = {connectId: 'foo', he: HASHED_EMAIL, lastSynced: last2Days, puid: '9', lastUsed: last21Days, ttl};
+ getCookieStub.withArgs(STORAGE_KEY).returns(JSON.stringify(cookieData));
+
+ let result = invokeGetIdAPI({
+ he: HASHED_EMAIL,
+ pixelId: PIXEL_ID
+ }, consentData);
+
+ expect(result).to.be.an('object').that.has.all.keys('id');
+ cookieData.lastUsed = result.id.lastUsed;
+ expect(result.id).to.deep.equal(cookieData);
+ });
+
+ it('returns an object with the stored ID from cookies and not syncs because of valid TTL with provided puid', () => {
+ const last2Days = Date.now() - (60 * 60 * 24 * 1000 * 2);
+ const last21Days = Date.now() - (60 * 60 * 24 * 1000 * 21);
+ const ttl = 60 * 60 * 24 * 1000 * 3;
+ const cookieData = {connectId: 'foo', he: HASHED_EMAIL, lastSynced: last2Days, puid: '9', lastUsed: last21Days, ttl};
+ getCookieStub.withArgs(STORAGE_KEY).returns(JSON.stringify(cookieData));
+
+ let result = invokeGetIdAPI({
+ he: HASHED_EMAIL,
+ pixelId: PIXEL_ID,
+ puid: '9'
+ }, consentData);
+
+ expect(result).to.be.an('object').that.has.all.keys('id');
+ cookieData.lastUsed = result.id.lastUsed;
+ expect(result.id).to.deep.equal(cookieData);
+ });
+
+ it('returns an object with the stored ID from cookies and syncs because is O&O traffic', () => {
+ const last2Days = Date.now() - (60 * 60 * 24 * 1000 * 2);
+ const last21Days = Date.now() - (60 * 60 * 24 * 1000 * 21);
+ const ttl = 60 * 60 * 24 * 1000 * 3;
+ const cookieData = {connectId: 'foo', he: HASHED_EMAIL, lastSynced: last2Days, puid: '9', lastUsed: last21Days, ttl};
+ getCookieStub.withArgs(STORAGE_KEY).returns(JSON.stringify(cookieData));
+ const getRefererInfoStub = sinon.stub(refererDetection, 'getRefererInfo');
+ getRefererInfoStub.returns({
+ ref: 'https://dev.fc.yahoo.com?test'
+ });
+ let result = invokeGetIdAPI({
+ he: HASHED_EMAIL,
+ pixelId: PIXEL_ID
+ }, consentData);
+ getRefererInfoStub.restore();
+
+ expect(result).to.be.an('object').that.has.all.keys('id', 'callback');
+ expect(result.id).to.deep.equal(cookieData);
+ expect(typeof result.callback).to.equal('function');
+ });
+
it('Makes an ajax GET request to the production API endpoint with stored puid when id is stale', () => {
const last15Days = Date.now() - (60 * 60 * 24 * 1000 * 15);
const last29Days = Date.now() - (60 * 60 * 24 * 1000 * 29);
diff --git a/test/spec/modules/consumableBidAdapter_spec.js b/test/spec/modules/consumableBidAdapter_spec.js
index deeb8f7100d..d8e75454245 100644
--- a/test/spec/modules/consumableBidAdapter_spec.js
+++ b/test/spec/modules/consumableBidAdapter_spec.js
@@ -651,21 +651,30 @@ describe('Consumable BidAdapter', function () {
expect(opts[0].url).to.equal('https://sync.serverbid.com/ss/730181.html?gdpr=0&gdpr_consent=GDPR_CONSENT_STRING');
})
- it('should return a sync url if iframe syncs are enabled and GPP applies', function () {
+ it('should return a sync url if iframe syncs are enabled and has GPP consent with applicable sections', function () {
let gppConsent = {
applicableSections: [1, 2],
gppString: 'GPP_CONSENT_STRING'
}
- let opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], {}, {}, gppConsent);
+ let opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], {}, '', gppConsent);
expect(opts.length).to.equal(1);
- expect(opts[0].url).to.equal('https://sync.serverbid.com/ss/730181.html?gpp=GPP_CONSENT_STRING&gpp_sid=1,2');
+ expect(opts[0].url).to.equal('https://sync.serverbid.com/ss/730181.html?gpp=GPP_CONSENT_STRING&gpp_sid=1%2C2');
})
- it('should return a sync url if iframe syncs are enabled and USP applies', function () {
- let uspConsent = {
- consentString: 'USP_CONSENT_STRING',
+ it('should return a sync url if iframe syncs are enabled and has GPP consent without applicable sections', function () {
+ let gppConsent = {
+ applicableSections: [],
+ gppString: 'GPP_CONSENT_STRING'
}
+ let opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], {}, '', gppConsent);
+
+ expect(opts.length).to.equal(1);
+ expect(opts[0].url).to.equal('https://sync.serverbid.com/ss/730181.html?gpp=GPP_CONSENT_STRING');
+ })
+
+ it('should return a sync url if iframe syncs are enabled and USP applies', function () {
+ let uspConsent = 'USP_CONSENT_STRING';
let opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], {}, uspConsent);
expect(opts.length).to.equal(1);
@@ -677,9 +686,7 @@ describe('Consumable BidAdapter', function () {
consentString: 'GDPR_CONSENT_STRING',
gdprApplies: true,
}
- let uspConsent = {
- consentString: 'USP_CONSENT_STRING',
- }
+ let uspConsent = 'USP_CONSENT_STRING';
let opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], gdprConsent, uspConsent);
expect(opts.length).to.equal(1);
@@ -704,50 +711,22 @@ describe('Consumable BidAdapter', function () {
sandbox.restore();
});
- it('Request should have unifiedId config params', function() {
+ it('Request should have EIDs', function() {
bidderRequest.bidRequest[0].userId = {};
bidderRequest.bidRequest[0].userId.tdid = 'TTD_ID';
- bidderRequest.bidRequest[0].userIdAsEids = createEidsArray(bidderRequest.bidRequest[0].userId);
- let request = spec.buildRequests(bidderRequest.bidRequest, BIDDER_REQUEST_1);
- let data = JSON.parse(request.data);
- expect(data.user.eids).to.deep.equal([{
+ bidderRequest.bidRequest[0].userIdAsEids = [{
'source': 'adserver.org',
'uids': [{
- 'id': 'TTD_ID',
+ 'id': 'TTD_ID_FROM_USER_ID_MODULE',
'atype': 1,
'ext': {
'rtiPartner': 'TDID'
}
}]
- }]);
- });
-
- it('Request should have adsrvrOrgId from UserId Module if config and userId module both have TTD ID', function() {
- sandbox.stub(config, 'getConfig').callsFake((key) => {
- var config = {
- adsrvrOrgId: {
- 'TDID': 'TTD_ID_FROM_CONFIG',
- 'TDID_LOOKUP': 'TRUE',
- 'TDID_CREATED_AT': '2022-06-21T09:47:00'
- }
- };
- return config[key];
- });
- bidderRequest.bidRequest[0].userId = {};
- bidderRequest.bidRequest[0].userId.tdid = 'TTD_ID';
- bidderRequest.bidRequest[0].userIdAsEids = createEidsArray(bidderRequest.bidRequest[0].userId);
+ }];
let request = spec.buildRequests(bidderRequest.bidRequest, BIDDER_REQUEST_1);
let data = JSON.parse(request.data);
- expect(data.user.eids).to.deep.equal([{
- 'source': 'adserver.org',
- 'uids': [{
- 'id': 'TTD_ID',
- 'atype': 1,
- 'ext': {
- 'rtiPartner': 'TDID'
- }
- }]
- }]);
+ expect(data.user.eids).to.deep.equal(bidderRequest.bidRequest[0].userIdAsEids);
});
it('Request should NOT have adsrvrOrgId params if userId is NOT object', function() {
diff --git a/test/spec/modules/criteoBidAdapter_spec.js b/test/spec/modules/criteoBidAdapter_spec.js
index 7cba0e2fbdf..97b80ce95db 100755
--- a/test/spec/modules/criteoBidAdapter_spec.js
+++ b/test/spec/modules/criteoBidAdapter_spec.js
@@ -1326,12 +1326,25 @@ describe('The Criteo bidding adapter', function () {
sizes: [[640, 480]],
mediaTypes: {
video: {
+ context: 'instream',
playerSize: [640, 480],
mimes: ['video/mp4', 'video/x-flv'],
maxduration: 30,
api: [1, 2],
protocols: [2, 3],
- plcmt: 3
+ plcmt: 3,
+ w: 640,
+ h: 480,
+ linearity: 1,
+ skipmin: 30,
+ skipafter: 30,
+ minbitrate: 10000,
+ maxbitrate: 48000,
+ delivery: [1, 2, 3],
+ pos: 1,
+ playbackend: 1,
+ adPodDurationSec: 30,
+ durationRangeSec: [1, 30],
}
},
params: {
@@ -1350,6 +1363,7 @@ describe('The Criteo bidding adapter', function () {
expect(request.url).to.match(/^https:\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/);
expect(request.method).to.equal('POST');
const ortbRequest = request.data;
+ expect(ortbRequest.slots[0].video.context).to.equal('instream');
expect(ortbRequest.slots[0].video.mimes).to.deep.equal(['video/mp4', 'video/x-flv']);
expect(ortbRequest.slots[0].sizes).to.deep.equal([]);
expect(ortbRequest.slots[0].video.playersizes).to.deep.equal(['640x480']);
@@ -1362,6 +1376,18 @@ describe('The Criteo bidding adapter', function () {
expect(ortbRequest.slots[0].video.playbackmethod).to.deep.equal([1, 3]);
expect(ortbRequest.slots[0].video.placement).to.equal(2);
expect(ortbRequest.slots[0].video.plcmt).to.equal(3);
+ expect(ortbRequest.slots[0].video.w).to.equal(640);
+ expect(ortbRequest.slots[0].video.h).to.equal(480);
+ expect(ortbRequest.slots[0].video.linearity).to.equal(1);
+ expect(ortbRequest.slots[0].video.skipmin).to.equal(30);
+ expect(ortbRequest.slots[0].video.skipafter).to.equal(30);
+ expect(ortbRequest.slots[0].video.minbitrate).to.equal(10000);
+ expect(ortbRequest.slots[0].video.maxbitrate).to.equal(48000);
+ expect(ortbRequest.slots[0].video.delivery).to.deep.equal([1, 2, 3]);
+ expect(ortbRequest.slots[0].video.pos).to.equal(1);
+ expect(ortbRequest.slots[0].video.playbackend).to.equal(1);
+ expect(ortbRequest.slots[0].video.adPodDurationSec).to.equal(30);
+ expect(ortbRequest.slots[0].video.durationRangeSec).to.deep.equal([1, 30]);
});
it('should properly build a video request with more than one player size', function () {
@@ -1879,6 +1905,70 @@ describe('The Criteo bidding adapter', function () {
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.data.slots[0].rwdd).to.be.undefined;
});
+
+ it('should properly build a request when FLEDGE is enabled', function () {
+ const bidderRequest = {
+ fledgeEnabled: true,
+ };
+ const bidRequests = [
+ {
+ bidder: 'criteo',
+ adUnitCode: 'bid-123',
+ transactionId: 'transaction-123',
+ mediaTypes: {
+ banner: {
+ sizes: [[728, 90]]
+ }
+ },
+ params: {
+ zoneId: 123,
+ ext: {
+ bidfloor: 0.75
+ }
+ },
+ ortb2Imp: {
+ ext: {
+ ae: 1
+ }
+ }
+ },
+ ];
+
+ const request = spec.buildRequests(bidRequests, bidderRequest);
+ expect(request.data.slots[0].ext.ae).to.equal(1);
+ });
+
+ it('should properly build a request when FLEDGE is disabled', function () {
+ const bidderRequest = {
+ fledgeEnabled: false,
+ };
+ const bidRequests = [
+ {
+ bidder: 'criteo',
+ adUnitCode: 'bid-123',
+ transactionId: 'transaction-123',
+ mediaTypes: {
+ banner: {
+ sizes: [[728, 90]]
+ }
+ },
+ params: {
+ zoneId: 123,
+ ext: {
+ bidfloor: 0.75
+ }
+ },
+ ortb2Imp: {
+ ext: {
+ ae: 1
+ }
+ }
+ },
+ ];
+
+ const request = spec.buildRequests(bidRequests, bidderRequest);
+ expect(request.data.slots[0].ext).to.not.have.property('ae');
+ });
});
describe('interpretResponse', function () {
@@ -2410,6 +2500,87 @@ describe('The Criteo bidding adapter', function () {
expect(bids[0].height).to.equal(90);
});
+ it('should properly parse a bid response with FLEDGE auction configs', function () {
+ const response = {
+ body: {
+ ext: {
+ igbid: [{
+ impid: 'test-bidId',
+ igbuyer: [{
+ origin: 'https://first-buyer-domain.com',
+ buyerdata: {
+ foo: 'bar',
+ },
+ }, {
+ origin: 'https://second-buyer-domain.com',
+ buyerdata: {
+ foo: 'baz',
+ },
+ }]
+ }],
+ seller: 'https://seller-domain.com',
+ sellerTimeout: 500,
+ sellerSignals: {
+ foo: 'bar',
+ },
+ },
+ },
+ };
+ const bidderRequest = {
+ ortb2: {
+ source: {
+ tid: 'abc'
+ }
+ }
+ };
+ const bidRequests = [
+ {
+ bidId: 'test-bidId',
+ bidder: 'criteo',
+ adUnitCode: 'bid-123',
+ transactionId: 'transaction-123',
+ mediaTypes: {
+ banner: {
+ sizes: [[728, 90]]
+ }
+ },
+ params: {
+ bidFloor: 1,
+ bidFloorCur: 'EUR'
+ }
+ },
+ ];
+ const request = spec.buildRequests(bidRequests, bidderRequest);
+ const interpretedResponse = spec.interpretResponse(response, request);
+ expect(interpretedResponse).to.have.property('bids');
+ expect(interpretedResponse).to.have.property('fledgeAuctionConfigs');
+ expect(interpretedResponse.bids).to.have.lengthOf(0);
+ expect(interpretedResponse.fledgeAuctionConfigs).to.have.lengthOf(1);
+ expect(interpretedResponse.fledgeAuctionConfigs[0]).to.deep.equal({
+ bidId: 'test-bidId',
+ config: {
+ auctionSignals: {},
+ decisionLogicUrl: 'https://grid-mercury.criteo.com/fledge/decision',
+ interestGroupBuyers: ['https://first-buyer-domain.com', 'https://second-buyer-domain.com'],
+ perBuyerSignals: {
+ 'https://first-buyer-domain.com': {
+ foo: 'bar',
+ },
+ 'https://second-buyer-domain.com': {
+ foo: 'baz'
+ },
+ },
+ seller: 'https://seller-domain.com',
+ sellerTimeout: 500,
+ sellerSignals: {
+ foo: 'bar',
+ floor: 1,
+ sellerCurrency: 'EUR',
+ },
+ },
+ });
+ });
+
[{
hasBidResponseLevelPafData: true,
hasBidResponseBidLevelPafData: true,
diff --git a/test/spec/modules/criteoIdSystem_spec.js b/test/spec/modules/criteoIdSystem_spec.js
index aaf63873d93..975271738e5 100644
--- a/test/spec/modules/criteoIdSystem_spec.js
+++ b/test/spec/modules/criteoIdSystem_spec.js
@@ -52,17 +52,21 @@ describe('CriteoId module', function () {
});
const storageTestCases = [
- { cookie: 'bidId', localStorage: 'bidId2', expected: 'bidId' },
- { cookie: 'bidId', localStorage: undefined, expected: 'bidId' },
- { cookie: undefined, localStorage: 'bidId', expected: 'bidId' },
- { cookie: undefined, localStorage: undefined, expected: undefined },
+ { submoduleConfig: undefined, cookie: 'bidId', localStorage: 'bidId2', expected: 'bidId' },
+ { submoduleConfig: undefined, cookie: 'bidId', localStorage: undefined, expected: 'bidId' },
+ { submoduleConfig: undefined, cookie: undefined, localStorage: 'bidId', expected: 'bidId' },
+ { submoduleConfig: undefined, cookie: undefined, localStorage: undefined, expected: undefined },
+ { submoduleConfig: { storage: { type: 'cookie' } }, cookie: 'bidId', localStorage: 'bidId2', expected: 'bidId' },
+ { submoduleConfig: { storage: { type: 'cookie' } }, cookie: undefined, localStorage: 'bidId2', expected: undefined },
+ { submoduleConfig: { storage: { type: 'html5' } }, cookie: 'bidId', localStorage: 'bidId2', expected: 'bidId2' },
+ { submoduleConfig: { storage: { type: 'html5' } }, cookie: 'bidId', localStorage: undefined, expected: undefined },
]
- storageTestCases.forEach(testCase => it('getId() should return the bidId when it exists in local storages', function () {
+ storageTestCases.forEach(testCase => it('getId() should return the user id depending on the storage type enabled and the data available', function () {
getCookieStub.withArgs('cto_bidid').returns(testCase.cookie);
getLocalStorageStub.withArgs('cto_bidid').returns(testCase.localStorage);
- const result = criteoIdSubmodule.getId();
+ const result = criteoIdSubmodule.getId(testCase.submoduleConfig);
expect(result.id).to.be.deep.equal(testCase.expected ? { criteoId: testCase.expected } : undefined);
expect(result.callback).to.be.a('function');
}))
@@ -95,22 +99,24 @@ describe('CriteoId module', function () {
});
const responses = [
- { bundle: 'bundle', bidId: 'bidId', acwsUrl: 'acwsUrl' },
- { bundle: 'bundle', bidId: undefined, acwsUrl: 'acwsUrl' },
- { bundle: 'bundle', bidId: 'bidId', acwsUrl: undefined },
- { bundle: undefined, bidId: 'bidId', acwsUrl: 'acwsUrl' },
- { bundle: 'bundle', bidId: undefined, acwsUrl: undefined },
- { bundle: undefined, bidId: 'bidId', acwsUrl: undefined },
- { bundle: undefined, bidId: undefined, acwsUrl: 'acwsUrl' },
- { bundle: undefined, bidId: undefined, acwsUrl: ['acwsUrl', 'acwsUrl2'] },
- { bundle: undefined, bidId: undefined, acwsUrl: undefined },
+ { submoduleConfig: undefined, shouldWriteCookie: true, shouldWriteLocalStorage: true, bundle: 'bundle', bidId: 'bidId', acwsUrl: 'acwsUrl' },
+ { submoduleConfig: undefined, shouldWriteCookie: true, shouldWriteLocalStorage: true, bundle: 'bundle', bidId: undefined, acwsUrl: 'acwsUrl' },
+ { submoduleConfig: undefined, shouldWriteCookie: true, shouldWriteLocalStorage: true, bundle: 'bundle', bidId: 'bidId', acwsUrl: undefined },
+ { submoduleConfig: undefined, shouldWriteCookie: true, shouldWriteLocalStorage: true, bundle: undefined, bidId: 'bidId', acwsUrl: 'acwsUrl' },
+ { submoduleConfig: undefined, shouldWriteCookie: true, shouldWriteLocalStorage: true, bundle: 'bundle', bidId: undefined, acwsUrl: undefined },
+ { submoduleConfig: undefined, shouldWriteCookie: true, shouldWriteLocalStorage: true, bundle: undefined, bidId: 'bidId', acwsUrl: undefined },
+ { submoduleConfig: undefined, shouldWriteCookie: true, shouldWriteLocalStorage: true, bundle: undefined, bidId: undefined, acwsUrl: 'acwsUrl' },
+ { submoduleConfig: undefined, shouldWriteCookie: true, shouldWriteLocalStorage: true, bundle: undefined, bidId: undefined, acwsUrl: ['acwsUrl', 'acwsUrl2'] },
+ { submoduleConfig: undefined, shouldWriteCookie: true, shouldWriteLocalStorage: true, bundle: undefined, bidId: undefined, acwsUrl: undefined },
+ { submoduleConfig: { storage: { type: 'cookie' } }, shouldWriteCookie: true, shouldWriteLocalStorage: false, bundle: 'bundle', bidId: 'bidId', acwsUrl: undefined },
+ { submoduleConfig: { storage: { type: 'html5' } }, shouldWriteCookie: false, shouldWriteLocalStorage: true, bundle: 'bundle', bidId: 'bidId', acwsUrl: undefined },
]
responses.forEach(response => describe('test user sync response behavior', function () {
const expirationTs = new Date(nowTimestamp + cookiesMaxAge).toString();
it('should save bidId if it exists', function () {
- const result = criteoIdSubmodule.getId();
+ const result = criteoIdSubmodule.getId(response.submoduleConfig);
result.callback((id) => {
expect(id).to.be.deep.equal(response.bidId ? { criteoId: response.bidId } : undefined);
});
@@ -127,16 +133,35 @@ describe('CriteoId module', function () {
expect(setCookieStub.calledWith('cto_bundle')).to.be.false;
expect(setLocalStorageStub.calledWith('cto_bundle')).to.be.false;
} else if (response.bundle) {
- expect(setCookieStub.calledWith('cto_bundle', response.bundle, expirationTs, null, '.com')).to.be.true;
- expect(setCookieStub.calledWith('cto_bundle', response.bundle, expirationTs, null, '.testdev.com')).to.be.true;
- expect(setLocalStorageStub.calledWith('cto_bundle', response.bundle)).to.be.true;
+ if (response.shouldWriteCookie) {
+ expect(setCookieStub.calledWith('cto_bundle', response.bundle, expirationTs, null, '.com')).to.be.true;
+ expect(setCookieStub.calledWith('cto_bundle', response.bundle, expirationTs, null, '.testdev.com')).to.be.true;
+ } else {
+ expect(setCookieStub.calledWith('cto_bundle', response.bundle, expirationTs, null, '.com')).to.be.false;
+ expect(setCookieStub.calledWith('cto_bundle', response.bundle, expirationTs, null, '.testdev.com')).to.be.false;
+ }
+
+ if (response.shouldWriteLocalStorage) {
+ expect(setLocalStorageStub.calledWith('cto_bundle', response.bundle)).to.be.true;
+ } else {
+ expect(setLocalStorageStub.calledWith('cto_bundle', response.bundle)).to.be.false;
+ }
expect(triggerPixelStub.called).to.be.false;
}
if (response.bidId) {
- expect(setCookieStub.calledWith('cto_bidid', response.bidId, expirationTs, null, '.com')).to.be.true;
- expect(setCookieStub.calledWith('cto_bidid', response.bidId, expirationTs, null, '.testdev.com')).to.be.true;
- expect(setLocalStorageStub.calledWith('cto_bidid', response.bidId)).to.be.true;
+ if (response.shouldWriteCookie) {
+ expect(setCookieStub.calledWith('cto_bidid', response.bidId, expirationTs, null, '.com')).to.be.true;
+ expect(setCookieStub.calledWith('cto_bidid', response.bidId, expirationTs, null, '.testdev.com')).to.be.true;
+ } else {
+ expect(setCookieStub.calledWith('cto_bidid', response.bidId, expirationTs, null, '.com')).to.be.false;
+ expect(setCookieStub.calledWith('cto_bidid', response.bidId, expirationTs, null, '.testdev.com')).to.be.false;
+ }
+ if (response.shouldWriteLocalStorage) {
+ expect(setLocalStorageStub.calledWith('cto_bidid', response.bidId)).to.be.true;
+ } else {
+ expect(setLocalStorageStub.calledWith('cto_bidid', response.bidId)).to.be.false;
+ }
} else {
expect(setCookieStub.calledWith('cto_bidid', '', pastDateString, null, '.com')).to.be.true;
expect(setCookieStub.calledWith('cto_bidid', '', pastDateString, null, '.testdev.com')).to.be.true;
diff --git a/test/spec/modules/currency_spec.js b/test/spec/modules/currency_spec.js
index ef80a17d2db..fa44b7daa7a 100644
--- a/test/spec/modules/currency_spec.js
+++ b/test/spec/modules/currency_spec.js
@@ -15,6 +15,7 @@ import {
import {createBid} from '../../../src/bidfactory.js';
import CONSTANTS from '../../../src/constants.json';
import {server} from '../../mocks/xhr.js';
+import * as events from 'src/events.js';
var assert = require('chai').assert;
var expect = require('chai').expect;
@@ -258,6 +259,19 @@ describe('currency', function () {
expect(innerBid.getCpmInNewCurrency('JPY')).to.equal('100.000');
});
+ it('does not block auctions if rates do not need to be fetched', () => {
+ sandbox.stub(responseReady, 'resolve');
+ setConfig({
+ adServerCurrency: 'USD',
+ rates: {
+ USD: {
+ JPY: 100
+ }
+ }
+ });
+ sinon.assert.called(responseReady.resolve);
+ })
+
it('uses rates specified in json when provided and consider boosted bid', function () {
setConfig({
adServerCurrency: 'USD',
@@ -286,32 +300,56 @@ describe('currency', function () {
expect(innerBid.getCpmInNewCurrency('JPY')).to.equal('1000.000');
});
- it('uses default rates when currency file fails to load', function () {
- setConfig({});
-
- setConfig({
- adServerCurrency: 'USD',
- defaultRates: {
- USD: {
- JPY: 100
+ describe('when rates fail to load', () => {
+ let bid, addBidResponse, reject;
+ beforeEach(() => {
+ bid = makeBid({cpm: 100, currency: 'JPY', bidder: 'rubicoin'});
+ addBidResponse = sinon.spy();
+ reject = sinon.spy();
+ })
+ it('uses default rates if specified', function () {
+ setConfig({
+ adServerCurrency: 'USD',
+ defaultRates: {
+ USD: {
+ JPY: 100
+ }
}
- }
- });
-
- // default response is 404
- fakeCurrencyFileServer.respond();
+ });
- var bid = { cpm: 100, currency: 'JPY', bidder: 'rubicon' };
- var innerBid;
+ // default response is 404
+ addBidResponseHook(addBidResponse, 'au', bid);
+ fakeCurrencyFileServer.respond();
+ sinon.assert.calledWith(addBidResponse, 'au', sinon.match(innerBid => {
+ expect(innerBid.cpm).to.equal('1.0000');
+ expect(typeof innerBid.getCpmInNewCurrency).to.equal('function');
+ expect(innerBid.getCpmInNewCurrency('JPY')).to.equal('100.000');
+ return true;
+ }));
+ });
- addBidResponseHook(function(adCodeId, bid) {
- innerBid = bid;
- }, 'elementId', bid);
+ it('rejects bids if no default rates are specified', () => {
+ setConfig({
+ adServerCurrency: 'USD',
+ });
+ addBidResponseHook(addBidResponse, 'au', bid, reject);
+ fakeCurrencyFileServer.respond();
+ sinon.assert.notCalled(addBidResponse);
+ sinon.assert.calledWith(reject, CONSTANTS.REJECTION_REASON.CANNOT_CONVERT_CURRENCY);
+ });
- expect(innerBid.cpm).to.equal('1.0000');
- expect(typeof innerBid.getCpmInNewCurrency).to.equal('function');
- expect(innerBid.getCpmInNewCurrency('JPY')).to.equal('100.000');
- });
+ it('attempts to load rates again on the next auction', () => {
+ setConfig({
+ adServerCurrency: 'USD',
+ });
+ fakeCurrencyFileServer.respond();
+ fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
+ events.emit(CONSTANTS.EVENTS.AUCTION_INIT, {});
+ addBidResponseHook(addBidResponse, 'au', bid, reject);
+ fakeCurrencyFileServer.respond();
+ sinon.assert.calledWith(addBidResponse, 'au', bid, reject);
+ })
+ })
});
describe('currency.addBidResponseDecorator bidResponseQueue', function () {
@@ -415,6 +453,23 @@ describe('currency', function () {
expect(reject.calledOnce).to.be.true;
});
+ it('should reject bid when rates have not loaded when the auction times out', () => {
+ fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
+ setConfig({'adServerCurrency': 'JPY'});
+ const bid = makeBid({cpm: 1, currency: 'USD', auctionId: 'aid'});
+ const noConversionBid = makeBid({cpm: 1, currency: 'JPY', auctionId: 'aid'});
+ const reject = sinon.spy();
+ const addBidResponse = sinon.spy();
+ addBidResponseHook(addBidResponse, 'au', bid, reject);
+ addBidResponseHook(addBidResponse, 'au', noConversionBid, reject);
+ events.emit(CONSTANTS.EVENTS.AUCTION_TIMEOUT, {auctionId: 'aid'});
+ fakeCurrencyFileServer.respond();
+ sinon.assert.calledOnce(addBidResponse);
+ sinon.assert.calledWith(addBidResponse, 'au', noConversionBid, reject);
+ sinon.assert.calledOnce(reject);
+ sinon.assert.calledWith(reject, CONSTANTS.REJECTION_REASON.CANNOT_CONVERT_CURRENCY);
+ })
+
it('should return 1 when currency support is enabled and same currency code is requested as is set to adServerCurrency', function () {
fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
setConfig({ 'adServerCurrency': 'JPY' });
diff --git a/test/spec/modules/discoveryBidAdapter_spec.js b/test/spec/modules/discoveryBidAdapter_spec.js
index 078add73046..8957f8bbd40 100644
--- a/test/spec/modules/discoveryBidAdapter_spec.js
+++ b/test/spec/modules/discoveryBidAdapter_spec.js
@@ -11,12 +11,59 @@ describe('discovery:BidAdapterTests', function () {
bidder: 'discovery',
params: {
token: 'd0f4902b616cc5c38cbe0a08676d0ed9',
+ siteId: 'siteId_01',
+ zoneId: 'zoneId_01',
+ publisher: '52',
+ position: 'left',
+ referrer: 'https://discovery.popin.cc',
+ },
+ refererInfo: {
+ page: 'https://discovery.popin.cc',
+ stack: [
+ 'a.com',
+ 'b.com'
+ ]
},
mediaTypes: {
banner: {
sizes: [[300, 250]],
+ pos: 'left',
+ },
+ },
+ ortb2: {
+ user: {
+ ext: {
+ data: {
+ CxSegments: []
+ }
+ }
+ },
+ site: {
+ domain: 'discovery.popin.cc',
+ publisher: {
+ domain: 'discovery.popin.cc'
+ },
+ page: 'https://discovery.popin.cc',
+ cat: ['IAB-19', 'IAB-20'],
},
},
+ ortb2Imp: {
+ ext: {
+ gpid: 'adslot_gpid',
+ tid: 'tid_01',
+ data: {
+ browsi: {
+ browsiViewability: 'NA',
+ },
+ adserver: {
+ name: 'adserver_name',
+ adslot: 'adslot_name',
+ },
+ keywords: ['travel', 'sport'],
+ pbadslot: '202309999'
+ }
+ }
+ },
adUnitCode: 'regular_iframe',
transactionId: 'd163f9e2-7ecd-4c2c-a3bd-28ceb52a60ee',
sizes: [[300, 250]],
diff --git a/test/spec/modules/docereeAdManagerBidAdapter_spec.js b/test/spec/modules/docereeAdManagerBidAdapter_spec.js
new file mode 100644
index 00000000000..26b054f4e29
--- /dev/null
+++ b/test/spec/modules/docereeAdManagerBidAdapter_spec.js
@@ -0,0 +1,125 @@
+import { expect } from 'chai';
+import { spec } from '../../../modules/docereeAdManagerBidAdapter.js';
+import { config } from '../../../src/config.js';
+
+describe('docereeadmanager', function () {
+ config.setConfig({
+ docereeadmanager: {
+ user: {
+ data: {
+ email: '',
+ firstname: '',
+ lastname: '',
+ mobile: '',
+ specialization: '',
+ organization: '',
+ hcpid: '',
+ dob: '',
+ gender: '',
+ city: '',
+ state: '',
+ country: '',
+ hashedhcpid: '',
+ hashedemail: '',
+ hashedmobile: '',
+ userid: '',
+ zipcode: '',
+ userconsent: '',
+ },
+ },
+ },
+ });
+ let bid = {
+ bidId: 'testing',
+ bidder: 'docereeadmanager',
+ params: {
+ placementId: 'DOC-19-1',
+ gdpr: '1',
+ gdprconsent:
+ 'CPQfU1jPQfU1jG0AAAENAwCAAAAAAAAAAAAAAAAAAAAA.IGLtV_T9fb2vj-_Z99_tkeYwf95y3p-wzhheMs-8NyZeH_B4Wv2MyvBX4JiQKGRgksjLBAQdtHGlcTQgBwIlViTLMYk2MjzNKJrJEilsbO2dYGD9Pn8HT3ZCY70-vv__7v3ff_3g',
+ },
+ };
+
+ describe('isBidRequestValid', function () {
+ it('Should return true if placementId is present', function () {
+ expect(spec.isBidRequestValid(bid)).to.be.true;
+ });
+ it('Should return false if placementId is not present', function () {
+ delete bid.params.placementId;
+ expect(spec.isBidRequestValid(bid)).to.be.false;
+ });
+ });
+
+ describe('isGdprConsentPresent', function () {
+ it('Should return true if gdpr consent is present', function () {
+ expect(spec.isGdprConsentPresent(bid)).to.be.true;
+ });
+ });
+
+ describe('buildRequests', function () {
+ let serverRequest = spec.buildRequests([bid]);
+ serverRequest = serverRequest[0];
+ it('Creates a ServerRequest object with method, URL and data', function () {
+ expect(serverRequest).to.exist;
+ expect(serverRequest.method).to.exist;
+ expect(serverRequest.url).to.exist;
+ expect(serverRequest.data).to.exist;
+ });
+ it('Returns POST method', function () {
+ expect(serverRequest.method).to.equal('POST');
+ });
+ it('Returns valid URL', function () {
+ expect(serverRequest.url).to.equal('https://dai.doceree.com/drs/quest');
+ });
+ });
+ describe('interpretResponse', function () {
+ it('Should interpret banner response', function () {
+ const banner = {
+ body: {
+ cpm: 3.576,
+ currency: 'USD',
+ width: 250,
+ height: 300,
+ ad: 'I am an ad
',
+ ttl: 30,
+ creativeId: 'div-1',
+ netRevenue: false,
+ bidderCode: '123',
+ dealId: 232,
+ requestId: '123',
+ meta: {
+ brandId: null,
+ advertiserDomains: ['https://dai.doceree.com/drs/quest'],
+ },
+ },
+ };
+ let bannerResponses = spec.interpretResponse(banner);
+ expect(bannerResponses).to.be.an('array').that.is.not.empty;
+ let dataItem = bannerResponses[0];
+ expect(dataItem).to.have.all.keys(
+ 'requestId',
+ 'cpm',
+ 'width',
+ 'height',
+ 'ad',
+ 'ttl',
+ 'netRevenue',
+ 'currency',
+ 'mediaType',
+ 'creativeId',
+ 'meta'
+ );
+ expect(dataItem.requestId).to.equal('123');
+ expect(dataItem.cpm).to.equal(3.576);
+ expect(dataItem.width).to.equal(250);
+ expect(dataItem.height).to.equal(300);
+ expect(dataItem.ad).to.equal('I am an ad
');
+ expect(dataItem.ttl).to.equal(30);
+ expect(dataItem.netRevenue).to.be.true;
+ expect(dataItem.currency).to.equal('USD');
+ expect(dataItem.creativeId).to.equal('div-1');
+ expect(dataItem.meta.advertiserDomains).to.be.an('array').that.is.not
+ .empty;
+ });
+ });
+});
diff --git a/test/spec/modules/dxkultureBidAdapter_spec.js b/test/spec/modules/dxkultureBidAdapter_spec.js
index ec7f6f146a3..d3ae8ec5124 100644
--- a/test/spec/modules/dxkultureBidAdapter_spec.js
+++ b/test/spec/modules/dxkultureBidAdapter_spec.js
@@ -1,137 +1,198 @@
import {expect} from 'chai';
-import {spec} from 'modules/dxkultureBidAdapter.js';
-
-const BANNER_REQUEST = {
- 'bidderCode': 'dxkulture',
- 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708',
- 'bidderRequestId': 'requestId',
- 'bidRequest': [{
- 'bidder': 'dxkulture',
- 'params': {
- 'placementId': 123456,
- },
- 'placementCode': 'div-gpt-dummy-placement-code',
- 'mediaTypes': {'banner': {'sizes': [[300, 250]]}},
- 'bidId': 'bidId1',
- 'bidderRequestId': 'bidderRequestId',
- 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708'
- },
- {
- 'bidder': 'dxkulture',
- 'params': {
- 'placementId': 123456,
- },
- 'placementCode': 'div-gpt-dummy-placement-code',
- 'mediaTypes': {'banner': {'sizes': [[300, 250]]}},
- 'bidId': 'bidId2',
- 'bidderRequestId': 'bidderRequestId',
- 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708'
- }],
- 'start': 1487883186070,
- 'auctionStart': 1487883186069,
- 'timeout': 3000
+import {spec, SYNC_URL} from 'modules/dxkultureBidAdapter.js';
+import {BANNER, VIDEO} from 'src/mediaTypes.js';
+
+const getBannerRequest = () => {
+ return {
+ bidderCode: 'dxkulture',
+ auctionId: 'ba87bfdf-493e-4a88-8e26-17b4cbc9adbd',
+ bidderRequestId: 'bidderRequestId',
+ bids: [
+ {
+ bidder: 'dxkulture',
+ params: {
+ placementId: 123456,
+ publisherId: 'publisherId',
+ bidfloor: 10,
+ },
+ auctionId: 'auctionId-56a2-4f71-9098-720a68f2f708',
+ placementCode: 'div-gpt-dummy-placement-code',
+ mediaTypes: {
+ banner: {
+ sizes: [
+ [ 300, 250 ],
+ ]
+ }
+ },
+ bidId: '2e9f38ea93bb9e',
+ bidderRequestId: 'bidderRequestId',
+ }
+ ],
+ start: 1487883186070,
+ auctionStart: 1487883186069,
+ timeout: 3000
+ }
};
-const RESPONSE = {
- 'headers': null,
- 'body': {
- 'id': 'responseId',
- 'seatbid': [
- {
- 'bid': [
- {
- 'id': 'bidId1',
- 'impid': 'bidId1',
- 'price': 0.18,
- 'adm': '',
- 'adid': '144762342',
- 'adomain': [
- 'https://dummydomain.com'
- ],
- 'iurl': 'iurl',
- 'cid': '109',
- 'crid': 'creativeId',
- 'cat': [],
- 'w': 300,
- 'h': 250,
- 'ext': {
- 'prebid': {
- 'type': 'banner'
- },
- 'bidder': {
- 'appnexus': {
- 'brand_id': 334553,
- 'auction_id': 514667951122925701,
- 'bidder_id': 2,
- 'bid_ad_type': 0
+const getVideoRequest = () => {
+ return {
+ bidderCode: 'dxkulture',
+ auctionId: 'e158486f-8c7f-472f-94ce-b0cbfbb50ab4',
+ bidderRequestId: '34feaad34lkj2',
+ bids: [{
+ mediaTypes: {
+ video: {
+ context: 'instream',
+ playerSize: [[640, 480]],
+ }
+ },
+ bidder: 'dxkulture',
+ sizes: [640, 480],
+ bidId: '30b3efwfwe1e',
+ adUnitCode: 'video1',
+ params: {
+ video: {
+ playerWidth: 640,
+ playerHeight: 480,
+ mimes: ['video/mp4', 'application/javascript'],
+ protocols: [2, 5],
+ api: [2],
+ position: 1,
+ delivery: [2],
+ sid: 134,
+ rewarded: 1,
+ placement: 1,
+ plcmt: 1,
+ hp: 1,
+ inventoryid: 123
+ },
+ site: {
+ id: 1,
+ page: 'https://test.com',
+ referrer: 'http://test.com'
+ },
+ publisherId: 'km123',
+ bidfloor: 10,
+ }
+ }, {
+ mediaTypes: {
+ video: {
+ context: 'instream',
+ playerSize: [[640, 480]],
+ }
+ },
+ bidder: 'dxkulture',
+ sizes: [640, 480],
+ bidId: '30b3efwfwe2e',
+ adUnitCode: 'video1',
+ params: {
+ video: {
+ playerWidth: 640,
+ playerHeight: 480,
+ mimes: ['video/mp4', 'application/javascript'],
+ protocols: [2, 5],
+ api: [2],
+ position: 1,
+ delivery: [2],
+ sid: 134,
+ rewarded: 1,
+ placement: 1,
+ plcmt: 1,
+ hp: 1,
+ inventoryid: 123
+ },
+ site: {
+ id: 1,
+ page: 'https://test.com',
+ referrer: 'http://test.com'
+ },
+ publisherId: 'km123',
+ bidfloor: 10,
+ }
+ }],
+ auctionStart: 1520001292880,
+ timeout: 5000,
+ start: 1520001292884,
+ doneCbCallCount: 0,
+ refererInfo: {
+ numIframes: 1,
+ reachedTop: true,
+ referer: 'test.com'
+ }
+ };
+};
+
+const getBidderResponse = () => {
+ return {
+ headers: null,
+ body: {
+ id: 'bid-response',
+ seatbid: [
+ {
+ bid: [
+ {
+ id: '2e9f38ea93bb9e',
+ impid: '2e9f38ea93bb9e',
+ price: 0.18,
+ adm: '',
+ adid: '144762342',
+ adomain: [
+ 'https://dummydomain.com'
+ ],
+ iurl: 'iurl',
+ cid: '109',
+ crid: 'creativeId',
+ cat: [],
+ w: 300,
+ h: 250,
+ ext: {
+ prebid: {
+ type: 'banner'
+ },
+ bidder: {
+ appnexus: {
+ brand_id: 334553,
+ auction_id: 514667951122925701,
+ bidder_id: 2,
+ bid_ad_type: 0
+ }
}
}
}
+ ],
+ seat: 'dxkulture'
+ }
+ ],
+ ext: {
+ usersync: {
+ sovrn: {
+ status: 'none',
+ syncs: [
+ {
+ url: 'urlsovrn',
+ type: 'iframe'
+ }
+ ]
},
- {
- 'id': 'bidId2',
- 'impid': 'bidId2',
- 'price': 0.1,
- 'adm': '',
- 'adid': '144762342',
- 'adomain': [
- 'https://dummydomain.com'
- ],
- 'iurl': 'iurl',
- 'cid': '109',
- 'crid': 'creativeId',
- 'cat': [],
- 'w': 300,
- 'h': 250,
- 'ext': {
- 'prebid': {
- 'type': 'banner'
- },
- 'bidder': {
- 'appnexus': {
- 'brand_id': 386046,
- 'auction_id': 517067951122925501,
- 'bidder_id': 2,
- 'bid_ad_type': 0
- }
+ appnexus: {
+ status: 'none',
+ syncs: [
+ {
+ url: 'urlappnexus',
+ type: 'pixel'
}
- }
+ ]
}
- ],
- 'seat': 'dxkulture'
- }
- ],
- 'ext': {
- 'usersync': {
- 'sovrn': {
- 'status': 'none',
- 'syncs': [
- {
- 'url': 'urlsovrn',
- 'type': 'iframe'
- }
- ]
},
- 'appnexus': {
- 'status': 'none',
- 'syncs': [
- {
- 'url': 'urlappnexus',
- 'type': 'pixel'
- }
- ]
+ responsetimemillis: {
+ appnexus: 127
}
- },
- 'responsetimemillis': {
- 'appnexus': 127
}
}
- }
-};
-
-const DEFAULT_NETWORK_ID = 1;
+ };
+}
-describe('dxkultureBidAdapter:', function () {
+describe('dxkultureBidAdapter', function() {
let videoBidRequest;
const VIDEO_REQUEST = {
@@ -183,51 +244,86 @@ describe('dxkultureBidAdapter:', function () {
page: 'https://test.com',
referrer: 'http://test.com'
},
- publisherId: 'km123'
+ publisherId: 'km123',
+ bidfloor: 0
}
};
});
- describe('isBidRequestValid', function () {
- context('basic validation', function () {
- beforeEach(function () {
- // Basic Valid BidRequest
- this.bid = {
- bidder: 'dxkulture',
- mediaTypes: {
- banner: {
- sizes: [[250, 300]]
- }
- },
- params: {
- placementId: 'placementId',
- publisherId: 'publisherId',
- }
- };
- });
+ describe('isValidRequest', function() {
+ let bidderRequest;
- it('should accept request if placementId and publisherId are passed', function () {
- expect(spec.isBidRequestValid(this.bid)).to.be.true;
- });
+ beforeEach(function() {
+ bidderRequest = getBannerRequest();
+ });
- it('reject requests without params', function () {
- this.bid.params = {};
- expect(spec.isBidRequestValid(this.bid)).to.be.false;
- });
+ it('should accept request if placementId and publisherId are passed', function () {
+ expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.be.true;
+ });
- it('returns false when banner mediaType does not exist', function () {
- this.bid.mediaTypes = {}
- expect(spec.isBidRequestValid(this.bid)).to.be.false;
- });
+ it('reject requests without params', function () {
+ bidderRequest.bids[0].params = {};
+ expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.be.false;
+ });
+
+ it('returns false when banner mediaType does not exist', function () {
+ bidderRequest.bids[0].mediaTypes = {}
+ expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.be.false;
+ });
+ });
+
+ describe('buildRequests', function() {
+ let bidderRequest;
+
+ beforeEach(function() {
+ bidderRequest = getBannerRequest();
+ });
+
+ it('should return expected request object', function() {
+ const bidRequest = spec.buildRequests(bidderRequest.bids, bidderRequest);
+ expect(bidRequest.url).equal('https://ads.kulture.media/pbjs?pid=publisherId&placementId=123456');
+ expect(bidRequest.method).equal('POST');
+ });
+ });
+
+ context('banner validation', function () {
+ let bidderRequest;
+
+ beforeEach(function() {
+ bidderRequest = getBannerRequest();
+ });
+
+ it('returns true when banner sizes are defined', function () {
+ const bid = {
+ bidder: 'dxkulture',
+ mediaTypes: {
+ banner: {
+ sizes: [[250, 300]]
+ }
+ },
+ params: {
+ placementId: 'placementId',
+ publisherId: 'publisherId',
+ }
+ };
+
+ expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.be.true;
});
- context('banner validation', function () {
- it('returns true when banner sizes are defined', function () {
+ it('returns false when banner sizes are invalid', function () {
+ const invalidSizes = [
+ undefined,
+ '2:1',
+ 123,
+ 'test'
+ ];
+
+ invalidSizes.forEach((sizes) => {
const bid = {
bidder: 'dxkulture',
mediaTypes: {
banner: {
- sizes: [[250, 300]]
+ sizes
}
},
params: {
@@ -236,350 +332,281 @@ describe('dxkultureBidAdapter:', function () {
}
};
- expect(spec.isBidRequestValid(bid)).to.be.true;
+ expect(spec.isBidRequestValid(bid)).to.be.false;
});
+ });
+ });
- it('returns false when banner sizes are invalid', function () {
- const invalidSizes = [
- undefined,
- '2:1',
- 123,
- 'test'
- ];
-
- invalidSizes.forEach((sizes) => {
- const bid = {
- bidder: 'dxkulture',
- mediaTypes: {
- banner: {
- sizes
- }
- },
- params: {
- placementId: 'placementId',
- publisherId: 'publisherId',
- }
- };
+ context('video validation', function () {
+ beforeEach(function () {
+ // Basic Valid BidRequest
+ this.bid = {
+ bidder: 'dxkulture',
+ mediaTypes: {
+ video: {
+ playerSize: [[300, 50]],
+ context: 'instream',
+ mimes: ['foo', 'bar'],
+ protocols: [1, 2]
+ }
+ },
+ params: {
+ placementId: 'placementId',
+ publisherId: 'publisherId',
+ }
+ };
+ });
- expect(spec.isBidRequestValid(bid)).to.be.false;
- });
- });
+ it('should return true (skip validations) when e2etest = true', function () {
+ this.bid.params = {
+ e2etest: true
+ };
+ expect(spec.isBidRequestValid(this.bid)).to.equal(true);
});
- context('video validation', function () {
- beforeEach(function () {
- // Basic Valid BidRequest
- this.bid = {
- bidder: 'dxkulture',
- mediaTypes: {
- video: {
- playerSize: [[300, 50]],
- context: 'instream',
- mimes: ['foo', 'bar'],
- protocols: [1, 2]
- }
- },
- params: {
- placementId: 'placementId',
- publisherId: 'publisherId',
- }
- };
- });
+ it('returns false when video context is not defined', function () {
+ delete this.bid.mediaTypes.video.context;
- it('should return true (skip validations) when e2etest = true', function () {
- this.bid.params = {
- e2etest: true
- };
- expect(spec.isBidRequestValid(this.bid)).to.equal(true);
- });
+ expect(spec.isBidRequestValid(this.bid)).to.be.false;
+ });
- it('returns false when video context is not defined', function () {
- delete this.bid.mediaTypes.video.context;
+ it('returns false when video playserSize is invalid', function () {
+ const invalidSizes = [
+ undefined,
+ '2:1',
+ 123,
+ 'test'
+ ];
+ invalidSizes.forEach((playerSize) => {
+ this.bid.mediaTypes.video.playerSize = playerSize;
expect(spec.isBidRequestValid(this.bid)).to.be.false;
});
+ });
- it('returns false when video playserSize is invalid', function () {
- const invalidSizes = [
- undefined,
- '2:1',
- 123,
- 'test'
- ];
-
- invalidSizes.forEach((playerSize) => {
- this.bid.mediaTypes.video.playerSize = playerSize;
- expect(spec.isBidRequestValid(this.bid)).to.be.false;
- });
- });
+ it('returns false when video mimes is invalid', function () {
+ const invalidMimes = [
+ undefined,
+ 'test',
+ 1,
+ []
+ ]
- it('returns false when video mimes is invalid', function () {
- const invalidMimes = [
- undefined,
- 'test',
- 1,
- []
- ]
-
- invalidMimes.forEach((mimes) => {
- this.bid.mediaTypes.video.mimes = mimes;
- expect(spec.isBidRequestValid(this.bid)).to.be.false;
- })
- });
+ invalidMimes.forEach((mimes) => {
+ this.bid.mediaTypes.video.mimes = mimes;
+ expect(spec.isBidRequestValid(this.bid)).to.be.false;
+ })
+ });
- it('returns false when video protocols is invalid', function () {
- const invalidMimes = [
- undefined,
- 'test',
- 1,
- []
- ]
-
- invalidMimes.forEach((protocols) => {
- this.bid.mediaTypes.video.protocols = protocols;
- expect(spec.isBidRequestValid(this.bid)).to.be.false;
- })
- });
+ it('returns false when video protocols is invalid', function () {
+ const invalidMimes = [
+ undefined,
+ 'test',
+ 1,
+ []
+ ]
+
+ invalidMimes.forEach((protocols) => {
+ this.bid.mediaTypes.video.protocols = protocols;
+ expect(spec.isBidRequestValid(this.bid)).to.be.false;
+ })
});
});
describe('buildRequests', function () {
+ let bidderBannerRequest;
+ let bidRequestsWithMediaTypes;
+ let mockBidderRequest;
+
+ beforeEach(function() {
+ bidderBannerRequest = getBannerRequest();
+
+ mockBidderRequest = {refererInfo: {}};
+
+ bidRequestsWithMediaTypes = [{
+ bidder: 'dxkulture',
+ params: {
+ publisherId: 'km123',
+ },
+ adUnitCode: '/adunit-code/test-path',
+ mediaTypes: {
+ banner: {
+ sizes: [[300, 250], [300, 600]]
+ }
+ },
+ bidId: 'test-bid-id-1',
+ bidderRequestId: 'test-bid-request-1',
+ auctionId: 'test-auction-1',
+ transactionId: 'test-transactionId-1',
+ ortb2Imp: {
+ ext: {
+ ae: 2
+ }
+ }
+ }, {
+ bidder: 'dxkulture',
+ params: {
+ publisherId: 'km123',
+ },
+ adUnitCode: 'adunit-code',
+ mediaTypes: {
+ video: {
+ playerSize: [640, 480],
+ placement: 1,
+ plcmt: 1,
+ }
+ },
+ bidId: 'test-bid-id-2',
+ bidderRequestId: 'test-bid-request-2',
+ auctionId: 'test-auction-2',
+ transactionId: 'test-transactionId-2'
+ }];
+ });
+
context('when mediaType is banner', function () {
it('creates request data', function () {
- let request = spec.buildRequests(BANNER_REQUEST.bidRequest, BANNER_REQUEST);
+ let request = spec.buildRequests(bidderBannerRequest.bids, bidderBannerRequest)
expect(request).to.exist.and.to.be.a('object');
- const payload = JSON.parse(request.data);
- expect(payload.imp[0]).to.have.property('id', BANNER_REQUEST.bidRequest[0].bidId);
- expect(payload.imp[1]).to.have.property('id', BANNER_REQUEST.bidRequest[1].bidId);
+ const payload = request.data;
+ expect(payload.imp[0]).to.have.property('id', bidderBannerRequest.bids[0].bidId);
});
it('has gdpr data if applicable', function () {
- const req = Object.assign({}, BANNER_REQUEST, {
+ const req = Object.assign({}, getBannerRequest(), {
gdprConsent: {
consentString: 'consentString',
gdprApplies: true,
}
});
- let request = spec.buildRequests(BANNER_REQUEST.bidRequest, req);
+ let request = spec.buildRequests(bidderBannerRequest.bids, req);
- const payload = JSON.parse(request.data);
+ const payload = request.data;
expect(payload.user.ext).to.have.property('consent', req.gdprConsent.consentString);
expect(payload.regs.ext).to.have.property('gdpr', 1);
});
+ });
- it('should properly forward eids parameters', function () {
- const req = Object.assign({}, BANNER_REQUEST);
- req.bidRequest[0].userIdAsEids = [
- {
- source: 'dummy.com',
- uids: [
- {
- id: 'd6d0a86c-20c6-4410-a47b-5cba383a698a',
- atype: 1
- }
- ]
- }];
- let request = spec.buildRequests(req.bidRequest, req);
+ if (FEATURES.VIDEO) {
+ context('video', function () {
+ it('should create a POST request for every bid', function () {
+ const requests = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest);
+ expect(requests.method).to.equal('POST');
+ expect(requests.url.trim()).to.equal(spec.ENDPOINT + '?pid=' + videoBidRequest.params.publisherId);
+ });
- const payload = JSON.parse(request.data);
- expect(payload.user.ext.eids[0].source).to.equal('dummy.com');
- expect(payload.user.ext.eids[0].uids[0].id).to.equal('d6d0a86c-20c6-4410-a47b-5cba383a698a');
- expect(payload.user.ext.eids[0].uids[0].atype).to.equal(1);
- });
- });
+ it('should attach request data', function () {
+ const requests = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest);
+ const data = requests.data;
+ const [width, height] = videoBidRequest.sizes;
+ const VERSION = '1.0.0';
+
+ expect(data.imp[1].video.w).to.equal(width);
+ expect(data.imp[1].video.h).to.equal(height);
+ expect(data.imp[1].bidfloor).to.equal(videoBidRequest.params.bidfloor);
+ expect(data.imp[1]['video']['placement']).to.equal(videoBidRequest.params.video['placement']);
+ expect(data.imp[1]['video']['plcmt']).to.equal(videoBidRequest.params.video['plcmt']);
+ expect(data.ext.prebidver).to.equal('$prebid.version$');
+ expect(data.ext.adapterver).to.equal(spec.VERSION);
+ });
- context('when mediaType is video', function () {
- it('should create a POST request for every bid', function () {
- const requests = spec.buildRequests([videoBidRequest], VIDEO_REQUEST);
- expect(requests.method).to.equal('POST');
- expect(requests.url.trim()).to.equal(spec.ENDPOINT + '?pid=' + videoBidRequest.params.publisherId + '&nId=' + DEFAULT_NETWORK_ID);
- });
+ it('should set pubId to e2etest when bid.params.e2etest = true', function () {
+ bidRequestsWithMediaTypes[0].params.e2etest = true;
+ const requests = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest);
+ expect(requests.method).to.equal('POST');
+ expect(requests.url).to.equal(spec.ENDPOINT + '?pid=e2etest');
+ });
- it('should attach request data', function () {
- const requests = spec.buildRequests([videoBidRequest], VIDEO_REQUEST);
- const data = JSON.parse(requests.data);
- const [width, height] = videoBidRequest.sizes;
- const VERSION = '1.0.0';
- expect(data.imp[0].video.w).to.equal(width);
- expect(data.imp[0].video.h).to.equal(height);
- expect(data.imp[0].bidfloor).to.equal(videoBidRequest.params.bidfloor);
- expect(data.imp[0]['video']['placement']).to.equal(videoBidRequest.params.video['placement']);
- expect(data.imp[0]['video']['plcmt']).to.equal(videoBidRequest.params.video['plcmt']);
- expect(data.ext.prebidver).to.equal('$prebid.version$');
- expect(data.ext.adapterver).to.equal(spec.VERSION);
+ it('should attach End 2 End test data', function () {
+ bidRequestsWithMediaTypes[1].params.e2etest = true;
+ const requests = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest);
+ const data = requests.data;
+ expect(data.imp[1].bidfloor).to.equal(0);
+ expect(data.imp[1].video.w).to.equal(640);
+ expect(data.imp[1].video.h).to.equal(480);
+ });
});
+ }
+ });
- it('should set pubId to e2etest when bid.params.e2etest = true', function () {
- videoBidRequest.params.e2etest = true;
- const requests = spec.buildRequests([videoBidRequest], VIDEO_REQUEST);
- expect(requests.method).to.equal('POST');
- expect(requests.url).to.equal(spec.ENDPOINT + '?pid=e2etest&nId=' + DEFAULT_NETWORK_ID);
+ describe('interpretResponse', function() {
+ context('when mediaType is banner', function() {
+ let bidRequest, bidderResponse;
+ beforeEach(function() {
+ const bidderRequest = getBannerRequest();
+ bidRequest = spec.buildRequests(bidderRequest.bids, bidderRequest);
+ bidderResponse = getBidderResponse();
});
- it('should attach End 2 End test data', function () {
- videoBidRequest.params.e2etest = true;
- const requests = spec.buildRequests([videoBidRequest], VIDEO_REQUEST);
- const data = JSON.parse(requests.data);
- expect(data.imp[0].bidfloor).to.not.exist;
- expect(data.imp[0].video.w).to.equal(640);
- expect(data.imp[0].video.h).to.equal(480);
+ it('handles empty response', function () {
+ const EMPTY_RESP = Object.assign({}, bidderResponse, {'body': {}});
+ const bids = spec.interpretResponse(EMPTY_RESP, bidRequest);
+
+ expect(bids).to.be.empty;
});
- });
- });
- describe('interpretResponse', function () {
- context('when mediaType is banner', function () {
it('have bids', function () {
- let bids = spec.interpretResponse(RESPONSE, BANNER_REQUEST);
+ let bids = spec.interpretResponse(bidderResponse, bidRequest);
expect(bids).to.be.an('array').that.is.not.empty;
validateBidOnIndex(0);
- validateBidOnIndex(1);
function validateBidOnIndex(index) {
expect(bids[index]).to.have.property('currency', 'USD');
- expect(bids[index]).to.have.property('requestId', RESPONSE.body.seatbid[0].bid[index].impid);
- expect(bids[index]).to.have.property('cpm', RESPONSE.body.seatbid[0].bid[index].price);
- expect(bids[index]).to.have.property('width', RESPONSE.body.seatbid[0].bid[index].w);
- expect(bids[index]).to.have.property('height', RESPONSE.body.seatbid[0].bid[index].h);
- expect(bids[index]).to.have.property('ad', RESPONSE.body.seatbid[0].bid[index].adm);
- expect(bids[index]).to.have.property('creativeId', RESPONSE.body.seatbid[0].bid[index].crid);
- expect(bids[index].meta).to.have.property('advertiserDomains', RESPONSE.body.seatbid[0].bid[index].adomain);
+ expect(bids[index]).to.have.property('requestId', getBidderResponse().body.seatbid[0].bid[index].impid);
+ expect(bids[index]).to.have.property('cpm', getBidderResponse().body.seatbid[0].bid[index].price);
+ expect(bids[index]).to.have.property('width', getBidderResponse().body.seatbid[0].bid[index].w);
+ expect(bids[index]).to.have.property('height', getBidderResponse().body.seatbid[0].bid[index].h);
+ expect(bids[index]).to.have.property('ad', getBidderResponse().body.seatbid[0].bid[index].adm);
+ expect(bids[index]).to.have.property('creativeId', getBidderResponse().body.seatbid[0].bid[index].crid);
+ expect(bids[index].meta).to.have.property('advertiserDomains');
expect(bids[index]).to.have.property('ttl', 300);
expect(bids[index]).to.have.property('netRevenue', true);
}
});
+ });
+
+ context('when mediaType is video', function () {
+ let bidRequest, bidderResponse;
+ beforeEach(function() {
+ const bidderRequest = getVideoRequest();
+ bidRequest = spec.buildRequests(bidderRequest.bids, bidderRequest);
+ bidderResponse = getBidderResponse();
+ });
it('handles empty response', function () {
- const EMPTY_RESP = Object.assign({}, RESPONSE, {'body': {}});
- const bids = spec.interpretResponse(EMPTY_RESP, BANNER_REQUEST);
+ const EMPTY_RESP = Object.assign({}, bidderResponse, {'body': {}});
+ const bids = spec.interpretResponse(EMPTY_RESP, bidRequest);
expect(bids).to.be.empty;
});
- });
-
- context('when mediaType is video', function () {
- it('should return no bids if the response is not valid', function () {
- const bidResponse = spec.interpretResponse({
- body: null
- }, {
- videoBidRequest
- });
- expect(bidResponse.length).to.equal(0);
- });
it('should return no bids if the response "nurl" and "adm" are missing', function () {
- const serverResponse = {
+ const SERVER_RESP = Object.assign({}, bidderResponse, {'body': {
seatbid: [{
bid: [{
price: 6.01
}]
}]
- };
- const bidResponse = spec.interpretResponse({
- body: serverResponse
- }, {
- videoBidRequest
- });
- expect(bidResponse.length).to.equal(0);
+ }});
+ const bids = spec.interpretResponse(SERVER_RESP, bidRequest);
+ expect(bids.length).to.equal(0);
});
it('should return no bids if the response "price" is missing', function () {
- const serverResponse = {
+ const SERVER_RESP = Object.assign({}, bidderResponse, {'body': {
seatbid: [{
bid: [{
adm: ''
}]
}]
- };
- const bidResponse = spec.interpretResponse({
- body: serverResponse
- }, {
- videoBidRequest
- });
- expect(bidResponse.length).to.equal(0);
- });
-
- it('should return a valid video bid response with just "adm"', function () {
- const serverResponse = {
- id: '123',
- seatbid: [{
- bid: [{
- id: 1,
- adid: 123,
- impid: 456,
- crid: 2,
- price: 6.01,
- adm: '',
- adomain: [
- 'dxkulture.com'
- ],
- w: 640,
- h: 480,
- ext: {
- prebid: {
- type: 'video'
- },
- }
- }]
- }],
- cur: 'USD'
- };
- const bidResponse = spec.interpretResponse({
- body: serverResponse
- }, {
- videoBidRequest
- });
- let o = {
- requestId: serverResponse.seatbid[0].bid[0].impid,
- ad: '',
- bidderCode: spec.code,
- cpm: serverResponse.seatbid[0].bid[0].price,
- creativeId: serverResponse.seatbid[0].bid[0].crid,
- vastXml: serverResponse.seatbid[0].bid[0].adm,
- width: 640,
- height: 480,
- mediaType: 'video',
- currency: 'USD',
- ttl: 300,
- netRevenue: true,
- meta: {
- advertiserDomains: ['dxkulture.com']
- }
- };
- expect(bidResponse[0]).to.deep.equal(o);
- });
-
- it('should default ttl to 300', function () {
- const serverResponse = {
- seatbid: [{bid: [{id: 1, adid: 123, crid: 2, price: 6.01, adm: ''}]}],
- cur: 'USD'
- };
- const bidResponse = spec.interpretResponse({body: serverResponse}, {videoBidRequest});
- expect(bidResponse[0].ttl).to.equal(300);
- });
- it('should not allow ttl above 3601, default to 300', function () {
- videoBidRequest.params.video.ttl = 3601;
- const serverResponse = {
- seatbid: [{bid: [{id: 1, adid: 123, crid: 2, price: 6.01, adm: ''}]}],
- cur: 'USD'
- };
- const bidResponse = spec.interpretResponse({body: serverResponse}, {videoBidRequest});
- expect(bidResponse[0].ttl).to.equal(300);
- });
- it('should not allow ttl below 1, default to 300', function () {
- videoBidRequest.params.video.ttl = 0;
- const serverResponse = {
- seatbid: [{bid: [{id: 1, adid: 123, crid: 2, price: 6.01, adm: ''}]}],
- cur: 'USD'
- };
- const bidResponse = spec.interpretResponse({body: serverResponse}, {videoBidRequest});
- expect(bidResponse[0].ttl).to.equal(300);
+ }});
+ const bids = spec.interpretResponse(SERVER_RESP, bidRequest);
+ expect(bids.length).to.equal(0);
});
});
});
- describe('getUserSyncs', function () {
+ describe('user sync', function () {
it('handles no parameters', function () {
let opts = spec.getUserSyncs({});
expect(opts).to.be.an('array').that.is.empty;
@@ -590,27 +617,66 @@ describe('dxkultureBidAdapter:', function () {
expect(opts).to.be.an('array').that.is.empty;
});
- it('iframe sync enabled should return results', function () {
- let opts = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: false}, [RESPONSE]);
+ describe('when gdpr applies', function () {
+ let gdprConsent;
+ let gdprPixelUrl;
+ const consentString = 'gdpr-pixel-consent';
+ const gdprApplies = '1';
+ beforeEach(() => {
+ gdprConsent = {
+ consentString,
+ gdprApplies: true
+ };
- expect(opts.length).to.equal(1);
- expect(opts[0].type).to.equal('iframe');
- expect(opts[0].url).to.equal(RESPONSE.body.ext.usersync['sovrn'].syncs[0].url);
- });
+ gdprPixelUrl = `${SYNC_URL}&gdpr=${gdprApplies}&gdpr_consent=${consentString}`;
+ });
- it('pixel sync enabled should return results', function () {
- let opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [RESPONSE]);
+ it('when there is a response, it should have the gdpr query params', () => {
+ let [{url}] = spec.getUserSyncs(
+ {iframeEnabled: true, pixelEnabled: true},
+ [],
+ gdprConsent
+ );
- expect(opts.length).to.equal(1);
- expect(opts[0].type).to.equal('image');
- expect(opts[0].url).to.equal(RESPONSE.body.ext.usersync['appnexus'].syncs[0].url);
+ expect(url).to.have.string(`gdpr_consent=${consentString}`);
+ expect(url).to.have.string(`gdpr=${gdprApplies}`);
+ });
+
+ it('should not send signals if no consent object is available', function () {
+ let [{url}] = spec.getUserSyncs(
+ {iframeEnabled: true, pixelEnabled: true},
+ [],
+ );
+ expect(url).to.not.have.string('gdpr_consent=');
+ expect(url).to.not.have.string('gdpr=');
+ });
});
- it('all sync enabled should return all results', function () {
- let opts = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [RESPONSE]);
+ describe('when ccpa applies', function () {
+ let usPrivacyConsent;
+ let uspPixelUrl;
+ const privacyString = 'TEST';
+ beforeEach(() => {
+ usPrivacyConsent = 'TEST';
+ uspPixelUrl = `${SYNC_URL}&us_privacy=${privacyString}`
+ });
+ it('should send the us privacy string, ', () => {
+ let [{url}] = spec.getUserSyncs(
+ {iframeEnabled: true, pixelEnabled: true},
+ [],
+ undefined,
+ usPrivacyConsent
+ );
+ expect(url).to.have.string(`us_privacy=${privacyString}`);
+ });
- expect(opts.length).to.equal(2);
+ it('should not send signals if no consent string is available', function () {
+ let [{url}] = spec.getUserSyncs(
+ {iframeEnabled: true, pixelEnabled: true},
+ [],
+ );
+ expect(url).to.not.have.string('us_privacy=');
+ });
});
});
-})
-;
+});
diff --git a/test/spec/modules/dynamicAdBoostRtdProvider_spec.js b/test/spec/modules/dynamicAdBoostRtdProvider_spec.js
new file mode 100644
index 00000000000..66c24435589
--- /dev/null
+++ b/test/spec/modules/dynamicAdBoostRtdProvider_spec.js
@@ -0,0 +1,77 @@
+import { subModuleObj as rtdProvider } from 'modules/dynamicAdBoostRtdProvider.js';
+import { loadExternalScript } from '../../../src/adloader.js';
+import { expect } from 'chai';
+
+const configWithParams = {
+ params: {
+ keyId: 'dynamic',
+ adUnits: ['gpt-123'],
+ threshold: 1
+ }
+};
+
+const configWithoutRequiredParams = {
+ params: {
+ keyId: ''
+ }
+};
+
+describe('dynamicAdBoost', function() {
+ let clock;
+ let sandbox;
+ beforeEach(function () {
+ sandbox = sinon.sandbox.create();
+ clock = sandbox.useFakeTimers(Date.now());
+ });
+ afterEach(function () {
+ sandbox.restore();
+ });
+ describe('init', function() {
+ describe('initialize without expected params', function() {
+ it('fails initalize when keyId is not present', function() {
+ expect(rtdProvider.init(configWithoutRequiredParams)).to.be.false;
+ })
+ })
+
+ describe('initialize with expected params', function() {
+ it('successfully initialize with load script', function() {
+ expect(rtdProvider.init(configWithParams)).to.be.true;
+ clock.tick(1000);
+ expect(loadExternalScript.called).to.be.true;
+ })
+ });
+ });
+})
+
+describe('markViewed tests', function() {
+ let sandbox;
+ const mockObserver = {
+ unobserve: sinon.spy()
+ };
+ const makeElement = (id) => {
+ const el = document.createElement('div');
+ el.setAttribute('id', id);
+ return el;
+ }
+ const mockEntry = {
+ target: makeElement('target_id')
+ };
+
+ beforeEach(function() {
+ sandbox = sinon.sandbox.create();
+ })
+
+ afterEach(function() {
+ sandbox.restore()
+ })
+
+ it('markViewed returns a function', function() {
+ expect(rtdProvider.markViewed(mockEntry, mockObserver)).to.be.a('function')
+ });
+
+ it('markViewed unobserves', function() {
+ const func = rtdProvider.markViewed(mockEntry, mockObserver);
+ func();
+ expect(mockObserver.unobserve.calledOnce).to.be.true;
+ });
+})
diff --git a/test/spec/modules/euidIdSystem_spec.js b/test/spec/modules/euidIdSystem_spec.js
index 4f6bacebe6a..9e4598bb5f5 100644
--- a/test/spec/modules/euidIdSystem_spec.js
+++ b/test/spec/modules/euidIdSystem_spec.js
@@ -6,6 +6,7 @@ import 'src/prebid.js';
import {apiHelpers, cookieHelpers, runAuction, setGdprApplies} from './uid2IdSystem_helpers.js';
import {hook} from 'src/hook.js';
import {uninstall as uninstallGdprEnforcement} from 'modules/gdprEnforcement.js';
+import {server} from 'test/mocks/xhr';
let expect = require('chai').expect;
@@ -32,8 +33,7 @@ const expectToken = (bid, token) => expect(bid?.userId ?? {}).to.deep.include(ma
const expectNoIdentity = (bid) => expect(bid).to.not.haveOwnProperty('userId');
describe('EUID module', function() {
- let suiteSandbox, testSandbox, timerSpy, fullTestTitle, restoreSubtleToUndefined = false;
- let server;
+ let suiteSandbox, restoreSubtleToUndefined = false;
const configureEuidResponse = (httpStatus, response) => server.respondWith('POST', apiUrl, (xhr) => xhr.respond(httpStatus, headers, response));
@@ -53,12 +53,10 @@ describe('EUID module', function() {
if (restoreSubtleToUndefined) window.crypto.subtle = undefined;
});
beforeEach(function() {
- server = sinon.createFakeServer();
init(config);
setSubmoduleRegistry([euidIdSubmodule]);
});
afterEach(function() {
- server.restore();
$$PREBID_GLOBAL$$.requestBids.removeAll();
config.resetConfig();
cookieHelpers.clearCookies(moduleCookieName, publisherCookieName);
diff --git a/test/spec/modules/fledgeForGpt_spec.js b/test/spec/modules/fledgeForGpt_spec.js
index b4bff8e82f0..60a8e196ae0 100644
--- a/test/spec/modules/fledgeForGpt_spec.js
+++ b/test/spec/modules/fledgeForGpt_spec.js
@@ -45,16 +45,17 @@ describe('fledgeForGpt module', () => {
});
it('should call next()', function () {
- fledge.addComponentAuctionHook(nextFnSpy, 'aid', 'auc', fledgeAuctionConfig);
- sinon.assert.calledWith(nextFnSpy, 'aid', 'auc', fledgeAuctionConfig);
+ const request = {auctionId: 'aid', adUnitCode: 'auc'};
+ fledge.addComponentAuctionHook(nextFnSpy, request, fledgeAuctionConfig);
+ sinon.assert.calledWith(nextFnSpy, request, fledgeAuctionConfig);
});
it('should collect auction configs and route them to GPT at end of auction', () => {
events.emit(CONSTANTS.EVENTS.AUCTION_INIT, {auctionId: 'aid'});
const cf1 = {...fledgeAuctionConfig, id: 1, seller: 'b1'};
const cf2 = {...fledgeAuctionConfig, id: 2, seller: 'b2'};
- fledge.addComponentAuctionHook(nextFnSpy, 'aid', 'au1', cf1);
- fledge.addComponentAuctionHook(nextFnSpy, 'aid', 'au2', cf2);
+ fledge.addComponentAuctionHook(nextFnSpy, {auctionId: 'aid', adUnitCode: 'au1'}, cf1);
+ fledge.addComponentAuctionHook(nextFnSpy, {auctionId: 'aid', adUnitCode: 'au2'}, cf2);
events.emit(CONSTANTS.EVENTS.AUCTION_END, {auctionId: 'aid'});
sinon.assert.calledWith(gptUtils.getGptSlotForAdUnitCode, 'au1');
sinon.assert.calledWith(gptUtils.getGptSlotForAdUnitCode, 'au2');
@@ -75,11 +76,31 @@ describe('fledgeForGpt module', () => {
it('should drop auction configs after end of auction', () => {
events.emit(CONSTANTS.EVENTS.AUCTION_INIT, {auctionId: 'aid'});
events.emit(CONSTANTS.EVENTS.AUCTION_END, {auctionId: 'aid'});
- fledge.addComponentAuctionHook(nextFnSpy, 'aid', 'au', fledgeAuctionConfig);
+ fledge.addComponentAuctionHook(nextFnSpy, {auctionId: 'aid', adUnitCode: 'au'}, fledgeAuctionConfig);
events.emit(CONSTANTS.EVENTS.AUCTION_END, {auctionId: 'aid'});
sinon.assert.notCalled(mockGptSlot.setConfig);
});
+ it('should augment auctionSignals with FPD', () => {
+ events.emit(CONSTANTS.EVENTS.AUCTION_INIT, {auctionId: 'aid'});
+ fledge.addComponentAuctionHook(nextFnSpy, {auctionId: 'aid', adUnitCode: 'au1', ortb2: {fpd: 1}, ortb2Imp: {fpd: 2}}, fledgeAuctionConfig);
+ events.emit(CONSTANTS.EVENTS.AUCTION_END, {auctionId: 'aid'});
+ sinon.assert.calledWith(mockGptSlot.setConfig, {
+ componentAuction: [{
+ configKey: 'bidder',
+ auctionConfig: {
+ ...fledgeAuctionConfig,
+ auctionSignals: {
+ prebid: {
+ ortb2: {fpd: 1},
+ ortb2Imp: {fpd: 2}
+ }
+ }
+ },
+ }]
+ })
+ })
+
describe('floor signal', () => {
before(() => {
if (!getGlobal().convertCurrency) {
@@ -173,7 +194,7 @@ describe('fledgeForGpt module', () => {
it('should populate bidfloor/bidfloorcur', () => {
events.emit(CONSTANTS.EVENTS.AUCTION_INIT, {auctionId: 'aid'});
- fledge.addComponentAuctionHook(nextFnSpy, 'aid', 'au', fledgeAuctionConfig);
+ fledge.addComponentAuctionHook(nextFnSpy, {auctionId: 'aid', adUnitCode: 'au'}, fledgeAuctionConfig);
events.emit(CONSTANTS.EVENTS.AUCTION_END, payload);
sinon.assert.calledWith(mockGptSlot.setConfig, sinon.match(arg => {
return arg.componentAuction.some(au => au.auctionConfig.auctionSignals?.prebid?.bidfloor === bidfloor && au.auctionConfig.auctionSignals?.prebid?.bidfloorcur === bidfloorcur)
@@ -223,6 +244,24 @@ describe('fledgeForGpt module', () => {
},
]
}];
+ function expectFledgeFlags(...enableFlags) {
+ const bidRequests = adapterManager.makeBidRequests(
+ adUnits,
+ Date.now(),
+ utils.getUniqueIdentifierStr(),
+ function callback() {
+ },
+ []
+ );
+
+ expect(bidRequests[0].bids[0].bidder).equals('appnexus');
+ expect(bidRequests[0].fledgeEnabled).to.eql(enableFlags[0].enabled)
+ bidRequests[0].bids.forEach(bid => expect(bid.ortb2Imp.ext.ae).to.eql(enableFlags[0].ae))
+
+ expect(bidRequests[1].bids[0].bidder).equals('rubicon');
+ expect(bidRequests[1].fledgeEnabled).to.eql(enableFlags[1].enabled)
+ bidRequests[1].bids.forEach(bid => expect(bid.ortb2Imp?.ext?.ae).to.eql(enableFlags[1].ae));
+ }
describe('with setBidderConfig()', () => {
it('should set fledgeEnabled correctly per bidder', function () {
@@ -234,23 +273,7 @@ describe('fledgeForGpt module', () => {
defaultForSlots: 1,
}
});
-
- const bidRequests = adapterManager.makeBidRequests(
- adUnits,
- Date.now(),
- utils.getUniqueIdentifierStr(),
- function callback() {
- },
- []
- );
-
- expect(bidRequests[0].bids[0].bidder).equals('appnexus');
- expect(bidRequests[0].fledgeEnabled).to.be.true;
- expect(bidRequests[0].defaultForSlots).to.equal(1);
-
- expect(bidRequests[1].bids[0].bidder).equals('rubicon');
- expect(bidRequests[1].fledgeEnabled).to.be.undefined;
- expect(bidRequests[1].defaultForSlots).to.be.undefined;
+ expectFledgeFlags({enabled: true, ae: 1}, {enabled: void 0, ae: void 0});
});
});
@@ -264,23 +287,7 @@ describe('fledgeForGpt module', () => {
defaultForSlots: 1,
}
});
-
- const bidRequests = adapterManager.makeBidRequests(
- adUnits,
- Date.now(),
- utils.getUniqueIdentifierStr(),
- function callback() {
- },
- []
- );
-
- expect(bidRequests[0].bids[0].bidder).equals('appnexus');
- expect(bidRequests[0].fledgeEnabled).to.be.true;
- expect(bidRequests[0].defaultForSlots).to.equal(1);
-
- expect(bidRequests[1].bids[0].bidder).equals('rubicon');
- expect(bidRequests[1].fledgeEnabled).to.be.undefined;
- expect(bidRequests[1].defaultForSlots).to.be.undefined;
+ expectFledgeFlags({enabled: true, ae: 1}, {enabled: void 0, ae: void 0});
});
it('should set fledgeEnabled correctly for all bidders', function () {
@@ -291,51 +298,33 @@ describe('fledgeForGpt module', () => {
defaultForSlots: 1,
}
});
-
- const bidRequests = adapterManager.makeBidRequests(
- adUnits,
- Date.now(),
- utils.getUniqueIdentifierStr(),
- function callback() {
- },
- []
- );
-
- expect(bidRequests[0].bids[0].bidder).equals('appnexus');
- expect(bidRequests[0].fledgeEnabled).to.be.true;
- expect(bidRequests[0].defaultForSlots).to.equal(1);
-
- expect(bidRequests[1].bids[0].bidder).equals('rubicon');
- expect(bidRequests[0].fledgeEnabled).to.be.true;
- expect(bidRequests[0].defaultForSlots).to.equal(1);
+ expectFledgeFlags({enabled: true, ae: 1}, {enabled: true, ae: 1});
});
+
+ it('should not override pub-defined ext.ae', () => {
+ config.setConfig({
+ bidderSequence: 'fixed',
+ fledgeForGpt: {
+ enabled: true,
+ defaultForSlots: 1,
+ }
+ });
+ Object.assign(adUnits[0], {ortb2Imp: {ext: {ae: 0}}});
+ expectFledgeFlags({enabled: true, ae: 0}, {enabled: true, ae: 0});
+ })
});
});
describe('ortb processors for fledge', () => {
- describe('when defaultForSlots is set', () => {
- it('imp.ext.ae should be set if fledge is enabled', () => {
- const imp = {};
- setImpExtAe(imp, {}, {bidderRequest: {fledgeEnabled: true, defaultForSlots: 1}});
- expect(imp.ext.ae).to.equal(1);
- });
- it('imp.ext.ae should be left intact if set on adunit and fledge is enabled', () => {
- const imp = {ext: {ae: 2}};
- setImpExtAe(imp, {}, {bidderRequest: {fledgeEnabled: true, defaultForSlots: 1}});
- expect(imp.ext.ae).to.equal(2);
- });
+ it('imp.ext.ae should be removed if fledge is not enabled', () => {
+ const imp = {ext: {ae: 1}};
+ setImpExtAe(imp, {}, {bidderRequest: {}});
+ expect(imp.ext.ae).to.not.exist;
});
- describe('when defaultForSlots is not defined', () => {
- it('imp.ext.ae should be removed if fledge is not enabled', () => {
- const imp = {ext: {ae: 1}};
- setImpExtAe(imp, {}, {bidderRequest: {}});
- expect(imp.ext.ae).to.not.exist;
- });
- it('imp.ext.ae should be left intact if fledge is enabled', () => {
- const imp = {ext: {ae: 2}};
- setImpExtAe(imp, {}, {bidderRequest: {fledgeEnabled: true}});
- expect(imp.ext.ae).to.equal(2);
- });
+ it('imp.ext.ae should be left intact if fledge is enabled', () => {
+ const imp = {ext: {ae: 2}};
+ setImpExtAe(imp, {}, {bidderRequest: {fledgeEnabled: true}});
+ expect(imp.ext.ae).to.equal(2);
});
describe('parseExtPrebidFledge', () => {
function packageConfigs(configs) {
diff --git a/test/spec/modules/freewheel-sspBidAdapter_spec.js b/test/spec/modules/freewheel-sspBidAdapter_spec.js
index c42c5e2528d..90ebe0b80ee 100644
--- a/test/spec/modules/freewheel-sspBidAdapter_spec.js
+++ b/test/spec/modules/freewheel-sspBidAdapter_spec.js
@@ -2,6 +2,7 @@ import { expect } from 'chai';
import { spec } from 'modules/freewheel-sspBidAdapter.js';
import { newBidder } from 'src/adapters/bidderFactory.js';
import { createEidsArray } from 'modules/userId/eids.js';
+import { config } from 'src/config.js';
const ENDPOINT = '//ads.stickyadstv.com/www/delivery/swfIndex.php';
const PREBID_VERSION = '$prebid.version$';
@@ -203,6 +204,14 @@ describe('freewheelSSP BidAdapter Test', () => {
let bidderRequest = {
'gdprConsent': {
'consentString': gdprConsentString
+ },
+ 'ortb2': {
+ 'site': {
+ 'content': {
+ 'test': 'news',
+ 'test2': 'param'
+ }
+ }
}
};
@@ -216,6 +225,7 @@ describe('freewheelSSP BidAdapter Test', () => {
expect(payload.playerSize).to.equal('300x600');
expect(payload._fw_gdpr_consent).to.exist.and.to.be.a('string');
expect(payload._fw_gdpr_consent).to.equal(gdprConsentString);
+ expect(payload._fw_prebid_content).to.deep.equal('{\"test\":\"news\",\"test2\":\"param\"}');
let gdprConsent = {
'gdprApplies': true,
diff --git a/test/spec/modules/gdprEnforcement_spec.js b/test/spec/modules/gdprEnforcement_spec.js
index 2880b2fac5d..295b14dd796 100644
--- a/test/spec/modules/gdprEnforcement_spec.js
+++ b/test/spec/modules/gdprEnforcement_spec.js
@@ -26,7 +26,7 @@ import * as events from 'src/events.js';
import 'modules/appnexusBidAdapter.js'; // some tests expect this to be in the adapter registry
import 'src/prebid.js';
import {hook} from '../../../src/hook.js';
-import {GDPR_GVLIDS, VENDORLESS_GVLID} from '../../../src/consentHandler.js';
+import {GDPR_GVLIDS, VENDORLESS_GVLID, FIRST_PARTY_GVLID} from '../../../src/consentHandler.js';
import {validateStorageEnforcement} from '../../../src/storageManager.js';
import {activityParams} from '../../../src/activities/activityParams.js';
@@ -789,6 +789,21 @@ describe('gdpr enforcement', function () {
})
})
+ it('if validateRules is passed FIRST_PARTY_GVLID, it will use publisher.consents', () => {
+ const rule = createGdprRule();
+ const consentData = {
+ 'vendorData': {
+ 'publisher': {
+ 'consents': {
+ '1': true
+ }
+ },
+ },
+ };
+ const result = validateRules(rule, consentData, 'cdep', FIRST_PARTY_GVLID);
+ expect(result).to.equal(true);
+ });
+
describe('validateRules', function () {
Object.entries({
'1 (which does not consider LI)': [1, 'storage', false],
diff --git a/test/spec/modules/genericAnalyticsAdapter_spec.js b/test/spec/modules/genericAnalyticsAdapter_spec.js
index a5a6074c425..79874f5d756 100644
--- a/test/spec/modules/genericAnalyticsAdapter_spec.js
+++ b/test/spec/modules/genericAnalyticsAdapter_spec.js
@@ -75,7 +75,7 @@ describe('Generic analytics', () => {
options: {
url: 'mock',
events: {
- bidResponse: null
+ mockEvent: null
}
}
});
diff --git a/test/spec/modules/goldfishAdsRtdProvider_spec.js b/test/spec/modules/goldfishAdsRtdProvider_spec.js
new file mode 100755
index 00000000000..39a1e0c9b33
--- /dev/null
+++ b/test/spec/modules/goldfishAdsRtdProvider_spec.js
@@ -0,0 +1,163 @@
+import {
+ goldfishAdsSubModule,
+ manageCallbackResponse,
+} from 'modules/goldfishAdsRtdProvider.js';
+import { getStorageManager } from '../../../src/storageManager.js';
+import { expect } from 'chai';
+import { server } from 'test/mocks/xhr.js';
+import { config as _config } from 'src/config.js';
+import { DATA_STORAGE_KEY, MODULE_NAME, MODULE_TYPE, getStorageData, updateUserData } from '../../../modules/goldfishAdsRtdProvider';
+
+const responseHeader = { 'Content-Type': 'application/json' };
+
+const sampleConfig = {
+ name: 'golfishAds',
+ waitForIt: true,
+ params: {
+ key: 'testkey'
+ }
+};
+
+const sampleAdUnits = [
+ {
+ code: 'one-div-id',
+ mediaTypes: {
+ banner: {
+ sizes: [970, 250]
+ }
+ },
+ bids: [
+ {
+ bidder: 'appnexus',
+ params: {
+ placementId: 12345370,
+ }
+ }]
+ },
+ {
+ code: 'two-div-id',
+ mediaTypes: {
+ banner: { sizes: [300, 250] }
+ },
+ bids: [
+ {
+ bidder: 'appnexus',
+ params: {
+ placementId: 12345370,
+ }
+ }]
+ }];
+
+const sampleOutputData = [1, 2, 3]
+
+describe('goldfishAdsRtdProvider is a RTD provider that', function () {
+ describe('has a method `init` that', function () {
+ it('exists', function () {
+ expect(goldfishAdsSubModule.init).to.be.a('function');
+ });
+ it('returns false missing config params', function () {
+ const config = {
+ name: 'goldfishAds',
+ waitForIt: true,
+ };
+ const value = goldfishAdsSubModule.init(config);
+ expect(value).to.equal(false);
+ });
+ it('returns false if missing providers param', function () {
+ const config = {
+ name: 'goldfishAds',
+ waitForIt: true,
+ params: {}
+ };
+ const value = goldfishAdsSubModule.init(config);
+ expect(value).to.equal(false);
+ });
+ it('returns false if wrong providers param included', function () {
+ const config = {
+ name: 'goldfishAds',
+ waitForIt: true,
+ params: {
+ account: 'test'
+ }
+ };
+ const value = goldfishAdsSubModule.init(config);
+ expect(value).to.equal(false);
+ });
+ it('returns true if good providers param included', function () {
+ const config = {
+ name: 'goldfishAds',
+ waitForIt: true,
+ params: {
+ key: 'testkey'
+ }
+ };
+ const value = goldfishAdsSubModule.init(config);
+ expect(value).to.equal(true);
+ });
+ });
+
+ describe('has a method `getBidRequestData` that', function () {
+ it('exists', function () {
+ expect(goldfishAdsSubModule.getBidRequestData).to.be.a('function');
+ });
+
+ it('send correct request', function () {
+ const callback = sinon.spy();
+ let request;
+ const reqBidsConfigObj = { adUnits: sampleAdUnits };
+ goldfishAdsSubModule.getBidRequestData(reqBidsConfigObj, callback, sampleConfig);
+ request = server.requests[0];
+ request.respond(200, responseHeader, JSON.stringify(sampleOutputData));
+ expect(request.url).to.be.include(`?key=testkey`);
+ });
+ });
+
+ describe('has a manageCallbackResponse that', function () {
+ it('properly transforms the response', function () {
+ const response = { response: '[\"1\", \"2\", \"3\"]' };
+ const output = manageCallbackResponse(response);
+ expect(output.name).to.be.equal('goldfishads.com');
+ });
+ });
+
+ describe('has an updateUserData that', function () {
+ it('properly transforms the response', function () {
+ const userData = {
+ segment: [{id: '1'}, {id: '2'}],
+ ext: {
+ segtax: 4,
+ }
+ };
+ const reqBidsConfigObj = { ortb2Fragments: { bidder: { appnexus: { user: { data: [] } } } } };
+ const output = updateUserData(userData, reqBidsConfigObj);
+ expect(output.ortb2Fragments.bidder.appnexus.user.data[0].segment).to.be.length(2);
+ expect(output.ortb2Fragments.bidder.appnexus.user.data[0].segment[0].id).to.be.eql('1');
+ });
+ });
+
+ describe('uses Local Storage to ', function () {
+ const sandbox = sinon.createSandbox();
+ const storage = getStorageManager({ moduleType: MODULE_TYPE, moduleName: MODULE_NAME })
+ beforeEach(() => {
+ storage.setDataInLocalStorage(DATA_STORAGE_KEY, JSON.stringify({
+ targeting: {
+ name: 'goldfishads.com',
+ segment: [{id: '1'}, {id: '2'}],
+ ext: {
+ segtax: 4,
+ }
+ },
+ expiry: new Date().getTime() + 1000 * 60 * 60 * 24 * 30,
+ }));
+ });
+ afterEach(() => {
+ sandbox.restore();
+ });
+ it('get data from local storage', function () {
+ const output = getStorageData();
+ expect(output.name).to.be.equal('goldfishads.com');
+ expect(output.segment).to.be.length(2);
+ expect(output.ext.segtax).to.be.equal(4);
+ });
+ });
+});
diff --git a/test/spec/modules/gridBidAdapter_spec.js b/test/spec/modules/gridBidAdapter_spec.js
index b12083236a2..0611fa68bf8 100644
--- a/test/spec/modules/gridBidAdapter_spec.js
+++ b/test/spec/modules/gridBidAdapter_spec.js
@@ -1559,37 +1559,9 @@ describe('TheMediaGrid Adapter', function () {
});
it('should send right request on onDataDeletionRequest call', function() {
- spec.onDataDeletionRequest([{
- bids: [
- {
- bidder: 'grid',
- params: {
- uid: 1
- }
- },
- {
- bidder: 'grid',
- params: {
- uid: 2
- }
- },
- {
- bidder: 'another',
- params: {
- uid: 3
- }
- },
- {
- bidder: 'gridNM',
- params: {
- uid: 4
- }
- }
- ],
- }]);
+ spec.onDataDeletionRequest([{}]);
expect(ajaxStub.calledOnce).to.equal(true);
- expect(ajaxStub.firstCall.args[0]).to.equal('https://media.grid.bidswitch.net/uspapi_delete');
- expect(ajaxStub.firstCall.args[2]).to.equal('{"uids":[1,2,4]}');
+ expect(ajaxStub.firstCall.args[0]).to.equal('https://media.grid.bidswitch.net/uspapi_delete_c2s');
});
});
diff --git a/test/spec/modules/gumgumBidAdapter_spec.js b/test/spec/modules/gumgumBidAdapter_spec.js
index 56c89d329dc..f541a69abe8 100644
--- a/test/spec/modules/gumgumBidAdapter_spec.js
+++ b/test/spec/modules/gumgumBidAdapter_spec.js
@@ -181,6 +181,7 @@ describe('gumgumAdapter', function () {
linearity: 1,
startdelay: 1,
placement: 123456,
+ plcmt: 3,
protocols: [1, 2]
}
};
@@ -457,6 +458,7 @@ describe('gumgumAdapter', function () {
linearity: 1,
startdelay: 1,
placement: 123456,
+ plcmt: 3,
protocols: [1, 2]
};
const request = Object.assign({}, bidRequests[0]);
@@ -475,6 +477,7 @@ describe('gumgumAdapter', function () {
expect(bidRequest.data.li).to.eq(videoVals.linearity);
expect(bidRequest.data.sd).to.eq(videoVals.startdelay);
expect(bidRequest.data.pt).to.eq(videoVals.placement);
+ expect(bidRequest.data.vplcmt).to.eq(videoVals.plcmt);
expect(bidRequest.data.pr).to.eq(videoVals.protocols.join(','));
expect(bidRequest.data.viw).to.eq(videoVals.playerSize[0].toString());
expect(bidRequest.data.vih).to.eq(videoVals.playerSize[1].toString());
@@ -488,6 +491,7 @@ describe('gumgumAdapter', function () {
linearity: 1,
startdelay: 1,
placement: 123456,
+ plcmt: 3,
protocols: [1, 2]
};
const request = Object.assign({}, bidRequests[0]);
@@ -506,6 +510,7 @@ describe('gumgumAdapter', function () {
expect(bidRequest.data.li).to.eq(inVideoVals.linearity);
expect(bidRequest.data.sd).to.eq(inVideoVals.startdelay);
expect(bidRequest.data.pt).to.eq(inVideoVals.placement);
+ expect(bidRequest.data.vplcmt).to.eq(inVideoVals.plcmt);
expect(bidRequest.data.pr).to.eq(inVideoVals.protocols.join(','));
expect(bidRequest.data.viw).to.eq(inVideoVals.playerSize[0].toString());
expect(bidRequest.data.vih).to.eq(inVideoVals.playerSize[1].toString());
diff --git a/test/spec/modules/identityLinkIdSystem_spec.js b/test/spec/modules/identityLinkIdSystem_spec.js
index a273f26b28b..f1c2773de07 100644
--- a/test/spec/modules/identityLinkIdSystem_spec.js
+++ b/test/spec/modules/identityLinkIdSystem_spec.js
@@ -3,6 +3,7 @@ import * as utils from 'src/utils.js';
import {server} from 'test/mocks/xhr.js';
import {getCoreStorageManager} from '../../../src/storageManager.js';
import {stub} from 'sinon';
+import { gppDataHandler } from '../../../src/adapterManager.js';
const storage = getCoreStorageManager();
@@ -20,6 +21,7 @@ function setTestEnvelopeCookie () {
describe('IdentityLinkId tests', function () {
let logErrorStub;
+ let gppConsentDataStub;
beforeEach(function () {
defaultConfigParams = { params: {pid: pid} };
@@ -112,6 +114,48 @@ describe('IdentityLinkId tests', function () {
expect(callBackSpy.calledOnce).to.be.true;
});
+ it('should call the LiveRamp envelope endpoint with GPP consent string', function() {
+ gppConsentDataStub = sinon.stub(gppDataHandler, 'getConsentData');
+ gppConsentDataStub.returns({
+ ready: true,
+ gppString: 'DBABLA~BVVqAAAACqA.QA',
+ applicableSections: [7]
+ });
+ let callBackSpy = sinon.spy();
+ let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback;
+ submoduleCallback(callBackSpy);
+ let request = server.requests[0];
+ expect(request.url).to.be.eq('https://api.rlcdn.com/api/identity/envelope?pid=14&gpp=DBABLA~BVVqAAAACqA.QA&gpp_sid=7');
+ request.respond(
+ 200,
+ responseHeader,
+ JSON.stringify({})
+ );
+ expect(callBackSpy.calledOnce).to.be.true;
+ gppConsentDataStub.restore();
+ });
+
+ it('should call the LiveRamp envelope endpoint without GPP consent string if consent string is not provided', function () {
+ gppConsentDataStub = sinon.stub(gppDataHandler, 'getConsentData');
+ gppConsentDataStub.returns({
+ ready: true,
+ gppString: '',
+ applicableSections: [7]
+ });
+ let callBackSpy = sinon.spy();
+ let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback;
+ submoduleCallback(callBackSpy);
+ let request = server.requests[0];
+ expect(request.url).to.be.eq('https://api.rlcdn.com/api/identity/envelope?pid=14');
+ request.respond(
+ 200,
+ responseHeader,
+ JSON.stringify({})
+ );
+ expect(callBackSpy.calledOnce).to.be.true;
+ gppConsentDataStub.restore();
+ });
+
it('should not throw Uncaught TypeError when envelope endpoint returns empty response', function () {
let callBackSpy = sinon.spy();
let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback;
diff --git a/test/spec/modules/impactifyBidAdapter_spec.js b/test/spec/modules/impactifyBidAdapter_spec.js
index 215972ff450..d9bf4becb22 100644
--- a/test/spec/modules/impactifyBidAdapter_spec.js
+++ b/test/spec/modules/impactifyBidAdapter_spec.js
@@ -1,6 +1,7 @@
import { expect } from 'chai';
-import { spec } from 'modules/impactifyBidAdapter.js';
+import { spec, STORAGE, STORAGE_KEY } from 'modules/impactifyBidAdapter.js';
import * as utils from 'src/utils.js';
+import sinon from 'sinon';
const BIDDER_CODE = 'impactify';
const BIDDER_ALIAS = ['imp'];
@@ -19,89 +20,202 @@ var gdprData = {
};
describe('ImpactifyAdapter', function () {
+ let getLocalStorageStub;
+ let localStorageIsEnabledStub;
+ let sandbox;
+
+ beforeEach(function () {
+ $$PREBID_GLOBAL$$.bidderSettings = {
+ impactify: {
+ storageAllowed: true
+ }
+ };
+ sinon.stub(document.body, 'appendChild');
+ sandbox = sinon.sandbox.create();
+ getLocalStorageStub = sandbox.stub(STORAGE, 'getDataFromLocalStorage');
+ localStorageIsEnabledStub = sandbox.stub(STORAGE, 'localStorageIsEnabled');
+ });
+
+ afterEach(function () {
+ $$PREBID_GLOBAL$$.bidderSettings = {};
+ document.body.appendChild.restore();
+ sandbox.restore();
+ });
+
describe('isBidRequestValid', function () {
- let validBid = {
- bidder: 'impactify',
- params: {
- appId: '1',
- format: 'screen',
- style: 'inline'
+ let validBids = [
+ {
+ bidder: 'impactify',
+ params: {
+ appId: 'example.com',
+ format: 'screen',
+ style: 'inline'
+ }
+ },
+ {
+ bidder: 'impactify',
+ params: {
+ appId: 'example.com',
+ format: 'display',
+ style: 'static'
+ }
+ }
+ ];
+
+ let videoBidRequests = [
+ {
+ bidder: 'impactify',
+ params: {
+ appId: '1',
+ format: 'screen',
+ style: 'inline'
+ },
+ mediaTypes: {
+ video: {
+ context: 'instream'
+ }
+ },
+ adUnitCode: 'adunit-code',
+ sizes: [[DEFAULT_VIDEO_WIDTH, DEFAULT_VIDEO_HEIGHT]],
+ bidId: '123456789',
+ bidderRequestId: '987654321',
+ auctionId: '19ab94a9-b0d7-4ed7-9f80-ad0c033cf1b1',
+ transactionId: 'f7b2c372-7a7b-11eb-9439-0242ac130002',
+ userId: {
+ pubcid: '87a0327b-851c-4bb3-a925-0c7be94548f5'
+ },
+ userIdAsEids: [
+ {
+ source: 'pubcid.org',
+ uids: [
+ {
+ id: '87a0327b-851c-4bb3-a925-0c7be94548f5',
+ atype: 1
+ }
+ ]
+ }
+ ]
+ }
+ ];
+ let videoBidderRequest = {
+ bidderRequestId: '98845765110',
+ auctionId: '165410516454',
+ bidderCode: 'impactify',
+ bids: [
+ {
+ ...videoBidRequests[0]
+ }
+ ],
+ refererInfo: {
+ referer: 'https://impactify.io'
}
};
it('should return true when required params found', function () {
- expect(spec.isBidRequestValid(validBid)).to.equal(true);
+ expect(spec.isBidRequestValid(validBids[0])).to.equal(true);
+ expect(spec.isBidRequestValid(validBids[1])).to.equal(true);
});
it('should return false when required params are not passed', function () {
- let bid = Object.assign({}, validBid);
+ let bid = Object.assign({}, validBids[0]);
delete bid.params;
bid.params = {};
expect(spec.isBidRequestValid(bid)).to.equal(false);
+
+ let bid2 = Object.assign({}, validBids[1]);
+ delete bid2.params;
+ bid2.params = {};
+ expect(spec.isBidRequestValid(bid2)).to.equal(false);
});
it('should return false when appId is missing', () => {
- const bid = utils.deepClone(validBid);
+ const bid = utils.deepClone(validBids[0]);
delete bid.params.appId;
-
expect(spec.isBidRequestValid(bid)).to.equal(false);
+
+ const bid2 = utils.deepClone(validBids[1]);
+ delete bid2.params.appId;
+ expect(spec.isBidRequestValid(bid2)).to.equal(false);
});
it('should return false when appId is not a string', () => {
- const bid = utils.deepClone(validBid);
+ const bid = utils.deepClone(validBids[0]);
+ const bid2 = utils.deepClone(validBids[1]);
bid.params.appId = 123;
+ bid2.params.appId = 123;
expect(spec.isBidRequestValid(bid)).to.equal(false);
+ expect(spec.isBidRequestValid(bid2)).to.equal(false);
bid.params.appId = false;
+ bid2.params.appId = false;
expect(spec.isBidRequestValid(bid)).to.equal(false);
+ expect(spec.isBidRequestValid(bid2)).to.equal(false);
bid.params.appId = void (0);
+ bid2.params.appId = void (0);
expect(spec.isBidRequestValid(bid)).to.equal(false);
+ expect(spec.isBidRequestValid(bid2)).to.equal(false);
bid.params.appId = {};
+ bid2.params.appId = {};
expect(spec.isBidRequestValid(bid)).to.equal(false);
+ expect(spec.isBidRequestValid(bid2)).to.equal(false);
});
it('should return false when format is missing', () => {
- const bid = utils.deepClone(validBid);
+ const bid = utils.deepClone(validBids[0]);
delete bid.params.format;
expect(spec.isBidRequestValid(bid)).to.equal(false);
});
it('should return false when format is not a string', () => {
- const bid = utils.deepClone(validBid);
+ const bid = utils.deepClone(validBids[0]);
+ const bid2 = utils.deepClone(validBids[1]);
bid.params.format = 123;
+ bid2.params.format = 123;
+ expect(spec.isBidRequestValid(bid)).to.equal(false);
expect(spec.isBidRequestValid(bid)).to.equal(false);
bid.params.format = false;
+ bid2.params.format = false;
expect(spec.isBidRequestValid(bid)).to.equal(false);
+ expect(spec.isBidRequestValid(bid2)).to.equal(false);
bid.params.format = void (0);
+ bid2.params.format = void (0);
expect(spec.isBidRequestValid(bid)).to.equal(false);
+ expect(spec.isBidRequestValid(bid2)).to.equal(false);
bid.params.format = {};
+ bid2.params.format = {};
expect(spec.isBidRequestValid(bid)).to.equal(false);
+ expect(spec.isBidRequestValid(bid2)).to.equal(false);
});
it('should return false when format is not equals to screen or display', () => {
- const bid = utils.deepClone(validBid);
+ const bid = utils.deepClone(validBids[0]);
if (bid.params.format != 'screen' && bid.params.format != 'display') {
expect(spec.isBidRequestValid(bid)).to.equal(false);
}
+
+ const bid2 = utils.deepClone(validBids[1]);
+ if (bid2.params.format != 'screen' && bid2.params.format != 'display') {
+ expect(spec.isBidRequestValid(bid2)).to.equal(false);
+ }
});
it('should return false when style is missing', () => {
- const bid = utils.deepClone(validBid);
+ const bid = utils.deepClone(validBids[0]);
delete bid.params.style;
expect(spec.isBidRequestValid(bid)).to.equal(false);
});
it('should return false when style is not a string', () => {
- const bid = utils.deepClone(validBid);
+ const bid = utils.deepClone(validBids[0]);
bid.params.style = 123;
expect(spec.isBidRequestValid(bid)).to.equal(false);
@@ -167,22 +281,44 @@ describe('ImpactifyAdapter', function () {
};
it('should pass bidfloor', function () {
- videoBidRequests[0].getFloor = function() {
+ videoBidRequests[0].getFloor = function () {
return {
currency: 'USD',
floor: 1.23,
}
}
- const res = spec.buildRequests(videoBidRequests, videoBidderRequest)
+ const res = spec.buildRequests(videoBidRequests, videoBidderRequest);
const resData = JSON.parse(res.data)
expect(resData.imp[0].bidfloor).to.equal(1.23)
});
it('sends video bid request to ENDPOINT via POST', function () {
+ localStorageIsEnabledStub.returns(true);
+
+ getLocalStorageStub.returns('testValue');
+
const request = spec.buildRequests(videoBidRequests, videoBidderRequest);
+
expect(request.url).to.equal(ORIGIN + AUCTIONURI);
expect(request.method).to.equal('POST');
+ expect(request.options.customHeaders['x-impact']).to.equal('testValue');
+ });
+
+ it('should set header value from localstorage correctly', function () {
+ localStorageIsEnabledStub.returns(true);
+ getLocalStorageStub.returns('testValue');
+
+ const request = spec.buildRequests(videoBidRequests, videoBidderRequest);
+ expect(request.options.customHeaders).to.be.an('object');
+ expect(request.options.customHeaders['x-impact']).to.equal('testValue');
+ });
+
+ it('should set header value to empty if localstorage is not enabled', function () {
+ localStorageIsEnabledStub.returns(false);
+
+ const request = spec.buildRequests(videoBidRequests, videoBidderRequest);
+ expect(request.options.customHeaders).to.be.undefined;
});
});
describe('interpretResponse', function () {
@@ -205,7 +341,7 @@ describe('ImpactifyAdapter', function () {
h: 1,
hash: 'test',
expiry: 166192938,
- meta: {'advertiserDomains': ['testdomain.com']},
+ meta: { 'advertiserDomains': ['testdomain.com'] },
ext: {
prebid: {
'type': 'video'
@@ -281,7 +417,7 @@ describe('ImpactifyAdapter', function () {
height: 1,
hash: 'test',
expiry: 166192938,
- meta: {'advertiserDomains': ['testdomain.com']},
+ meta: { 'advertiserDomains': ['testdomain.com'] },
ttl: 300,
creativeId: '97517771'
}
@@ -343,7 +479,7 @@ describe('ImpactifyAdapter', function () {
h: 1,
hash: 'test',
expiry: 166192938,
- meta: {'advertiserDomains': ['testdomain.com']},
+ meta: { 'advertiserDomains': ['testdomain.com'] },
ext: {
prebid: {
'type': 'video'
@@ -399,8 +535,8 @@ describe('ImpactifyAdapter', function () {
const result = spec.getUserSyncs('bad', [], gdprData);
expect(result).to.be.empty;
});
- it('should append the various values if they exist', function() {
- const result = spec.getUserSyncs({iframeEnabled: true}, validResponse, gdprData);
+ it('should append the various values if they exist', function () {
+ const result = spec.getUserSyncs({ iframeEnabled: true }, validResponse, gdprData);
expect(result[0].url).to.include('gdpr=1');
expect(result[0].url).to.include('gdpr_consent=BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA');
});
diff --git a/test/spec/modules/improvedigitalBidAdapter_spec.js b/test/spec/modules/improvedigitalBidAdapter_spec.js
index f427f9e7624..a86b9be73e6 100644
--- a/test/spec/modules/improvedigitalBidAdapter_spec.js
+++ b/test/spec/modules/improvedigitalBidAdapter_spec.js
@@ -1181,6 +1181,16 @@ describe('Improve Digital Adapter Tests', function () {
expect(bids[0].dealId).to.equal(268515);
});
+ it('should set deal type targeting KV for PG', function () {
+ const request = makeRequest(bidderRequest);
+ const response = deepClone(serverResponse);
+ let bids;
+
+ response.body.seatbid[0].bid[0].ext.improvedigital.pg = 1;
+ bids = spec.interpretResponse(response, request);
+ expect(bids[0].adserverTargeting.hb_deal_type_improve).to.equal('pg');
+ });
+
it('should set currency', function () {
const response = deepClone(serverResponse);
response.body.cur = 'EUR';
diff --git a/test/spec/modules/ixBidAdapter_spec.js b/test/spec/modules/ixBidAdapter_spec.js
index eb87f51b6f9..500f2239e55 100644
--- a/test/spec/modules/ixBidAdapter_spec.js
+++ b/test/spec/modules/ixBidAdapter_spec.js
@@ -832,6 +832,8 @@ describe('IndexexchangeAdapter', function () {
id5id: { uid: 'testid5id' }, // ID5
imuid: 'testimuid',
'33acrossId': { envelope: 'v1.5fs.1000.fjdiosmclds' },
+ 'criteoID': { envelope: 'testcriteoID' },
+ 'euidID': { envelope: 'testeuid' },
pairId: {envelope: 'testpairId'}
};
@@ -891,6 +893,16 @@ describe('IndexexchangeAdapter', function () {
uids: [{
id: DEFAULT_USERID_DATA['33acrossId'].envelope
}]
+ }, {
+ source: 'criteo.com',
+ uids: [{
+ id: DEFAULT_USERID_DATA['criteoID'].envelope
+ }]
+ }, {
+ source: 'euid.eu',
+ uids: [{
+ id: DEFAULT_USERID_DATA['euidID'].envelope
+ }]
}, {
source: 'google.com',
uids: [{
@@ -1302,7 +1314,7 @@ describe('IndexexchangeAdapter', function () {
const payload = extractPayload(request[0]);
expect(request).to.be.an('array');
expect(request).to.have.lengthOf.above(0); // should be 1 or more
- expect(payload.user.eids).to.have.lengthOf(9);
+ expect(payload.user.eids).to.have.lengthOf(11);
expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[0]);
});
});
@@ -1490,7 +1502,7 @@ describe('IndexexchangeAdapter', function () {
cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA);
const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0];
const payload = extractPayload(request);
- expect(payload.user.eids).to.have.lengthOf(9);
+ expect(payload.user.eids).to.have.lengthOf(11);
expect(payload.user.eids).to.have.deep.members(DEFAULT_USERID_PAYLOAD);
});
@@ -1623,7 +1635,7 @@ describe('IndexexchangeAdapter', function () {
})
expect(payload.user).to.exist;
- expect(payload.user.eids).to.have.lengthOf(11);
+ expect(payload.user.eids).to.have.lengthOf(13);
expect(payload.user.eids).to.have.deep.members(validUserIdPayload);
});
@@ -1665,7 +1677,7 @@ describe('IndexexchangeAdapter', function () {
});
const payload = extractPayload(request);
- expect(payload.user.eids).to.have.lengthOf(10);
+ expect(payload.user.eids).to.have.lengthOf(12);
expect(payload.user.eids).to.have.deep.members(validUserIdPayload);
});
});
@@ -3283,6 +3295,84 @@ describe('IndexexchangeAdapter', function () {
});
});
+ describe('integration through exchangeId and externalId', function () {
+ const expectedExchangeId = 123456;
+ // create banner bids with externalId but no siteId as bidder param
+ const bannerBids = utils.deepClone(DEFAULT_BANNER_VALID_BID);
+ delete bannerBids[0].params.siteId;
+ bannerBids[0].params.externalId = 'exteranl_id_1';
+
+ beforeEach(() => {
+ config.setConfig({ exchangeId: expectedExchangeId });
+ spec.resetSiteID();
+ });
+
+ afterEach(() => {
+ config.resetConfig();
+ });
+
+ it('when exchangeId and externalId set but no siteId, isBidRequestValid should return true', function () {
+ const bid = utils.deepClone(bannerBids[0]);
+ expect(spec.isBidRequestValid(bid)).to.equal(true);
+ });
+
+ it('when neither exchangeId nor siteId set, isBidRequestValid should return false', function () {
+ config.resetConfig();
+ const bid = utils.deepClone(bannerBids[0]);
+ expect(spec.isBidRequestValid(bid)).to.equal(false);
+ });
+
+ it('when exchangeId and externalId set with banner impression but no siteId, bidrequest sent to endpoint with p param and externalID inside imp.ext', function () {
+ const requests = spec.buildRequests(bannerBids, DEFAULT_OPTION);
+ const payload = extractPayload(requests[0]);
+
+ const expectedURL = IX_SECURE_ENDPOINT + '?p=' + expectedExchangeId;
+ expect(requests[0].url).to.equal(expectedURL);
+ expect(payload.imp[0].ext.externalID).to.equal(bannerBids[0].params.externalId);
+ expect(payload.imp[0].banner.format[0].ext).to.be.undefined;
+ expect(payload.imp[0].ext.siteID).to.be.undefined;
+ });
+
+ it('when exchangeId and externalId set with video impression, bidrequest sent to endpoint with p param and externalID inside imp.ext', function () {
+ const validBids = utils.deepClone(DEFAULT_VIDEO_VALID_BID);
+ delete validBids[0].params.siteId;
+ validBids[0].params.externalId = 'exteranl_id_1';
+
+ const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
+ const payload = extractPayload(requests[0]);
+
+ const expectedURL = IX_SECURE_ENDPOINT + '?p=' + expectedExchangeId;
+ expect(requests[0].url).to.equal(expectedURL);
+ expect(payload.imp[0].ext.externalID).to.equal(validBids[0].params.externalId);
+ expect(payload.imp[0].ext.siteID).to.be.undefined;
+ });
+
+ it('when exchangeId and externalId set beside siteId, bidrequest sent to endpoint with both p param and s param and externalID inside imp.ext and siteID inside imp.banner.format.ext', function () {
+ bannerBids[0].params.siteId = '1234';
+ const requests = spec.buildRequests(bannerBids, DEFAULT_OPTION);
+ const payload = extractPayload(requests[0]);
+
+ const expectedURL = IX_SECURE_ENDPOINT + '?s=' + bannerBids[0].params.siteId + '&p=' + expectedExchangeId;
+ expect(requests[0].url).to.equal(expectedURL);
+ expect(payload.imp[0].ext.externalID).to.equal(bannerBids[0].params.externalId);
+ expect(payload.imp[0].banner.format[0].ext.externalID).to.be.undefined;
+ expect(payload.imp[0].ext.siteID).to.be.undefined;
+ expect(payload.imp[0].banner.format[0].ext.siteID).to.equal(bannerBids[0].params.siteId);
+ });
+
+ it('when exchangeId and siteId set, but no externalId, bidrequest sent to exchange', function () {
+ bannerBids[0].params.siteId = '1234';
+ delete bannerBids[0].params.externalId;
+ const requests = spec.buildRequests(bannerBids, DEFAULT_OPTION);
+ const payload = extractPayload(requests[0]);
+
+ const expectedURL = IX_SECURE_ENDPOINT + '?s=' + bannerBids[0].params.siteId + '&p=' + expectedExchangeId;
+ expect(requests[0].url).to.equal(expectedURL);
+ expect(payload.imp[0].ext.externalID).to.be.undefined;
+ expect(payload.imp[0].banner.format[0].ext.siteID).to.equal(bannerBids[0].params.siteId);
+ });
+ });
+
describe('interpretResponse', function () {
// generate bidderRequest with real buildRequest logic for intepretResponse testing
let bannerBidderRequest
diff --git a/test/spec/modules/jixieBidAdapter_spec.js b/test/spec/modules/jixieBidAdapter_spec.js
index fd0d7e8a033..fa7618814f8 100644
--- a/test/spec/modules/jixieBidAdapter_spec.js
+++ b/test/spec/modules/jixieBidAdapter_spec.js
@@ -76,8 +76,11 @@ describe('jixie Adapter', function () {
const jxifoTest1_ = 'fffffbbbbbcccccaaaaae890606aaaaa';
const jxtdidTest1_ = '222223d1-1111-2222-3333-b9f129299999';
const jxcompTest1_ = 'AAAAABBBBBCCCCCDDDDDEEEEEUkkZPQfifpkPnnlJhtsa4o+gf4nfqgN5qHiTVX73ymTSbLT9jz1nf+Q7QdxNh9nTad9UaN5pzfHMt/rs1woQw72c1ip+8heZXPfKGZtZP7ldJesYhlo3/0FVcL/wl9ZlAo1jYOEfHo7Y9zFzNXABbbbbb==';
-
+ const ckname1Val_ = 'ckckname1';
+ const ckname2Val_ = 'ckckname2';
const refJxEids_ = {
+ 'pubid1': ckname1Val_,
+ 'pubid2': ckname2Val_,
'_jxtoko': jxtokoTest1_,
'_jxifo': jxifoTest1_,
'_jxtdid': jxtdidTest1_,
@@ -206,6 +209,17 @@ describe('jixie Adapter', function () {
}
];
+ const testJixieCfg_ = {
+ genids: [
+ { id: 'pubid1', ck: 'ckname1' },
+ { id: 'pubid2', ck: 'ckname2' },
+ { id: '_jxtoko' },
+ { id: '_jxifo' },
+ { id: '_jxtdid' },
+ { id: '_jxcomp' }
+ ]
+ };
+
it('should attach valid params to the adserver endpoint (1)', function () {
// this one we do not intercept the cookie stuff so really don't know
// what will be in there. so we do not check here (using expect)
@@ -216,7 +230,6 @@ describe('jixie Adapter', function () {
})
expect(request.data).to.be.an('string');
const payload = JSON.parse(request.data);
- expect(payload).to.have.property('auctionid', auctionId_);
expect(payload).to.have.property('timeout', timeout_);
expect(payload).to.have.property('currency', currency_);
expect(payload).to.have.property('bids').that.deep.equals(refBids_);
@@ -226,8 +239,25 @@ describe('jixie Adapter', function () {
// similar to above test case but here we force some clientid sessionid values
// and domain, pageurl
// get the interceptors ready:
+ let getConfigStub = sinon.stub(config, 'getConfig');
+ getConfigStub.callsFake(function fakeFn(prop) {
+ if (prop == 'jixie') {
+ return testJixieCfg_;
+ }
+ return null;
+ });
+
let getCookieStub = sinon.stub(storage, 'getCookie');
let getLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage');
+ getCookieStub
+ .withArgs('ckname1')
+ .returns(ckname1Val_);
+ getCookieStub
+ .withArgs('ckname2')
+ .returns(ckname2Val_);
+ getCookieStub
+ .withArgs('_jxtoko')
+ .returns(jxtokoTest1_);
getCookieStub
.withArgs('_jxtoko')
.returns(jxtokoTest1_);
@@ -265,7 +295,6 @@ describe('jixie Adapter', function () {
expect(request.data).to.be.an('string');
const payload = JSON.parse(request.data);
- expect(payload).to.have.property('auctionid', auctionId_);
expect(payload).to.have.property('client_id_c', clientIdTest1_);
expect(payload).to.have.property('client_id_ls', clientIdTest1_);
expect(payload).to.have.property('session_id_c', sessionIdTest1_);
@@ -282,6 +311,7 @@ describe('jixie Adapter', function () {
// unwire interceptors
getCookieStub.restore();
getLocalStorageStub.restore();
+ getConfigStub.restore();
miscDimsStub.restore();
});// it
@@ -362,6 +392,27 @@ describe('jixie Adapter', function () {
expect(payload.bids[0].bidFloor).to.exist.and.to.equal(2.1);
});
+ it('it should populate the aid field when available', function () {
+ let oneSpecialBidReq = deepClone(bidRequests_[0]);
+ // 1 aid is not set in the jixie config
+ let request = spec.buildRequests([oneSpecialBidReq], bidderRequest_);
+ let payload = JSON.parse(request.data);
+ expect(payload.aid).to.eql('');
+
+ // 2 aid is set in the jixie config
+ let getConfigStub = sinon.stub(config, 'getConfig');
+ getConfigStub.callsFake(function fakeFn(prop) {
+ if (prop == 'jixie') {
+ return { aid: '11223344556677889900' };
+ }
+ return null;
+ });
+ request = spec.buildRequests([oneSpecialBidReq], bidderRequest_);
+ payload = JSON.parse(request.data);
+ expect(payload.aid).to.exist.and.to.equal('11223344556677889900');
+ getConfigStub.restore();
+ });
+
it('should populate eids when supported userIds are available', function () {
const oneSpecialBidReq = Object.assign({}, bidRequests_[0], {
userIdAsEids: [
@@ -425,7 +476,6 @@ describe('jixie Adapter', function () {
'bids': [
// video (vast tag url) returned here
{
- 'trackingUrlBase': 'https://traid.jixie.io/sync/ad?',
'jxBidId': '62847e4c696edcb-028d5dee-2c83-44e3-bed1-b75002475cdf',
'requestId': '62847e4c696edcb',
'cpm': 2.19,
@@ -458,7 +508,6 @@ describe('jixie Adapter', function () {
// display ad returned here: This one there is advertiserDomains
// in the response . Will be checked in the unit tests below
{
- 'trackingUrlBase': 'https://traid.jixie.io/sync/ad?',
'jxBidId': '600c9ae6fda1acb-028d5dee-2c83-44e3-bed1-b75002475cdf',
'requestId': '600c9ae6fda1acb',
'cpm': 1.999,
@@ -495,7 +544,6 @@ describe('jixie Adapter', function () {
},
// outstream, jx non-default renderer specified:
{
- 'trackingUrlBase': 'https://traid.jixie.io/sync/ad?',
'jxBidId': '99bc539c81b00ce-028d5dee-2c83-44e3-bed1-b75002475cdf',
'requestId': '99bc539c81b00ce',
'cpm': 2.99,
@@ -514,7 +562,6 @@ describe('jixie Adapter', function () {
},
// outstream, jx default renderer:
{
- 'trackingUrlBase': 'https://traid.jixie.io/sync/ad?',
'jxBidId': '61bc539c81b00ce-028d5dee-2c83-44e3-bed1-b75002475cdf',
'requestId': '61bc539c81b00ce',
'cpm': 1.99,
@@ -585,7 +632,6 @@ describe('jixie Adapter', function () {
expect(result[0].netRevenue).to.equal(true)
expect(result[0].ttl).to.equal(300)
expect(result[0].vastUrl).to.include('https://ad.jixie.io/v1/video?creativeid=')
- expect(result[0].trackingUrlBase).to.include('sync')
// We will always make sure the meta->advertiserDomains property is there
// If no info it is an empty array.
expect(result[0].meta.advertiserDomains.length).to.equal(0)
@@ -601,7 +647,6 @@ describe('jixie Adapter', function () {
expect(result[1].ttl).to.equal(300)
expect(result[1].ad).to.include('jxoutstream')
expect(result[1].meta.advertiserDomains.length).to.equal(3)
- expect(result[1].trackingUrlBase).to.include('sync')
// should pick up about using alternative outstream renderer
expect(result[2].requestId).to.equal('99bc539c81b00ce')
@@ -613,7 +658,6 @@ describe('jixie Adapter', function () {
expect(result[2].netRevenue).to.equal(true)
expect(result[2].ttl).to.equal(300)
expect(result[2].vastXml).to.include('')
- expect(result[2].trackingUrlBase).to.include('sync');
expect(result[2].renderer.id).to.equal('demoslot4-div')
expect(result[2].meta.advertiserDomains.length).to.equal(0)
expect(result[2].renderer.url).to.equal(JX_OTHER_OUTSTREAM_RENDERER_URL);
@@ -628,7 +672,6 @@ describe('jixie Adapter', function () {
expect(result[3].netRevenue).to.equal(true)
expect(result[3].ttl).to.equal(300)
expect(result[3].vastXml).to.include('')
- expect(result[3].trackingUrlBase).to.include('sync');
expect(result[3].renderer.id).to.equal('demoslot2-div')
expect(result[3].meta.advertiserDomains.length).to.equal(0)
expect(result[3].renderer.url).to.equal(JX_OUTSTREAM_RENDERER_URL)
@@ -663,116 +706,5 @@ describe('jixie Adapter', function () {
spec.onBidWon({ trackingUrl: TRACKINGURL_ })
expect(jixieaux.ajax.calledWith(TRACKINGURL_)).to.equal(true);
})
-
- it('Should not fire if the adserver response indicates no firing', function() {
- let called = false;
- ajaxStub.callsFake(function fakeFn() {
- called = true;
- });
- spec.onBidWon({ notrack: 1 })
- expect(called).to.equal(false);
- });
-
- // A reference to check again:
- const QPARAMS_ = {
- action: 'hbbidwon',
- device: device_,
- pageurl: encodeURIComponent(pageurl_),
- domain: encodeURIComponent(domain_),
- cid: 121,
- cpid: 99,
- jxbidid: '62847e4c696edcb-028d5dee-2c83-44e3-bed1-b75002475cdf',
- auctionid: '028d5dee-2c83-44e3-bed1-b75002475cdf',
- cpm: 1.11,
- requestid: '62847e4c696edcb'
- };
-
- it('check it is sending the correct ajax url and qparameters', function() {
- spec.onBidWon({
- trackingUrlBase: 'https://mytracker.com/sync?',
- cid: 121,
- cpid: 99,
- jxBidId: '62847e4c696edcb-028d5dee-2c83-44e3-bed1-b75002475cdf',
- auctionId: '028d5dee-2c83-44e3-bed1-b75002475cdf',
- cpm: 1.11,
- requestId: '62847e4c696edcb'
- })
- expect(jixieaux.ajax.calledWith('https://mytracker.com/sync?', null, QPARAMS_)).to.equal(true);
- });
}); // describe
-
- /**
- * onTimeout
- */
- describe('onTimeout', function() {
- let ajaxStub;
- let miscDimsStub;
- beforeEach(function() {
- ajaxStub = sinon.stub(jixieaux, 'ajax');
- miscDimsStub = sinon.stub(jixieaux, 'getMiscDims');
- miscDimsStub
- .returns({ device: device_, pageurl: pageurl_, domain: domain_, mkeywords: keywords_ });
- })
-
- afterEach(function() {
- miscDimsStub.restore();
- ajaxStub.restore();
- })
-
- // reference to check against:
- const QPARAMS_ = {
- action: 'hbtimeout',
- device: device_,
- pageurl: encodeURIComponent(pageurl_),
- domain: encodeURIComponent(domain_),
- auctionid: '028d5dee-2c83-44e3-bed1-b75002475cdf',
- timeout: 1000,
- count: 2
- };
-
- it('check it is sending the correct ajax url and qparameters', function() {
- spec.onTimeout([
- {auctionId: '028d5dee-2c83-44e3-bed1-b75002475cdf', timeout: 1000},
- {auctionId: '028d5dee-2c83-44e3-bed1-b75002475cdf', timeout: 1000}
- ])
- expect(jixieaux.ajax.calledWith(spec.EVENTS_URL, null, QPARAMS_)).to.equal(true);
- })
-
- it('if turned off via config then dont do onTimeout sending of event', function() {
- let getConfigStub = sinon.stub(config, 'getConfig');
- getConfigStub.callsFake(function fakeFn(prop) {
- if (prop == 'jixie') {
- return { onTimeout: 'off' };
- }
- return null;
- });
- let called = false;
- ajaxStub.callsFake(function fakeFn() {
- called = true;
- });
- spec.onTimeout([
- {auctionId: '028d5dee-2c83-44e3-bed1-b75002475cdf', timeout: 1000},
- {auctionId: '028d5dee-2c83-44e3-bed1-b75002475cdf', timeout: 1000}
- ])
- expect(called).to.equal(false);
- getConfigStub.restore();
- })
-
- const otherUrl_ = 'https://other.azurewebsites.net/sync/evt?';
- it('if config specifies a different endpoint then should send there instead', function() {
- let getConfigStub = sinon.stub(config, 'getConfig');
- getConfigStub.callsFake(function fakeFn(prop) {
- if (prop == 'jixie') {
- return { onTimeoutUrl: otherUrl_ };
- }
- return null;
- });
- spec.onTimeout([
- {auctionId: '028d5dee-2c83-44e3-bed1-b75002475cdf', timeout: 1000},
- {auctionId: '028d5dee-2c83-44e3-bed1-b75002475cdf', timeout: 1000}
- ])
- expect(jixieaux.ajax.calledWith(otherUrl_, null, QPARAMS_)).to.equal(true);
- getConfigStub.restore();
- })
- });// describe
});
diff --git a/test/spec/modules/kargoBidAdapter_spec.js b/test/spec/modules/kargoBidAdapter_spec.js
index f7010c1886f..f43c3b11aac 100644
--- a/test/spec/modules/kargoBidAdapter_spec.js
+++ b/test/spec/modules/kargoBidAdapter_spec.js
@@ -147,6 +147,22 @@ describe('kargo adapter tests', function () {
id: '1234',
name: 'SiteName',
cat: ['IAB1', 'IAB2', 'IAB3']
+ },
+ user: {
+ data: [
+ {
+ name: 'prebid.org',
+ ext: {
+ segtax: 600,
+ segclass: 'v1',
+ },
+ segment: [
+ {
+ id: '133'
+ },
+ ]
+ },
+ ]
}
},
ortb2Imp: {
@@ -155,9 +171,9 @@ describe('kargo adapter tests', function () {
data: {
adServer: {
name: 'gam',
- adSlot: '/22558409563,18834096/dfy_mobile_adhesion'
+ adslot: '/22558409563,18834096/dfy_mobile_adhesion'
},
- pbAdSlot: '/22558409563,18834096/dfy_mobile_adhesion'
+ pbadslot: '/22558409563,18834096/dfy_mobile_adhesion'
},
gpid: '/22558409563,18834096/dfy_mobile_adhesion'
}
@@ -184,9 +200,9 @@ describe('kargo adapter tests', function () {
data: {
adServer: {
name: 'gam',
- adSlot: '/22558409563,18834096/dfy_mobile_adhesion'
+ adslot: '/22558409563,18834096/dfy_mobile_adhesion'
},
- pbAdSlot: '/22558409563,18834096/dfy_mobile_adhesion'
+ pbadslot: '/22558409563,18834096/dfy_mobile_adhesion'
}
}
}
@@ -209,9 +225,10 @@ describe('kargo adapter tests', function () {
data: {
adServer: {
name: 'gam',
- adSlot: '/22558409563,18834096/dfy_mobile_adhesion'
+ adslot: '/22558409563,18834096/dfy_mobile_adhesion'
}
- }
+ },
+ gpid: '/22558409563,18834096/dfy_mobile_adhesion'
}
}
}
@@ -521,6 +538,20 @@ describe('kargo adapter tests', function () {
}
]
}
+ ],
+ data: [
+ {
+ name: 'prebid.org',
+ ext: {
+ segtax: 600,
+ segclass: 'v1',
+ },
+ segment: [
+ {
+ id: '133'
+ }
+ ]
+ }
]
}
};
diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js
index a51082f26bd..9f57a5aa405 100644
--- a/test/spec/modules/liveIntentIdSystem_spec.js
+++ b/test/spec/modules/liveIntentIdSystem_spec.js
@@ -1,6 +1,6 @@
import { liveIntentIdSubmodule, reset as resetLiveIntentIdSubmodule, storage } from 'modules/liveIntentIdSystem.js';
import * as utils from 'src/utils.js';
-import { gdprDataHandler, uspDataHandler } from '../../../src/adapterManager.js';
+import { gdprDataHandler, uspDataHandler, gppDataHandler } from '../../../src/adapterManager.js';
import { server } from 'test/mocks/xhr.js';
resetLiveIntentIdSubmodule();
liveIntentIdSubmodule.setModuleMode('standard')
@@ -12,6 +12,7 @@ describe('LiveIntentId', function() {
let logErrorStub;
let uspConsentDataStub;
let gdprConsentDataStub;
+ let gppConsentDataStub;
let getCookieStub;
let getDataFromLocalStorageStub;
let imgStub;
@@ -24,6 +25,7 @@ describe('LiveIntentId', function() {
logErrorStub = sinon.stub(utils, 'logError');
uspConsentDataStub = sinon.stub(uspDataHandler, 'getConsentData');
gdprConsentDataStub = sinon.stub(gdprDataHandler, 'getConsentData');
+ gppConsentDataStub = sinon.stub(gppDataHandler, 'getConsentData');
});
afterEach(function() {
@@ -33,6 +35,7 @@ describe('LiveIntentId', function() {
logErrorStub.restore();
uspConsentDataStub.restore();
gdprConsentDataStub.restore();
+ gppConsentDataStub.restore();
resetLiveIntentIdSubmodule();
});
@@ -42,11 +45,15 @@ describe('LiveIntentId', function() {
gdprApplies: true,
consentString: 'consentDataString'
})
+ gppConsentDataStub.returns({
+ gppString: 'gppConsentDataString',
+ applicableSections: [1, 2]
+ })
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
- expect(request.url).to.match(/.*us_privacy=1YNY.*&gdpr=1&n3pc=1&gdpr_consent=consentDataString.*/);
+ expect(request.url).to.match(/.*us_privacy=1YNY.*&gdpr=1&n3pc=1&gdpr_consent=consentDataString.*&gpp_s=gppConsentDataString&gpp_as=1%2C2.*/);
const response = {
unifiedId: 'a_unified_id',
segments: [123, 234]
@@ -65,9 +72,13 @@ describe('LiveIntentId', function() {
gdprApplies: true,
consentString: 'consentDataString'
})
+ gppConsentDataStub.returns({
+ gppString: 'gppConsentDataString',
+ applicableSections: [1]
+ })
liveIntentIdSubmodule.getId(defaultConfigParams);
setTimeout(() => {
- expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*&us_privacy=1YNY.*&wpn=prebid.*&gdpr=1&n3pc=1&n3pct=1&nb=1&gdpr_consent=consentDataString.*/);
+ expect(server.requests[0].url).to.match(/https:\/\/rp.liadm.com\/j\?.*&us_privacy=1YNY.*&wpn=prebid.*&gdpr=1&n3pc=1&n3pct=1&nb=1&gdpr_consent=consentDataString&gpp_s=gppConsentDataString&gpp_as=1.*/);
done();
}, 200);
});
@@ -123,9 +134,13 @@ describe('LiveIntentId', function() {
gdprApplies: false,
consentString: 'consentDataString'
})
+ gppConsentDataStub.returns({
+ gppString: 'gppConsentDataString',
+ applicableSections: [1]
+ })
liveIntentIdSubmodule.decode({}, defaultConfigParams);
setTimeout(() => {
- expect(server.requests[0].url).to.match(/.*us_privacy=1YNY.*&gdpr=0&gdpr_consent=consentDataString.*/);
+ expect(server.requests[0].url).to.match(/.*us_privacy=1YNY.*&gdpr=0&gdpr_consent=consentDataString.*&gpp_s=gppConsentDataString&gpp_as=1.*/);
done();
}, 200);
});
diff --git a/test/spec/modules/mediabramaBidAdapter_spec.js b/test/spec/modules/mediabramaBidAdapter_spec.js
new file mode 100644
index 00000000000..d7341e02f17
--- /dev/null
+++ b/test/spec/modules/mediabramaBidAdapter_spec.js
@@ -0,0 +1,256 @@
+import {expect} from 'chai';
+import {spec} from '../../../modules/mediabramaBidAdapter.js';
+import { BANNER } from '../../../src/mediaTypes.js';
+import * as utils from '../../../src/utils.js';
+
+describe('MediaBramaBidAdapter', function () {
+ const bid = {
+ bidId: '23dc19818e5293',
+ bidder: 'mediabrama',
+ mediaTypes: {
+ [BANNER]: {
+ sizes: [[300, 250]]
+ }
+ },
+ params: {
+ placementId: 24428,
+ }
+ };
+
+ const bidderRequest = {
+ refererInfo: {
+ referer: 'test.com'
+ }
+ };
+
+ describe('isBidRequestValid', function () {
+ it('Should return true if there are bidId, params and key parameters present', function () {
+ expect(spec.isBidRequestValid(bid)).to.be.true;
+ });
+ it('Should return false if at least one of parameters is not present', function () {
+ delete bid.params.placementId;
+ expect(spec.isBidRequestValid(bid)).to.be.false;
+ });
+ });
+
+ describe('buildRequests', function () {
+ let serverRequest = spec.buildRequests([bid], bidderRequest);
+ it('Creates a ServerRequest object with method, URL and data', function () {
+ expect(serverRequest).to.exist;
+ expect(serverRequest.method).to.exist;
+ expect(serverRequest.url).to.exist;
+ expect(serverRequest.data).to.exist;
+ });
+ it('Returns POST method', function () {
+ expect(serverRequest.method).to.equal('POST');
+ });
+ it('Returns valid URL', function () {
+ expect(serverRequest.url).to.equal('https://prebid.mediabrama.com/pbjs');
+ });
+ it('Returns valid data if array of bids is valid', function () {
+ let data = serverRequest.data;
+ expect(data).to.be.an('object');
+ expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'host', 'page', 'placements');
+ expect(data.deviceWidth).to.be.a('number');
+ expect(data.deviceHeight).to.be.a('number');
+ expect(data.language).to.be.a('string');
+ expect(data.host).to.be.a('string');
+ expect(data.page).to.be.a('string');
+ expect(data.gdpr).to.not.exist;
+ expect(data.ccpa).to.not.exist;
+ let placement = data['placements'][0];
+ expect(placement).to.have.keys('placementId', 'bidId', 'adFormat', 'sizes', 'schain', 'bidfloor');
+ expect(placement.placementId).to.equal(24428);
+ expect(placement.bidId).to.equal('23dc19818e5293');
+ expect(placement.adFormat).to.equal(BANNER);
+ expect(placement.schain).to.be.an('object');
+ expect(placement.sizes).to.be.an('array');
+ expect(placement.bidfloor).to.exist.and.to.equal(0);
+ });
+
+ it('Returns data with gdprConsent and without uspConsent', function () {
+ bidderRequest.gdprConsent = 'test';
+ serverRequest = spec.buildRequests([bid], bidderRequest);
+ let data = serverRequest.data;
+ expect(data.gdpr).to.exist;
+ expect(data.gdpr).to.be.a('string');
+ expect(data.gdpr).to.equal(bidderRequest.gdprConsent);
+ expect(data.ccpa).to.not.exist;
+ delete bidderRequest.gdprConsent;
+ });
+
+ it('Returns data with uspConsent and without gdprConsent', function () {
+ bidderRequest.uspConsent = 'test';
+ serverRequest = spec.buildRequests([bid], bidderRequest);
+ let data = serverRequest.data;
+ expect(data.ccpa).to.exist;
+ expect(data.ccpa).to.be.a('string');
+ expect(data.ccpa).to.equal(bidderRequest.uspConsent);
+ expect(data.gdpr).to.not.exist;
+ });
+
+ it('Returns empty data if no valid requests are passed', function () {
+ serverRequest = spec.buildRequests([]);
+ let data = serverRequest.data;
+ expect(data.placements).to.be.an('array').that.is.empty;
+ });
+ });
+ describe('interpretResponse', function () {
+ it('Should interpret banner response', function () {
+ const banner = {
+ body: [{
+ mediaType: 'banner',
+ width: 300,
+ height: 250,
+ cpm: 0.4,
+ ad: 'Test',
+ requestId: '23dc19818e5293',
+ ttl: 120,
+ creativeId: '2',
+ netRevenue: true,
+ currency: 'USD',
+ dealId: '1',
+ meta: {}
+ }]
+ };
+ let bannerResponses = spec.interpretResponse(banner);
+ expect(bannerResponses).to.be.an('array').that.is.not.empty;
+ let dataItem = bannerResponses[0];
+ expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId',
+ 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
+ expect(dataItem.requestId).to.equal('23dc19818e5293');
+ expect(dataItem.cpm).to.equal(0.4);
+ expect(dataItem.width).to.equal(300);
+ expect(dataItem.height).to.equal(250);
+ expect(dataItem.ad).to.equal('Test');
+ expect(dataItem.ttl).to.equal(120);
+ expect(dataItem.creativeId).to.equal('2');
+ expect(dataItem.netRevenue).to.be.true;
+ expect(dataItem.currency).to.equal('USD');
+ expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains');
+ });
+ it('Should return an empty array if invalid banner response is passed', function () {
+ const invBanner = {
+ body: [{
+ width: 300,
+ cpm: 0.4,
+ ad: 'Test',
+ requestId: '23dc19818e5293',
+ ttl: 120,
+ creativeId: '2',
+ netRevenue: true,
+ currency: 'USD',
+ dealId: '1'
+ }]
+ };
+
+ let serverResponses = spec.interpretResponse(invBanner);
+ expect(serverResponses).to.be.an('array').that.is.empty;
+ });
+ it('Should return an empty array if invalid response is passed', function () {
+ const invalid = {
+ body: [{
+ ttl: 120,
+ creativeId: '2',
+ netRevenue: true,
+ currency: 'USD',
+ dealId: '1'
+ }]
+ };
+ let serverResponses = spec.interpretResponse(invalid);
+ expect(serverResponses).to.be.an('array').that.is.empty;
+ });
+ });
+
+ describe('getUserSyncs', function () {
+ it('should do nothing on getUserSyncs', function () {
+ const syncData = spec.getUserSyncs({}, {}, {
+ consentString: 'ALL',
+ gdprApplies: true
+ }, {});
+ expect(syncData).to.be.an('array').which.is.not.empty;
+ expect(syncData[0]).to.be.an('object')
+ expect(syncData[0].type).to.be.a('string')
+ expect(syncData[0].type).to.equal('image')
+ expect(syncData[0].url).to.be.a('string')
+ expect(syncData[0].url).to.equal('https://prebid.mediabrama.com/sync/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0')
+ });
+ });
+
+ describe('on bidWon', function () {
+ beforeEach(function() {
+ sinon.stub(utils, 'triggerPixel');
+ });
+ afterEach(function() {
+ utils.triggerPixel.restore();
+ });
+ it('should replace nurl for banner', function () {
+ const nurl = 'nurl/?ap=${' + 'AUCTION_PRICE}';
+ const bid = {
+ 'bidderCode': 'mediabrama',
+ 'width': 300,
+ 'height': 250,
+ 'statusMessage': 'Bid available',
+ 'adId': '5691dd18ba6ab6',
+ 'requestId': '23dc19818e5293',
+ 'transactionId': '948c716b-bf64-4303-bcf4-395c2f6a9770',
+ 'auctionId': 'a6b7c61f-15a9-481b-8f64-e859787e9c07',
+ 'mediaType': 'banner',
+ 'source': 'client',
+ 'ad': "\n",
+ 'cpm': 0.61,
+ 'nurl': nurl,
+ 'creativeId': 'test',
+ 'currency': 'USD',
+ 'dealId': '',
+ 'meta': {
+ 'advertiserDomains': [],
+ 'dchain': {
+ 'ver': '1.0',
+ 'complete': 0,
+ 'nodes': [
+ {
+ 'name': 'mediabrama'
+ }
+ ]
+ }
+ },
+ 'netRevenue': true,
+ 'ttl': 185,
+ 'metrics': {},
+ 'adapterCode': 'mediabrama',
+ 'originalCpm': 0.61,
+ 'originalCurrency': 'USD',
+ 'responseTimestamp': 1668162732297,
+ 'requestTimestamp': 1668162732292,
+ 'bidder': 'mediabrama',
+ 'adUnitCode': 'div-prebid',
+ 'timeToRespond': 5,
+ 'pbLg': '0.50',
+ 'pbMg': '0.60',
+ 'pbHg': '0.61',
+ 'pbAg': '0.61',
+ 'pbDg': '0.61',
+ 'pbCg': '',
+ 'size': '300x250',
+ 'adserverTargeting': {
+ 'hb_bidder': 'mediabrama',
+ 'hb_adid': '5691dd18ba6ab6',
+ 'hb_pb': '0.61',
+ 'hb_size': '300x250',
+ 'hb_source': 'client',
+ 'hb_format': 'banner',
+ 'hb_adomain': ''
+ },
+ 'status': 'rendered',
+ 'params': [
+ {
+ 'placementId': 24428
+ }
+ ]
+ };
+ spec.onBidWon(bid);
+ expect(bid.nurl).to.deep.equal('nurl/?ap=0.61');
+ });
+ });
+});
diff --git a/test/spec/modules/mediafilterRtdProvider_spec.js b/test/spec/modules/mediafilterRtdProvider_spec.js
new file mode 100644
index 00000000000..3395c7be691
--- /dev/null
+++ b/test/spec/modules/mediafilterRtdProvider_spec.js
@@ -0,0 +1,147 @@
+import * as utils from '../../../src/utils.js';
+import * as hook from '../../../src/hook.js'
+import * as events from '../../../src/events.js';
+import CONSTANTS from '../../../src/constants.json';
+
+import {
+ MediaFilter,
+ MEDIAFILTER_EVENT_TYPE,
+ MEDIAFILTER_BASE_URL
+} from '../../../modules/mediafilterRtdProvider.js';
+
+describe('The Media Filter RTD module', function () {
+ describe('register()', function() {
+ let submoduleSpy, generateInitHandlerSpy;
+
+ beforeEach(function () {
+ submoduleSpy = sinon.spy(hook, 'submodule');
+ generateInitHandlerSpy = sinon.spy(MediaFilter, 'generateInitHandler');
+ });
+
+ afterEach(function () {
+ submoduleSpy.restore();
+ generateInitHandlerSpy.restore();
+ });
+
+ it('should register and call the submodule function(s)', function () {
+ MediaFilter.register();
+
+ expect(submoduleSpy.calledOnceWithExactly('realTimeData', sinon.match.object)).to.be.true;
+ expect(submoduleSpy.called).to.be.true;
+ expect(generateInitHandlerSpy.called).to.be.true;
+ });
+ });
+
+ describe('setup()', function() {
+ let setupEventListenerSpy, setupScriptSpy;
+
+ beforeEach(function() {
+ setupEventListenerSpy = sinon.spy(MediaFilter, 'setupEventListener');
+ setupScriptSpy = sinon.spy(MediaFilter, 'setupScript');
+ });
+
+ afterEach(function() {
+ setupEventListenerSpy.restore();
+ setupScriptSpy.restore();
+ });
+
+ it('should call setupEventListener and setupScript function(s)', function() {
+ MediaFilter.setup({ configurationHash: 'abc123' });
+
+ expect(setupEventListenerSpy.called).to.be.true;
+ expect(setupScriptSpy.called).to.be.true;
+ });
+ });
+
+ describe('setupEventListener()', function() {
+ let setupEventListenerSpy, addEventListenerSpy;
+
+ beforeEach(function() {
+ setupEventListenerSpy = sinon.spy(MediaFilter, 'setupEventListener');
+ addEventListenerSpy = sinon.spy(window, 'addEventListener');
+ });
+
+ afterEach(function() {
+ setupEventListenerSpy.restore();
+ addEventListenerSpy.restore();
+ });
+
+ it('should call addEventListener function(s)', function() {
+ MediaFilter.setupEventListener();
+ expect(addEventListenerSpy.called).to.be.true;
+ expect(addEventListenerSpy.calledWith('message', sinon.match.func)).to.be.true;
+ });
+ });
+
+ describe('generateInitHandler()', function() {
+ let generateInitHandlerSpy, setupMock, logErrorSpy;
+
+ beforeEach(function() {
+ generateInitHandlerSpy = sinon.spy(MediaFilter, 'generateInitHandler');
+ setupMock = sinon.stub(MediaFilter, 'setup').throws(new Error('Mocked error!'));
+ logErrorSpy = sinon.spy(utils, 'logError');
+ });
+
+ afterEach(function() {
+ generateInitHandlerSpy.restore();
+ setupMock.restore();
+ logErrorSpy.restore();
+ });
+
+ it('should handle errors in the catch block when setup throws an error', function() {
+ const initHandler = MediaFilter.generateInitHandler();
+ initHandler({});
+
+ expect(logErrorSpy.calledWith('Error in initialization: Mocked error!')).to.be.true;
+ });
+ });
+
+ describe('generateEventHandler()', function() {
+ let generateEventHandlerSpy, eventsEmitSpy;
+
+ beforeEach(function() {
+ generateEventHandlerSpy = sinon.spy(MediaFilter, 'generateEventHandler');
+ eventsEmitSpy = sinon.spy(events, 'emit');
+ });
+
+ afterEach(function() {
+ generateEventHandlerSpy.restore();
+ eventsEmitSpy.restore();
+ });
+
+ it('should emit a billable event when the event type matches', function() {
+ const configurationHash = 'abc123';
+ const eventHandler = MediaFilter.generateEventHandler(configurationHash);
+
+ const mockEvent = {
+ data: {
+ type: MEDIAFILTER_EVENT_TYPE.concat('.', configurationHash)
+ }
+ };
+
+ eventHandler(mockEvent);
+
+ expect(eventsEmitSpy.calledWith(CONSTANTS.EVENTS.BILLABLE_EVENT, {
+ 'billingId': sinon.match.string,
+ 'configurationHash': configurationHash,
+ 'type': 'impression',
+ 'vendor': 'mediafilter',
+ })).to.be.true;
+ });
+
+ it('should not emit a billable event when the event type does not match', function() {
+ const configurationHash = 'abc123';
+ const eventHandler = MediaFilter.generateEventHandler(configurationHash);
+
+ const mockEvent = {
+ data: {
+ type: 'differentEventType'
+ }
+ };
+
+ eventHandler(mockEvent);
+
+ expect(eventsEmitSpy.called).to.be.false;
+ });
+ });
+});
diff --git a/test/spec/modules/mediagoBidAdapter_spec.js b/test/spec/modules/mediagoBidAdapter_spec.js
index e77af544429..5eb362893e3 100644
--- a/test/spec/modules/mediagoBidAdapter_spec.js
+++ b/test/spec/modules/mediagoBidAdapter_spec.js
@@ -11,11 +11,40 @@ describe('mediago:BidAdapterTests', function () {
bidder: 'mediago',
params: {
token: '85a6b01e41ac36d49744fad726e3655d',
+ siteId: 'siteId_01',
+ zoneId: 'zoneId_01',
+ publisher: '52',
+ position: 'left',
+ referrer: 'https://trace.mediago.io',
bidfloor: 0.01,
+ ortb2Imp: {
+ ext: {
+ gpid: 'adslot_gpid',
+ tid: 'tid_01',
+ data: {
+ browsi: {
+ browsiViewability: 'NA',
+ },
+ adserver: {
+ name: 'adserver_name',
+ adslot: 'adslot_name',
+ },
+ },
+ },
+ },
},
mediaTypes: {
banner: {
sizes: [[300, 250]],
+ pos: 'left',
+ },
+ },
+ ortb2: {
+ user: {
+ ext: {
+ data: {
+ },
+ },
},
},
adUnitCode: 'regular_iframe',
diff --git a/test/spec/modules/missenaBidAdapter_spec.js b/test/spec/modules/missenaBidAdapter_spec.js
index f61987298e8..15f9eff89e7 100644
--- a/test/spec/modules/missenaBidAdapter_spec.js
+++ b/test/spec/modules/missenaBidAdapter_spec.js
@@ -1,23 +1,61 @@
import { expect } from 'chai';
-import { spec, _getPlatform } from 'modules/missenaBidAdapter.js';
-import { newBidder } from 'src/adapters/bidderFactory.js';
+import { spec, storage } from 'modules/missenaBidAdapter.js';
+import { BANNER } from '../../../src/mediaTypes.js';
describe('Missena Adapter', function () {
- const adapter = newBidder(spec);
+ $$PREBID_GLOBAL$$.bidderSettings = {
+ missena: {
+ storageAllowed: true,
+ },
+ };
const bidId = 'abc';
-
const bid = {
bidder: 'missena',
bidId: bidId,
sizes: [[1, 1]],
+ mediaTypes: { banner: { sizes: [[1, 1]] } },
+ params: {
+ apiKey: 'PA-34745704',
+ placement: 'sticky',
+ formats: ['sticky-banner'],
+ },
+ getFloor: (inputParams) => {
+ if (inputParams.mediaType === BANNER) {
+ return {
+ currency: 'EUR',
+ floor: 3.5,
+ };
+ } else {
+ return {};
+ }
+ },
+ };
+ const bidWithoutFloor = {
+ bidder: 'missena',
+ bidId: bidId,
+ sizes: [[1, 1]],
+ mediaTypes: { banner: { sizes: [[1, 1]] } },
params: {
apiKey: 'PA-34745704',
placement: 'sticky',
formats: ['sticky-banner'],
},
};
+ const consentString = 'AAAAAAAAA==';
+ const bidderRequest = {
+ gdprConsent: {
+ consentString: consentString,
+ gdprApplies: true,
+ },
+ refererInfo: {
+ topmostLocation: 'https://referer',
+ canonicalUrl: 'https://canonical',
+ },
+ };
+
+ const bids = [bid, bidWithoutFloor];
describe('codes', function () {
it('should return a bidder code of missena', function () {
expect(spec.code).to.equal('missena');
@@ -31,34 +69,27 @@ describe('Missena Adapter', function () {
it('should return false if the apiKey is missing', function () {
expect(
- spec.isBidRequestValid(Object.assign(bid, { params: {} }))
+ spec.isBidRequestValid(Object.assign(bid, { params: {} })),
).to.equal(false);
});
it('should return false if the apiKey is an empty string', function () {
expect(
- spec.isBidRequestValid(Object.assign(bid, { params: { apiKey: '' } }))
+ spec.isBidRequestValid(Object.assign(bid, { params: { apiKey: '' } })),
).to.equal(false);
});
});
describe('buildRequests', function () {
- const consentString = 'AAAAAAAAA==';
-
- const bidderRequest = {
- gdprConsent: {
- consentString: consentString,
- gdprApplies: true,
- },
- refererInfo: {
- topmostLocation: 'https://referer',
- canonicalUrl: 'https://canonical',
- },
- };
+ let getDataFromLocalStorageStub = sinon.stub(
+ storage,
+ 'getDataFromLocalStorage',
+ );
- const requests = spec.buildRequests([bid, bid], bidderRequest);
+ const requests = spec.buildRequests(bids, bidderRequest);
const request = requests[0];
const payload = JSON.parse(request.data);
+ const payloadNoFloor = JSON.parse(requests[1].data);
it('should return as many server requests as bidder requests', function () {
expect(requests.length).to.equal(2);
@@ -89,6 +120,32 @@ describe('Missena Adapter', function () {
expect(payload.consent_string).to.equal(consentString);
expect(payload.consent_required).to.equal(true);
});
+ it('should send floor data', function () {
+ expect(payload.floor).to.equal(3.5);
+ expect(payload.floor_currency).to.equal('EUR');
+ });
+ it('should not send floor data if not available', function () {
+ expect(payloadNoFloor.floor).to.equal(undefined);
+ expect(payloadNoFloor.floor_currency).to.equal(undefined);
+ });
+
+ getDataFromLocalStorageStub.restore();
+ getDataFromLocalStorageStub = sinon.stub(
+ storage,
+ 'getDataFromLocalStorage',
+ );
+ const localStorageData = {
+ [`missena.missena.capper.remove-bubble.${bid.params.apiKey}`]:
+ JSON.stringify({
+ expiry: new Date().getTime() + 600_000, // 10 min into the future
+ }),
+ };
+ getDataFromLocalStorageStub.callsFake((key) => localStorageData[key]);
+ const cappedRequests = spec.buildRequests(bids, bidderRequest);
+
+ it('should not participate if capped', function () {
+ expect(cappedRequests.length).to.equal(0);
+ });
});
describe('interpretResponse', function () {
@@ -121,14 +178,14 @@ describe('Missena Adapter', function () {
expect(result.length).to.equal(1);
expect(Object.keys(result[0])).to.have.members(
- Object.keys(serverResponse)
+ Object.keys(serverResponse),
);
});
it('should return an empty response when the server answers with a timeout', function () {
const result = spec.interpretResponse(
{ body: serverTimeoutResponse },
- bid
+ bid,
);
expect(result).to.deep.equal([]);
});
@@ -136,7 +193,7 @@ describe('Missena Adapter', function () {
it('should return an empty response when the server answers with an empty ad', function () {
const result = spec.interpretResponse(
{ body: serverEmptyAdResponse },
- bid
+ bid,
);
expect(result).to.deep.equal([]);
});
diff --git a/test/spec/modules/nobidBidAdapter_spec.js b/test/spec/modules/nobidBidAdapter_spec.js
index f2059900a2e..b1e303bde6e 100644
--- a/test/spec/modules/nobidBidAdapter_spec.js
+++ b/test/spec/modules/nobidBidAdapter_spec.js
@@ -57,26 +57,27 @@ describe('Nobid Adapter', function () {
'auctionId': '1d1a030790a475',
};
- it('should return true when required params found 1', function () {
+ it('should return true when required params found', function () {
expect(spec.isBidRequestValid(bid)).to.equal(true);
});
- it('should return true when required params found 2', function () {
- let mybid = Object.assign({}, bid);
- delete mybid.params;
- mybid.params = {
+ it('should return true when required params found', function () {
+ let bid = Object.assign({}, bid);
+ delete bid.params;
+ bid.params = {
'siteId': 2
};
- expect(spec.isBidRequestValid(mybid)).to.equal(true);
+
+ expect(spec.isBidRequestValid(bid)).to.equal(true);
});
it('should return false when required params are not passed', function () {
- let mybid = Object.assign({}, bid);
- delete mybid.params;
- mybid.params = {
+ let bid = Object.assign({}, bid);
+ delete bid.params;
+ bid.params = {
'siteId': 0
};
- expect(spec.isBidRequestValid(mybid)).to.equal(false);
+ expect(spec.isBidRequestValid(bid)).to.equal(false);
});
});
@@ -252,12 +253,12 @@ describe('Nobid Adapter', function () {
});
it('sends bid request to site id', function () {
- const request = spec.buildRequests(bidRequests);
- const payload = JSON.parse(request.data);
- expect(payload.a).to.exist;
- expect(payload.a[0].sid).to.equal(2);
- expect(payload.a[0].at).to.equal('banner');
- expect(payload.a[0].params.siteId).to.equal(2);
+ const request = spec.buildRequests(bidRequests);
+ const payload = JSON.parse(request.data);
+ expect(payload.a).to.exist;
+ expect(payload.a[0].sid).to.equal(2);
+ expect(payload.a[0].at).to.equal('banner');
+ expect(payload.a[0].params.siteId).to.equal(2);
});
it('sends bid request to ad type', function () {
@@ -422,58 +423,6 @@ describe('Nobid Adapter', function () {
});
});
- describe('First Party ID Test', function () {
- const CREATIVE_ID_300x250 = 'CREATIVE-100';
- const ADUNIT_300x250 = 'ADUNIT-1';
- const ADMARKUP_300x250 = 'ADMARKUP-300x250';
- const PRICE_300x250 = 0.51;
- const REQUEST_ID = '3db3773286ee59';
- const DEAL_ID = 'deal123';
- let response = {
- country: 'US',
- ip: '68.83.15.75',
- device: 'COMPUTER',
- site: 2,
- fpid: true,
- bids: [
- {id: 1,
- bdrid: 101,
- divid: ADUNIT_300x250,
- creativeid: CREATIVE_ID_300x250,
- size: {'w': 300, 'h': 250},
- adm: ADMARKUP_300x250,
- price: '' + PRICE_300x250
- }
- ]
- };
-
- it('first party ID', function () {
- const bidderRequest = {
- bids: [{
- bidId: REQUEST_ID,
- adUnitCode: ADUNIT_300x250
- }]
- }
- const bidRequests = [
- {
- 'bidder': 'nobid',
- 'params': {
- 'siteId': 2
- },
- 'adUnitCode': 'adunit-code',
- 'sizes': [[300, 250]],
- 'bidId': '30b31c1838de1e',
- 'bidderRequestId': '22edbae2733bf6',
- 'auctionId': '1d1a030790a475',
- }
- ];
- const request = spec.buildRequests(bidRequests, bidderRequest);
- expect(request.method).to.equal('POST');
- spec.interpretResponse({ body: response }, {bidderRequest: bidderRequest});
- expect(window.nobid.firstPartyIdEnabled).to.equal(true);
- });
- });
-
describe('isVideoBidRequestValid', function () {
let bid = {
bidder: 'nobid',
@@ -686,12 +635,12 @@ describe('Nobid Adapter', function () {
});
it('sends bid request to site id', function () {
- const request = spec.buildRequests(bidRequests);
- const payload = JSON.parse(request.data);
- expect(payload.a).to.exist;
- expect(payload.a[0].sid).to.equal(2);
- expect(payload.a[0].at).to.equal('banner');
- expect(payload.a[0].params.siteId).to.equal(2);
+ const request = spec.buildRequests(bidRequests);
+ const payload = JSON.parse(request.data);
+ expect(payload.a).to.exist;
+ expect(payload.a[0].sid).to.equal(2);
+ expect(payload.a[0].at).to.equal('banner');
+ expect(payload.a[0].params.siteId).to.equal(2);
});
it('sends bid request to ad type', function () {
@@ -990,19 +939,19 @@ describe('Nobid Adapter', function () {
auctionId: '1d1a030790a475',
coppa: true,
schain: {
- validation: 'strict',
- config: {
- ver: '1.0',
- complete: 1,
- nodes: [
- {
- asi: 'indirectseller.com',
- sid: '00001',
- name: 'name.com',
- hp: 1
- }
- ]
- }
+ validation: 'strict',
+ config: {
+ ver: '1.0',
+ complete: 1,
+ nodes: [
+ {
+ asi: 'indirectseller.com',
+ sid: '00001',
+ name: 'name.com',
+ hp: 1
+ }
+ ]
+ }
}
}
];
@@ -1052,7 +1001,7 @@ describe('Nobid Adapter', function () {
]
};
- it('Limit should be respected', function () {
+ it('should ULimit be respected', function () {
const bidderRequest = {
bids: [{
bidId: REQUEST_ID,
@@ -1111,8 +1060,8 @@ describe('Nobid Adapter', function () {
});
it('should get correct user sync when !iframeEnabled', function () {
- let pixel = spec.getUserSyncs({})
- expect(pixel.length).to.equal(0);
+ let pixel = spec.getUserSyncs({})
+ expect(pixel.length).to.equal(0);
});
});
diff --git a/test/spec/modules/oguryBidAdapter_spec.js b/test/spec/modules/oguryBidAdapter_spec.js
index ed358af19b6..aad753571a8 100644
--- a/test/spec/modules/oguryBidAdapter_spec.js
+++ b/test/spec/modules/oguryBidAdapter_spec.js
@@ -42,7 +42,21 @@ describe('OguryBidAdapter', function () {
return floorResult;
},
- transactionId: 'transactionId'
+ transactionId: 'transactionId',
+ userId: {
+ pubcid: '2abb10e5-c4f6-4f70-9f45-2200e4487714'
+ },
+ userIdAsEids: [
+ {
+ source: 'pubcid.org',
+ uids: [
+ {
+ id: '2abb10e5-c4f6-4f70-9f45-2200e4487714',
+ atype: 1
+ }
+ ]
+ }
+ ]
},
{
adUnitCode: 'adUnitCode2',
@@ -407,12 +421,26 @@ describe('OguryBidAdapter', function () {
},
user: {
ext: {
- consent: bidderRequest.gdprConsent.consentString
+ consent: bidderRequest.gdprConsent.consentString,
+ uids: {
+ pubcid: '2abb10e5-c4f6-4f70-9f45-2200e4487714'
+ },
+ eids: [
+ {
+ source: 'pubcid.org',
+ uids: [
+ {
+ id: '2abb10e5-c4f6-4f70-9f45-2200e4487714',
+ atype: 1
+ }
+ ]
+ }
+ ],
},
},
ext: {
prebidversion: '$prebid.version$',
- adapterversion: '1.5.0'
+ adapterversion: '1.6.0'
},
device: {
w: stubbedWidth,
@@ -637,7 +665,9 @@ describe('OguryBidAdapter', function () {
},
user: {
ext: {
- consent: ''
+ consent: '',
+ uids: expectedRequestObject.user.ext.uids,
+ eids: expectedRequestObject.user.ext.eids
},
}
};
@@ -663,7 +693,9 @@ describe('OguryBidAdapter', function () {
},
user: {
ext: {
- consent: ''
+ consent: '',
+ uids: expectedRequestObject.user.ext.uids,
+ eids: expectedRequestObject.user.ext.eids
},
}
};
@@ -689,7 +721,9 @@ describe('OguryBidAdapter', function () {
},
user: {
ext: {
- consent: ''
+ consent: '',
+ uids: expectedRequestObject.user.ext.uids,
+ eids: expectedRequestObject.user.ext.eids
},
}
};
@@ -701,6 +735,48 @@ describe('OguryBidAdapter', function () {
expect(request.data.regs.ext.gdpr).to.be.a('number');
});
+ it('should should not add uids infos if userId is undefined', () => {
+ const expectedRequestWithUndefinedUserId = {
+ ...expectedRequestObject,
+ user: {
+ ext: {
+ consent: expectedRequestObject.user.ext.consent,
+ eids: expectedRequestObject.user.ext.eids
+ }
+ }
+ };
+
+ const validBidRequests = utils.deepClone(bidRequests);
+ validBidRequests[0] = {
+ ...validBidRequests[0],
+ userId: undefined
+ };
+
+ const request = spec.buildRequests(validBidRequests, bidderRequest);
+ expect(request.data).to.deep.equal(expectedRequestWithUndefinedUserId);
+ });
+
+ it('should should not add uids infos if userIdAsEids is undefined', () => {
+ const expectedRequestWithUndefinedUserIdAsEids = {
+ ...expectedRequestObject,
+ user: {
+ ext: {
+ consent: expectedRequestObject.user.ext.consent,
+ uids: expectedRequestObject.user.ext.uids
+ }
+ }
+ };
+
+ const validBidRequests = utils.deepClone(bidRequests);
+ validBidRequests[0] = {
+ ...validBidRequests[0],
+ userIdAsEids: undefined
+ };
+
+ const request = spec.buildRequests(validBidRequests, bidderRequest);
+ expect(request.data).to.deep.equal(expectedRequestWithUndefinedUserIdAsEids);
+ });
+
it('should handle bidFloor undefined', () => {
const expectedRequestWithUndefinedFloor = {
...expectedRequestObject
@@ -814,7 +890,7 @@ describe('OguryBidAdapter', function () {
advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[0].adomain
},
nurl: openRtbBidResponse.body.seatbid[0].bid[0].nurl,
- adapterVersion: '1.5.0',
+ adapterVersion: '1.6.0',
prebidVersion: '$prebid.version$'
}, {
requestId: openRtbBidResponse.body.seatbid[0].bid[1].impid,
@@ -831,7 +907,7 @@ describe('OguryBidAdapter', function () {
advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[1].adomain
},
nurl: openRtbBidResponse.body.seatbid[0].bid[1].nurl,
- adapterVersion: '1.5.0',
+ adapterVersion: '1.6.0',
prebidVersion: '$prebid.version$'
}]
diff --git a/test/spec/modules/onetagBidAdapter_spec.js b/test/spec/modules/onetagBidAdapter_spec.js
index df6456db82e..7960574c1a4 100644
--- a/test/spec/modules/onetagBidAdapter_spec.js
+++ b/test/spec/modules/onetagBidAdapter_spec.js
@@ -15,9 +15,14 @@ describe('onetag', function () {
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
- ortb2Imp: {
- ext: {
- tid: 'qwerty123'
+ 'ortb2Imp': {
+ 'ext': {
+ 'tid': '0000'
+ }
+ },
+ 'ortb2': {
+ 'source': {
+ 'tid': '1111'
}
},
'schain': {
@@ -184,7 +189,7 @@ describe('onetag', function () {
});
it('Should contain all keys', function () {
expect(data).to.be.an('object');
- expect(data).to.include.all.keys('location', 'referrer', 'stack', 'numIframes', 'sHeight', 'sWidth', 'docHeight', 'wHeight', 'wWidth', 'oHeight', 'oWidth', 'aWidth', 'aHeight', 'sLeft', 'sTop', 'hLength', 'bids', 'docHidden', 'xOffset', 'yOffset', 'networkConnectionType', 'networkEffectiveConnectionType', 'timing', 'version');
+ expect(data).to.include.all.keys('location', 'referrer', 'stack', 'numIframes', 'sHeight', 'sWidth', 'docHeight', 'wHeight', 'wWidth', 'oHeight', 'oWidth', 'aWidth', 'aHeight', 'sLeft', 'sTop', 'hLength', 'bids', 'docHidden', 'xOffset', 'yOffset', 'networkConnectionType', 'networkEffectiveConnectionType', 'timing', 'version', 'fledgeEnabled');
expect(data.location).to.satisfy(function (value) {
return value === null || typeof value === 'string';
});
@@ -208,6 +213,7 @@ describe('onetag', function () {
expect(data.networkEffectiveConnectionType).to.satisfy(function (value) {
return value === null || typeof value === 'string'
});
+ expect(data.fledgeEnabled).to.be.a('boolean');
expect(data.bids).to.be.an('array');
expect(data.version).to.have.all.keys('prebid', 'adapter');
const bids = data['bids'];
@@ -256,6 +262,15 @@ describe('onetag', function () {
expect(dataObj.bids).to.be.an('array').that.is.empty;
} catch (e) { }
});
+ it('Should pick each bid\'s auctionId and transactionId from ortb2 related fields', function () {
+ const serverRequest = spec.buildRequests([bannerBid]);
+ const payload = JSON.parse(serverRequest.data);
+
+ expect(payload).to.exist;
+ expect(payload.bids).to.exist.and.to.have.length(1);
+ expect(payload.bids[0].auctionId).to.equal(bannerBid.ortb2.source.tid);
+ expect(payload.bids[0].transactionId).to.equal(bannerBid.ortb2Imp.ext.tid);
+ });
it('should send GDPR consent data', function () {
let consentString = 'consentString';
let bidderRequest = {
@@ -382,13 +397,61 @@ describe('onetag', function () {
expect(payload.ortb2).to.exist.and.to.deep.equal(firtPartyData);
});
});
+ it('Should send FLEDGE eligibility flag when FLEDGE is enabled', function () {
+ let bidderRequest = {
+ 'bidderCode': 'onetag',
+ 'auctionId': '1d1a030790a475',
+ 'bidderRequestId': '22edbae2733bf6',
+ 'timeout': 3000,
+ 'fledgeEnabled': true
+ };
+ let serverRequest = spec.buildRequests([bannerBid], bidderRequest);
+ const payload = JSON.parse(serverRequest.data);
+
+ expect(payload.fledgeEnabled).to.exist;
+ expect(payload.fledgeEnabled).to.exist.and.to.equal(bidderRequest.fledgeEnabled);
+ });
+ it('Should send FLEDGE eligibility flag when FLEDGE is not enabled', function () {
+ let bidderRequest = {
+ 'bidderCode': 'onetag',
+ 'auctionId': '1d1a030790a475',
+ 'bidderRequestId': '22edbae2733bf6',
+ 'timeout': 3000,
+ 'fledgeEnabled': false
+ };
+ let serverRequest = spec.buildRequests([bannerBid], bidderRequest);
+ const payload = JSON.parse(serverRequest.data);
+
+ expect(payload.fledgeEnabled).to.exist;
+ expect(payload.fledgeEnabled).to.exist.and.to.equal(bidderRequest.fledgeEnabled);
+ });
+ it('Should send FLEDGE eligibility flag set to false when fledgeEnabled is not defined', function () {
+ let bidderRequest = {
+ 'bidderCode': 'onetag',
+ 'auctionId': '1d1a030790a475',
+ 'bidderRequestId': '22edbae2733bf6',
+ 'timeout': 3000,
+ };
+ let serverRequest = spec.buildRequests([bannerBid], bidderRequest);
+ const payload = JSON.parse(serverRequest.data);
+
+ expect(payload.fledgeEnabled).to.exist;
+ expect(payload.fledgeEnabled).to.exist.and.to.equal(false);
+ });
describe('interpretResponse', function () {
const request = getBannerVideoRequest();
const response = getBannerVideoResponse();
+ const fledgeResponse = getFledgeBannerResponse();
const requestData = JSON.parse(request.data);
it('Returns an array of valid server responses if response object is valid', function () {
const interpretedResponse = spec.interpretResponse(response, request);
+ const fledgeInterpretedResponse = spec.interpretResponse(fledgeResponse, request);
expect(interpretedResponse).to.be.an('array').that.is.not.empty;
+ expect(fledgeInterpretedResponse).to.be.an('object');
+ expect(fledgeInterpretedResponse.bids).to.satisfy(function (value) {
+ return value === null || Array.isArray(value);
+ });
+ expect(fledgeInterpretedResponse.fledgeAuctionConfigs).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', 'meta', 'dealId');
@@ -586,6 +649,24 @@ function getBannerVideoResponse() {
};
}
+function getFledgeBannerResponse() {
+ const bannerVideoResponse = getBannerVideoResponse();
+ bannerVideoResponse.body.fledgeAuctionConfigs = [
+ {
+ bidId: 'fledge',
+ config: {
+ seller: 'https://onetag-sys.com',
+ decisionLogicUrl:
+ 'https://onetag-sys.com/paapi/decision_logic.js',
+ interestGroupBuyers: [
+ 'https://onetag-sys.com'
+ ],
+ }
+ }
+ ]
+ return bannerVideoResponse;
+}
+
function getBannerVideoRequest() {
return {
data: JSON.stringify({
diff --git a/test/spec/modules/openxBidAdapter_spec.js b/test/spec/modules/openxBidAdapter_spec.js
index f2cff7f470c..1af0fce103d 100644
--- a/test/spec/modules/openxBidAdapter_spec.js
+++ b/test/spec/modules/openxBidAdapter_spec.js
@@ -14,6 +14,7 @@ import 'modules/consentManagement.js';
import 'modules/consentManagementUsp.js';
import 'modules/schain.js';
import {deepClone} from 'src/utils.js';
+import {version} from 'package.json';
import {syncAddFPDToBidderRequest} from '../../helpers/fpd.js';
import {hook} from '../../../src/hook.js';
@@ -316,6 +317,7 @@ describe('OpenxRtbAdapter', function () {
const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest);
expect(request[0].url).to.equal(REQUEST_URL);
expect(request[0].method).to.equal('POST');
+ expect(request[0].data.ext.pv).to.equal(version);
});
it('should send delivery domain, if available', function () {
diff --git a/test/spec/modules/operaadsBidAdapter_spec.js b/test/spec/modules/operaadsBidAdapter_spec.js
index 37d4a2c7bc0..9a8981235d5 100644
--- a/test/spec/modules/operaadsBidAdapter_spec.js
+++ b/test/spec/modules/operaadsBidAdapter_spec.js
@@ -266,6 +266,95 @@ describe('Opera Ads Bid Adapter', function () {
}
});
+ describe('test fulfilling inventory information', function () {
+ const bidRequest = {
+ adUnitCode: 'test-div',
+ auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
+ bidId: '22c4871113f461',
+ bidder: 'operaads',
+ bidderRequestId: '15246a574e859f',
+ mediaTypes: {
+ banner: {sizes: [[300, 250]]}
+ },
+ params: {
+ placementId: 's12345678',
+ publisherId: 'pub12345678',
+ endpointId: 'ep12345678'
+ }
+ }
+
+ const getRequest = function () {
+ let reqs;
+ expect(function () {
+ reqs = spec.buildRequests([bidRequest], bidderRequest);
+ }).to.not.throw();
+ return JSON.parse(reqs[0].data);
+ }
+
+ it('test default case', function () {
+ let requestData = getRequest();
+ expect(requestData.site).to.be.an('object');
+ expect(requestData.site.id).to.equal(bidRequest.params.publisherId);
+ expect(requestData.site.domain).to.not.be.empty;
+ expect(requestData.site.page).to.equal(bidderRequest.refererInfo.page);
+ });
+
+ it('test a case with site information specified', function () {
+ bidRequest.params = {
+ placementId: 's12345678',
+ publisherId: 'pub12345678',
+ endpointId: 'ep12345678',
+ site: {
+ name: 'test-site-1',
+ domain: 'www.test.com'
+ }
+ }
+ let requestData = getRequest();
+ expect(requestData.site).to.be.an('object');
+ expect(requestData.site.id).to.equal(bidRequest.params.publisherId);
+ expect(requestData.site.name).to.equal('test-site-1');
+ expect(requestData.site.domain).to.equal('www.test.com');
+ expect(requestData.site.page).to.equal(bidderRequest.refererInfo.page);
+ });
+
+ it('test a case with app information specified', function () {
+ bidRequest.params = {
+ placementId: 's12345678',
+ publisherId: 'pub12345678',
+ endpointId: 'ep12345678',
+ app: {
+ name: 'test-app-1'
+ }
+ }
+ let requestData = getRequest();
+ expect(requestData.app).to.be.an('object');
+ expect(requestData.app.id).to.equal(bidRequest.params.publisherId);
+ expect(requestData.app.name).to.equal('test-app-1');
+ expect(requestData.app.domain).to.not.be.empty;
+ });
+
+ it('test a case with both site and app information specified', function () {
+ bidRequest.params = {
+ placementId: 's12345678',
+ publisherId: 'pub12345678',
+ endpointId: 'ep12345678',
+ site: {
+ name: 'test-site-2',
+ page: 'test-page'
+ },
+ app: {
+ name: 'test-app-1'
+ }
+ }
+ let requestData = getRequest();
+ expect(requestData.site).to.be.an('object');
+ expect(requestData.site.id).to.equal(bidRequest.params.publisherId);
+ expect(requestData.site.name).to.equal('test-site-2');
+ expect(requestData.site.page).to.equal('test-page');
+ expect(requestData.site.domain).to.not.be.empty;
+ });
+ });
+
it('test getBidFloor', function() {
const bidRequests = [
{
diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js
index 5af5a4d710f..cf58d35e636 100644
--- a/test/spec/modules/orbidderBidAdapter_spec.js
+++ b/test/spec/modules/orbidderBidAdapter_spec.js
@@ -9,39 +9,57 @@ describe('orbidderBidAdapter', () => {
const defaultBidRequestBanner = {
bidId: 'd66fa86787e0b0ca900a96eacfd5f0bb',
auctionId: 'ccc4c7cdfe11cfbd74065e6dd28413d8',
- ortb2Imp: {
- ext: {
- tid: 'd58851660c0c4461e4aa06344fc9c0c6',
- }
- },
+ transactionId: 'd58851660c0c4461e4aa06344fc9c0c6',
bidRequestCount: 1,
adUnitCode: 'adunit-code',
sizes: [[300, 250], [300, 600]],
params: {
'accountId': 'string1',
- 'placementId': 'string2'
+ 'placementId': 'string2',
+ 'bidfloor': 1.23
},
mediaTypes: {
banner: {
- sizes: [[300, 250], [300, 600]],
+ sizes: [[300, 250], [300, 600]]
}
- }
+ },
+ userId: {
+ 'id5id': {
+ 'uid': 'ID5*XXXXXXXXXXXXX',
+ 'ext': {
+ 'linkType': 2,
+ 'pba': 'XXXXXXXXXXXX=='
+ }
+ }
+ },
+ userIdAsEids: [
+ {
+ 'source': 'id5-sync.com',
+ 'uids': [
+ {
+ 'id': 'ID5*XXXXXXXXXXXXX',
+ 'atype': 1,
+ 'ext': {
+ 'linkType': 2,
+ 'pba': 'XXXXXXXXXXXX=='
+ }
+ }
+ ]
+ }
+ ]
};
const defaultBidRequestNative = {
bidId: 'd66fa86787e0b0ca900a96eacfd5f0bc',
auctionId: 'ccc4c7cdfe11cfbd74065e6dd28413d9',
- ortb2Imp: {
- ext: {
- tid: 'd58851660c0c4461e4aa06344fc9c0c7',
- }
- },
+ transactionId: 'd58851660c0c4461e4aa06344fc9c0c6',
bidRequestCount: 1,
adUnitCode: 'adunit-code-native',
sizes: [],
params: {
'accountId': 'string3',
- 'placementId': 'string4'
+ 'placementId': 'string4',
+ 'bidfloor': 2.34
},
mediaTypes: {
native: {
@@ -56,7 +74,31 @@ describe('orbidderBidAdapter', () => {
required: true
}
}
- }
+ },
+ userId: {
+ 'id5id': {
+ 'uid': 'ID5*YYYYYYYYYYYYYYY',
+ 'ext': {
+ 'linkType': 2,
+ 'pba': 'YYYYYYYYYYYYY=='
+ }
+ }
+ },
+ userIdAsEids: [
+ {
+ 'source': 'id5-sync.com',
+ 'uids': [
+ {
+ 'id': 'ID5*YYYYYYYYYYYYYYY',
+ 'atype': 1,
+ 'ext': {
+ 'linkType': 2,
+ 'pba': 'YYYYYYYYYYYYY=='
+ }
+ }
+ ]
+ }
+ ]
};
const deepClone = function(val) {
@@ -179,34 +221,20 @@ describe('orbidderBidAdapter', () => {
// we add two, because we add pageUrl and version from bidderRequest object
expect(Object.keys(request.data).length).to.equal(Object.keys(defaultBidRequestBanner).length + 2);
- expect(request.data.bidId).to.equal(defaultBidRequestBanner.bidId);
- expect(request.data.auctionId).to.equal(defaultBidRequestBanner.auctionId);
- expect(request.data.transactionId).to.equal(defaultBidRequestBanner.ortb2Imp.ext.tid);
- expect(request.data.bidRequestCount).to.equal(defaultBidRequestBanner.bidRequestCount);
- expect(request.data.adUnitCode).to.equal(defaultBidRequestBanner.adUnitCode);
- expect(request.data.pageUrl).to.equal('https://localhost:9876/');
- expect(request.data.v).to.equal($$PREBID_GLOBAL$$.version);
- expect(request.data.sizes).to.equal(defaultBidRequestBanner.sizes);
-
- expect(_.isEqual(request.data.params, defaultBidRequestBanner.params)).to.be.true;
- expect(_.isEqual(request.data.mediaTypes, defaultBidRequestBanner.mediaTypes)).to.be.true;
+ const expectedBidRequest = deepClone(defaultBidRequestBanner);
+ expectedBidRequest.pageUrl = 'https://localhost:9876/';
+ expectedBidRequest.v = $$PREBID_GLOBAL$$.version;
+ expect(request.data).to.deep.equal(expectedBidRequest);
});
it('native: sends correct bid parameters', () => {
// we add two, because we add pageUrl and version from bidderRequest object
expect(Object.keys(nativeRequest.data).length).to.equal(Object.keys(defaultBidRequestNative).length + 2);
- expect(nativeRequest.data.bidId).to.equal(defaultBidRequestNative.bidId);
- expect(nativeRequest.data.auctionId).to.equal(defaultBidRequestNative.auctionId);
- expect(nativeRequest.data.transactionId).to.equal(defaultBidRequestNative.ortb2Imp.ext.tid);
- expect(nativeRequest.data.bidRequestCount).to.equal(defaultBidRequestNative.bidRequestCount);
- expect(nativeRequest.data.adUnitCode).to.equal(defaultBidRequestNative.adUnitCode);
- expect(nativeRequest.data.pageUrl).to.equal('https://localhost:9876/');
- expect(nativeRequest.data.v).to.equal($$PREBID_GLOBAL$$.version);
- expect(nativeRequest.data.sizes).to.be.empty;
-
- expect(_.isEqual(nativeRequest.data.params, defaultBidRequestNative.params)).to.be.true;
- expect(_.isEqual(nativeRequest.data.mediaTypes, defaultBidRequestNative.mediaTypes)).to.be.true;
+ const expectedBidRequest = deepClone(defaultBidRequestNative);
+ expectedBidRequest.pageUrl = 'https://localhost:9876/';
+ expectedBidRequest.v = $$PREBID_GLOBAL$$.version;
+ expect(nativeRequest.data).to.deep.equal(expectedBidRequest);
});
it('banner: handles empty gdpr object', () => {
diff --git a/test/spec/modules/outbrainBidAdapter_spec.js b/test/spec/modules/outbrainBidAdapter_spec.js
index ba394a68675..e6abb5e9caa 100644
--- a/test/spec/modules/outbrainBidAdapter_spec.js
+++ b/test/spec/modules/outbrainBidAdapter_spec.js
@@ -427,7 +427,7 @@ describe('Outbrain Adapter', function () {
expect(resData.badv).to.deep.equal(['bad-advertiser'])
});
- it('first party data', function () {
+ it('should pass first party data', function () {
const bidRequest = {
...commonBidRequest,
...nativeBidRequestParams,
@@ -508,6 +508,28 @@ describe('Outbrain Adapter', function () {
config.resetConfig()
});
+ it('should pass gpp information', function () {
+ const bidRequest = {
+ ...commonBidRequest,
+ ...nativeBidRequestParams,
+ };
+ const bidderRequest = {
+ ...commonBidderRequest,
+ 'gppConsent': {
+ 'gppString': 'abc12345',
+ 'applicableSections': [8]
+ }
+ }
+
+ const res = spec.buildRequests([bidRequest], bidderRequest);
+ const resData = JSON.parse(res.data);
+
+ expect(resData.regs.ext.gpp).to.exist;
+ expect(resData.regs.ext.gpp_sid).to.exist;
+ expect(resData.regs.ext.gpp).to.equal('abc12345');
+ expect(resData.regs.ext.gpp_sid).to.deep.equal([8]);
+ });
+
it('should pass extended ids', function () {
let bidRequest = {
bidId: 'bidId',
@@ -861,6 +883,12 @@ describe('Outbrain Adapter', function () {
type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=foo&us_privacy=1NYN`
}]);
});
+
+ it('should pass gpp consent', function () {
+ expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined, '', { gppString: 'abc12345', applicableSections: [1, 2] })).to.deep.equal([{
+ type: 'image', url: `${usersyncUrl}?gpp=abc12345&gpp_sid=1%2C2`
+ }]);
+ });
})
describe('onBidWon', function () {
diff --git a/test/spec/modules/ozoneBidAdapter_spec.js b/test/spec/modules/ozoneBidAdapter_spec.js
index 64b345c5d9c..73df2fba8fd 100644
--- a/test/spec/modules/ozoneBidAdapter_spec.js
+++ b/test/spec/modules/ozoneBidAdapter_spec.js
@@ -2069,6 +2069,19 @@ describe('ozone Adapter', function () {
expect(request.length).to.equal(3);
config.resetConfig();
});
+ it('should not batch into 10s if config is set to false and singleRequest is true', function () {
+ config.setConfig({ozone: {'batchRequests': false, 'singleRequest': true}});
+ var specMock = utils.deepClone(spec);
+ let arrReq = [];
+ for (let i = 0; i < 15; i++) {
+ let b = validBidRequests[0];
+ b.adUnitCode += i;
+ arrReq.push(b);
+ }
+ const request = specMock.buildRequests(arrReq, validBidderRequest);
+ expect(request.method).to.equal('POST');
+ config.resetConfig();
+ });
it('should use GET values auction=dev & cookiesync=dev if set', function() {
var specMock = utils.deepClone(spec);
specMock.getGetParametersAsObject = function() {
diff --git a/test/spec/modules/pangleBidAdapter_spec.js b/test/spec/modules/pangleBidAdapter_spec.js
index 79cbc30b4ec..94f5a6e4b1d 100644
--- a/test/spec/modules/pangleBidAdapter_spec.js
+++ b/test/spec/modules/pangleBidAdapter_spec.js
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { spec } from 'modules/pangleBidAdapter.js';
+import { logInfo } from '../../../src/utils';
const REQUEST = [{
adUnitCode: 'adUnitCode1',
@@ -45,6 +46,7 @@ const REQUEST = [{
appid: 111,
},
}];
+
const DEFAULT_OPTIONS = {
userId: {
britepoolid: 'pangle-britepool',
@@ -184,4 +186,110 @@ describe('pangle bid adapter', function () {
expect(deviceType).to.equal(2);
});
});
+
+ // describe('video', function () {
+ // it('video config', function() {
+ // logInfo(spec.buildRequests(VIDEO_REQUEST, DEFAULT_OPTIONS)[0].data, 'spec.buildRequests(videoConfig, DEFAULT_OPTIONS)[0].data.imp[0]');
+ // const request = spec.buildRequests(VIDEO_REQUEST, DEFAULT_OPTIONS)[0];
+
+ // expect(request).to.exist.and.to.be.a('object');
+ // const payload = request.data;
+ // expect(payload).to.exist.and.to.be.a('object');
+ // const video = payload.imp[0].video;
+ // expect(video).to.exist.and.to.be.a('object');
+ // // console.log(video, 'video???')
+ // // expect(url).to.equal('https://pangle.pangleglobal.com/api/ad/union/web_js/common/get_ads');
+ // // assert.deepEqual(video, {
+ // // h: 380,
+ // // mimes: ['video/mp4'],
+ // // w: 240
+ // // })
+ // })
+ // })
+});
+
+describe('Pangle Adapter with video', function() {
+ const videoBidRequest = [
+ {
+ bidId: '2820132fe18114',
+ mediaTypes: { video: { context: 'outstream', playerSize: [[300, 250]] } },
+ params: { token: 'test-token' }
+ }
+ ];
+ const bidderRequest = {
+ refererInfo: {
+ referer: 'https://example.com'
+ }
+ };
+ const serverResponse = {
+ 'headers': null,
+ 'body': {
+ 'id': '233f1693-68d1-470a-ad85-c156c3faaf6f',
+ 'seatbid': [
+ {
+ 'bid': [
+ {
+ 'id': '2820132fe18114',
+ 'impid': '2820132fe18114',
+ 'price': 0.03294,
+ 'nurl': 'https://api16-event-sg2.pangle.io/api/ad/union/openrtb/win/?req_id=233f1693-68d1-470a-ad85-c156c3faaf6fu1450&ttdsp_adx_index=256&rit=980589944&extra=oqveoB%2Bg4%2ByNz9L8wwu%2Fy%2FwKxQsGaKsJHuB4NMK77uqZ9%2FJKpnsVZculJX8%2FxrRBAtaktU1DRN%2Fy6TKAqibCbj%2FM3%2BZ6biAKQG%2BCyt4eIV0KVvri9jCCnaajbkN7YNJWJJw2lW6cJ6Va3SuJG9H7a%2FAJd2PMbhK7fXWhoW72TwgOcKHKBgjM6sNDISBKbWlZyY3L1PhKSX%2FM8LOvL6qahsb%2FDpEObIx24vhQLNWp28XY1L4UqeibuRjam3eCvN7nXoQq74KkJ45QQsTgvV4j6I6EbLOdjOi%2FURhWMDjUD1VCMpqUT%2B6L8ZROgrX9Tp53eJ3bFOczmSTOmDSazKMHa%2B3uZZ7JHcSx32eoY4hfYc99NOJmYBKXNKCmoXyJvS3PCM3PlAz97hKrDMGnVv1wAQ7QGDCbittF0vZwtsRAvvx2mWINNIB3%2FUB2PjhxFsoDA%2BWE2urVZwEdyu%2FJrCznJsMwenXjcbMD5jmUF5vDkkLS%2B7TMDIEawJPJKZ62pK35enrwGxCs6ePXi21rJJkA0bF8tgAdl4mU1illBIVO4kCL%2ByRASskHPjgg%2FcdFe9HP%2Fi8byjAprH%2BhRerN%2FRKFxC3xv8b75x2pb1g7dY%2FTj9IjT0evsBSPVwFNqtKmPId35IcY%2FSXiqPHh%2FrAHZzr5BPsTT19P49SlNMR9UZYTzViX1iJpcCL1UFjuDdrdff%2BhHCviXxo%2FkRmufEF3umHZwxbdDOPAghuZ0DtRCY6S1rnb%2FK9BbpsVKSndOtgfCwMHFwiPmdw1XjEXGc1eOWXY6qfSp90PIfL6WS7Neh3ba2qMv6WxG3HSOBYvrcCqVTsNxk4UdVm3qb1J0CMVByweTMo45usSkCTdvX3JuEB7tVA6%2BrEk57b3XJd5Phf2AN8hon%2F7lmcXE41kwMQuXq89ViwQmW0G247UFWOQx4t1cmBqFiP6qNA%2F%2BunkZDno1pmAsGnTv7Mz9xtpOaIqKl8BKrVQSTopZ9WcUVzdBUutF19mn1f43BvyA9gIEhcDJHOj&win_price=${AUCTION_PRICE}&auction_mwb=${AUCTION_BID_TO_WIN}&use_pb=1',
+ 'lurl': 'https://api16-event-sg2.pangle.io/api/ad/union/openrtb/loss/?req_id=233f1693-68d1-470a-ad85-c156c3faaf6fu1450&ttdsp_adx_index=256&rit=980589944&extra=oqveoB%2Bg4%2ByNz9L8wwu%2Fy%2FwKxQsGaKsJHuB4NMK77uqZ9%2FJKpnsVZculJX8%2FxrRBAtaktU1DRN%2Fy6TKAqibCbj%2FM3%2BZ6biAKQG%2BCyt4eIV0KVvri9jCCnaajbkN7YNJWJJw2lW6cJ6Va3SuJG9H7a%2FAJd2PMbhK7fXWhoW72TwgOcKHKBgjM6sNDISBKbWlZyY3L1PhKSX%2FM8LOvL6qahsb%2FDpEObIx24vhQLNWp28XY1L4UqeibuRjam3eCvN7nXoQq74KkJ45QQsTgvV4j6I6EbLOdjOi%2FURhWMDjUD1VCMpqUT%2B6L8ZROgrX9Tp53eJ3bFOczmSTOmDSazKMHa%2B3uZZ7JHcSx32eoY4hfYc99NOJmYBKXNKCmoXyJvS3PCM3PlAz97hKrDMGnVv1wAQ7QGDCbittF0vZwtsRAvvx2mWINNIB3%2FUB2PjhxFsoDA%2BWE2urVZwEdyu%2FJrCznJsMwenXjcbMD5jmUF5vDkkLS%2B7TMDIEawJPJKZ62pK35enrwGxCs6ePXi21rJJkA0bF8tgAdl4mU1illBIVO4kCL%2ByRASskHPjgg%2FcdFe9HP%2Fi8byjAprH%2BhRerN%2FRKFxC3xv8b75x2pb1g7dY%2FTj9IjT0evsBSPVwFNqtKmPId35IcY%2FSXiqPHh%2FrAHZzr5BPsTT19P49SlNMR9UZYTzViX1iJpcCL1UFjuDdrdff%2BhHCviXxo%2FkRmufEF3umHZwxbdDOPAghuZ0DtRCY6S1rnb%2FK9BbpsVKSndOtgfCwMHFwiPmdw1XjEXGc1eOWXY6qfSp90PIfL6WS7Neh3ba2qMv6WxG3HSOBYvrcCqVTsNxk4UdVm3qb1J0CMVByweTMo45usSkCTdvX3JuEB7tVA6%2BrEk57b3XJd5Phf2AN8hon%2F7lmcXE41kwMQuXq89ViwQmW0G247UFWOQx4t1cmBqFiP6qNA%2F%2BunkZDno1pmAsGnTv7Mz9xtpOaIqKl8BKrVQSTopZ9WcUVzdBUutF19mn1f43BvyA9gIEhcDJHOj&reason=${AUCTION_LOSS}&ad_slot_type=8&auction_mwb=${AUCTION_PRICE}&use_pb=1',
+ 'adm': '',
+ 'adid': '1780626232977441',
+ 'adomain': [
+ 'swi.esxcmnb.com'
+ ],
+ 'iurl': 'https://p16-ttam-va.ibyteimg.com/origin/ad-site-i18n-sg/202310245d0d598b3ff5993c4f129a8b',
+ 'cid': '1780626232977441',
+ 'crid': '1780626232977441',
+ 'attr': [
+ 4
+ ],
+ 'w': 640,
+ 'h': 640,
+ 'ext': {
+ 'pangle': {
+ 'adtype': 8
+ },
+ 'event_notification_token': {
+ 'payload': '980589944:8:1450:7492'
+ }
+ }
+ }
+ ],
+ 'seat': 'pangle'
+ }
+ ]
+ }
+ };
+
+ describe('Video: buildRequests', function() {
+ it('should create a POST request for video bid', function() {
+ const requests = spec.buildRequests(videoBidRequest, bidderRequest);
+ expect(requests[0].method).to.equal('POST');
+ });
+
+ it('should have a valid URL and payload for an out-stream video bid', function () {
+ const requests = spec.buildRequests(videoBidRequest, bidderRequest);
+ expect(requests[0].url).to.equal('https://pangle.pangleglobal.com/api/ad/union/web_js/common/get_ads');
+ expect(requests[0].data).to.exist;
+ });
+ });
+
+ describe('interpretResponse: Video', function () {
+ it('should get correct bid response', function () {
+ const request = spec.buildRequests(videoBidRequest, bidderRequest)[0];
+ const interpretedResponse = spec.interpretResponse(serverResponse, request);
+ expect(interpretedResponse).to.be.an('array');
+ const bid = interpretedResponse[0];
+ expect(bid).to.exist;
+ expect(bid.requestId).to.exist;
+ expect(bid.cpm).to.be.above(0);
+ expect(bid.ttl).to.exist;
+ expect(bid.creativeId).to.exist;
+ if (bid.renderer) {
+ expect(bid.renderer.render).to.exist;
+ }
+ });
+ });
});
diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js
index ecace22f97f..5b591804b95 100644
--- a/test/spec/modules/prebidServerBidAdapter_spec.js
+++ b/test/spec/modules/prebidServerBidAdapter_spec.js
@@ -14,7 +14,6 @@ import {config} from 'src/config.js';
import * as events from 'src/events.js';
import CONSTANTS from 'src/constants.json';
import {server} from 'test/mocks/xhr.js';
-import {createEidsArray} from 'modules/userId/eids.js';
import 'modules/appnexusBidAdapter.js'; // appnexus alias test
import 'modules/rubiconBidAdapter.js'; // rubicon alias test
import 'src/prebid.js'; // $$PREBID_GLOBAL$$.aliasBidder test
@@ -34,11 +33,9 @@ import {auctionManager} from '../../../src/auctionManager.js';
import {stubAuctionIndex} from '../../helpers/indexStub.js';
import {addComponentAuction, registerBidder} from 'src/adapters/bidderFactory.js';
import {getGlobal} from '../../../src/prebidGlobal.js';
-import {syncAddFPDEnrichments, syncAddFPDToBidderRequest} from '../../helpers/fpd.js';
+import {syncAddFPDToBidderRequest} from '../../helpers/fpd.js';
import {deepSetValue} from '../../../src/utils.js';
-import {sandbox} from 'sinon';
import {ACTIVITY_TRANSMIT_UFPD} from '../../../src/activities/activities.js';
-import {activityParams} from '../../../src/activities/activityParams.js';
import {MODULE_TYPE_PREBID} from '../../../src/activities/modules.js';
let CONFIG = {
@@ -2054,7 +2051,7 @@ describe('S2S Adapter', function () {
const bidRequests = utils.deepClone(BID_REQUESTS);
adapter.callBids(REQUEST, bidRequests, addBidResponse, done, ajax);
- const parsedRequestBody = JSON.parse(server.requests[1].requestBody);
+ const parsedRequestBody = JSON.parse(server.requests.find(req => req.method === 'POST').requestBody);
expect(parsedRequestBody.cur).to.deep.equal(['NZ']);
});
@@ -3425,29 +3422,6 @@ describe('S2S Adapter', function () {
});
});
describe('when the response contains ext.prebid.fledge', () => {
- let fledgeStub, request, bidderRequests;
-
- function fledgeHook(next, ...args) {
- fledgeStub(...args);
- }
-
- before(() => {
- addComponentAuction.before(fledgeHook);
- });
-
- after(() => {
- addComponentAuction.getHooks({hook: fledgeHook}).remove();
- })
-
- beforeEach(function () {
- fledgeStub = sinon.stub();
- config.setConfig({CONFIG});
- request = deepClone(REQUEST);
- request.ad_units.forEach(au => deepSetValue(au, 'ortb2Imp.ext.ae', 1));
- bidderRequests = deepClone(BID_REQUESTS);
- bidderRequests.forEach(req => req.fledgeEnabled = true);
- });
-
const AU = 'div-gpt-ad-1460505748561-0';
const FLEDGE_RESP = {
ext: {
@@ -3456,12 +3430,14 @@ describe('S2S Adapter', function () {
auctionconfigs: [
{
impid: AU,
+ bidder: 'appnexus',
config: {
id: 1
}
},
{
impid: AU,
+ bidder: 'other',
config: {
id: 2
}
@@ -3472,20 +3448,62 @@ describe('S2S Adapter', function () {
}
}
+ let fledgeStub, request, bidderRequests;
+
+ function fledgeHook(next, ...args) {
+ fledgeStub(...args);
+ }
+
+ before(() => {
+ addComponentAuction.before(fledgeHook);
+ });
+
+ after(() => {
+ addComponentAuction.getHooks({hook: fledgeHook}).remove();
+ })
+
+ beforeEach(function () {
+ fledgeStub = sinon.stub();
+ config.setConfig({CONFIG});
+ bidderRequests = deepClone(BID_REQUESTS);
+ AU
+ bidderRequests.forEach(req => {
+ Object.assign(req, {
+ fledgeEnabled: true,
+ ortb2: {
+ fpd: 1
+ }
+ })
+ req.bids.forEach(bid => {
+ Object.assign(bid, {
+ ortb2Imp: {
+ fpd: 2
+ }
+ })
+ })
+ });
+ request = deepClone(REQUEST);
+ request.ad_units.forEach(au => deepSetValue(au, 'ortb2Imp.ext.ae', 1));
+ });
+
+ function expectFledgeCalls() {
+ const auctionId = bidderRequests[0].auctionId;
+ sinon.assert.calledWith(fledgeStub, sinon.match({auctionId, adUnitCode: AU, ortb2: bidderRequests[0].ortb2, ortb2Imp: bidderRequests[0].bids[0].ortb2Imp}), {id: 1})
+ sinon.assert.calledWith(fledgeStub, sinon.match({auctionId, adUnitCode: AU, ortb2: undefined, ortb2Imp: undefined}), {id: 2})
+ }
+
it('calls addComponentAuction alongside addBidResponse', function () {
adapter.callBids(request, bidderRequests, addBidResponse, done, ajax);
server.requests[0].respond(200, {}, JSON.stringify(mergeDeep({}, RESPONSE_OPENRTB, FLEDGE_RESP)));
expect(addBidResponse.called).to.be.true;
- sinon.assert.calledWith(fledgeStub, bidderRequests[0].auctionId, AU, {id: 1});
- sinon.assert.calledWith(fledgeStub, bidderRequests[0].auctionId, AU, {id: 2});
+ expectFledgeCalls();
});
it('calls addComponentAuction when there is no bid in the response', () => {
adapter.callBids(request, bidderRequests, addBidResponse, done, ajax);
server.requests[0].respond(200, {}, JSON.stringify(FLEDGE_RESP));
expect(addBidResponse.called).to.be.false;
- sinon.assert.calledWith(fledgeStub, bidderRequests[0].auctionId, AU, {id: 1});
- sinon.assert.calledWith(fledgeStub, bidderRequests[0].auctionId, AU, {id: 2});
+ expectFledgeCalls();
})
});
});
@@ -3743,6 +3761,74 @@ describe('S2S Adapter', function () {
})
});
+ it('should configure the s2sConfig object with openwrap vendor defaults unless specified by user', function () {
+ const options = {
+ accountId: '1234',
+ bidders: ['pubmatic'],
+ defaultVendor: 'openwrap'
+ };
+
+ config.setConfig({ s2sConfig: options });
+ sinon.assert.notCalled(logErrorSpy);
+
+ let vendorConfig = config.getConfig('s2sConfig');
+ expect(vendorConfig).to.have.property('accountId', '1234');
+ expect(vendorConfig).to.have.property('adapter', 'prebidServer');
+ expect(vendorConfig.bidders).to.deep.equal(['pubmatic']);
+ expect(vendorConfig.enabled).to.be.true;
+ expect(vendorConfig.endpoint).to.deep.equal({
+ p1Consent: 'https://ow.pubmatic.com/openrtb2/auction?source=pbjs',
+ noP1Consent: 'https://ow.pubmatic.com/openrtb2/auction?source=pbjs'
+ });
+ expect(vendorConfig).to.have.property('timeout', 500);
+ });
+
+ it('should return proper defaults', function () {
+ const options = {
+ accountId: '1234',
+ bidders: ['pubmatic'],
+ defaultVendor: 'openwrap',
+ timeout: 500
+ };
+
+ config.setConfig({ s2sConfig: options });
+ expect(config.getConfig('s2sConfig')).to.deep.equal({
+ 'accountId': '1234',
+ 'adapter': 'prebidServer',
+ 'bidders': ['pubmatic'],
+ 'defaultVendor': 'openwrap',
+ 'enabled': true,
+ 'endpoint': {
+ p1Consent: 'https://ow.pubmatic.com/openrtb2/auction?source=pbjs',
+ noP1Consent: 'https://ow.pubmatic.com/openrtb2/auction?source=pbjs'
+ },
+ 'timeout': 500
+ })
+ });
+
+ it('should return default adapterOptions if not set', function () {
+ config.setConfig({
+ s2sConfig: {
+ accountId: '1234',
+ bidders: ['pubmatic'],
+ defaultVendor: 'openwrap',
+ timeout: 500
+ }
+ });
+ expect(config.getConfig('s2sConfig')).to.deep.equal({
+ enabled: true,
+ timeout: 500,
+ adapter: 'prebidServer',
+ accountId: '1234',
+ bidders: ['pubmatic'],
+ defaultVendor: 'openwrap',
+ endpoint: {
+ p1Consent: 'https://ow.pubmatic.com/openrtb2/auction?source=pbjs',
+ noP1Consent: 'https://ow.pubmatic.com/openrtb2/auction?source=pbjs'
+ },
+ })
+ });
+
it('should set adapterOptions', function () {
config.setConfig({
s2sConfig: {
diff --git a/test/spec/modules/priceFloors_spec.js b/test/spec/modules/priceFloors_spec.js
index 950e039491d..673a821b497 100644
--- a/test/spec/modules/priceFloors_spec.js
+++ b/test/spec/modules/priceFloors_spec.js
@@ -2011,6 +2011,12 @@ describe('the price floors module', function () {
expect(returnedBidResponse).to.not.haveOwnProperty('floorData');
expect(logWarnSpy.calledOnce).to.equal(true);
});
+ it('if it finds a rule with a floor price of zero it should not call log warn', function () {
+ _floorDataForAuction[AUCTION_ID] = utils.deepClone(basicFloorConfig);
+ _floorDataForAuction[AUCTION_ID].data.values = { '*': 0 };
+ runBidResponse();
+ expect(logWarnSpy.calledOnce).to.equal(false);
+ });
it('if it finds a rule and floors should update the bid accordingly', function () {
_floorDataForAuction[AUCTION_ID] = utils.deepClone(basicFloorConfig);
_floorDataForAuction[AUCTION_ID].data.values = { 'banner': 1.0 };
diff --git a/test/spec/modules/programmaticaBidAdapter_spec.js b/test/spec/modules/programmaticaBidAdapter_spec.js
new file mode 100644
index 00000000000..247d20752c3
--- /dev/null
+++ b/test/spec/modules/programmaticaBidAdapter_spec.js
@@ -0,0 +1,263 @@
+import { expect } from 'chai';
+import { spec } from 'modules/programmaticaBidAdapter.js';
+import { deepClone } from 'src/utils.js';
+
+describe('programmaticaBidAdapterTests', function () {
+ let bidRequestData = {
+ bids: [
+ {
+ bidId: 'testbid',
+ bidder: 'programmatica',
+ params: {
+ siteId: 'testsite',
+ placementId: 'testplacement',
+ },
+ sizes: [[300, 250]]
+ }
+ ]
+ };
+ let request = [];
+
+ it('validate_pub_params', function () {
+ expect(
+ spec.isBidRequestValid({
+ bidder: 'programmatica',
+ params: {
+ siteId: 'testsite',
+ placementId: 'testplacement',
+ }
+ })
+ ).to.equal(true);
+ });
+
+ it('validate_generated_url', function () {
+ const request = spec.buildRequests(deepClone(bidRequestData.bids), { timeout: 1234 });
+ let req_url = request[0].url;
+
+ expect(req_url).to.equal('https://asr.programmatica.com/get');
+ });
+
+ it('validate_response_params', function () {
+ let serverResponse = {
+ body: {
+ 'id': 'crid',
+ 'type': {
+ 'format': 'Image',
+ 'source': 'passback',
+ 'dspId': '',
+ 'dspCreativeId': ''
+ },
+ 'content': {
+ 'data': 'test ad',
+ 'imps': null,
+ 'click': {
+ 'url': '',
+ 'track': null
+ }
+ },
+ 'size': '300x250',
+ 'matching': '',
+ 'cpm': 10,
+ 'currency': 'USD'
+ }
+ };
+
+ const bidRequest = deepClone(bidRequestData.bids)
+ bidRequest[0].mediaTypes = {
+ banner: {}
+ }
+
+ const request = spec.buildRequests(bidRequest);
+ let bids = spec.interpretResponse(serverResponse, request[0]);
+ expect(bids).to.have.lengthOf(1);
+
+ let bid = bids[0];
+ expect(bid.ad).to.equal('test ad');
+ expect(bid.cpm).to.equal(10);
+ expect(bid.currency).to.equal('USD');
+ expect(bid.width).to.equal(300);
+ expect(bid.height).to.equal(250);
+ expect(bid.creativeId).to.equal('crid');
+ expect(bid.meta.advertiserDomains).to.deep.equal(['programmatica.com']);
+ });
+
+ it('validate_response_params_imps', function () {
+ let serverResponse = {
+ body: {
+ 'id': 'crid',
+ 'type': {
+ 'format': 'Image',
+ 'source': 'passback',
+ 'dspId': '',
+ 'dspCreativeId': ''
+ },
+ 'content': {
+ 'data': 'test ad',
+ 'imps': [
+ 'testImp'
+ ],
+ 'click': {
+ 'url': '',
+ 'track': null
+ }
+ },
+ 'size': '300x250',
+ 'matching': '',
+ 'cpm': 10,
+ 'currency': 'USD'
+ }
+ };
+
+ const bidRequest = deepClone(bidRequestData.bids)
+ bidRequest[0].mediaTypes = {
+ banner: {}
+ }
+
+ const request = spec.buildRequests(bidRequest);
+ let bids = spec.interpretResponse(serverResponse, request[0]);
+ expect(bids).to.have.lengthOf(1);
+
+ let bid = bids[0];
+ expect(bid.ad).to.equal('test ad');
+ expect(bid.cpm).to.equal(10);
+ expect(bid.currency).to.equal('USD');
+ expect(bid.width).to.equal(300);
+ expect(bid.height).to.equal(250);
+ expect(bid.creativeId).to.equal('crid');
+ expect(bid.meta.advertiserDomains).to.deep.equal(['programmatica.com']);
+ })
+
+ it('validate_invalid_response', function () {
+ let serverResponse = {
+ body: {}
+ };
+
+ const bidRequest = deepClone(bidRequestData.bids)
+ bidRequest[0].mediaTypes = {
+ banner: {}
+ }
+
+ const request = spec.buildRequests(bidRequest);
+ let bids = spec.interpretResponse(serverResponse, request[0]);
+ expect(bids).to.have.lengthOf(0);
+ })
+
+ it('video_bid', function () {
+ const bidRequest = deepClone(bidRequestData.bids);
+ bidRequest[0].mediaTypes = {
+ video: {
+ playerSize: [234, 765]
+ }
+ };
+
+ const request = spec.buildRequests(bidRequest, { timeout: 1234 });
+ const vastXml = '';
+ let serverResponse = {
+ body: {
+ 'id': 'cki2n3n6snkuulqutpf0',
+ 'type': {
+ 'format': '',
+ 'source': 'rtb',
+ 'dspId': '1'
+ },
+ 'content': {
+ 'data': vastXml,
+ 'imps': [
+ 'https://asr.dev.programmatica.com/track/imp'
+ ],
+ 'click': {
+ 'url': '',
+ 'track': null
+ }
+ },
+ 'size': '',
+ 'matching': '',
+ 'cpm': 70,
+ 'currency': 'RUB'
+ }
+ };
+
+ let bids = spec.interpretResponse(serverResponse, request[0]);
+ expect(bids).to.have.lengthOf(1);
+
+ let bid = bids[0];
+ expect(bid.mediaType).to.equal('video');
+ expect(bid.vastXml).to.equal(vastXml);
+ expect(bid.width).to.equal(234);
+ expect(bid.height).to.equal(765);
+ });
+});
+
+describe('getUserSyncs', function() {
+ it('returns empty sync array', function() {
+ const syncOptions = {};
+
+ expect(spec.getUserSyncs(syncOptions)).to.deep.equal([]);
+ });
+
+ it('Should return array of objects with proper sync config , include CCPA', function() {
+ const syncData = spec.getUserSyncs({
+ pixelEnabled: true,
+ }, {}, {}, '1---');
+ expect(syncData).to.be.an('array').which.is.not.empty;
+ expect(syncData[0]).to.be.an('object')
+ expect(syncData[0].type).to.be.a('string')
+ expect(syncData[0].type).to.equal('image')
+ expect(syncData[0].url).to.be.a('string')
+ expect(syncData[0].url).to.equal('//sync.programmatica.com/match/sp?usp=1---&consent=')
+ });
+
+ it('Should return array of objects with proper sync config , include GDPR', function() {
+ const syncData = spec.getUserSyncs({
+ iframeEnabled: true,
+ }, {}, {
+ gdprApplies: true,
+ consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw',
+ vendorData: {
+ purpose: {
+ consents: {
+ 1: true
+ },
+ },
+ }
+ }, '');
+ expect(syncData).to.be.an('array').which.is.not.empty;
+ expect(syncData[0]).to.be.an('object')
+ expect(syncData[0].type).to.be.a('string')
+ expect(syncData[0].type).to.equal('iframe')
+ expect(syncData[0].url).to.be.a('string')
+ expect(syncData[0].url).to.equal('//sync.programmatica.com/match/sp.ifr?usp=&consent=COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw&gdpr=1')
+ });
+
+ it('Should return array of objects with proper sync config , include GDPR, no purpose', function() {
+ const syncData = spec.getUserSyncs({
+ iframeEnabled: true,
+ }, {}, {
+ gdprApplies: true,
+ consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw',
+ vendorData: {
+ purpose: {
+ consents: {
+ 1: false
+ },
+ },
+ }
+ }, '');
+ expect(syncData).is.empty;
+ });
+
+ it('Should return array of objects with proper sync config , GDPR not applies', function() {
+ const syncData = spec.getUserSyncs({
+ iframeEnabled: true,
+ }, {}, {
+ gdprApplies: false,
+ consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw',
+ }, '');
+ expect(syncData).to.be.an('array').which.is.not.empty;
+ expect(syncData[0]).to.be.an('object')
+ expect(syncData[0].type).to.be.a('string')
+ expect(syncData[0].type).to.equal('iframe')
+ expect(syncData[0].url).to.be.a('string')
+ expect(syncData[0].url).to.equal('//sync.programmatica.com/match/sp.ifr?usp=&consent=COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw&gdpr=0')
+ });
+})
diff --git a/test/spec/modules/publinkIdSystem_spec.js b/test/spec/modules/publinkIdSystem_spec.js
index f35a7453403..5ad58ea1a37 100644
--- a/test/spec/modules/publinkIdSystem_spec.js
+++ b/test/spec/modules/publinkIdSystem_spec.js
@@ -72,11 +72,6 @@ describe('PublinkIdSystem', () => {
expect(result.callback).to.be.a('function');
});
- it('Use local copy', () => {
- const result = publinkIdSubmodule.getId({}, undefined, TEST_COOKIE_VALUE);
- expect(result).to.be.undefined;
- });
-
describe('callout for id', () => {
let callbackSpy = sinon.spy();
@@ -84,6 +79,44 @@ describe('PublinkIdSystem', () => {
callbackSpy.resetHistory();
});
+ it('Has cached id', () => {
+ const config = {storage: {type: 'cookie'}};
+ let submoduleCallback = publinkIdSubmodule.getId(config, undefined, TEST_COOKIE_VALUE).callback;
+ submoduleCallback(callbackSpy);
+
+ const request = server.requests[0];
+ const parsed = parseUrl(request.url);
+
+ expect(parsed.hostname).to.equal('proc.ad.cpe.dotomi.com');
+ expect(parsed.pathname).to.equal('/cvx/client/sync/publink/refresh');
+ expect(parsed.search.mpn).to.equal('Prebid.js');
+ expect(parsed.search.mpv).to.equal('$prebid.version$');
+ expect(parsed.search.publink).to.equal(TEST_COOKIE_VALUE);
+
+ request.respond(200, {}, JSON.stringify(serverResponse));
+ expect(callbackSpy.calledOnce).to.be.true;
+ expect(callbackSpy.lastCall.lastArg).to.equal(serverResponse.publink);
+ });
+
+ it('Request path has priority', () => {
+ const config = {storage: {type: 'cookie'}, params: {e: 'ca11c0ca7', site_id: '102030'}};
+ let submoduleCallback = publinkIdSubmodule.getId(config, undefined, TEST_COOKIE_VALUE).callback;
+ submoduleCallback(callbackSpy);
+
+ const request = server.requests[0];
+ const parsed = parseUrl(request.url);
+
+ expect(parsed.hostname).to.equal('proc.ad.cpe.dotomi.com');
+ expect(parsed.pathname).to.equal('/cvx/client/sync/publink');
+ expect(parsed.search.mpn).to.equal('Prebid.js');
+ expect(parsed.search.mpv).to.equal('$prebid.version$');
+ expect(parsed.search.publink).to.equal(TEST_COOKIE_VALUE);
+
+ request.respond(200, {}, JSON.stringify(serverResponse));
+ expect(callbackSpy.calledOnce).to.be.true;
+ expect(callbackSpy.lastCall.lastArg).to.equal(serverResponse.publink);
+ });
+
it('Fetch with consent data', () => {
const config = {storage: {type: 'cookie'}, params: {e: 'ca11c0ca7', site_id: '102030'}};
const consentData = {gdprApplies: 1, consentString: 'myconsentstring'};
diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js
index 066004bd954..154a8e1253b 100644
--- a/test/spec/modules/pubmaticBidAdapter_spec.js
+++ b/test/spec/modules/pubmaticBidAdapter_spec.js
@@ -82,6 +82,7 @@ describe('PubMatic adapter', function () {
ortb2Imp: {
ext: {
tid: '92489f71-1bf2-49a0-adf9-000cea934729',
+ gpid: '/1111/homepage-leftnav'
}
},
schain: schainConfig
@@ -1172,6 +1173,7 @@ describe('PubMatic adapter', function () {
expect(data.imp[0].tagid).to.equal('/15671365/DMDemo'); // tagid
expect(data.imp[0].banner.w).to.equal(300); // width
expect(data.imp[0].banner.h).to.equal(250); // height
+ expect(data.imp[0].ext.gpid).to.equal(bidRequests[0].ortb2Imp.ext.gpid);
expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid
expect(data.imp[0].ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr);
expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency);
@@ -1439,6 +1441,7 @@ describe('PubMatic adapter', function () {
expect(data.imp[0].banner.w).to.equal(728); // width
expect(data.imp[0].banner.h).to.equal(90); // height
expect(data.imp[0].banner.format).to.deep.equal([{w: 160, h: 600}]);
+ expect(data.imp[0].ext.gpid).to.equal(bidRequests[0].ortb2Imp.ext.gpid);
expect(data.imp[0].ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr);
expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid
expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency);
@@ -1663,6 +1666,7 @@ describe('PubMatic adapter', function () {
expect(data.imp[0].tagid).to.equal('/15671365/DMDemo'); // tagid
expect(data.imp[0].banner.w).to.equal(300); // width
expect(data.imp[0].banner.h).to.equal(250); // height
+ expect(data.imp[0].ext.gpid).to.equal(bidRequests[0].ortb2Imp.ext.gpid);
expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid
});
@@ -1711,6 +1715,7 @@ describe('PubMatic adapter', function () {
expect(data.imp[0].id).to.equal(bidRequests[0].bidId); // Prebid bid id is passed as id
expect(data.imp[0].bidfloor).to.equal(parseFloat(bidRequests[0].params.kadfloor)); // kadfloor
expect(data.imp[0].tagid).to.equal('/15671365/DMDemo'); // tagid
+ expect(data.imp[0].ext.gpid).to.equal(bidRequests[0].ortb2Imp.ext.gpid);
expect(data.imp[0].banner.w).to.equal(300); // width
expect(data.imp[0].banner.h).to.equal(250); // height
expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid
@@ -1759,6 +1764,7 @@ describe('PubMatic adapter', function () {
expect(data.imp[0].tagid).to.equal('/15671365/DMDemo'); // tagid
expect(data.imp[0].banner.w).to.equal(300); // width
expect(data.imp[0].banner.h).to.equal(250); // height
+ expect(data.imp[0].ext.gpid).to.equal(bidRequests[0].ortb2Imp.ext.gpid);
expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid
// second request without USP/CCPA
@@ -1909,6 +1915,33 @@ describe('PubMatic adapter', function () {
});
describe('ortb2Imp', function() {
+ describe('ortb2Imp.ext.gpid', function() {
+ beforeEach(function () {
+ if (bidRequests[0].hasOwnProperty('ortb2Imp')) {
+ delete bidRequests[0].ortb2Imp;
+ }
+ });
+
+ it('should send gpid if imp[].ext.gpid is specified', function() {
+ bidRequests[0].ortb2Imp = {
+ ext: {
+ gpid: 'ortb2Imp.ext.gpid'
+ }
+ };
+ const request = spec.buildRequests(bidRequests, {});
+ let data = JSON.parse(request.data);
+ expect(data.imp[0].ext).to.have.property('gpid');
+ expect(data.imp[0].ext.gpid).to.equal('ortb2Imp.ext.gpid');
+ });
+
+ it('should not send if imp[].ext.gpid is not specified', function() {
+ bidRequests[0].ortb2Imp = { ext: { } };
+ const request = spec.buildRequests(bidRequests, {});
+ let data = JSON.parse(request.data);
+ expect(data.imp[0].ext).to.not.have.property('gpid');
+ });
+ });
+
describe('ortb2Imp.ext.data.pbadslot', function() {
beforeEach(function () {
if (bidRequests[0].hasOwnProperty('ortb2Imp')) {
@@ -2278,6 +2311,23 @@ describe('PubMatic adapter', function () {
expect(data.device.sua).to.deep.equal(suaObject);
});
+ it('should pass device.ext.cdep if present in bidderRequest fpd ortb2 object', function () {
+ const cdepObj = {
+ cdep: 'example_label_1'
+ };
+ let request = spec.buildRequests(multipleMediaRequests, {
+ auctionId: 'new-auction-id',
+ ortb2: {
+ device: {
+ ext: cdepObj
+ }
+ }
+ });
+ let data = JSON.parse(request.data);
+ expect(data.device.ext.cdep).to.exist.and.to.be.an('string');
+ expect(data.device.ext).to.deep.equal(cdepObj);
+ });
+
it('Request params should have valid native bid request for all valid params', function () {
let request = spec.buildRequests(nativeBidRequests, {
auctionId: 'new-auction-id'
diff --git a/test/spec/modules/qortexRtdProvider_spec.js b/test/spec/modules/qortexRtdProvider_spec.js
index f6cf8798850..9baa526e4cc 100644
--- a/test/spec/modules/qortexRtdProvider_spec.js
+++ b/test/spec/modules/qortexRtdProvider_spec.js
@@ -168,21 +168,21 @@ describe('qortexRtdProvider', () => {
dispatchEvent(new CustomEvent('qortex-rtd', validImpressionEvent));
dispatchEvent(new CustomEvent('qortex-rtd', validImpressionEvent));
expect(billableEvents.length).to.be.equal(1);
- expect(logWarnSpy.calledWith('recieved invalid billable event due to duplicate uid: qx-impression')).to.be.ok;
+ expect(logWarnSpy.calledWith('received invalid billable event due to duplicate uid: qx-impression')).to.be.ok;
})
it('will not allow events with missing uid', () => {
loadScriptTag(config);
dispatchEvent(new CustomEvent('qortex-rtd', missingIdImpressionEvent));
expect(billableEvents.length).to.be.equal(0);
- expect(logWarnSpy.calledWith('recieved invalid billable event due to missing uid: qx-impression')).to.be.ok;
+ expect(logWarnSpy.calledWith('received invalid billable event due to missing uid: qx-impression')).to.be.ok;
})
it('will not allow events with unavailable type', () => {
loadScriptTag(config);
dispatchEvent(new CustomEvent('qortex-rtd', invalidTypeQortexEvent));
expect(billableEvents.length).to.be.equal(0);
- expect(logWarnSpy.calledWith('recieved invalid billable event: invalid-type')).to.be.ok;
+ expect(logWarnSpy.calledWith('received invalid billable event: invalid-type')).to.be.ok;
})
})
@@ -281,7 +281,7 @@ describe('qortexRtdProvider', () => {
initializeModuleData(validModuleConfig);
addContextToRequests(reqBidsConfig);
expect(logWarnSpy.calledOnce).to.be.true;
- expect(logWarnSpy.calledWith('No context data recieved at this time')).to.be.ok;
+ expect(logWarnSpy.calledWith('No context data received at this time')).to.be.ok;
expect(reqBidsConfig.ortb2Fragments.global).to.be.eql({});
expect(reqBidsConfig.ortb2Fragments.bidder).to.be.eql({});
})
diff --git a/test/spec/modules/relaidoBidAdapter_spec.js b/test/spec/modules/relaidoBidAdapter_spec.js
index 7778e9cbf80..f0d019913e8 100644
--- a/test/spec/modules/relaidoBidAdapter_spec.js
+++ b/test/spec/modules/relaidoBidAdapter_spec.js
@@ -239,6 +239,7 @@ describe('RelaidoAdapter', function () {
const request = data.bids[0];
expect(bidRequests.method).to.equal('POST');
expect(bidRequests.url).to.equal('https://api.relaido.jp/bid/v1/sprebid');
+ expect(data.canonical_url).to.equal('https://publisher.com/home');
expect(data.canonical_url_hash).to.equal('e6092f44a0044903ae3764126eedd6187c1d9f04');
expect(data.ref).to.equal(bidderRequest.refererInfo.page);
expect(data.timeout_ms).to.equal(bidderRequest.timeout);
@@ -317,6 +318,23 @@ describe('RelaidoAdapter', function () {
expect(data.bids).to.have.lengthOf(1);
expect(data.imuid).to.equal('i.tjHcK_7fTcqnbrS_YA2vaw');
});
+
+ it('should get userIdAsEids', function () {
+ const userIdAsEids = [
+ {
+ source: 'hogehoge.com',
+ uids: {
+ atype: 1,
+ id: 'hugahuga'
+ }
+ }
+ ]
+ bidRequest.userIdAsEids = userIdAsEids
+ const bidRequests = spec.buildRequests([bidRequest], bidderRequest);
+ const data = JSON.parse(bidRequests.data);
+ expect(data.bids[0].userIdAsEids).to.have.lengthOf(1);
+ expect(data.bids[0].userIdAsEids[0].source).to.equal('hogehoge.com');
+ });
});
describe('spec.interpretResponse', function () {
@@ -325,6 +343,7 @@ describe('RelaidoAdapter', function () {
expect(bidResponses).to.have.lengthOf(1);
const response = bidResponses[0];
expect(response.requestId).to.equal(serverRequest.data.bids[0].bidId);
+ expect(response.placementId).to.equal(serverResponse.body.ads[0].placementId);
expect(response.width).to.equal(serverRequest.data.bids[0].width);
expect(response.height).to.equal(serverRequest.data.bids[0].height);
expect(response.cpm).to.equal(serverResponse.body.ads[0].price);
@@ -343,6 +362,7 @@ describe('RelaidoAdapter', function () {
expect(bidResponses).to.have.lengthOf(1);
const response = bidResponses[0];
expect(response.requestId).to.equal(serverRequest.data.bids[0].bidId);
+ expect(response.placementId).to.equal(serverResponse.body.ads[0].placementId);
expect(response.width).to.equal(serverRequest.data.bids[0].width);
expect(response.height).to.equal(serverRequest.data.bids[0].height);
expect(response.cpm).to.equal(serverResponse.body.ads[0].price);
@@ -360,6 +380,7 @@ describe('RelaidoAdapter', function () {
expect(bidResponses).to.have.lengthOf(1);
const response = bidResponses[0];
expect(response.requestId).to.equal(serverRequest.data.bids[0].bidId);
+ expect(response.placementId).to.equal(serverResponseBanner.body.ads[0].placementId);
expect(response.cpm).to.equal(serverResponseBanner.body.ads[0].price);
expect(response.currency).to.equal(serverResponseBanner.body.ads[0].currency);
expect(response.creativeId).to.equal(serverResponseBanner.body.ads[0].creativeId);
diff --git a/test/spec/modules/relevantdigitalBidAdapter_spec.js b/test/spec/modules/relevantdigitalBidAdapter_spec.js
index b2a5495b3cb..0e21453c8ba 100644
--- a/test/spec/modules/relevantdigitalBidAdapter_spec.js
+++ b/test/spec/modules/relevantdigitalBidAdapter_spec.js
@@ -1,5 +1,10 @@
import {spec, resetBidderConfigs} from 'modules/relevantdigitalBidAdapter.js';
import { parseUrl, deepClone } from 'src/utils.js';
+import { config } from 'src/config.js';
+import CONSTANTS from 'src/constants.json';
+
+import adapterManager, {
+} from 'src/adapterManager.js';
const expect = require('chai').expect;
@@ -9,14 +14,29 @@ const ACCOUNT_ID = 'example_account_id';
const TEST_DOMAIN = 'example.com';
const TEST_PAGE = `https://${TEST_DOMAIN}/page.html`;
-const BID_REQUEST =
-{
- 'bidder': 'relevantdigital',
+const CONFIG = {
+ enabled: true,
+ endpoint: CONSTANTS.S2S.DEFAULT_ENDPOINT,
+ timeout: 1000,
+ maxBids: 1,
+ adapter: 'prebidServer',
+ bidders: ['relevantdigital'],
+ accountId: 'abc'
+};
+
+const ADUNIT_CODE = '/19968336/header-bid-tag-0';
+
+const BID_PARAMS = {
'params': {
'placementId': PLACEMENT_ID,
'accountId': ACCOUNT_ID,
- 'pbsHost': PBS_HOST,
- },
+ 'pbsHost': PBS_HOST
+ }
+};
+
+const BID_REQUEST = {
+ 'bidder': 'relevantdigital',
+ ...BID_PARAMS,
'ortb2Imp': {
'ext': {
'tid': 'e13391ea-00f3-495d-99a6-d937990d73a9'
@@ -32,7 +52,7 @@ const BID_REQUEST =
]
}
},
- 'adUnitCode': '/19968336/header-bid-tag-0',
+ 'adUnitCode': ADUNIT_CODE,
'transactionId': 'e13391ea-00f3-495d-99a6-d937990d73a9',
'sizes': [
[
@@ -292,4 +312,64 @@ describe('Relevant Digital Bid Adaper', function () {
expect(allSyncs).to.deep.equal(expectedResult)
});
});
+ describe('transformBidParams', function () {
+ beforeEach(() => {
+ config.setConfig({
+ s2sConfig: CONFIG,
+ });
+ });
+ afterEach(() => {
+ config.resetConfig();
+ });
+
+ const adUnit = (params) => ({
+ code: ADUNIT_CODE,
+ bids: [
+ {
+ bidder: 'relevantdigital',
+ adUnitCode: ADUNIT_CODE,
+ params,
+ }
+ ]
+ });
+
+ const request = (params) => adapterManager.makeBidRequests([adUnit(params)], 123, 'auction-id', 123, [], {})[0];
+
+ it('transforms adunit bid params and config params correctly', function () {
+ config.setConfig({
+ relevantdigital: {
+ pbsHost: PBS_HOST,
+ accountId: ACCOUNT_ID,
+ },
+ });
+ const adUnitParams = { placementId: PLACEMENT_ID };
+ const expextedTransformedBidParams = {
+ ...BID_PARAMS.params, pbsHost: `https://${BID_PARAMS.params.pbsHost}`, 'pbsBufferMs': 250
+ };
+ expect(spec.transformBidParams(adUnitParams, null, null, [request(adUnitParams)])).to.deep.equal(expextedTransformedBidParams);
+ });
+ it('transforms adunit bid params correctly', function () {
+ const adUnitParams = { ...BID_PARAMS.params, pbsHost: 'host.relevant-digital.com', pbsBufferMs: 500 };
+ const expextedTransformedBidParams = {
+ ...BID_PARAMS.params, pbsHost: 'host.relevant-digital.com', pbsBufferMs: 500
+ };
+ expect(spec.transformBidParams(adUnitParams, null, null, [request(adUnitParams)])).to.deep.equal(expextedTransformedBidParams);
+ });
+ it('transforms adunit bid params correctly', function () {
+ const adUnitParams = { ...BID_PARAMS.params, pbsHost: 'host.relevant-digital.com', pbsBufferMs: 500 };
+ const expextedTransformedBidParams = {
+ ...BID_PARAMS.params, pbsHost: 'host.relevant-digital.com', pbsBufferMs: 500
+ };
+ expect(spec.transformBidParams(adUnitParams, null, null, [request(adUnitParams)])).to.deep.equal(expextedTransformedBidParams);
+ });
+ it('does not transform bid params if placementId is missing', function () {
+ const adUnitParams = { ...BID_PARAMS.params, placementId: null };
+ expect(spec.transformBidParams(adUnitParams, null, null, [request(adUnitParams)])).to.equal(undefined);
+ });
+ it('does not transform bid params s2s config is missing', function () {
+ config.resetConfig();
+ const adUnitParams = BID_PARAMS.params;
+ expect(spec.transformBidParams(adUnitParams, null, null, [request(adUnitParams)])).to.equal(undefined);
+ });
+ })
});
diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js
index dd6f52c0646..3f3cbfbb46c 100644
--- a/test/spec/modules/rubiconBidAdapter_spec.js
+++ b/test/spec/modules/rubiconBidAdapter_spec.js
@@ -696,6 +696,16 @@ describe('the rubicon adapter', function () {
expect(data['p_pos']).to.equal('atf;;btf;;');
});
+ it('should correctly send cdep signal when requested', () => {
+ var badposRequest = utils.deepClone(bidderRequest);
+ badposRequest.bids[0].ortb2 = {device: {ext: {cdep: 3}}};
+
+ let [request] = spec.buildRequests(badposRequest.bids, badposRequest);
+ let data = parseQuery(request.data);
+
+ expect(data['o_cdep']).to.equal('3');
+ });
+
it('ad engine query params should be ordered correctly', function () {
sandbox.stub(Math, 'random').callsFake(() => 0.1);
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
@@ -1808,6 +1818,126 @@ describe('the rubicon adapter', function () {
expect(data['tg_i.dfp_ad_unit_code']).to.equal('/a/b/c');
});
});
+
+ describe('client hints', function () {
+ let standardSuaObject;
+ beforeEach(function () {
+ standardSuaObject = {
+ source: 2,
+ platform: {
+ brand: 'macOS',
+ version: [
+ '12',
+ '6',
+ '0'
+ ]
+ },
+ browsers: [
+ {
+ brand: 'Not.A/Brand',
+ version: [
+ '8',
+ '0',
+ '0',
+ '0'
+ ]
+ },
+ {
+ brand: 'Chromium',
+ version: [
+ '114',
+ '0',
+ '5735',
+ '198'
+ ]
+ },
+ {
+ brand: 'Google Chrome',
+ version: [
+ '114',
+ '0',
+ '5735',
+ '198'
+ ]
+ }
+ ],
+ mobile: 0,
+ model: '',
+ bitness: '64',
+ architecture: 'x86'
+ }
+ });
+ it('should send m_ch_* params if ortb2.device.sua object is there', function () {
+ let bidRequestSua = utils.deepClone(bidderRequest);
+ bidRequestSua.bids[0].ortb2 = { device: { sua: standardSuaObject } };
+
+ // How should fastlane query be constructed with default SUA
+ let expectedValues = {
+ m_ch_arch: 'x86',
+ m_ch_bitness: '64',
+ m_ch_ua: `"Not.A/Brand"|v="8","Chromium"|v="114","Google Chrome"|v="114"`,
+ m_ch_full_ver: `"Not.A/Brand"|v="8.0.0.0","Chromium"|v="114.0.5735.198","Google Chrome"|v="114.0.5735.198"`,
+ m_ch_mobile: '?0',
+ m_ch_platform: 'macOS',
+ m_ch_platform_ver: '12.6.0'
+ }
+
+ // Build Fastlane call
+ let [request] = spec.buildRequests(bidRequestSua.bids, bidRequestSua);
+ let data = parseQuery(request.data);
+
+ // Loop through expected values and if they do not match push an error
+ const errors = Object.entries(expectedValues).reduce((accum, [key, val]) => {
+ if (data[key] !== val) accum.push(`${key} - expect: ${val} - got: ${data[key]}`)
+ return accum;
+ }, []);
+
+ // should be no errors
+ expect(errors).to.deep.equal([]);
+ });
+ it('should not send invalid values for m_ch_*', function () {
+ let bidRequestSua = utils.deepClone(bidderRequest);
+
+ // Alter input SUA object
+ // send model
+ standardSuaObject.model = 'Suface Duo';
+ // send mobile = 1
+ standardSuaObject.mobile = 1;
+
+ // make browsers not an array
+ standardSuaObject.browsers = 'My Browser';
+
+ // make platform not have version
+ delete standardSuaObject.platform.version;
+
+ // delete architecture
+ delete standardSuaObject.architecture;
+
+ // add SUA to bid
+ bidRequestSua.bids[0].ortb2 = { device: { sua: standardSuaObject } };
+
+ // Build Fastlane request
+ let [request] = spec.buildRequests(bidRequestSua.bids, bidRequestSua);
+ let data = parseQuery(request.data);
+
+ // should show new names
+ expect(data.m_ch_model).to.equal('Suface Duo');
+ expect(data.m_ch_mobile).to.equal('?1');
+
+ // should still send platform
+ expect(data.m_ch_platform).to.equal('macOS');
+
+ // platform version not sent
+ expect(data).to.not.haveOwnProperty('m_ch_platform_ver');
+
+ // both ua and full_ver not sent because browsers not array
+ expect(data).to.not.haveOwnProperty('m_ch_ua');
+ expect(data).to.not.haveOwnProperty('m_ch_full_ver');
+
+ // arch not sent
+ expect(data).to.not.haveOwnProperty('m_ch_arch');
+ });
+ });
});
if (FEATURES.VIDEO) {
@@ -2589,6 +2719,15 @@ describe('the rubicon adapter', function () {
const slotParams = spec.createSlotParams(bidderRequest.bids[0], bidderRequest);
expect(slotParams.kw).to.equal('a,b,c');
});
+
+ it('should pass along o_ae param when fledge is enabled', () => {
+ const localBidRequest = Object.assign({}, bidderRequest.bids[0]);
+ localBidRequest.ortb2Imp.ext.ae = true;
+
+ const slotParams = spec.createSlotParams(localBidRequest, bidderRequest);
+
+ expect(slotParams['o_ae']).to.equal(1)
+ });
});
describe('classifiedAsVideo', function () {
@@ -3309,6 +3448,43 @@ describe('the rubicon adapter', function () {
expect(bids).to.be.lengthOf(0);
});
+ it('Should support recieving an auctionConfig and pass it along to Prebid', function () {
+ let response = {
+ 'status': 'ok',
+ 'account_id': 14062,
+ 'site_id': 70608,
+ 'zone_id': 530022,
+ 'size_id': 15,
+ 'alt_size_ids': [
+ 43
+ ],
+ 'tracking': '',
+ 'inventory': {},
+ 'ads': [{
+ 'status': 'ok',
+ 'cpm': 0,
+ 'size_id': 15
+ }],
+ 'component_auction_config': [{
+ 'random': 'value',
+ 'bidId': '5432'
+ },
+ {
+ 'random': 'string',
+ 'bidId': '6789'
+ }]
+ };
+
+ let {bids, fledgeAuctionConfigs} = spec.interpretResponse({body: response}, {
+ bidRequest: bidderRequest.bids[0]
+ });
+
+ expect(bids).to.be.lengthOf(1);
+ expect(fledgeAuctionConfigs[0].bidId).to.equal('5432');
+ expect(fledgeAuctionConfigs[0].config.random).to.equal('value');
+ expect(fledgeAuctionConfigs[1].bidId).to.equal('6789');
+ });
+
it('should handle an error', function () {
let response = {
'status': 'ok',
diff --git a/test/spec/modules/shinezRtbBidAdapter_spec.js b/test/spec/modules/shinezRtbBidAdapter_spec.js
new file mode 100644
index 00000000000..3965cd69c5f
--- /dev/null
+++ b/test/spec/modules/shinezRtbBidAdapter_spec.js
@@ -0,0 +1,639 @@
+import {expect} from 'chai';
+import {
+ spec as adapter,
+ createDomain,
+ hashCode,
+ extractPID,
+ extractCID,
+ extractSubDomain,
+ getStorageItem,
+ setStorageItem,
+ tryParseJSON,
+ getUniqueDealId,
+} from 'modules/shinezRtbBidAdapter';
+import * as utils from 'src/utils.js';
+import {version} from 'package.json';
+import {useFakeTimers} from 'sinon';
+import {BANNER, VIDEO} from '../../../src/mediaTypes';
+import {config} from '../../../src/config';
+import {deepAccess} from 'src/utils.js';
+
+export const TEST_ID_SYSTEMS = ['britepoolid', 'criteoId', 'id5id', 'idl_env', 'lipb', 'netId', 'parrableId', 'pubcid', 'tdid', 'pubProvidedId', 'digitrustid'];
+
+const SUB_DOMAIN = 'exchange';
+
+const BID = {
+ 'bidId': '2d52001cabd527',
+ 'adUnitCode': 'div-gpt-ad-12345-0',
+ 'params': {
+ 'subDomain': SUB_DOMAIN,
+ 'cId': '59db6b3b4ffaa70004f45cdc',
+ 'pId': '59ac17c192832d0011283fe3',
+ 'bidFloor': 0.1,
+ 'ext': {
+ 'param1': 'loremipsum',
+ 'param2': 'dolorsitamet'
+ }
+ },
+ 'placementCode': 'div-gpt-ad-1460505748561-0',
+ 'sizes': [[300, 250], [300, 600]],
+ 'bidderRequestId': '1fdb5ff1b6eaa7',
+ 'bidRequestsCount': 4,
+ 'bidderRequestsCount': 3,
+ 'bidderWinsCount': 1,
+ 'requestId': 'b0777d85-d061-450e-9bc7-260dd54bbb7a',
+ 'schain': 'a0819c69-005b-41ed-af06-1be1e0aefefc',
+ 'mediaTypes': [BANNER],
+ 'ortb2Imp': {
+ 'ext': {
+ 'gpid': '0123456789',
+ 'tid': '56e184c6-bde9-497b-b9b9-cf47a61381ee'
+ }
+ }
+};
+
+const VIDEO_BID = {
+ 'bidId': '2d52001cabd527',
+ 'adUnitCode': '63550ad1ff6642d368cba59dh5884270560',
+ 'bidderRequestId': '12a8ae9ada9c13',
+ 'bidRequestsCount': 4,
+ 'bidderRequestsCount': 3,
+ 'bidderWinsCount': 1,
+ 'schain': 'a0819c69-005b-41ed-af06-1be1e0aefefc',
+ 'params': {
+ 'subDomain': SUB_DOMAIN,
+ 'cId': '635509f7ff6642d368cb9837',
+ 'pId': '59ac17c192832d0011283fe3',
+ 'bidFloor': 0.1
+ },
+ 'sizes': [[545, 307]],
+ 'mediaTypes': {
+ 'video': {
+ 'playerSize': [[545, 307]],
+ 'context': 'instream',
+ 'mimes': [
+ 'video/mp4',
+ 'application/javascript'
+ ],
+ 'protocols': [2, 3, 5, 6],
+ 'maxduration': 60,
+ 'minduration': 0,
+ 'startdelay': 0,
+ 'linearity': 1,
+ 'api': [2],
+ 'placement': 1
+ }
+ },
+ 'ortb2Imp': {
+ 'ext': {
+ 'gpid': '0123456789',
+ 'tid': '56e184c6-bde9-497b-b9b9-cf47a61381ee'
+ }
+ }
+}
+
+const BIDDER_REQUEST = {
+ 'gdprConsent': {
+ 'consentString': 'consent_string',
+ 'gdprApplies': true
+ },
+ 'gppConsent': {
+ 'gppString': 'gpp_string',
+ 'applicableSections': [7]
+ },
+ 'uspConsent': 'consent_string',
+ 'refererInfo': {
+ 'page': 'https://www.greatsite.com',
+ 'ref': 'https://www.somereferrer.com'
+ },
+ 'ortb2': {
+ 'regs': {
+ 'gpp': 'gpp_string',
+ 'gpp_sid': [7]
+ },
+ 'device': {
+ 'sua': {
+ 'source': 2,
+ 'platform': {
+ 'brand': 'Android',
+ 'version': ['8', '0', '0']
+ },
+ 'browsers': [
+ {'brand': 'Not_A Brand', 'version': ['99', '0', '0', '0']},
+ {'brand': 'Google Chrome', 'version': ['109', '0', '5414', '119']},
+ {'brand': 'Chromium', 'version': ['109', '0', '5414', '119']}
+ ],
+ 'mobile': 1,
+ 'model': 'SM-G955U',
+ 'bitness': '64',
+ 'architecture': ''
+ }
+ }
+ }
+};
+
+const SERVER_RESPONSE = {
+ body: {
+ cid: 'testcid123',
+ results: [{
+ 'ad': '',
+ 'price': 0.8,
+ 'creativeId': '12610997325162499419',
+ 'exp': 30,
+ 'width': 300,
+ 'height': 250,
+ 'advertiserDomains': ['securepubads.g.doubleclick.net'],
+ 'cookies': [{
+ 'src': 'https://sync.com',
+ 'type': 'iframe'
+ }, {
+ 'src': 'https://sync.com',
+ 'type': 'img'
+ }]
+ }]
+ }
+};
+
+const VIDEO_SERVER_RESPONSE = {
+ body: {
+ 'cid': '635509f7ff6642d368cb9837',
+ 'results': [{
+ 'ad': '',
+ 'advertiserDomains': ['sweetgum.io'],
+ 'exp': 60,
+ 'width': 545,
+ 'height': 307,
+ 'mediaType': 'video',
+ 'creativeId': '12610997325162499419',
+ 'price': 2,
+ 'cookies': []
+ }]
+ }
+};
+
+const REQUEST = {
+ data: {
+ width: 300,
+ height: 250,
+ bidId: '2d52001cabd527'
+ }
+};
+
+function getTopWindowQueryParams() {
+ try {
+ const parsedUrl = utils.parseUrl(window.top.document.URL, {decodeSearchAsString: true});
+ return parsedUrl.search;
+ } catch (e) {
+ return '';
+ }
+}
+
+describe('ShinezRtbBidAdapter', function () {
+ describe('validtae spec', function () {
+ it('exists and is a function', function () {
+ expect(adapter.isBidRequestValid).to.exist.and.to.be.a('function');
+ });
+
+ it('exists and is a function', function () {
+ expect(adapter.buildRequests).to.exist.and.to.be.a('function');
+ });
+
+ it('exists and is a function', function () {
+ expect(adapter.interpretResponse).to.exist.and.to.be.a('function');
+ });
+
+ it('exists and is a function', function () {
+ expect(adapter.getUserSyncs).to.exist.and.to.be.a('function');
+ });
+
+ it('exists and is a string', function () {
+ expect(adapter.code).to.exist.and.to.be.a('string');
+ });
+
+ it('exists and contains media types', function () {
+ expect(adapter.supportedMediaTypes).to.exist.and.to.be.an('array').with.length(2);
+ expect(adapter.supportedMediaTypes).to.contain.members([BANNER, VIDEO]);
+ });
+ });
+
+ describe('validate bid requests', function () {
+ it('should require cId', function () {
+ const isValid = adapter.isBidRequestValid({
+ params: {
+ pId: 'pid'
+ }
+ });
+ expect(isValid).to.be.false;
+ });
+
+ it('should require pId', function () {
+ const isValid = adapter.isBidRequestValid({
+ params: {
+ cId: 'cid'
+ }
+ });
+ expect(isValid).to.be.false;
+ });
+
+ it('should validate correctly', function () {
+ const isValid = adapter.isBidRequestValid({
+ params: {
+ cId: 'cid',
+ pId: 'pid'
+ }
+ });
+ expect(isValid).to.be.true;
+ });
+ });
+
+ describe('build requests', function () {
+ let sandbox;
+ before(function () {
+ $$PREBID_GLOBAL$$.bidderSettings = {
+ shinezRtb: {
+ storageAllowed: true
+ }
+ };
+ sandbox = sinon.sandbox.create();
+ sandbox.stub(Date, 'now').returns(1000);
+ });
+
+ it('should build video request', function () {
+ const hashUrl = hashCode(BIDDER_REQUEST.refererInfo.page);
+ config.setConfig({
+ bidderTimeout: 3000,
+ enableTIDs: true
+ });
+ const requests = adapter.buildRequests([VIDEO_BID], BIDDER_REQUEST);
+ expect(requests).to.have.length(1);
+ expect(requests[0]).to.deep.equal({
+ method: 'POST',
+ url: `${createDomain(SUB_DOMAIN)}/prebid/multi/635509f7ff6642d368cb9837`,
+ data: {
+ adUnitCode: '63550ad1ff6642d368cba59dh5884270560',
+ bidFloor: 0.1,
+ bidId: '2d52001cabd527',
+ bidderVersion: adapter.version,
+ bidderRequestId: '12a8ae9ada9c13',
+ cb: 1000,
+ gdpr: 1,
+ gdprConsent: 'consent_string',
+ usPrivacy: 'consent_string',
+ gppString: 'gpp_string',
+ gppSid: [7],
+ transactionId: '56e184c6-bde9-497b-b9b9-cf47a61381ee',
+ prebidVersion: version,
+ bidRequestsCount: 4,
+ bidderRequestsCount: 3,
+ bidderWinsCount: 1,
+ bidderTimeout: 3000,
+ publisherId: '59ac17c192832d0011283fe3',
+ url: 'https%3A%2F%2Fwww.greatsite.com',
+ referrer: 'https://www.somereferrer.com',
+ res: `${window.top.screen.width}x${window.top.screen.height}`,
+ schain: VIDEO_BID.schain,
+ sizes: ['545x307'],
+ sua: {
+ 'source': 2,
+ 'platform': {
+ 'brand': 'Android',
+ 'version': ['8', '0', '0']
+ },
+ 'browsers': [
+ {'brand': 'Not_A Brand', 'version': ['99', '0', '0', '0']},
+ {'brand': 'Google Chrome', 'version': ['109', '0', '5414', '119']},
+ {'brand': 'Chromium', 'version': ['109', '0', '5414', '119']}
+ ],
+ 'mobile': 1,
+ 'model': 'SM-G955U',
+ 'bitness': '64',
+ 'architecture': ''
+ },
+ uniqueDealId: `${hashUrl}_${Date.now().toString()}`,
+ uqs: getTopWindowQueryParams(),
+ mediaTypes: {
+ video: {
+ api: [2],
+ context: 'instream',
+ linearity: 1,
+ maxduration: 60,
+ mimes: [
+ 'video/mp4',
+ 'application/javascript'
+ ],
+ minduration: 0,
+ placement: 1,
+ playerSize: [[545, 307]],
+ protocols: [2, 3, 5, 6],
+ startdelay: 0
+ }
+ },
+ gpid: '0123456789'
+ }
+ });
+ });
+
+ it('should build banner request for each size', function () {
+ const hashUrl = hashCode(BIDDER_REQUEST.refererInfo.page);
+ config.setConfig({
+ bidderTimeout: 3000,
+ enableTIDs: true
+ });
+ const requests = adapter.buildRequests([BID], BIDDER_REQUEST);
+ expect(requests).to.have.length(1);
+ expect(requests[0]).to.deep.equal({
+ method: 'POST',
+ url: `${createDomain(SUB_DOMAIN)}/prebid/multi/59db6b3b4ffaa70004f45cdc`,
+ data: {
+ gdprConsent: 'consent_string',
+ gdpr: 1,
+ gppString: 'gpp_string',
+ gppSid: [7],
+ usPrivacy: 'consent_string',
+ bidRequestsCount: 4,
+ bidderRequestsCount: 3,
+ bidderWinsCount: 1,
+ bidderTimeout: 3000,
+ bidderRequestId: '1fdb5ff1b6eaa7',
+ transactionId: '56e184c6-bde9-497b-b9b9-cf47a61381ee',
+ sizes: ['300x250', '300x600'],
+ sua: {
+ 'source': 2,
+ 'platform': {
+ 'brand': 'Android',
+ 'version': ['8', '0', '0']
+ },
+ 'browsers': [
+ {'brand': 'Not_A Brand', 'version': ['99', '0', '0', '0']},
+ {'brand': 'Google Chrome', 'version': ['109', '0', '5414', '119']},
+ {'brand': 'Chromium', 'version': ['109', '0', '5414', '119']}
+ ],
+ 'mobile': 1,
+ 'model': 'SM-G955U',
+ 'bitness': '64',
+ 'architecture': ''
+ },
+ url: 'https%3A%2F%2Fwww.greatsite.com',
+ referrer: 'https://www.somereferrer.com',
+ cb: 1000,
+ bidFloor: 0.1,
+ bidId: '2d52001cabd527',
+ adUnitCode: 'div-gpt-ad-12345-0',
+ publisherId: '59ac17c192832d0011283fe3',
+ uniqueDealId: `${hashUrl}_${Date.now().toString()}`,
+ bidderVersion: adapter.version,
+ prebidVersion: version,
+ schain: BID.schain,
+ res: `${window.top.screen.width}x${window.top.screen.height}`,
+ mediaTypes: [BANNER],
+ gpid: '0123456789',
+ uqs: getTopWindowQueryParams(),
+ 'ext.param1': 'loremipsum',
+ 'ext.param2': 'dolorsitamet',
+ }
+ });
+ });
+
+ after(function () {
+ $$PREBID_GLOBAL$$.bidderSettings = {};
+ sandbox.restore();
+ });
+ });
+ describe('getUserSyncs', function () {
+ it('should have valid user sync with iframeEnabled', function () {
+ const result = adapter.getUserSyncs({iframeEnabled: true}, [SERVER_RESPONSE]);
+
+ expect(result).to.deep.equal([{
+ type: 'iframe',
+ url: 'https://sync.sweetgum.io/api/sync/iframe/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy='
+ }]);
+ });
+
+ it('should have valid user sync with cid on response', function () {
+ const result = adapter.getUserSyncs({iframeEnabled: true}, [SERVER_RESPONSE]);
+ expect(result).to.deep.equal([{
+ type: 'iframe',
+ url: 'https://sync.sweetgum.io/api/sync/iframe/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy='
+ }]);
+ });
+
+ it('should have valid user sync with pixelEnabled', function () {
+ const result = adapter.getUserSyncs({pixelEnabled: true}, [SERVER_RESPONSE]);
+
+ expect(result).to.deep.equal([{
+ 'url': 'https://sync.sweetgum.io/api/sync/image/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy=',
+ 'type': 'image'
+ }]);
+ })
+ });
+
+ describe('interpret response', function () {
+ it('should return empty array when there is no response', function () {
+ const responses = adapter.interpretResponse(null);
+ expect(responses).to.be.empty;
+ });
+
+ it('should return empty array when there is no ad', function () {
+ const responses = adapter.interpretResponse({price: 1, ad: ''});
+ expect(responses).to.be.empty;
+ });
+
+ it('should return empty array when there is no price', function () {
+ const responses = adapter.interpretResponse({price: null, ad: 'great ad'});
+ expect(responses).to.be.empty;
+ });
+
+ it('should return an array of interpreted banner responses', function () {
+ const responses = adapter.interpretResponse(SERVER_RESPONSE, REQUEST);
+ expect(responses).to.have.length(1);
+ expect(responses[0]).to.deep.equal({
+ requestId: '2d52001cabd527',
+ cpm: 0.8,
+ width: 300,
+ height: 250,
+ creativeId: '12610997325162499419',
+ currency: 'USD',
+ netRevenue: true,
+ ttl: 30,
+ ad: '',
+ meta: {
+ advertiserDomains: ['securepubads.g.doubleclick.net']
+ }
+ });
+ });
+
+ it('should get meta from response metaData', function () {
+ const serverResponse = utils.deepClone(SERVER_RESPONSE);
+ serverResponse.body.results[0].metaData = {
+ advertiserDomains: ['sweetgum.io'],
+ agencyName: 'Agency Name',
+ };
+ const responses = adapter.interpretResponse(serverResponse, REQUEST);
+ expect(responses[0].meta).to.deep.equal({
+ advertiserDomains: ['sweetgum.io'],
+ agencyName: 'Agency Name'
+ });
+ });
+
+ it('should return an array of interpreted video responses', function () {
+ const responses = adapter.interpretResponse(VIDEO_SERVER_RESPONSE, REQUEST);
+ expect(responses).to.have.length(1);
+ expect(responses[0]).to.deep.equal({
+ requestId: '2d52001cabd527',
+ cpm: 2,
+ width: 545,
+ height: 307,
+ mediaType: 'video',
+ creativeId: '12610997325162499419',
+ currency: 'USD',
+ netRevenue: true,
+ ttl: 60,
+ vastXml: '',
+ meta: {
+ advertiserDomains: ['sweetgum.io']
+ }
+ });
+ });
+
+ it('should take default TTL', function () {
+ const serverResponse = utils.deepClone(SERVER_RESPONSE);
+ delete serverResponse.body.results[0].exp;
+ const responses = adapter.interpretResponse(serverResponse, REQUEST);
+ expect(responses).to.have.length(1);
+ expect(responses[0].ttl).to.equal(300);
+ });
+ });
+
+ describe('user id system', function () {
+ TEST_ID_SYSTEMS.forEach((idSystemProvider) => {
+ const id = Date.now().toString();
+ const bid = utils.deepClone(BID);
+
+ const userId = (function () {
+ switch (idSystemProvider) {
+ case 'digitrustid':
+ return {data: {id}};
+ case 'lipb':
+ return {lipbid: id};
+ case 'parrableId':
+ return {eid: id};
+ case 'id5id':
+ return {uid: id};
+ default:
+ return id;
+ }
+ })();
+
+ bid.userId = {
+ [idSystemProvider]: userId
+ };
+
+ it(`should include 'uid.${idSystemProvider}' in request params`, function () {
+ const requests = adapter.buildRequests([bid], BIDDER_REQUEST);
+ expect(requests[0].data[`uid.${idSystemProvider}`]).to.equal(id);
+ });
+ });
+ });
+
+ describe('alternate param names extractors', function () {
+ it('should return undefined when param not supported', function () {
+ const cid = extractCID({'c_id': '1'});
+ const pid = extractPID({'p_id': '1'});
+ const subDomain = extractSubDomain({'sub_domain': 'prebid'});
+ expect(cid).to.be.undefined;
+ expect(pid).to.be.undefined;
+ expect(subDomain).to.be.undefined;
+ });
+
+ it('should return value when param supported', function () {
+ const cid = extractCID({'cID': '1'});
+ const pid = extractPID({'Pid': '2'});
+ const subDomain = extractSubDomain({'subDOMAIN': 'prebid'});
+ expect(cid).to.be.equal('1');
+ expect(pid).to.be.equal('2');
+ expect(subDomain).to.be.equal('prebid');
+ });
+ });
+
+ describe('unique deal id', function () {
+ before(function () {
+ $$PREBID_GLOBAL$$.bidderSettings = {
+ shinezRtb: {
+ storageAllowed: true
+ }
+ };
+ });
+ after(function () {
+ $$PREBID_GLOBAL$$.bidderSettings = {};
+ });
+ const key = 'myKey';
+ let uniqueDealId;
+ beforeEach(() => {
+ uniqueDealId = getUniqueDealId(key, 0);
+ })
+
+ it('should get current unique deal id', function (done) {
+ // waiting some time so `now` will become past
+ setTimeout(() => {
+ const current = getUniqueDealId(key);
+ expect(current).to.be.equal(uniqueDealId);
+ done();
+ }, 200);
+ });
+
+ it('should get new unique deal id on expiration', function (done) {
+ setTimeout(() => {
+ const current = getUniqueDealId(key, 100);
+ expect(current).to.not.be.equal(uniqueDealId);
+ done();
+ }, 200)
+ });
+ });
+
+ describe('storage utils', function () {
+ before(function () {
+ $$PREBID_GLOBAL$$.bidderSettings = {
+ shinezRtb: {
+ storageAllowed: true
+ }
+ };
+ });
+ after(function () {
+ $$PREBID_GLOBAL$$.bidderSettings = {};
+ });
+ it('should get value from storage with create param', function () {
+ const now = Date.now();
+ const clock = useFakeTimers({
+ shouldAdvanceTime: true,
+ now
+ });
+ setStorageItem('myKey', 2020);
+ const {value, created} = getStorageItem('myKey');
+ expect(created).to.be.equal(now);
+ expect(value).to.be.equal(2020);
+ expect(typeof value).to.be.equal('number');
+ expect(typeof created).to.be.equal('number');
+ clock.restore();
+ });
+
+ it('should get external stored value', function () {
+ const value = 'superman'
+ window.localStorage.setItem('myExternalKey', value);
+ const item = getStorageItem('myExternalKey');
+ expect(item).to.be.equal(value);
+ });
+
+ it('should parse JSON value', function () {
+ const data = JSON.stringify({event: 'send'});
+ const {event} = tryParseJSON(data);
+ expect(event).to.be.equal('send');
+ });
+
+ it('should get original value on parse fail', function () {
+ const value = 21;
+ const parsed = tryParseJSON(value);
+ expect(typeof parsed).to.be.equal('number');
+ expect(parsed).to.be.equal(value);
+ });
+ });
+});
diff --git a/test/spec/modules/snigelBidAdapter_spec.js b/test/spec/modules/snigelBidAdapter_spec.js
index 7fe2387ca6c..3ba84228872 100644
--- a/test/spec/modules/snigelBidAdapter_spec.js
+++ b/test/spec/modules/snigelBidAdapter_spec.js
@@ -23,6 +23,7 @@ const BASE_BIDDER_REQUEST = {
auctionId: 'test',
bidderRequestId: 'test',
refererInfo: {
+ page: 'https://localhost',
canonicalUrl: 'https://localhost',
},
};
diff --git a/test/spec/modules/sonobiAnalyticsAdapter_spec.js b/test/spec/modules/sonobiAnalyticsAdapter_spec.js
index 76ff88836d4..ed8ccd22eea 100644
--- a/test/spec/modules/sonobiAnalyticsAdapter_spec.js
+++ b/test/spec/modules/sonobiAnalyticsAdapter_spec.js
@@ -1,4 +1,4 @@
-import sonobiAnalytics from 'modules/sonobiAnalyticsAdapter.js';
+import sonobiAnalytics, {DEFAULT_EVENT_URL} from 'modules/sonobiAnalyticsAdapter.js';
import {expect} from 'chai';
import {server} from 'test/mocks/xhr.js';
let events = require('src/events');
@@ -76,8 +76,8 @@ describe('Sonobi Prebid Analytic', function () {
events.emit(constants.EVENTS.AUCTION_END, {auctionId: '13', bidsReceived: [bid]});
clock.tick(5000);
- expect(server.requests).to.have.length(1);
- expect(JSON.parse(server.requests[0].requestBody)).to.have.length(3)
+ const req = server.requests.find(req => req.url.indexOf(DEFAULT_EVENT_URL) !== -1);
+ expect(JSON.parse(req.requestBody)).to.have.length(3)
done();
});
});
diff --git a/test/spec/modules/sparteoBidAdapter_spec.js b/test/spec/modules/sparteoBidAdapter_spec.js
new file mode 100644
index 00000000000..d6b8b0cc2d8
--- /dev/null
+++ b/test/spec/modules/sparteoBidAdapter_spec.js
@@ -0,0 +1,435 @@
+import {expect} from 'chai';
+import { deepClone, mergeDeep } from 'src/utils';
+import {spec as adapter} from 'modules/sparteoBidAdapter';
+
+const CURRENCY = 'EUR';
+const TTL = 60;
+const HTTP_METHOD = 'POST';
+const REQUEST_URL = 'https://bid.sparteo.com/auction';
+
+const VALID_BID_BANNER = {
+ bidder: 'sparteo',
+ bidId: '1a2b3c4d',
+ adUnitCode: 'id-1234',
+ params: {
+ networkId: '1234567a-eb1b-1fae-1d23-e1fbaef234cf',
+ formats: ['corner']
+ },
+ mediaTypes: {
+ banner: {
+ sizes: [
+ [1, 1]
+ ]
+ }
+ }
+};
+
+const VALID_BID_VIDEO = {
+ bidder: 'sparteo',
+ bidId: '5e6f7g8h',
+ adUnitCode: 'id-5678',
+ params: {
+ networkId: '1234567a-eb1b-1fae-1d23-e1fbaef234cf'
+ },
+ mediaTypes: {
+ video: {
+ playerSize: [640, 360],
+ protocols: [1, 2, 3, 4, 5, 6, 7, 8],
+ api: [1, 2],
+ mimes: ['video/mp4'],
+ skip: 1,
+ startdelay: 0,
+ placement: 1,
+ linearity: 1,
+ minduration: 5,
+ maxduration: 30,
+ context: 'instream'
+ }
+ },
+ ortb2Imp: {
+ ext: {
+ pbadslot: 'video'
+ }
+ }
+};
+
+const VALID_REQUEST_BANNER = {
+ method: HTTP_METHOD,
+ url: REQUEST_URL,
+ data: {
+ 'imp': [{
+ 'id': '1a2b3c4d',
+ 'banner': {
+ 'format': [{
+ 'h': 1,
+ 'w': 1
+ }],
+ 'topframe': 0
+ },
+ 'ext': {
+ 'sparteo': {
+ 'params': {
+ 'networkId': '1234567a-eb1b-1fae-1d23-e1fbaef234cf',
+ 'formats': ['corner']
+ }
+ }
+ }
+ }],
+ 'site': {
+ 'publisher': {
+ 'ext': {
+ 'params': {
+ 'networkId': '1234567a-eb1b-1fae-1d23-e1fbaef234cf'
+ }
+ }
+ }
+ },
+ 'test': 0
+ }
+};
+
+const VALID_REQUEST_VIDEO = {
+ method: HTTP_METHOD,
+ url: REQUEST_URL,
+ data: {
+ 'imp': [{
+ 'id': '5e6f7g8h',
+ 'video': {
+ 'w': 640,
+ 'h': 360,
+ 'protocols': [1, 2, 3, 4, 5, 6, 7, 8],
+ 'api': [1, 2],
+ 'mimes': ['video/mp4'],
+ 'skip': 1,
+ 'startdelay': 0,
+ 'placement': 1,
+ 'linearity': 1,
+ 'minduration': 5,
+ 'maxduration': 30,
+ },
+ 'ext': {
+ 'pbadslot': 'video',
+ 'sparteo': {
+ 'params': {
+ 'networkId': '1234567a-eb1b-1fae-1d23-e1fbaef234cf'
+ }
+ }
+ }
+ }],
+ 'site': {
+ 'publisher': {
+ 'ext': {
+ 'params': {
+ 'networkId': '1234567a-eb1b-1fae-1d23-e1fbaef234cf'
+ }
+ }
+ }
+ },
+ 'test': 0
+ }
+};
+
+const VALID_REQUEST = {
+ method: HTTP_METHOD,
+ url: REQUEST_URL,
+ data: {
+ 'imp': [{
+ 'id': '1a2b3c4d',
+ 'banner': {
+ 'format': [{
+ 'h': 1,
+ 'w': 1
+ }],
+ 'topframe': 0
+ },
+ 'ext': {
+ 'sparteo': {
+ 'params': {
+ 'networkId': '1234567a-eb1b-1fae-1d23-e1fbaef234cf',
+ 'formats': ['corner']
+ }
+ }
+ }
+ }, {
+ 'id': '5e6f7g8h',
+ 'video': {
+ 'w': 640,
+ 'h': 360,
+ 'protocols': [1, 2, 3, 4, 5, 6, 7, 8],
+ 'api': [1, 2],
+ 'mimes': ['video/mp4'],
+ 'skip': 1,
+ 'startdelay': 0,
+ 'placement': 1,
+ 'linearity': 1,
+ 'minduration': 5,
+ 'maxduration': 30,
+ },
+ 'ext': {
+ 'pbadslot': 'video',
+ 'sparteo': {
+ 'params': {
+ 'networkId': '1234567a-eb1b-1fae-1d23-e1fbaef234cf'
+ }
+ }
+ }
+ }],
+ 'site': {
+ 'publisher': {
+ 'ext': {
+ 'params': {
+ 'networkId': '1234567a-eb1b-1fae-1d23-e1fbaef234cf'
+ }
+ }
+ }
+ },
+ 'test': 0
+ }
+};
+
+const BIDDER_REQUEST = {
+ bids: [VALID_BID_BANNER, VALID_BID_VIDEO]
+}
+
+const BIDDER_REQUEST_BANNER = {
+ bids: [VALID_BID_BANNER]
+}
+
+const BIDDER_REQUEST_VIDEO = {
+ bids: [VALID_BID_VIDEO]
+}
+
+describe('SparteoAdapter', function () {
+ describe('isBidRequestValid', function () {
+ describe('Check method return', function () {
+ it('should return true', function () {
+ expect(adapter.isBidRequestValid(VALID_BID_BANNER)).to.equal(true);
+ expect(adapter.isBidRequestValid(VALID_BID_VIDEO)).to.equal(true);
+ });
+
+ it('should return false because the networkId is missing', function () {
+ let wrongBid = deepClone(VALID_BID_BANNER);
+ delete wrongBid.params.networkId;
+
+ expect(adapter.isBidRequestValid(wrongBid)).to.equal(false);
+ });
+
+ it('should return false because the banner size is missing', function () {
+ let wrongBid = deepClone(VALID_BID_BANNER);
+
+ wrongBid.mediaTypes.banner.sizes = '123456';
+ expect(adapter.isBidRequestValid(wrongBid)).to.equal(false);
+
+ delete wrongBid.mediaTypes.banner.sizes;
+ expect(adapter.isBidRequestValid(wrongBid)).to.equal(false);
+ });
+
+ it('should return false because the video player size paramater is missing', function () {
+ let wrongBid = deepClone(VALID_BID_VIDEO);
+
+ wrongBid.mediaTypes.video.playerSize = '123456';
+ expect(adapter.isBidRequestValid(wrongBid)).to.equal(false);
+
+ delete wrongBid.mediaTypes.video.playerSize;
+ expect(adapter.isBidRequestValid(wrongBid)).to.equal(false);
+ });
+ });
+ });
+
+ describe('buildRequests', function () {
+ describe('Check method return', function () {
+ if (FEATURES.VIDEO) {
+ it('should return the right formatted requests', function() {
+ const request = adapter.buildRequests([VALID_BID_BANNER, VALID_BID_VIDEO], BIDDER_REQUEST);
+ delete request.data.id;
+
+ expect(request).to.deep.equal(VALID_REQUEST);
+ });
+ }
+
+ it('should return the right formatted banner requests', function() {
+ const request = adapter.buildRequests([VALID_BID_BANNER], BIDDER_REQUEST_BANNER);
+ delete request.data.id;
+
+ expect(request).to.deep.equal(VALID_REQUEST_BANNER);
+ });
+
+ if (FEATURES.VIDEO) {
+ it('should return the right formatted video requests', function() {
+ const request = adapter.buildRequests([VALID_BID_VIDEO], BIDDER_REQUEST_VIDEO);
+ delete request.data.id;
+
+ expect(request).to.deep.equal(VALID_REQUEST_VIDEO);
+ });
+ }
+
+ it('should return the right formatted request with endpoint test', function() {
+ let endpoint = 'https://bid-test.sparteo.com/auction';
+
+ let bids = mergeDeep(deepClone([VALID_BID_BANNER, VALID_BID_VIDEO]), {
+ params: {
+ endpoint: endpoint
+ }
+ });
+
+ let requests = mergeDeep(deepClone(VALID_REQUEST));
+
+ const request = adapter.buildRequests(bids, BIDDER_REQUEST);
+ requests.url = endpoint;
+ delete request.data.id;
+
+ expect(requests).to.deep.equal(requests);
+ });
+ });
+ });
+
+ describe('interpretResponse', function() {
+ describe('Check method return', function () {
+ it('should return the right formatted response', function() {
+ let response = {
+ body: {
+ 'id': '63f4d300-6896-4bdc-8561-0932f73148b1',
+ 'cur': 'EUR',
+ 'seatbid': [
+ {
+ 'seat': 'sparteo',
+ 'group': 0,
+ 'bid': [
+ {
+ 'id': 'cdbb6982-a269-40c7-84e5-04797f11d87a',
+ 'impid': '1a2b3c4d',
+ 'price': 4.5,
+ 'ext': {
+ 'prebid': {
+ 'type': 'banner'
+ }
+ },
+ 'adm': 'script',
+ 'crid': 'crid',
+ 'w': 1,
+ 'h': 1,
+ 'nurl': 'https://t.bidder.sparteo.com/img'
+ }
+ ]
+ }
+ ]
+ }
+ };
+
+ if (FEATURES.VIDEO) {
+ response.body.seatbid[0].bid.push({
+ 'id': 'cdbb6982-a269-40c7-84e5-04797f11d87b',
+ 'impid': '5e6f7g8h',
+ 'price': 5,
+ 'ext': {
+ 'prebid': {
+ 'type': 'video'
+ }
+ },
+ 'adm': 'tag',
+ 'crid': 'crid',
+ 'w': 640,
+ 'h': 480,
+ 'nurl': 'https://t.bidder.sparteo.com/img'
+ });
+ }
+
+ let formattedReponse = [
+ {
+ requestId: '1a2b3c4d',
+ seatBidId: 'cdbb6982-a269-40c7-84e5-04797f11d87a',
+ cpm: 4.5,
+ width: 1,
+ height: 1,
+ creativeId: 'crid',
+ creative_id: 'crid',
+ currency: CURRENCY,
+ netRevenue: true,
+ ttl: TTL,
+ mediaType: 'banner',
+ meta: {},
+ ad: 'script'
+ }
+ ];
+
+ if (FEATURES.VIDEO) {
+ formattedReponse.push({
+ requestId: '5e6f7g8h',
+ seatBidId: 'cdbb6982-a269-40c7-84e5-04797f11d87b',
+ cpm: 5,
+ width: 640,
+ height: 480,
+ playerWidth: 640,
+ playerHeight: 360,
+ creativeId: 'crid',
+ creative_id: 'crid',
+ currency: CURRENCY,
+ netRevenue: true,
+ ttl: TTL,
+ mediaType: 'video',
+ meta: {},
+ vastUrl: 'https://t.bidder.sparteo.com/img',
+ vastXml: 'tag'
+ });
+ }
+
+ if (FEATURES.VIDEO) {
+ const request = adapter.buildRequests([VALID_BID_BANNER, VALID_BID_VIDEO], BIDDER_REQUEST);
+ expect(adapter.interpretResponse(response, request)).to.deep.equal(formattedReponse);
+ } else {
+ const request = adapter.buildRequests([VALID_BID_BANNER], BIDDER_REQUEST_BANNER);
+ expect(adapter.interpretResponse(response, request)).to.deep.equal(formattedReponse);
+ }
+ });
+ });
+ });
+
+ describe('onBidWon', function() {
+ describe('Check methods succeed', function () {
+ it('should not throw error', function() {
+ let bids = [
+ {
+ requestId: '1a2b3c4d',
+ seatBidId: 'cdbb6982-a269-40c7-84e5-04797f11d87a',
+ cpm: 4.5,
+ width: 1,
+ height: 1,
+ creativeId: 'crid',
+ creative_id: 'crid',
+ currency: CURRENCY,
+ netRevenue: true,
+ ttl: TTL,
+ mediaType: 'banner',
+ meta: {},
+ ad: 'script',
+ nurl: [
+ 'win.domain.com'
+ ]
+ },
+ {
+ requestId: '2570',
+ seatBidId: 'cdbb6982-a269-40c7-84e5-04797f11d87b',
+ id: 'id-5678',
+ cpm: 5,
+ width: 640,
+ height: 480,
+ creativeId: 'crid',
+ currency: CURRENCY,
+ netRevenue: true,
+ ttl: TTL,
+ mediaType: 'video',
+ meta: {},
+ vastXml: 'vast xml',
+ nurl: [
+ 'win.domain2.com'
+ ]
+ }
+ ];
+
+ bids.forEach(function(bid) {
+ expect(adapter.onBidWon.bind(adapter, bid)).to.not.throw();
+ });
+ });
+ });
+ });
+});
diff --git a/test/spec/modules/taboolaBidAdapter_spec.js b/test/spec/modules/taboolaBidAdapter_spec.js
index 16bbb525ee7..1b6104599d7 100644
--- a/test/spec/modules/taboolaBidAdapter_spec.js
+++ b/test/spec/modules/taboolaBidAdapter_spec.js
@@ -275,6 +275,26 @@ describe('Taboola Adapter', function () {
expect(resData.tmax).to.equal(500);
});
+ it('should pass bidder tmax as int', function () {
+ const bidderRequest = {
+ ...commonBidderRequest,
+ timeout: '500'
+ }
+ const res = spec.buildRequests([defaultBidRequest], bidderRequest);
+ const resData = JSON.parse(res.data);
+ expect(resData.tmax).to.equal(500);
+ });
+
+ it('should pass bidder timeout as null', function () {
+ const bidderRequest = {
+ ...commonBidderRequest,
+ timeout: null
+ }
+ const res = spec.buildRequests([defaultBidRequest], bidderRequest);
+ const resData = JSON.parse(res.data);
+ expect(resData.tmax).to.equal(undefined);
+ });
+
describe('first party data', function () {
it('should parse first party data', function () {
const bidderRequest = {
diff --git a/test/spec/modules/tpmnBidAdapter_spec.js b/test/spec/modules/tpmnBidAdapter_spec.js
index e2b14b18f61..505bc9d878f 100644
--- a/test/spec/modules/tpmnBidAdapter_spec.js
+++ b/test/spec/modules/tpmnBidAdapter_spec.js
@@ -1,16 +1,130 @@
/* eslint-disable no-tabs */
-import {expect} from 'chai';
-import {spec, storage} from 'modules/tpmnBidAdapter.js';
-import {generateUUID} from '../../../src/utils.js';
-import {newBidder} from '../../../src/adapters/bidderFactory';
+import { spec, storage, VIDEO_RENDERER_URL, ADAPTER_VERSION } from 'modules/tpmnBidAdapter.js';
+import { generateUUID } from '../../../src/utils.js';
+import { expect } from 'chai';
+import * as utils from 'src/utils';
import * as sinon from 'sinon';
+import 'modules/consentManagement.js';
+import {syncAddFPDToBidderRequest} from '../../helpers/fpd.js';
+import {mockGdprConsent} from '../../helpers/consentData.js';
+
+const BIDDER_CODE = 'tpmn';
+const BANNER_BID = {
+ bidder: BIDDER_CODE,
+ params: {
+ inventoryId: 1
+ },
+ mediaTypes: {
+ banner: {
+ sizes: [
+ [300, 250]
+ ],
+ },
+ },
+ adUnitCode: 'adUnitCode1',
+ bidId: 'bidId',
+ bidderRequestId: 'bidderRequestId',
+ auctionId: 'auctionId-56a2-4f71-9098-720a68f2f708',
+};
+
+const VIDEO_BID = {
+ bidder: BIDDER_CODE,
+ params: {
+ inventoryId: 1
+ },
+ mediaTypes: {
+ video: {
+ context: 'outstream',
+ api: [1, 2, 4, 6],
+ mimes: ['video/mp4'],
+ playbackmethod: [2, 4, 6],
+ playerSize: [[1024, 768]],
+ protocols: [3, 4, 7, 8, 10],
+ placement: 1,
+ plcmt: 1,
+ minduration: 0,
+ maxduration: 60,
+ startdelay: 0
+ },
+ },
+ adUnitCode: 'adUnitCode1',
+ bidId: 'bidId',
+ bidderRequestId: 'bidderRequestId',
+ auctionId: 'auctionId-56a2-4f71-9098-720a68f2f708',
+};
+
+const BIDDER_REQUEST = {
+ auctionId: 'auctionId-56a2-4f71-9098-720a68f2f708',
+ bidderRequestId: 'bidderRequestId',
+ timeout: 500,
+ refererInfo: {
+ page: 'https://hello-world-page.com/',
+ domain: 'hello-world-page.com',
+ ref: 'http://example-domain.com/foo',
+ }
+};
+
+const BANNER_BID_RESPONSE = {
+ 'id': 'bidderRequestId',
+ 'bidId': 'bidid',
+ 'seatbid': [
+ {
+ 'bid': [
+ {
+ 'id': 'id',
+ 'impid': 'bidId',
+ 'price': 0.18,
+ 'adm': '',
+ 'adid': '144762342',
+ 'burl': 'http://0.0.0.0:8181/burl',
+ 'adomain': [
+ 'https://dummydomain.com'
+ ],
+ 'cid': 'cid',
+ 'crid': 'crid',
+ 'iurl': 'iurl',
+ 'cat': [],
+ 'w': 300,
+ 'h': 250
+ }
+ ]
+ }
+ ],
+ 'cur': 'USD'
+};
+
+const VIDEO_BID_RESPONSE = {
+ 'id': 'bidderRequestId',
+ 'bidid': 'bidid',
+ 'seatbid': [
+ {
+ 'bid': [
+ {
+ 'id': 'id',
+ 'impid': 'bidId',
+ 'price': 1.09,
+ 'adid': '144762342',
+ 'burl': 'http://0.0.0.0:8181/burl',
+ 'adm': '',
+ 'adomain': [
+ 'https://dummydomain.com'
+ ],
+ 'cid': 'cid',
+ 'crid': 'crid',
+ 'iurl': 'iurl',
+ 'cat': [],
+ 'h': 768,
+ 'w': 1024
+ }
+ ]
+ }
+ ],
+ 'cur': 'USD'
+};
describe('tpmnAdapterTests', function () {
- const adapter = newBidder(spec);
- const BIDDER_CODE = 'tpmn';
let sandbox = sinon.sandbox.create();
let getCookieStub;
-
beforeEach(function () {
$$PREBID_GLOBAL$$.bidderSettings = {
tpmn: {
@@ -27,152 +141,277 @@ describe('tpmnAdapterTests', function () {
$$PREBID_GLOBAL$$.bidderSettings = {};
});
- describe('inherited functions', function () {
- it('exists and is a function', function () {
- expect(adapter.callBids).to.exist.and.to.be.a('function')
- })
- });
-
- describe('isBidRequestValid', function () {
- let bid = {
- adUnitCode: 'temp-unitcode',
- bidder: 'tpmn',
- params: {
- inventoryId: '1',
- publisherId: 'TPMN'
- },
- bidId: '29092404798c9',
- bidderRequestId: 'a01',
- auctionId: 'da1d7a33-0260-4e83-a621-14674116f3f9',
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
- }
- };
-
- it('should return true if a bid is valid banner bid request', function () {
- expect(spec.isBidRequestValid(bid)).to.be.equal(true);
- });
-
- it('should return false where requried param is missing', function () {
- let bid = Object.assign({}, bid);
- bid.params = {};
- expect(spec.isBidRequestValid(bid)).to.be.equal(false);
- });
-
- it('should return false when required param values have invalid type', function () {
- let bid = Object.assign({}, bid);
- bid.params = {
- 'inventoryId': null,
- 'publisherId': null
- };
- expect(spec.isBidRequestValid(bid)).to.be.equal(false);
- });
- });
-
- describe('buildRequests', function () {
- it('should return an empty list if there are no bid requests', function () {
- const emptyBidRequests = [];
- const bidderRequest = {};
- const request = spec.buildRequests(emptyBidRequests, bidderRequest);
- expect(request).to.be.an('array').that.is.empty;
- });
- it('should generate a POST server request with bidder API url, data', function () {
- const bid = {
- adUnitCode: 'temp-unitcode',
- bidder: 'tpmn',
+ describe('isBidRequestValid()', function () {
+ it('should accept request if placementId is passed', function () {
+ let bid = {
+ bidder: BIDDER_CODE,
params: {
- inventoryId: '1',
- publisherId: 'TPMN'
+ inventoryId: 123
},
- bidId: '29092404798c9',
- bidderRequestId: 'a01',
- auctionId: 'da1d7a33-0260-4e83-a621-14674116f3f9',
mediaTypes: {
banner: {
sizes: [[300, 250]]
}
}
};
- const tempBidRequests = [bid];
- const tempBidderRequest = {
- refererInfo: {
- page: 'http://localhost/test',
- site: {
- domain: 'localhost',
- page: 'http://localhost/test'
- }
- }
+ expect(spec.isBidRequestValid(bid)).to.equal(true);
+ });
+
+ it('should reject requests without params', function () {
+ let bid = {
+ bidder: BIDDER_CODE,
+ params: {}
};
- const builtRequest = spec.buildRequests(tempBidRequests, tempBidderRequest);
-
- expect(builtRequest).to.have.lengthOf(1);
- expect(builtRequest[0].method).to.equal('POST');
- expect(builtRequest[0].url).to.match(/ad.tpmn.co.kr\/prebidhb.tpmn/);
- const apiRequest = builtRequest[0].data;
- expect(apiRequest.site).to.deep.equal({
- domain: 'localhost',
- page: 'http://localhost/test'
- });
- expect(apiRequest.bids).to.have.lengthOf('1');
- expect(apiRequest.bids[0].inventoryId).to.equal('1');
- expect(apiRequest.bids[0].publisherId).to.equal('TPMN');
- expect(apiRequest.bids[0].bidId).to.equal('29092404798c9');
- expect(apiRequest.bids[0].adUnitCode).to.equal('temp-unitcode');
- expect(apiRequest.bids[0].auctionId).to.equal('da1d7a33-0260-4e83-a621-14674116f3f9');
- expect(apiRequest.bids[0].sizes).to.have.lengthOf('1');
- expect(apiRequest.bids[0].sizes[0]).to.deep.equal({
- width: 300,
- height: 250
- });
+ expect(spec.isBidRequestValid(bid)).to.equal(false);
+ });
+
+ it('should return true when required params found', () => {
+ expect(spec.isBidRequestValid(BANNER_BID)).to.equal(true);
+ expect(spec.isBidRequestValid(VIDEO_BID)).to.equal(true);
});
});
- describe('interpretResponse', function () {
- const bid = {
- adUnitCode: 'temp-unitcode',
- bidder: 'tpmn',
- params: {
- inventoryId: '1',
- publisherId: 'TPMN'
- },
- bidId: '29092404798c9',
- bidderRequestId: 'a01',
- auctionId: 'da1d7a33-0260-4e83-a621-14674116f3f9',
- mediaTypes: {
- banner: {
- sizes: [[300, 250]]
+ describe('buildRequests()', function () {
+ it('should have gdpr data if applicable', function () {
+ const bid = utils.deepClone(BANNER_BID);
+
+ const req = syncAddFPDToBidderRequest(Object.assign({}, BIDDER_REQUEST, {
+ gdprConsent: {
+ consentString: 'consentString',
+ gdprApplies: true,
}
+ }));
+ let request = spec.buildRequests([bid], req)[0];
+
+ const payload = request.data;
+ expect(payload.user.ext).to.have.property('consent', req.gdprConsent.consentString);
+ expect(payload.regs.ext).to.have.property('gdpr', 1);
+ });
+
+ it('should properly forward ORTB blocking params', function () {
+ let bid = utils.deepClone(BANNER_BID);
+ bid = utils.mergeDeep(bid, {
+ params: { bcat: ['IAB1-1'], badv: ['example.com'], bapp: ['com.example'], battr: [1] },
+ mediaTypes: { banner: { battr: [1] } }
+ });
+
+ let [request] = spec.buildRequests([bid], BIDDER_REQUEST);
+
+ expect(request).to.exist.and.to.be.an('object');
+ const payload = request.data;
+ expect(payload).to.have.deep.property('bcat', ['IAB1-1']);
+ expect(payload).to.have.deep.property('badv', ['example.com']);
+ expect(payload).to.have.deep.property('bapp', ['com.example']);
+ expect(payload.imp[0].banner).to.have.deep.property('battr', [1]);
+ });
+
+ context('when mediaType is banner', function () {
+ it('should build correct request for banner bid with both w, h', () => {
+ const bid = utils.deepClone(BANNER_BID);
+
+ const [request] = spec.buildRequests([bid], BIDDER_REQUEST);
+ const requestData = request.data;
+ // expect(requestData.imp[0].banner).to.equal(null);
+ expect(requestData.imp[0].banner.format[0].w).to.equal(300);
+ expect(requestData.imp[0].banner.format[0].h).to.equal(250);
+ });
+
+ it('should create request data', function () {
+ const bid = utils.deepClone(BANNER_BID);
+
+ let [request] = spec.buildRequests([bid], BIDDER_REQUEST);
+ expect(request).to.exist.and.to.be.a('object');
+ const payload = request.data;
+ expect(payload.imp[0]).to.have.property('id', bid.bidId);
+ });
+ });
+
+ context('when mediaType is video', function () {
+ if (FEATURES.VIDEO) {
+ it('should return false when there is no video in mediaTypes', () => {
+ const bid = utils.deepClone(VIDEO_BID);
+ delete bid.mediaTypes.video;
+
+ expect(spec.isBidRequestValid(bid)).to.equal(false);
+ });
}
- };
- const tempBidRequests = [bid];
- it('should return an empty aray to indicate no valid bids', function () {
- const emptyServerResponse = {};
- const bidResponses = spec.interpretResponse(emptyServerResponse, tempBidRequests);
- expect(bidResponses).is.an('array').that.is.empty;
+ if (FEATURES.VIDEO) {
+ it('should reutrn false if player size is not set', () => {
+ const bid = utils.deepClone(VIDEO_BID);
+ delete bid.mediaTypes.video.playerSize;
+
+ expect(spec.isBidRequestValid(bid)).to.equal(false);
+ });
+ }
+ if (FEATURES.VIDEO) {
+ it('when mediaType is Video - check', () => {
+ const bid = utils.deepClone(VIDEO_BID);
+ const check = {
+ w: 1024,
+ h: 768,
+ mimes: ['video/mp4'],
+ playbackmethod: [2, 4, 6],
+ api: [1, 2, 4, 6],
+ protocols: [3, 4, 7, 8, 10],
+ placement: 1,
+ minduration: 0,
+ maxduration: 60,
+ startdelay: 0,
+ plcmt: 1
+ };
+ expect(spec.isBidRequestValid(bid)).to.equal(true);
+ const requests = spec.buildRequests([bid], BIDDER_REQUEST);
+ const request = requests[0].data;
+ expect(request.imp[0].video).to.deep.include({...check});
+ });
+ }
+
+ if (FEATURES.VIDEO) {
+ it('when mediaType New Video', () => {
+ const NEW_VIDEO_BID = {
+ 'bidder': 'tpmn',
+ 'params': {'inventoryId': 2, 'bidFloor': 2},
+ 'userId': {'pubcid': '88a49ee6-beeb-4dd6-92ac-3b6060e127e1'},
+ 'mediaTypes': {
+ 'video': {
+ 'context': 'outstream',
+ 'mimes': ['video/mp4'],
+ 'playerSize': [[1024, 768]],
+ 'playbackmethod': [2, 4, 6],
+ 'protocols': [3, 4],
+ 'api': [1, 2, 3, 6],
+ 'placement': 1,
+ 'minduration': 0,
+ 'maxduration': 30,
+ 'startdelay': 0,
+ 'skip': 1,
+ 'plcmt': 4
+ }
+ },
+ };
+
+ const check = {
+ w: 1024,
+ h: 768,
+ mimes: [ 'video/mp4' ],
+ playbackmethod: [2, 4, 6],
+ api: [1, 2, 3, 6],
+ protocols: [3, 4],
+ placement: 1,
+ minduration: 0,
+ maxduration: 30,
+ startdelay: 0,
+ skip: 1,
+ plcmt: 4
+ }
+
+ expect(spec.isBidRequestValid(NEW_VIDEO_BID)).to.equal(true);
+ let requests = spec.buildRequests([NEW_VIDEO_BID], BIDDER_REQUEST);
+ const request = requests[0].data;
+ expect(request.imp[0].video.w).to.equal(check.w);
+ expect(request.imp[0].video.h).to.equal(check.h);
+ expect(request.imp[0].video.placement).to.equal(check.placement);
+ expect(request.imp[0].video.minduration).to.equal(check.minduration);
+ expect(request.imp[0].video.maxduration).to.equal(check.maxduration);
+ expect(request.imp[0].video.startdelay).to.equal(check.startdelay);
+ expect(request.imp[0].video.skip).to.equal(check.skip);
+ expect(request.imp[0].video.plcmt).to.equal(check.plcmt);
+ expect(request.imp[0].video.mimes).to.deep.have.same.members(check.mimes);
+ expect(request.imp[0].video.playbackmethod).to.deep.have.same.members(check.playbackmethod);
+ expect(request.imp[0].video.api).to.deep.have.same.members(check.api);
+ expect(request.imp[0].video.protocols).to.deep.have.same.members(check.protocols);
+ });
+ }
+
+ if (FEATURES.VIDEO) {
+ it('should use bidder video params if they are set', () => {
+ let bid = utils.deepClone(VIDEO_BID);
+ const check = {
+ api: [1, 2],
+ mimes: ['video/mp4', 'video/x-flv'],
+ playbackmethod: [3, 4],
+ protocols: [5, 6],
+ placement: 1,
+ plcmt: 1,
+ minduration: 0,
+ maxduration: 30,
+ startdelay: 0,
+ w: 640,
+ h: 480
+
+ };
+ bid.mediaTypes.video = {...check};
+ bid.mediaTypes.video.context = 'instream';
+ bid.mediaTypes.video.playerSize = [[640, 480]];
+
+ expect(spec.isBidRequestValid(bid)).to.equal(true);
+ const requests = spec.buildRequests([bid], BIDDER_REQUEST);
+ const request = requests[0].data;
+ expect(request.imp[0].video).to.deep.include({...check});
+ });
+ }
});
- it('should return an empty array to indicate no valid bids', function () {
- const mockBidResult = {
- requestId: '9cf19229-34f6-4d06-bc1d-0e44e8d616c8',
- cpm: 10.0,
- creativeId: '1',
- width: 300,
- height: 250,
- netRevenue: true,
- currency: 'USD',
- ttl: 1800,
- ad: '',
- adType: 'banner'
- };
- const testServerResponse = {
- headers: [],
- body: [mockBidResult]
- };
- const bidResponses = spec.interpretResponse(testServerResponse, tempBidRequests);
- expect(bidResponses).deep.equal([mockBidResult]);
+ });
+
+ describe('interpretResponse()', function () {
+ context('when mediaType is banner', function () {
+ it('should correctly interpret valid banner response', function () {
+ const bid = utils.deepClone(BANNER_BID);
+ const [request] = spec.buildRequests([bid], BIDDER_REQUEST);
+ const response = utils.deepClone(BANNER_BID_RESPONSE);
+
+ const bids = spec.interpretResponse({ body: response }, request);
+ expect(bids).to.be.an('array').that.is.not.empty;
+
+ expect(bids[0].mediaType).to.equal('banner');
+ expect(bids[0].burl).to.equal(BANNER_BID_RESPONSE.seatbid[0].bid[0].burl);
+ expect(bids[0].currency).to.equal('USD');
+ expect(bids[0].requestId).to.equal(BANNER_BID_RESPONSE.seatbid[0].bid[0].impid);
+ expect(bids[0].cpm).to.equal(BANNER_BID_RESPONSE.seatbid[0].bid[0].price);
+ expect(bids[0].width).to.equal(BANNER_BID_RESPONSE.seatbid[0].bid[0].w);
+ expect(bids[0].height).to.equal(BANNER_BID_RESPONSE.seatbid[0].bid[0].h);
+ expect(bids[0].ad).to.equal(BANNER_BID_RESPONSE.seatbid[0].bid[0].adm);
+ expect(bids[0].creativeId).to.equal(BANNER_BID_RESPONSE.seatbid[0].bid[0].crid);
+ expect(bids[0].meta.advertiserDomains[0]).to.equal('https://dummydomain.com');
+ expect(bids[0].ttl).to.equal(500);
+ expect(bids[0].netRevenue).to.equal(true);
+ });
+
+ it('should handle empty bid response', function () {
+ const bid = utils.deepClone(BANNER_BID);
+
+ let request = spec.buildRequests([bid], BIDDER_REQUEST)[0];
+ const EMPTY_RESP = Object.assign({}, BANNER_BID_RESPONSE, { 'body': {} });
+ const bids = spec.interpretResponse(EMPTY_RESP, request);
+ expect(bids).to.be.empty;
+ });
});
+ if (FEATURES.VIDEO) {
+ context('when mediaType is video', function () {
+ it('should correctly interpret valid instream video response', () => {
+ const bid = utils.deepClone(VIDEO_BID);
+
+ const [request] = spec.buildRequests([bid], BIDDER_REQUEST);
+ const bids = spec.interpretResponse({ body: VIDEO_BID_RESPONSE }, request);
+ expect(bids).to.be.an('array').that.is.not.empty;
+
+ expect(bids[0].mediaType).to.equal('video');
+ expect(bids[0].burl).to.equal(VIDEO_BID_RESPONSE.seatbid[0].bid[0].burl);
+ expect(bids[0].currency).to.equal('USD');
+ expect(bids[0].requestId).to.equal(VIDEO_BID_RESPONSE.seatbid[0].bid[0].impid);
+ expect(bids[0].cpm).to.equal(VIDEO_BID_RESPONSE.seatbid[0].bid[0].price);
+ expect(bids[0].width).to.equal(VIDEO_BID_RESPONSE.seatbid[0].bid[0].w);
+ expect(bids[0].height).to.equal(VIDEO_BID_RESPONSE.seatbid[0].bid[0].h);
+ expect(bids[0].vastXml).to.equal(VIDEO_BID_RESPONSE.seatbid[0].bid[0].adm);
+ expect(bids[0].rendererUrl).to.equal(VIDEO_RENDERER_URL);
+ expect(bids[0].creativeId).to.equal(VIDEO_BID_RESPONSE.seatbid[0].bid[0].crid);
+ expect(bids[0].meta.advertiserDomains[0]).to.equal('https://dummydomain.com');
+ expect(bids[0].ttl).to.equal(500);
+ expect(bids[0].netRevenue).to.equal(true);
+ });
+ });
+ }
});
describe('getUserSync', function () {
diff --git a/test/spec/modules/uid2IdSystem_helpers.js b/test/spec/modules/uid2IdSystem_helpers.js
index 5006a50dedd..e0bef047acb 100644
--- a/test/spec/modules/uid2IdSystem_helpers.js
+++ b/test/spec/modules/uid2IdSystem_helpers.js
@@ -26,12 +26,12 @@ export const runAuction = async () => {
}
export const apiHelpers = {
- makeTokenResponse: (token, shouldRefresh = false, expired = false) => ({
+ makeTokenResponse: (token, shouldRefresh = false, expired = false, refreshExpired = false) => ({
advertising_token: token,
refresh_token: 'fake-refresh-token',
identity_expires: expired ? Date.now() - 1000 : Date.now() + 60 * 60 * 1000,
refresh_from: shouldRefresh ? Date.now() - 1000 : Date.now() + 60 * 1000,
- refresh_expires: Date.now() + 24 * 60 * 60 * 1000, // 24 hours
+ refresh_expires: refreshExpired ? Date.now() - 1000 : Date.now() + 24 * 60 * 60 * 1000, // 24 hours
refresh_response_key: 'wR5t6HKMfJ2r4J7fEGX9Gw==', // Fake data
}),
respondAfterDelay: (delay, srv = server) => new Promise((resolve) => setTimeout(() => {
diff --git a/test/spec/modules/uid2IdSystem_spec.js b/test/spec/modules/uid2IdSystem_spec.js
index f33060869df..8e3728704c7 100644
--- a/test/spec/modules/uid2IdSystem_spec.js
+++ b/test/spec/modules/uid2IdSystem_spec.js
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
-import {coreStorage, init, setSubmoduleRegistry, requestBidsHook} from 'modules/userId/index.js';
+import {coreStorage, init, setSubmoduleRegistry} from 'modules/userId/index.js';
import {config} from 'src/config.js';
import * as utils from 'src/utils.js';
import { uid2IdSubmodule } from 'modules/uid2IdSystem.js';
@@ -11,6 +11,7 @@ import { configureTimerInterceptors } from 'test/mocks/timers.js';
import { cookieHelpers, runAuction, apiHelpers, setGdprApplies } from './uid2IdSystem_helpers.js';
import {hook} from 'src/hook.js';
import {uninstall as uninstallGdprEnforcement} from 'modules/gdprEnforcement.js';
+import {server} from 'test/mocks/xhr';
let expect = require('chai').expect;
@@ -23,16 +24,22 @@ const auctionDelayMs = 10;
const initialToken = `initial-advertising-token`;
const legacyToken = 'legacy-advertising-token';
const refreshedToken = 'refreshed-advertising-token';
+const clientSideGeneratedToken = 'client-side-generated-advertising-token';
const legacyConfigParams = {storage: null};
const serverCookieConfigParams = { uid2ServerCookie: publisherCookieName };
const newServerCookieConfigParams = { uid2Cookie: publisherCookieName };
+const cstgConfigParams = { serverPublicKey: 'UID2-X-L-24B8a/eLYBmRkXA9yPgRZt+ouKbXewG2OPs23+ov3JC8mtYJBCx6AxGwJ4MlwUcguebhdDp2CvzsCgS9ogwwGA==', subscriptionId: 'subscription-id' }
const makeUid2IdentityContainer = (token) => ({uid2: {id: token}});
let useLocalStorage = false;
const makePrebidConfig = (params = null, extraSettings = {}, debug = false) => ({
userSync: { auctionDelay: auctionDelayMs, userIds: [{name: 'uid2', params: {storage: useLocalStorage ? 'localStorage' : 'cookie', ...params}}] }, debug, ...extraSettings
});
+const makeOriginalIdentity = (identity, salt = 1) => ({
+ identity: utils.cyrb53Hash(identity, salt),
+ salt
+})
const getFromAppropriateStorage = () => {
if (useLocalStorage) return coreStorage.getDataFromLocalStorage(moduleCookieName);
@@ -46,15 +53,18 @@ const expectGlobalToHaveToken = (token) => expect(getGlobal().getUserIds()).to.d
const expectGlobalToHaveNoUid2 = () => expect(getGlobal().getUserIds()).to.not.haveOwnProperty('uid2');
const expectNoLegacyToken = (bid) => expect(bid.userId).to.not.deep.include(makeUid2IdentityContainer(legacyToken));
const expectModuleStorageEmptyOrMissing = () => expect(getFromAppropriateStorage()).to.be.null;
-const expectModuleStorageToContain = (initialIdentity, latestIdentity) => {
+const expectModuleStorageToContain = (originalAdvertisingToken, latestAdvertisingToken, originalIdentity) => {
const cookie = JSON.parse(getFromAppropriateStorage());
- if (initialIdentity) expect(cookie.originalToken.advertising_token).to.equal(initialIdentity);
- if (latestIdentity) expect(cookie.latestToken.advertising_token).to.equal(latestIdentity);
+ if (originalAdvertisingToken) expect(cookie.originalToken.advertising_token).to.equal(originalAdvertisingToken);
+ if (latestAdvertisingToken) expect(cookie.latestToken.advertising_token).to.equal(latestAdvertisingToken);
+ if (originalIdentity) expect(cookie.originalIdentity).to.eql(makeOriginalIdentity(Object.values(originalIdentity)[0], cookie.originalIdentity.salt));
}
-const apiUrl = 'https://prod.uidapi.com/v2/token/refresh';
+const apiUrl = 'https://prod.uidapi.com/v2/token'
+const refreshApiUrl = `${apiUrl}/refresh`;
const headers = { 'Content-Type': 'application/json' };
-const makeSuccessResponseBody = () => btoa(JSON.stringify({ status: 'success', body: { ...apiHelpers.makeTokenResponse(initialToken), advertising_token: refreshedToken } }));
+const makeSuccessResponseBody = (responseToken) => btoa(JSON.stringify({ status: 'success', body: { ...apiHelpers.makeTokenResponse(initialToken), advertising_token: responseToken } }));
+const cstgApiUrl = `${apiUrl}/client-generate`;
const testCookieAndLocalStorage = (description, test, only = false) => {
const describeFn = only ? describe.only : describe;
@@ -76,7 +86,7 @@ const testCookieAndLocalStorage = (description, test, only = false) => {
};
describe(`UID2 module`, function () {
- let server, suiteSandbox, testSandbox, timerSpy, fullTestTitle, restoreSubtleToUndefined = false;
+ let suiteSandbox, testSandbox, timerSpy, fullTestTitle, restoreSubtleToUndefined = false;
before(function () {
timerSpy = configureTimerInterceptors(debugOutput);
hook.ready();
@@ -87,10 +97,18 @@ describe(`UID2 module`, function () {
// I've confirmed it's available in Firefox since v34 (it seems to be unavailable on BrowserStack in Firefox v106).
if (typeof window.crypto.subtle === 'undefined') {
restoreSubtleToUndefined = true;
- window.crypto.subtle = { importKey: () => {}, decrypt: () => {} };
+ window.crypto.subtle = { importKey: () => {}, digest: () => {}, decrypt: () => {}, deriveKey: () => {}, encrypt: () => {}, generateKey: () => {}, exportKey: () => {} };
}
suiteSandbox.stub(window.crypto.subtle, 'importKey').callsFake(() => Promise.resolve());
+ suiteSandbox.stub(window.crypto.subtle, 'digest').callsFake(() => Promise.resolve('hashed_value'));
suiteSandbox.stub(window.crypto.subtle, 'decrypt').callsFake((settings, key, data) => Promise.resolve(new Uint8Array([...settings.iv, ...data])));
+ suiteSandbox.stub(window.crypto.subtle, 'deriveKey').callsFake(() => Promise.resolve());
+ suiteSandbox.stub(window.crypto.subtle, 'exportKey').callsFake(() => Promise.resolve());
+ suiteSandbox.stub(window.crypto.subtle, 'encrypt').callsFake(() => Promise.resolve(new ArrayBuffer()));
+ suiteSandbox.stub(window.crypto.subtle, 'generateKey').callsFake(() => Promise.resolve({
+ privateKey: {},
+ publicKey: {}
+ }));
});
after(function () {
@@ -99,18 +117,18 @@ describe(`UID2 module`, function () {
if (restoreSubtleToUndefined) window.crypto.subtle = undefined;
});
- const configureUid2Response = (httpStatus, response) => server.respondWith('POST', apiUrl, (xhr) => xhr.respond(httpStatus, headers, response));
- const configureUid2ApiSuccessResponse = () => configureUid2Response(200, makeSuccessResponseBody());
- const configureUid2ApiFailResponse = () => configureUid2Response(500, 'Error');
+ const configureUid2Response = (apiUrl, httpStatus, response) => server.respondWith('POST', apiUrl, (xhr) => xhr.respond(httpStatus, headers, response));
+ const configureUid2ApiSuccessResponse = (apiUrl, responseToken) => configureUid2Response(apiUrl, 200, makeSuccessResponseBody(responseToken));
+ const configureUid2ApiFailResponse = (apiUrl) => configureUid2Response(apiUrl, 500, 'Error');
// Runs the provided test twice - once with a successful API mock, once with one which returns a server error
- const testApiSuccessAndFailure = (act, testDescription, failTestDescription, only = false) => {
+ const testApiSuccessAndFailure = (act, apiUrl, testDescription, failTestDescription, only = false, responseToken = refreshedToken) => {
const testFn = only ? it.only : it;
testFn(`API responds successfully: ${testDescription}`, async function() {
- configureUid2ApiSuccessResponse();
+ configureUid2ApiSuccessResponse(apiUrl, responseToken);
await act(true);
});
testFn(`API responds with an error: ${failTestDescription ?? testDescription}`, async function() {
- configureUid2ApiFailResponse();
+ configureUid2ApiFailResponse(apiUrl);
await act(false);
});
}
@@ -123,8 +141,6 @@ describe(`UID2 module`, function () {
debugOutput(fullTestTitle);
testSandbox = sinon.sandbox.create();
testSandbox.stub(utils, 'logWarn');
- server = sinon.createFakeServer();
-
init(config);
setSubmoduleRegistry([uid2IdSubmodule]);
});
@@ -151,13 +167,13 @@ describe(`UID2 module`, function () {
it('When no baseUrl is provided in config, the module calls the production endpoint', function() {
const uid2Token = apiHelpers.makeTokenResponse(initialToken, true, true);
config.setConfig(makePrebidConfig({uid2Token}));
- expect(server.requests[0]?.url).to.have.string('https://prod.uidapi.com/');
+ expect(server.requests[0]?.url).to.have.string('https://prod.uidapi.com/v2/token/refresh');
});
it('When a baseUrl is provided in config, the module calls the provided endpoint', function() {
const uid2Token = apiHelpers.makeTokenResponse(initialToken, true, true);
config.setConfig(makePrebidConfig({uid2Token, uid2ApiBase: 'https://operator-integ.uidapi.com'}));
- expect(server.requests[0]?.url).to.have.string('https://operator-integ.uidapi.com/');
+ expect(server.requests[0]?.url).to.have.string('https://operator-integ.uidapi.com/v2/token/refresh');
});
});
@@ -238,7 +254,7 @@ describe(`UID2 module`, function () {
cookieHelpers.setPublisherCookie(publisherCookieName, token);
config.setConfig(makePrebidConfig(serverCookieConfigParams, extraConfig));
},
- }
+ },
]
scenarios.forEach(function(scenario) {
@@ -252,7 +268,7 @@ describe(`UID2 module`, function () {
if (apiSucceeds) expectToken(bid, refreshedToken);
else expectNoIdentity(bid);
- }, 'it should be used in the auction', 'the auction should have no uid2');
+ }, refreshApiUrl, 'it should be used in the auction', 'the auction should have no uid2');
testApiSuccessAndFailure(async function(apiSucceeds) {
scenario.setConfig(apiHelpers.makeTokenResponse(initialToken, true, true));
@@ -264,14 +280,14 @@ describe(`UID2 module`, function () {
} else {
expectModuleStorageEmptyOrMissing();
}
- }, 'the refreshed token should be stored in the module storage', 'the module storage should not be set');
+ }, refreshApiUrl, 'the refreshed token should be stored in the module storage', 'the module storage should not be set');
});
describe(`when the response doesn't arrive before the auction timer`, function() {
testApiSuccessAndFailure(async function() {
scenario.setConfig(apiHelpers.makeTokenResponse(initialToken, true, true));
const bid = await runAuction();
expectNoIdentity(bid);
- }, 'it should run the auction');
+ }, refreshApiUrl, 'it should run the auction');
testApiSuccessAndFailure(async function(apiSucceeds) {
scenario.setConfig(apiHelpers.makeTokenResponse(initialToken, true, true));
@@ -283,7 +299,7 @@ describe(`UID2 module`, function () {
await promise;
if (apiSucceeds) expectGlobalToHaveToken(refreshedToken);
else expectGlobalToHaveNoUid2();
- }, 'it should update the userId after the auction', 'there should be no global identity');
+ }, refreshApiUrl, 'it should update the userId after the auction', 'there should be no global identity');
})
describe('and there is a refreshed token in the module cookie', function() {
it('the refreshed value from the cookie is used', async function() {
@@ -322,7 +338,7 @@ describe(`UID2 module`, function () {
apiHelpers.respondAfterDelay(10, server);
const bid = await runAuction();
expectToken(bid, initialToken);
- }, 'it should not be refreshed before the auction runs');
+ }, refreshApiUrl, 'it should not be refreshed before the auction runs');
testApiSuccessAndFailure(async function(success) {
const promise = apiHelpers.respondAfterDelay(1, server);
@@ -333,7 +349,7 @@ describe(`UID2 module`, function () {
} else {
expectModuleStorageToContain(initialToken, initialToken);
}
- }, 'the refreshed token should be stored in the module cookie after the auction runs', 'the module cookie should only have the original token');
+ }, refreshApiUrl, 'the refreshed token should be stored in the module cookie after the auction runs', 'the module cookie should only have the original token');
it('it should use the current token in the auction', async function() {
const bid = await runAuction();
@@ -342,4 +358,277 @@ describe(`UID2 module`, function () {
});
});
});
+
+ if (FEATURES.UID2_CSTG) {
+ describe('When CSTG is enabled provided', function () {
+ const scenarios = [
+ {
+ name: 'email provided in config',
+ identity: { email: 'test@example.com' },
+ setConfig: function (extraConfig) { config.setConfig(makePrebidConfig({ ...cstgConfigParams, ...this.identity }, extraConfig)) },
+ setInvalidConfig: (extraConfig) => config.setConfig(makePrebidConfig({ ...cstgConfigParams, email: 'test . test@gmail.com' }, extraConfig))
+ },
+ {
+ name: 'phone provided in config',
+ identity: { phone: '+12345678910' },
+ setConfig: function (extraConfig) { config.setConfig(makePrebidConfig({ ...cstgConfigParams, ...this.identity }, extraConfig)) },
+ setInvalidConfig: (extraConfig) => config.setConfig(makePrebidConfig({ ...cstgConfigParams, phone: 'test123' }, extraConfig))
+ },
+ {
+ name: 'email hash provided in config',
+ identity: { email_hash: 'lz3+Rj7IV4X1+Vr1ujkG7tstkxwk5pgkqJ6mXbpOgTs=' },
+ setConfig: function (extraConfig) { config.setConfig(makePrebidConfig({ ...cstgConfigParams, emailHash: this.identity.email_hash }, extraConfig)) },
+ setInvalidConfig: (extraConfig) => config.setConfig(makePrebidConfig({ ...cstgConfigParams, emailHash: 'test@example.com' }, extraConfig))
+ },
+ {
+ name: 'phone hash provided in config',
+ identity: { phone_hash: 'kVJ+4ilhrqm3HZDDnCQy4niZknvCoM4MkoVzZrQSdJw=' },
+ setConfig: function (extraConfig) { config.setConfig(makePrebidConfig({ ...cstgConfigParams, phoneHash: this.identity.phone_hash }, extraConfig)) },
+ setInvalidConfig: (extraConfig) => config.setConfig(makePrebidConfig({ ...cstgConfigParams, phoneHash: '614332222111' }, extraConfig))
+ },
+ ]
+ scenarios.forEach(function(scenario) {
+ describe(`And ${scenario.name}`, function() {
+ describe(`When invalid identity is provided`, function() {
+ it('the auction should have no uid2', async function () {
+ scenario.setInvalidConfig()
+ const bid = await runAuction();
+ expectNoIdentity(bid);
+ expectGlobalToHaveNoUid2();
+ expectModuleStorageEmptyOrMissing();
+ })
+ });
+
+ describe('When valid identity is provided, and the auction is set to run immediately', function() {
+ it('it should ignores token provided in config, and the auction should have no uid2', async function() {
+ scenario.setConfig({ uid2Token: apiHelpers.makeTokenResponse(initialToken), auctionDelay: 0, syncDelay: 1 });
+ const bid = await runAuction();
+ expectNoIdentity(bid);
+ expectGlobalToHaveNoUid2();
+ expectModuleStorageEmptyOrMissing();
+ })
+
+ it('it should ignores token provided in server-set cookie', async function() {
+ cookieHelpers.setPublisherCookie(publisherCookieName, initialToken);
+ scenario.setConfig({ ...newServerCookieConfigParams, auctionDelay: 0, syncDelay: 1 })
+ const bid = await runAuction();
+ expectNoIdentity(bid);
+ expectGlobalToHaveNoUid2();
+ expectModuleStorageEmptyOrMissing();
+ })
+
+ describe('When the token generated in time', function() {
+ testApiSuccessAndFailure(async function(apiSucceeds) {
+ scenario.setConfig();
+ apiHelpers.respondAfterDelay(auctionDelayMs / 10, server);
+ const bid = await runAuction();
+
+ if (apiSucceeds) expectToken(bid, clientSideGeneratedToken);
+ else expectNoIdentity(bid);
+ }, cstgApiUrl, 'it should be used in the auction', 'the auction should have no uid2', false, clientSideGeneratedToken);
+
+ testApiSuccessAndFailure(async function(apiSucceeds) {
+ scenario.setConfig();
+ apiHelpers.respondAfterDelay(auctionDelayMs / 10, server);
+
+ await runAuction();
+ if (apiSucceeds) {
+ expectModuleStorageToContain(undefined, clientSideGeneratedToken, scenario.identity);
+ } else {
+ expectModuleStorageEmptyOrMissing();
+ }
+ }, cstgApiUrl, 'the generated token should be stored in the module storage', 'the module storage should not be set', false, clientSideGeneratedToken);
+ });
+ });
+ });
+ });
+ describe(`when the response doesn't arrive before the auction timer`, function() {
+ testApiSuccessAndFailure(async function() {
+ config.setConfig(makePrebidConfig({ ...cstgConfigParams, email: 'test@test.com' }));
+ const bid = await runAuction();
+ expectNoIdentity(bid);
+ }, cstgApiUrl, 'it should run the auction', undefined, false, clientSideGeneratedToken);
+
+ testApiSuccessAndFailure(async function(apiSucceeds) {
+ config.setConfig(makePrebidConfig({ ...cstgConfigParams, email: 'test@test.com' }));
+ const promise = apiHelpers.respondAfterDelay(auctionDelayMs * 2, server);
+
+ const bid = await runAuction();
+ expectNoIdentity(bid);
+ expectGlobalToHaveNoUid2();
+ await promise;
+ if (apiSucceeds) expectGlobalToHaveToken(clientSideGeneratedToken);
+ else expectGlobalToHaveNoUid2();
+ }, cstgApiUrl, 'it should update the userId after the auction', 'there should be no global identity', false, clientSideGeneratedToken);
+ })
+
+ describe('when there is a token in the module cookie', function() {
+ describe('when originalIdentity matches', function() {
+ describe('When the storedToken is valid', function() {
+ it('it should use the stored token in the auction', async function() {
+ const refreshedIdentity = apiHelpers.makeTokenResponse(refreshedToken);
+ const moduleCookie = {originalIdentity: makeOriginalIdentity('test@test.com'), latestToken: refreshedIdentity};
+ coreStorage.setCookie(moduleCookieName, JSON.stringify(moduleCookie), cookieHelpers.getFutureCookieExpiry());
+ config.setConfig(makePrebidConfig({ ...cstgConfigParams, email: 'test@test.com', auctionDelay: 0, syncDelay: 1 }));
+ const bid = await runAuction();
+ expectToken(bid, refreshedToken);
+ });
+ })
+
+ describe('When the storedToken is expired and can be refreshed ', function() {
+ it('it should calls refresh API', function() {
+ testApiSuccessAndFailure(async function(apiSucceeds) {
+ const refreshedIdentity = apiHelpers.makeTokenResponse(refreshedToken, true, true);
+ const moduleCookie = {originalIdentity: makeOriginalIdentity('test@test.com'), latestToken: refreshedIdentity};
+ coreStorage.setCookie(moduleCookieName, JSON.stringify(moduleCookie), cookieHelpers.getFutureCookieExpiry());
+ config.setConfig(makePrebidConfig({ ...cstgConfigParams, email: 'test@test.com' }));
+ apiHelpers.respondAfterDelay(auctionDelayMs / 10, server);
+
+ const bid = await runAuction();
+
+ if (apiSucceeds) expectToken(bid, refreshedToken);
+ else expectNoIdentity(bid);
+ }, refreshApiUrl, 'it should use refreshed token in the auction', 'the auction should have no uid2');
+ });
+ })
+
+ describe('When the storedToken is expired for refresh', function() {
+ it('it should calls CSTG API and not use the stored token', function() {
+ testApiSuccessAndFailure(async function(apiSucceeds) {
+ const refreshedIdentity = apiHelpers.makeTokenResponse(refreshedToken, true, true, true);
+ const moduleCookie = {originalIdentity: makeOriginalIdentity('test@test.com'), latestToken: refreshedIdentity};
+ coreStorage.setCookie(moduleCookieName, JSON.stringify(moduleCookie), cookieHelpers.getFutureCookieExpiry());
+ config.setConfig(makePrebidConfig({ ...cstgConfigParams, email: 'test@test.com' }));
+ apiHelpers.respondAfterDelay(auctionDelayMs / 10, server);
+
+ const bid = await runAuction();
+
+ if (apiSucceeds) expectToken(bid, clientSideGeneratedToken);
+ else expectNoIdentity(bid);
+ }, cstgApiUrl, 'it should use generated token in the auction', 'the auction should have no uid2', false, clientSideGeneratedToken);
+ });
+ })
+ })
+
+ it('when originalIdentity not match, the auction should has no uid2', async function() {
+ const refreshedIdentity = apiHelpers.makeTokenResponse(refreshedToken);
+ const moduleCookie = {originalIdentity: makeOriginalIdentity('123@test.com'), latestToken: refreshedIdentity};
+ coreStorage.setCookie(moduleCookieName, JSON.stringify(moduleCookie), cookieHelpers.getFutureCookieExpiry());
+ config.setConfig(makePrebidConfig({ ...cstgConfigParams, email: 'test@test.com' }));
+ const bid = await runAuction();
+ expectNoIdentity(bid);
+ });
+ })
+ });
+ describe('When invalid CSTG configuration is provided', function () {
+ const invalidConfigs = [
+ {
+ name: 'CSTG option is not a object',
+ cstgOptions: ''
+ },
+ {
+ name: 'CSTG option is null',
+ cstgOptions: ''
+ },
+ {
+ name: 'serverPublicKey is not a string',
+ cstgOptions: { subscriptionId: cstgConfigParams.subscriptionId, serverPublicKey: {} }
+ },
+ {
+ name: 'serverPublicKey not match regular expression',
+ cstgOptions: { subscriptionId: cstgConfigParams.subscriptionId, serverPublicKey: 'serverPublicKey' }
+ },
+ {
+ name: 'subscriptionId is not a string',
+ cstgOptions: { subscriptionId: {}, serverPublicKey: cstgConfigParams.serverPublicKey }
+ },
+ {
+ name: 'subscriptionId is empty',
+ cstgOptions: { subscriptionId: '', serverPublicKey: cstgConfigParams.serverPublicKey }
+ },
+ ]
+ invalidConfigs.forEach(function(scenario) {
+ describe(`When ${scenario.name}`, function() {
+ it('should not generate token using identity', async () => {
+ config.setConfig(makePrebidConfig({ ...scenario.cstgOptions, email: 'test@email.com' }));
+ const bid = await runAuction();
+ expectNoIdentity(bid);
+ expectGlobalToHaveNoUid2();
+ expectModuleStorageEmptyOrMissing();
+ });
+ });
+ });
+ });
+ describe('When email is provided in different format', function () {
+ const testCases = [
+ { originalEmail: 'TEst.TEST@Test.com ', normalizedEmail: 'test.test@test.com' },
+ { originalEmail: 'test+test@test.com', normalizedEmail: 'test+test@test.com' },
+ { originalEmail: ' testtest@test.com ', normalizedEmail: 'testtest@test.com' },
+ { originalEmail: 'TEst.TEst+123@GMail.Com', normalizedEmail: 'testtest@gmail.com' }
+ ];
+ testCases.forEach((testCase) => {
+ describe('it should normalize the email and generate token on normalized email', async () => {
+ testApiSuccessAndFailure(async function(apiSucceeds) {
+ config.setConfig(makePrebidConfig({ ...cstgConfigParams, email: testCase.originalEmail }));
+ apiHelpers.respondAfterDelay(auctionDelayMs / 10, server);
+
+ await runAuction();
+ if (apiSucceeds) {
+ expectModuleStorageToContain(undefined, clientSideGeneratedToken, { email: testCase.normalizedEmail });
+ } else {
+ expectModuleStorageEmptyOrMissing();
+ }
+ }, cstgApiUrl, 'the generated token should be stored in the module storage', 'the module storage should not be set', false, clientSideGeneratedToken);
+ });
+ });
+ });
+ }
+
+ describe('When neither token nor CSTG config provided', function () {
+ describe('when there is a non-cstg-derived token in the module cookie', function () {
+ it('the auction use stored token if it is valid', async function () {
+ const originalIdentity = apiHelpers.makeTokenResponse(initialToken);
+ const moduleCookie = {originalToken: originalIdentity, latestToken: originalIdentity};
+ coreStorage.setCookie(moduleCookieName, JSON.stringify(moduleCookie), cookieHelpers.getFutureCookieExpiry());
+ config.setConfig(makePrebidConfig({}));
+ const bid = await runAuction();
+ expectToken(bid, initialToken);
+ })
+
+ it('the auction should has no uid2 if stored token is invalid', async function () {
+ const originalIdentity = apiHelpers.makeTokenResponse(initialToken, true, true, true);
+ const moduleCookie = {originalToken: originalIdentity, latestToken: originalIdentity};
+ coreStorage.setCookie(moduleCookieName, JSON.stringify(moduleCookie), cookieHelpers.getFutureCookieExpiry());
+ config.setConfig(makePrebidConfig({}));
+ const bid = await runAuction();
+ expectNoIdentity(bid);
+ })
+ })
+
+ describe('when there is a cstg-derived token in the module cookie', function () {
+ it('the auction use stored token if it is valid', async function () {
+ const originalIdentity = apiHelpers.makeTokenResponse(initialToken);
+ const moduleCookie = {originalIdentity: makeOriginalIdentity('123@test.com'), originalToken: originalIdentity, latestToken: originalIdentity};
+ coreStorage.setCookie(moduleCookieName, JSON.stringify(moduleCookie), cookieHelpers.getFutureCookieExpiry());
+ config.setConfig(makePrebidConfig({}));
+ const bid = await runAuction();
+ expectToken(bid, initialToken);
+ })
+
+ it('the auction should has no uid2 if stored token is invalid', async function () {
+ const originalIdentity = apiHelpers.makeTokenResponse(initialToken, true, true, true);
+ const moduleCookie = {originalIdentity: makeOriginalIdentity('123@test.com'), originalToken: originalIdentity, latestToken: originalIdentity};
+ coreStorage.setCookie(moduleCookieName, JSON.stringify(moduleCookie), cookieHelpers.getFutureCookieExpiry());
+ config.setConfig(makePrebidConfig({}));
+ const bid = await runAuction();
+ expectNoIdentity(bid);
+ })
+ })
+
+ it('the auction should has no uid2', async function () {
+ config.setConfig(makePrebidConfig({}));
+ const bid = await runAuction();
+ expectNoIdentity(bid);
+ })
+ })
});
diff --git a/test/spec/modules/unrulyBidAdapter_spec.js b/test/spec/modules/unrulyBidAdapter_spec.js
index 6d1d8f9949f..f1f6517af67 100644
--- a/test/spec/modules/unrulyBidAdapter_spec.js
+++ b/test/spec/modules/unrulyBidAdapter_spec.js
@@ -42,9 +42,40 @@ describe('UnrulyAdapter', function () {
}
}
- const createExchangeResponse = (...bids) => ({
- body: {bids}
- });
+ function createOutStreamExchangeAuctionConfig() {
+ return {
+ 'seller': 'https://nexxen.tech',
+ 'decisionLogicURL': 'https://nexxen.tech/padecisionlogic',
+ 'interestGroupBuyers': 'https://mydsp.com',
+ 'perBuyerSignals': {
+ 'https://mydsp.com': {
+ 'floor': 'bouttreefiddy'
+ }
+ }
+ }
+ };
+
+ function createExchangeResponse (bidList, auctionConfigs = null) {
+ let bids = [];
+ if (Array.isArray(bidList)) {
+ bids = bidList;
+ } else if (bidList) {
+ bids.push(bidList);
+ }
+
+ if (!auctionConfigs) {
+ return {
+ 'body': {bids}
+ };
+ }
+
+ return {
+ 'body': {
+ bids,
+ auctionConfigs
+ }
+ }
+ };
const inStreamServerResponse = {
'requestId': '262594d5d1f8104',
@@ -658,6 +689,227 @@ describe('UnrulyAdapter', function () {
let result = adapter.buildRequests(mockBidRequests.bids, mockBidRequests);
expect(result[0].data).to.deep.equal(expectedResult);
});
+ describe('Protected Audience Support', function() {
+ it('should return an array with 2 items and enabled protected audience', function () {
+ mockBidRequests = {
+ 'bidderCode': 'unruly',
+ 'fledgeEnabled': true,
+ 'bids': [
+ {
+ 'bidder': 'unruly',
+ 'params': {
+ 'siteId': 233261,
+ },
+ 'mediaTypes': {
+ 'video': {
+ 'context': 'outstream',
+ 'mimes': [
+ 'video/mp4'
+ ],
+ 'playerSize': [
+ [
+ 640,
+ 480
+ ]
+ ]
+ }
+ },
+ 'adUnitCode': 'video2',
+ 'transactionId': 'a89619e3-137d-4cc5-9ed4-58a0b2a0bbc2',
+ 'sizes': [
+ [
+ 640,
+ 480
+ ]
+ ],
+ 'bidId': '27a3ee1626a5c7',
+ 'bidderRequestId': '12e00d17dff07b',
+ 'ortb2Imp': {
+ 'ext': {
+ 'ae': 1
+ }
+ }
+ },
+ {
+ 'bidder': 'unruly',
+ 'params': {
+ 'siteId': 2234554,
+ },
+ 'mediaTypes': {
+ 'video': {
+ 'context': 'outstream',
+ 'mimes': [
+ 'video/mp4'
+ ],
+ 'playerSize': [
+ [
+ 640,
+ 480
+ ]
+ ]
+ }
+ },
+ 'adUnitCode': 'video2',
+ 'transactionId': 'a89619e3-137d-4cc5-9ed4-58a0b2a0bbc2',
+ 'sizes': [
+ [
+ 640,
+ 480
+ ]
+ ],
+ 'bidId': '27a3ee1626a5c7',
+ 'bidderRequestId': '12e00d17dff07b',
+ 'ortb2Imp': {
+ 'ext': {
+ 'ae': 1
+ }
+ }
+ }
+ ]
+ };
+
+ let result = adapter.buildRequests(mockBidRequests.bids, mockBidRequests);
+ expect(typeof result).to.equal('object');
+ expect(result.length).to.equal(2);
+ expect(result[0].data.bidderRequest.bids.length).to.equal(1);
+ expect(result[1].data.bidderRequest.bids.length).to.equal(1);
+ expect(result[0].data.bidderRequest.bids[0].ortb2Imp.ext.ae).to.equal(1);
+ expect(result[1].data.bidderRequest.bids[0].ortb2Imp.ext.ae).to.equal(1);
+ });
+ it('should return an array with 2 items and enabled protected audience on only one unit', function () {
+ mockBidRequests = {
+ 'bidderCode': 'unruly',
+ 'fledgeEnabled': true,
+ 'bids': [
+ {
+ 'bidder': 'unruly',
+ 'params': {
+ 'siteId': 233261,
+ },
+ 'mediaTypes': {
+ 'video': {
+ 'context': 'outstream',
+ 'mimes': [
+ 'video/mp4'
+ ],
+ 'playerSize': [
+ [
+ 640,
+ 480
+ ]
+ ]
+ }
+ },
+ 'adUnitCode': 'video2',
+ 'transactionId': 'a89619e3-137d-4cc5-9ed4-58a0b2a0bbc2',
+ 'sizes': [
+ [
+ 640,
+ 480
+ ]
+ ],
+ 'bidId': '27a3ee1626a5c7',
+ 'bidderRequestId': '12e00d17dff07b',
+ 'ortb2Imp': {
+ 'ext': {
+ 'ae': 1
+ }
+ }
+ },
+ {
+ 'bidder': 'unruly',
+ 'params': {
+ 'siteId': 2234554,
+ },
+ 'mediaTypes': {
+ 'video': {
+ 'context': 'outstream',
+ 'mimes': [
+ 'video/mp4'
+ ],
+ 'playerSize': [
+ [
+ 640,
+ 480
+ ]
+ ]
+ }
+ },
+ 'adUnitCode': 'video2',
+ 'transactionId': 'a89619e3-137d-4cc5-9ed4-58a0b2a0bbc2',
+ 'sizes': [
+ [
+ 640,
+ 480
+ ]
+ ],
+ 'bidId': '27a3ee1626a5c7',
+ 'bidderRequestId': '12e00d17dff07b',
+ 'ortb2Imp': {
+ 'ext': {}
+ }
+ }
+ ]
+ };
+
+ let result = adapter.buildRequests(mockBidRequests.bids, mockBidRequests);
+ expect(typeof result).to.equal('object');
+ expect(result.length).to.equal(2);
+ expect(result[0].data.bidderRequest.bids.length).to.equal(1);
+ expect(result[1].data.bidderRequest.bids.length).to.equal(1);
+ expect(result[0].data.bidderRequest.bids[0].ortb2Imp.ext.ae).to.equal(1);
+ expect(result[1].data.bidderRequest.bids[0].ortb2Imp.ext.ae).to.be.undefined;
+ });
+ it('disables configured protected audience when fledge is not availble', function () {
+ mockBidRequests = {
+ 'bidderCode': 'unruly',
+ 'fledgeEnabled': false,
+ 'bids': [
+ {
+ 'bidder': 'unruly',
+ 'params': {
+ 'siteId': 233261,
+ },
+ 'mediaTypes': {
+ 'video': {
+ 'context': 'outstream',
+ 'mimes': [
+ 'video/mp4'
+ ],
+ 'playerSize': [
+ [
+ 640,
+ 480
+ ]
+ ]
+ }
+ },
+ 'adUnitCode': 'video2',
+ 'transactionId': 'a89619e3-137d-4cc5-9ed4-58a0b2a0bbc2',
+ 'sizes': [
+ [
+ 640,
+ 480
+ ]
+ ],
+ 'bidId': '27a3ee1626a5c7',
+ 'bidderRequestId': '12e00d17dff07b',
+ 'ortb2Imp': {
+ 'ext': {
+ 'ae': 1
+ }
+ }
+ }
+ ]
+ };
+
+ let result = adapter.buildRequests(mockBidRequests.bids, mockBidRequests);
+ expect(typeof result).to.equal('object');
+ expect(result.length).to.equal(1);
+ expect(result[0].data.bidderRequest.bids.length).to.equal(1);
+ expect(result[0].data.bidderRequest.bids[0].ortb2Imp.ext.ae).to.be.undefined;
+ });
+ });
});
describe('interpretResponse', function () {
@@ -705,7 +957,167 @@ describe('UnrulyAdapter', function () {
renderer: fakeRenderer,
mediaType: 'video'
}
- ])
+ ]);
+ });
+
+ it('should return object with an array of bids and an array of auction configs when it receives a successful response from server', function () {
+ let bidId = '27a3ee1626a5c7'
+ const mockExchangeBid = createOutStreamExchangeBid({adUnitCode: 'video1', requestId: 'mockBidId'});
+ const mockExchangeAuctionConfig = {};
+ mockExchangeAuctionConfig[bidId] = createOutStreamExchangeAuctionConfig();
+ const mockServerResponse = createExchangeResponse(mockExchangeBid, mockExchangeAuctionConfig);
+ const originalRequest = {
+ 'data': {
+ 'bidderRequest': {
+ 'bids': [
+ {
+ 'bidder': 'unruly',
+ 'params': {
+ 'siteId': 233261,
+ },
+ 'mediaTypes': {
+ 'banner': {
+ 'sizes': [
+ [
+ 640,
+ 480
+ ],
+ [
+ 640,
+ 480
+ ],
+ [
+ 300,
+ 250
+ ],
+ [
+ 300,
+ 250
+ ]
+ ]
+ }
+ },
+ 'adUnitCode': 'video2',
+ 'transactionId': 'a89619e3-137d-4cc5-9ed4-58a0b2a0bbc2',
+ 'bidId': bidId,
+ 'bidderRequestId': '12e00d17dff07b',
+ }
+ ]
+ }
+ }
+ };
+
+ expect(adapter.interpretResponse(mockServerResponse, originalRequest)).to.deep.equal({
+ 'bids': [
+ {
+ 'ext': {
+ 'statusCode': 1,
+ 'renderer': {
+ 'id': 'unruly_inarticle',
+ 'config': {
+ 'siteId': 123456,
+ 'targetingUUID': 'xxx-yyy-zzz'
+ },
+ 'url': 'https://video.unrulymedia.com/native/prebid-loader.js'
+ },
+ 'adUnitCode': 'video1'
+ },
+ requestId: 'mockBidId',
+ bidderCode: 'unruly',
+ cpm: 20,
+ width: 323,
+ height: 323,
+ vastUrl: 'https://targeting.unrulymedia.com/in_article?uuid=74544e00-d43b-4f3a-a799-69d22ce979ce&supported_mime_type=application/javascript&supported_mime_type=video/mp4&tj=%7B%22site%22%3A%7B%22lang%22%3A%22en-GB%22%2C%22ref%22%3A%22%22%2C%22page%22%3A%22https%3A%2F%2Fdemo.unrulymedia.com%2FinArticle%2Finarticle_nypost_upbeat%2Ftravel_magazines.html%22%2C%22domain%22%3A%22demo.unrulymedia.com%22%7D%2C%22user%22%3A%7B%22profile%22%3A%7B%22quantcast%22%3A%7B%22segments%22%3A%5B%7B%22id%22%3A%22D%22%7D%2C%7B%22id%22%3A%22T%22%7D%5D%7D%7D%7D%7D&video_width=618&video_height=347',
+ netRevenue: true,
+ creativeId: 'mockBidId',
+ ttl: 360,
+ 'meta': {
+ 'mediaType': 'video',
+ 'videoContext': 'outstream'
+ },
+ currency: 'USD',
+ renderer: fakeRenderer,
+ mediaType: 'video'
+ }
+ ],
+ 'fledgeAuctionConfigs': [{
+ 'bidId': bidId,
+ 'config': {
+ 'seller': 'https://nexxen.tech',
+ 'decisionLogicURL': 'https://nexxen.tech/padecisionlogic',
+ 'interestGroupBuyers': 'https://mydsp.com',
+ 'perBuyerSignals': {
+ 'https://mydsp.com': {
+ 'floor': 'bouttreefiddy'
+ }
+ }
+ }
+ }]
+ });
+ });
+
+ it('should return object with an array of auction configs when it receives a successful response from server without bids', function () {
+ let bidId = '27a3ee1626a5c7';
+ const mockExchangeAuctionConfig = {};
+ mockExchangeAuctionConfig[bidId] = createOutStreamExchangeAuctionConfig();
+ const mockServerResponse = createExchangeResponse(null, mockExchangeAuctionConfig);
+ const originalRequest = {
+ 'data': {
+ 'bidderRequest': {
+ 'bids': [
+ {
+ 'bidder': 'unruly',
+ 'params': {
+ 'siteId': 233261,
+ },
+ 'mediaTypes': {
+ 'banner': {
+ 'sizes': [
+ [
+ 640,
+ 480
+ ],
+ [
+ 640,
+ 480
+ ],
+ [
+ 300,
+ 250
+ ],
+ [
+ 300,
+ 250
+ ]
+ ]
+ }
+ },
+ 'adUnitCode': 'video2',
+ 'transactionId': 'a89619e3-137d-4cc5-9ed4-58a0b2a0bbc2',
+ 'bidId': bidId,
+ 'bidderRequestId': '12e00d17dff07b',
+ }
+ ]
+ }
+ }
+ };
+
+ expect(adapter.interpretResponse(mockServerResponse, originalRequest)).to.deep.equal({
+ 'bids': [],
+ 'fledgeAuctionConfigs': [{
+ 'bidId': bidId,
+ 'config': {
+ 'seller': 'https://nexxen.tech',
+ 'decisionLogicURL': 'https://nexxen.tech/padecisionlogic',
+ 'interestGroupBuyers': 'https://mydsp.com',
+ 'perBuyerSignals': {
+ 'https://mydsp.com': {
+ 'floor': 'bouttreefiddy'
+ }
+ }
+ }
+ }]
+ });
});
it('should initialize and set the renderer', function () {
@@ -875,7 +1287,7 @@ describe('UnrulyAdapter', function () {
it('should return correct response for multiple bids', function () {
const outStreamServerResponse = createOutStreamExchangeBid({adUnitCode: 'video1', requestId: 'mockBidId'});
- const mockServerResponse = createExchangeResponse(outStreamServerResponse, inStreamServerResponse, bannerServerResponse);
+ const mockServerResponse = createExchangeResponse([outStreamServerResponse, inStreamServerResponse, bannerServerResponse]);
const expectedOutStreamResponse = outStreamServerResponse;
expectedOutStreamResponse.mediaType = 'video';
@@ -890,7 +1302,7 @@ describe('UnrulyAdapter', function () {
it('should return only valid bids', function () {
const {ad, ...bannerServerResponseNoAd} = bannerServerResponse;
- const mockServerResponse = createExchangeResponse(bannerServerResponseNoAd, inStreamServerResponse);
+ const mockServerResponse = createExchangeResponse([bannerServerResponseNoAd, inStreamServerResponse]);
const expectedInStreamResponse = inStreamServerResponse;
expectedInStreamResponse.mediaType = 'video';
diff --git a/test/spec/modules/yieldmoBidAdapter_spec.js b/test/spec/modules/yieldmoBidAdapter_spec.js
index 229dc05e2fa..a80d0a842b7 100644
--- a/test/spec/modules/yieldmoBidAdapter_spec.js
+++ b/test/spec/modules/yieldmoBidAdapter_spec.js
@@ -74,7 +74,6 @@ describe('YieldmoAdapter', function () {
bidderRequestId: '14c4ede8c693f',
bids,
auctionStart: 1520001292880,
- timeout: 3000,
start: 1520001292884,
doneCbCallCount: 0,
refererInfo: {
@@ -169,6 +168,14 @@ describe('YieldmoAdapter', function () {
expect(requests[0].url).to.be.equal(BANNER_ENDPOINT);
});
+ it('should pass default timeout in bid request', function () {
+ const requests = build([mockBannerBid()]);
+ expect(requests[0].data.tmax).to.equal(400);
+ });
+ it('should pass tmax to bid request', function () {
+ const requests = build([mockBannerBid()], mockBidderRequest({timeout: 1000}));
+ expect(requests[0].data.tmax).to.equal(1000);
+ });
it('should not blow up if crumbs is undefined', function () {
expect(function () {
build([mockBannerBid({crumbs: undefined})]);
diff --git a/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js b/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js
index 0796736a162..5194a6a526a 100644
--- a/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js
+++ b/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js
@@ -398,5 +398,32 @@ describe('Zeta Global SSP Analytics Adapter', function() {
expect(auctionSucceeded.bid.params[0]).to.be.deep.equal(EVENTS.AUCTION_END.adUnits[0].bids[0].params);
expect(EVENTS.AUCTION_END.adUnits[0].bids[0].bidder).to.be.equal('zeta_global_ssp');
});
+
+ it('Keep only needed fields', function() {
+ this.timeout(3000);
+
+ events.emit(CONSTANTS.EVENTS.AUCTION_END, EVENTS.AUCTION_END);
+ events.emit(CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED, EVENTS.AD_RENDER_SUCCEEDED);
+
+ expect(requests.length).to.equal(2);
+ const auctionEnd = JSON.parse(requests[0].requestBody);
+ const auctionSucceeded = JSON.parse(requests[1].requestBody);
+
+ expect(auctionEnd.adUnitCodes[0]).to.be.equal('/19968336/header-bid-tag-0');
+ expect(auctionEnd.adUnits[0].bids[0].bidder).to.be.equal('zeta_global_ssp');
+ expect(auctionEnd.auctionEnd).to.be.equal(1638441234784);
+ expect(auctionEnd.auctionId).to.be.equal('75e394d9-ccce-4978-9238-91e6a1ac88a1');
+ expect(auctionEnd.bidderRequests[0].bidderCode).to.be.equal('zeta_global_ssp');
+ expect(auctionEnd.bidsReceived[0].bidderCode).to.be.equal('zeta_global_ssp');
+ expect(auctionEnd.noBids[0].bidder).to.be.equal('appnexus');
+
+ expect(auctionSucceeded.adId).to.be.equal('5759bb3ef7be1e8');
+ expect(auctionSucceeded.bid.auctionId).to.be.equal('75e394d9-ccce-4978-9238-91e6a1ac88a1');
+ expect(auctionSucceeded.bid.requestId).to.be.equal('206be9a13236af');
+ expect(auctionSucceeded.bid.bidderCode).to.be.equal('zeta_global_ssp');
+ expect(auctionSucceeded.bid.creativeId).to.be.equal('456456456');
+ expect(auctionSucceeded.bid.size).to.be.equal('480x320');
+ expect(auctionSucceeded.doc.location.hostname).to.be.equal('localhost');
+ });
});
});
diff --git a/test/spec/modules/zeta_global_sspBidAdapter_spec.js b/test/spec/modules/zeta_global_sspBidAdapter_spec.js
index 601f4546a29..d4fe28eff90 100644
--- a/test/spec/modules/zeta_global_sspBidAdapter_spec.js
+++ b/test/spec/modules/zeta_global_sspBidAdapter_spec.js
@@ -1,5 +1,6 @@
import {spec} from '../../../modules/zeta_global_sspBidAdapter.js'
import {BANNER, VIDEO} from '../../../src/mediaTypes';
+import {deepClone} from '../../../src/utils';
describe('Zeta Ssp Bid Adapter', function () {
const eids = [
@@ -50,7 +51,6 @@ describe('Zeta Ssp Bid Adapter', function () {
someTag: 444,
},
sid: 'publisherId',
- shortname: 'test_shortname',
tagid: 'test_tag_id',
site: {
page: 'testPage'
@@ -253,11 +253,13 @@ describe('Zeta Ssp Bid Adapter', function () {
};
it('Test the bid validation function', function () {
- const validBid = spec.isBidRequestValid(bannerRequest[0]);
- const invalidBid = spec.isBidRequestValid(null);
+ const invalidBid = deepClone(bannerRequest[0]);
+ invalidBid.params = {};
+ const isValidBid = spec.isBidRequestValid(bannerRequest[0]);
+ const isInvalidBid = spec.isBidRequestValid(null);
- expect(validBid).to.be.true;
- expect(invalidBid).to.be.false;
+ expect(isValidBid).to.be.true;
+ expect(isInvalidBid).to.be.false;
});
it('Test provide eids', function () {
@@ -453,7 +455,7 @@ describe('Zeta Ssp Bid Adapter', function () {
it('Test required params in banner request', function () {
const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
const payload = JSON.parse(request.data);
- expect(request.url).to.eql('https://ssp.disqus.com/bid/prebid?shortname=test_shortname');
+ expect(request.url).to.eql('https://ssp.disqus.com/bid/prebid?sid=publisherId');
expect(payload.ext.sid).to.eql('publisherId');
expect(payload.ext.tags.someTag).to.eql(444);
expect(payload.ext.tags.shortname).to.be.undefined;
@@ -462,7 +464,7 @@ describe('Zeta Ssp Bid Adapter', function () {
it('Test required params in video request', function () {
const request = spec.buildRequests(videoRequest, videoRequest[0]);
const payload = JSON.parse(request.data);
- expect(request.url).to.eql('https://ssp.disqus.com/bid/prebid?shortname=test_shortname');
+ expect(request.url).to.eql('https://ssp.disqus.com/bid/prebid?sid=publisherId');
expect(payload.ext.sid).to.eql('publisherId');
expect(payload.ext.tags.someTag).to.eql(444);
expect(payload.ext.tags.shortname).to.be.undefined;
@@ -471,7 +473,7 @@ describe('Zeta Ssp Bid Adapter', function () {
it('Test multi imp', function () {
const request = spec.buildRequests(multiImpRequest, multiImpRequest[0]);
const payload = JSON.parse(request.data);
- expect(request.url).to.eql('https://ssp.disqus.com/bid/prebid?shortname=test_shortname');
+ expect(request.url).to.eql('https://ssp.disqus.com/bid/prebid?sid=publisherId');
expect(payload.imp.length).to.eql(2);
diff --git a/test/spec/unit/core/bidderFactory_spec.js b/test/spec/unit/core/bidderFactory_spec.js
index 4c13d830206..9dcdb627698 100644
--- a/test/spec/unit/core/bidderFactory_spec.js
+++ b/test/spec/unit/core/bidderFactory_spec.js
@@ -422,7 +422,15 @@ describe('bidderFactory', () => {
});
describe('browsingTopics ajax option', () => {
- let transmitUfpdAllowed, bidder;
+ let transmitUfpdAllowed, bidder, origBS;
+ before(() => {
+ origBS = window.$$PREBID_GLOBAL$$.bidderSettings;
+ })
+
+ after(() => {
+ window.$$PREBID_GLOBAL$$.bidderSettings = origBS;
+ });
+
beforeEach(() => {
activityRules.isActivityAllowed.reset();
activityRules.isActivityAllowed.callsFake((activity) => activity === ACTIVITY_TRANSMIT_UFPD ? transmitUfpdAllowed : true);
@@ -448,49 +456,71 @@ describe('bidderFactory', () => {
});
Object.entries({
- 'allowed': true,
- 'not allowed': false
- }).forEach(([t, allow]) => {
- it(`should be set to ${allow} when transmitUfpd is ${t}`, () => {
- transmitUfpdAllowed = allow;
- spec.buildRequests.returns([
- {
- method: 'GET',
- url: '1',
- },
- {
- method: 'POST',
- url: '2',
- data: {}
- },
- {
- method: 'GET',
- url: '3',
- options: {
- browsingTopics: true
- }
- },
- {
- method: 'POST',
- url: '4',
- data: {},
- options: {
- browsingTopics: true
+ 'omitted': [undefined, true],
+ 'enabled': [true, true],
+ 'disabled': [false, false]
+ }).forEach(([t, [topicsHeader, enabled]]) => {
+ describe(`when bidderSettings.topicsHeader is ${t}`, () => {
+ beforeEach(() => {
+ window.$$PREBID_GLOBAL$$.bidderSettings = {
+ [CODE]: {
+ topicsHeader: topicsHeader
}
}
- ]);
- bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);
- ['1', '2', '3', '4'].forEach(url => {
- sinon.assert.calledWith(
- ajaxStub,
- url,
- sinon.match.any,
- sinon.match.any,
- sinon.match({browsingTopics: allow})
- );
});
- });
- });
+
+ afterEach(() => {
+ delete window.$$PREBID_GLOBAL$$.bidderSettings[CODE];
+ });
+
+ Object.entries({
+ 'allowed': true,
+ 'not allowed': false
+ }).forEach(([t, allow]) => {
+ const shouldBeSet = allow && enabled;
+
+ it(`should be set to ${shouldBeSet} when transmitUfpd is ${t}`, () => {
+ transmitUfpdAllowed = allow;
+ spec.buildRequests.returns([
+ {
+ method: 'GET',
+ url: '1',
+ },
+ {
+ method: 'POST',
+ url: '2',
+ data: {}
+ },
+ {
+ method: 'GET',
+ url: '3',
+ options: {
+ browsingTopics: true
+ }
+ },
+ {
+ method: 'POST',
+ url: '4',
+ data: {},
+ options: {
+ browsingTopics: true
+ }
+ }
+ ]);
+ bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);
+ ['1', '2', '3', '4'].forEach(url => {
+ sinon.assert.calledWith(
+ ajaxStub,
+ url,
+ sinon.match.any,
+ sinon.match.any,
+ sinon.match({browsingTopics: shouldBeSet})
+ );
+ });
+ });
+ });
+ })
+ })
});
it('should not add bids for each placement code if no requests are given', function () {
@@ -1448,7 +1478,7 @@ describe('bidderFactory', () => {
bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);
expect(fledgeStub.calledOnce).to.equal(true);
- sinon.assert.calledWith(fledgeStub, bidRequest.auctionId, 'mock/placement', fledgeAuctionConfig.config);
+ sinon.assert.calledWith(fledgeStub, bidRequest.bids[0], fledgeAuctionConfig.config);
expect(addBidResponseStub.calledOnce).to.equal(true);
expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement');
})
@@ -1462,7 +1492,7 @@ describe('bidderFactory', () => {
bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);
expect(fledgeStub.calledOnce).to.be.true;
- sinon.assert.calledWith(fledgeStub, bidRequest.auctionId, 'mock/placement', fledgeAuctionConfig.config);
+ sinon.assert.calledWith(fledgeStub, bidRequest.bids[0], fledgeAuctionConfig.config);
expect(addBidResponseStub.calledOnce).to.equal(false);
})
})
diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js
index 664f7ebb58f..00eedb9a2b5 100644
--- a/test/spec/unit/pbjs_api_spec.js
+++ b/test/spec/unit/pbjs_api_spec.js
@@ -14,7 +14,7 @@ import { config as configObj } from 'src/config.js';
import * as ajaxLib from 'src/ajax.js';
import * as auctionModule from 'src/auction.js';
import { registerBidder } from 'src/adapters/bidderFactory.js';
-import { _sendAdToCreative } from 'src/secureCreatives.js';
+import {resizeRemoteCreative} from 'src/secureCreatives.js';
import {find} from 'src/polyfill.js';
import * as pbjsModule from 'src/prebid.js';
import {hook} from '../../../src/hook.js';
@@ -1104,7 +1104,7 @@ describe('Unit: Prebid Module', function () {
adUnitCode: config.adUnitCodes[0],
};
- _sendAdToCreative(mockAdObject, sinon.stub());
+ resizeRemoteCreative(mockAdObject);
expect(slots[0].spyGetSlotElementId.called).to.equal(false);
expect(slots[1].spyGetSlotElementId.called).to.equal(true);
@@ -1233,7 +1233,8 @@ describe('Unit: Prebid Module', function () {
}
},
getElementsByTagName: sinon.stub(),
- querySelector: sinon.stub()
+ querySelector: sinon.stub(),
+ createElement: sinon.stub(),
};
elStub = {
@@ -1264,7 +1265,7 @@ describe('Unit: Prebid Module', function () {
it('should require doc and id params', function () {
$$PREBID_GLOBAL$$.renderAd();
- var error = 'Error trying to write ad Id :undefined to the page. Missing adId';
+ var error = 'Error rendering ad (id: undefined): missing adId';
assert.ok(spyLogError.calledWith(error), 'expected param error was logged');
});
@@ -1289,14 +1290,13 @@ describe('Unit: Prebid Module', function () {
adUrl: 'http://server.example.com/ad/ad.js'
});
$$PREBID_GLOBAL$$.renderAd(doc, bidId);
- assert.ok(elStub.insertBefore.called, 'url was written to iframe in doc');
+ sinon.assert.calledWith(doc.createElement, 'iframe');
});
it('should log an error when no ad or url', function () {
pushBidResponseToAuction({});
$$PREBID_GLOBAL$$.renderAd(doc, bidId);
- var error = 'Error trying to write ad. No ad for bid response id: ' + bidId;
- assert.ok(spyLogError.calledWith(error), 'expected error was logged');
+ sinon.assert.called(spyLogError);
});
it('should log an error when not in an iFrame', function () {
@@ -1305,7 +1305,7 @@ describe('Unit: Prebid Module', function () {
});
inIframe = false;
$$PREBID_GLOBAL$$.renderAd(document, bidId);
- const error = 'Error trying to write ad. Ad render call ad id ' + bidId + ' was prevented from writing to the main document.';
+ const error = `Error rendering ad (id: ${bidId}): renderAd was prevented from writing to the main document.`;
assert.ok(spyLogError.calledWith(error), 'expected error was logged');
});
@@ -1326,14 +1326,14 @@ describe('Unit: Prebid Module', function () {
doc.write = sinon.stub().throws(error);
$$PREBID_GLOBAL$$.renderAd(doc, bidId);
- var errorMessage = 'Error trying to write ad Id :' + bidId + ' to the page:' + error.message;
+ var errorMessage = `Error rendering ad (id: ${bidId}): doc write error`
assert.ok(spyLogError.calledWith(errorMessage), 'expected error was logged');
});
it('should log an error when ad not found', function () {
var fakeId = 99;
$$PREBID_GLOBAL$$.renderAd(doc, fakeId);
- var error = 'Error trying to write ad. Cannot find ad by given id : ' + fakeId;
+ var error = `Error rendering ad (id: ${fakeId}): Cannot find ad '${fakeId}'`
assert.ok(spyLogError.calledWith(error), 'expected error was logged');
});
@@ -1345,14 +1345,6 @@ describe('Unit: Prebid Module', function () {
assert.deepEqual($$PREBID_GLOBAL$$.getAllWinningBids()[0], adResponse);
});
- it('should replace ${CLICKTHROUGH} macro in winning bids response', function () {
- pushBidResponseToAuction({
- ad: ""
- });
- $$PREBID_GLOBAL$$.renderAd(doc, bidId, {clickThrough: 'https://someadserverclickurl.com'});
- expect(adResponse).to.have.property('ad').and.to.match(/https:\/\/someadserverclickurl\.com/i);
- });
-
it('fires billing url if present on s2s bid', function () {
const burl = 'http://www.example.com/burl';
pushBidResponseToAuction({
diff --git a/test/spec/unit/secureCreatives_spec.js b/test/spec/unit/secureCreatives_spec.js
index 7d5f9af35dd..895bf03165a 100644
--- a/test/spec/unit/secureCreatives_spec.js
+++ b/test/spec/unit/secureCreatives_spec.js
@@ -1,6 +1,4 @@
-import {
- _sendAdToCreative, getReplier, receiveMessage
-} from 'src/secureCreatives.js';
+import {getReplier, receiveMessage} from 'src/secureCreatives.js';
import * as utils from 'src/utils.js';
import {getAdUnits, getBidRequests, getBidResponses} from 'test/fixtures/fixtures.js';
import {auctionManager} from 'src/auctionManager.js';
@@ -8,10 +6,11 @@ import * as auctionModule from 'src/auction.js';
import * as native from 'src/native.js';
import {fireNativeTrackers, getAllAssetsMessage} from 'src/native.js';
import * as events from 'src/events.js';
-import { config as configObj } from 'src/config.js';
+import {config as configObj} from 'src/config.js';
import 'src/prebid.js';
-import { expect } from 'chai';
+import {expect} from 'chai';
+import {handleRender} from '../../../src/adRendering.js';
var CONSTANTS = require('src/constants.json');
@@ -54,37 +53,45 @@ describe('secureCreatives', () => {
});
});
- describe('_sendAdToCreative', () => {
- beforeEach(function () {
- sinon.stub(utils, 'logError');
- sinon.stub(utils, 'logWarn');
+ describe('handleRender', () => {
+ let bidResponse, renderFn, result;
+ beforeEach(() => {
+ result = null;
+ renderFn = sinon.stub().callsFake((r) => { result = r; });
+ bidResponse = {
+ adId: 123
+ }
});
- afterEach(function () {
- utils.logError.restore();
- utils.logWarn.restore();
+ it('does not invoke renderFn, but the renderer instead, if the ad has one', () => {
+ const renderer = {
+ url: 'some-custom-renderer',
+ render: sinon.spy()
+ }
+ handleRender(renderFn, {bidResponse: {renderer}});
+ sinon.assert.notCalled(renderFn);
+ sinon.assert.called(renderer.render);
});
- it('should macro replace ${AUCTION_PRICE} with the winning bid for ad and adUrl', () => {
- const oldVal = window.googletag;
- const oldapntag = window.apntag;
- window.apntag = null
- window.googletag = null;
- const mockAdObject = {
- adId: 'someAdId',
- ad: '',
- adUrl: 'http://creative.prebid.org/${AUCTION_PRICE}',
- width: 300,
- height: 250,
- renderer: null,
- cpm: '1.00',
- adUnitCode: 'some_dom_id'
- };
- const reply = sinon.spy();
- _sendAdToCreative(mockAdObject, reply);
- expect(reply.args[0][0].ad).to.equal('');
- expect(reply.args[0][0].adUrl).to.equal('http://creative.prebid.org/1.00');
- window.googletag = oldVal;
- window.apntag = oldapntag;
+
+ ['ad', 'adUrl'].forEach((prop) => {
+ describe(`on ${prop}`, () => {
+ it('replaces AUCTION_PRICE macro', () => {
+ bidResponse[prop] = 'pre${AUCTION_PRICE}post';
+ bidResponse.cpm = 123;
+ handleRender(renderFn, {adId: 123, bidResponse});
+ expect(result[prop]).to.eql('pre123post');
+ });
+ it('replaces CLICKTHROUGH macro', () => {
+ bidResponse[prop] = 'pre${CLICKTHROUGH}post';
+ handleRender(renderFn, {adId: 123, bidResponse, options: {clickUrl: 'clk'}});
+ expect(result[prop]).to.eql('preclkpost');
+ });
+ it('defaults CLICKTHROUGH to empty string', () => {
+ bidResponse[prop] = 'pre${CLICKTHROUGH}post';
+ handleRender(renderFn, {adId: 123, bidResponse});
+ expect(result[prop]).to.eql('prepost');
+ });
+ });
});
});
diff --git a/test/test_deps.js b/test/test_deps.js
index 35713106f8c..c8a3bcc9426 100644
--- a/test/test_deps.js
+++ b/test/test_deps.js
@@ -4,6 +4,16 @@ window.process = {
}
};
+window.addEventListener('error', function (ev) {
+ // eslint-disable-next-line no-console
+ console.error('Uncaught exception:', ev.error, ev.error?.stack);
+})
+
+window.addEventListener('unhandledrejection', function (ev) {
+ // eslint-disable-next-line no-console
+ console.error('Unhandled rejection:', ev.reason);
+})
+
require('test/helpers/consentData.js');
require('test/helpers/prebidGlobal.js');
require('test/mocks/adloaderStub.js');
diff --git a/webpack.creative.js b/webpack.creative.js
new file mode 100644
index 00000000000..7279455e155
--- /dev/null
+++ b/webpack.creative.js
@@ -0,0 +1,19 @@
+const path = require('path');
+
+module.exports = {
+ mode: 'production',
+ resolve: {
+ modules: [
+ path.resolve('.'),
+ 'node_modules'
+ ],
+ },
+ entry: {
+ 'creative': {
+ import: './libraries/creativeRender/crossDomain.js',
+ },
+ },
+ output: {
+ path: path.resolve('./build/creative'),
+ },
+}