diff --git a/.circleci/config.yml b/.circleci/config.yml
index 5ea5e87218c..ea5fb916a91 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -8,7 +8,7 @@ aliases:
docker:
# specify the version you desire here
- image: circleci/node:12.16.1
-
+ resource_class: xlarge
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
@@ -94,4 +94,4 @@ workflows:
- e2etest
experimental:
- pipelines: true
\ No newline at end of file
+ pipelines: true
diff --git a/PR_REVIEW.md b/PR_REVIEW.md
index 9a57539a0cd..d7703cf20ae 100644
--- a/PR_REVIEW.md
+++ b/PR_REVIEW.md
@@ -24,6 +24,7 @@ For modules and core platform updates, the initial reviewer should request an ad
- If they support SChain, add `schain_supported: true`
- If their bidder doesn't work well with safeframed creatives, add `safeframes_ok: false`. This will alert publishers to not use safeframed creatives when creating the ad server entries for their bidder.
- If they're setting a deal ID in some scenarios, add `bidder_supports_deals: true`
+ - If they have an IAB Global Vendor List ID, add `gvl_id: ID`. There's no default.
- If all above is good, add a `LGTM` comment and request 1 additional core member to review.
- Once there is 2 `LGTM` on the PR, merge to master
- Ask the submitter to add a PR for documentation if applicable.
diff --git a/integrationExamples/gpt/userId_example.html b/integrationExamples/gpt/userId_example.html
index 8115e60fcd1..dddc0915db2 100644
--- a/integrationExamples/gpt/userId_example.html
+++ b/integrationExamples/gpt/userId_example.html
@@ -83,9 +83,10 @@
var adUnits = [
{
code: 'test-div',
- sizes: [[300,250],[300,600],[728,90]],
mediaTypes: {
- banner: {}
+ banner: {
+ sizes: [[300,250],[300,600],[728,90]]
+ }
},
bids: [
{
@@ -133,6 +134,30 @@
// },
userSync: {
userIds: [{
+ name: "pubProvidedId",
+ params: {
+ eids: [{
+ source: "domain.com",
+ uids:[{
+ id: "value read from cookie or local storage",
+ atype: 1,
+ ext: {
+ stype: "ppuid" // allowable options are sha256email, DMP, ppuid for now
+ }
+ }]
+ },{
+ source: "3rdpartyprovided.com",
+ uids:[{
+ id: "value read from cookie or local storage",
+ atype: 3,
+ ext: {
+ stype: "sha256email"
+ }
+ }]
+ }],
+ eidsFunction: getHashedEmail // any user defined function that exists in the page
+ }
+ },{
name: "unifiedId",
params: {
partner: "prebid",
@@ -216,10 +241,10 @@
name: "sharedid",
expires: 28
}
- },
+ },
{
name: 'lotamePanoramaId'
- },
+ },
{
name: "liveIntentId",
params: {
@@ -230,7 +255,22 @@
name: "_li_pbid",
expires: 28
}
- }],
+ },
+ {
+ name: "zeotapIdPlus"
+ },
+ {
+ name: 'haloId',
+ storage: {
+ type: "cookie",
+ name: "haloId",
+ expires: 28
+ }
+ },
+ {
+ name: "quantcastId"
+ }
+ ],
syncDelay: 5000,
auctionDelay: 1000
}
diff --git a/modules/.submodules.json b/modules/.submodules.json
index 50d17fc5f6c..91cda9d95ad 100644
--- a/modules/.submodules.json
+++ b/modules/.submodules.json
@@ -12,7 +12,12 @@
"netIdSystem",
"identityLinkIdSystem",
"sharedIdSystem",
- "intentIqIdSystem"
+ "intentIqIdSystem",
+ "zeotapIdPlusIdSystem",
+ "haloIdSystem",
+ "quantcastIdSystem",
+ "idxIdSystem",
+ "fabrickIdSystem"
],
"adpod": [
"freeWheelAdserverVideo",
@@ -20,6 +25,7 @@
],
"rtdModule": [
"browsiRtdProvider",
+ "audigentRtdProvider",
"jwplayerRtdProvider"
]
}
diff --git a/modules/ablidaBidAdapter.js b/modules/ablidaBidAdapter.js
index 470a845cd20..2400952367f 100644
--- a/modules/ablidaBidAdapter.js
+++ b/modules/ablidaBidAdapter.js
@@ -1,14 +1,14 @@
import * as utils from '../src/utils.js';
import {config} from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
-import { BANNER, NATIVE } from '../src/mediaTypes.js';
+import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
const BIDDER_CODE = 'ablida';
const ENDPOINT_URL = 'https://bidder.ablida.net/prebid';
export const spec = {
code: BIDDER_CODE,
- supportedMediaTypes: [BANNER, NATIVE],
+ supportedMediaTypes: [BANNER, NATIVE, VIDEO],
/**
* Determines whether or not the given bid request is valid.
@@ -35,6 +35,8 @@ export const spec = {
let sizes = []
if (bidRequest.mediaTypes && bidRequest.mediaTypes[BANNER] && bidRequest.mediaTypes[BANNER].sizes) {
sizes = bidRequest.mediaTypes[BANNER].sizes;
+ } else if (bidRequest.mediaTypes[VIDEO] && bidRequest.mediaTypes[VIDEO].playerSize) {
+ sizes = bidRequest.mediaTypes[VIDEO].playerSize
}
const jaySupported = 'atob' in window && 'currentScript' in document;
const device = getDevice();
@@ -46,8 +48,9 @@ export const spec = {
referer: bidderRequest.refererInfo.referer,
jaySupported: jaySupported,
device: device,
- adapterVersion: 3,
- mediaTypes: bidRequest.mediaTypes
+ adapterVersion: 5,
+ mediaTypes: bidRequest.mediaTypes,
+ gdprConsent: bidderRequest.gdprConsent
};
return {
method: 'POST',
diff --git a/modules/ablidaBidAdapter.md b/modules/ablidaBidAdapter.md
index 001bee4f35c..e0a9f3f9405 100644
--- a/modules/ablidaBidAdapter.md
+++ b/modules/ablidaBidAdapter.md
@@ -51,6 +51,22 @@ Module that connects to Ablida's bidder for bids.
}
}
]
+ }, {
+ code: 'video-ad',
+ mediaTypes: {
+ video: {
+ playerSize: [[640, 360]],
+ context: 'instream'
+ }
+ },
+ bids: [
+ {
+ bidder: 'ablida',
+ params: {
+ placementId: 'instream-demo'
+ }
+ }
+ ]
}
];
```
diff --git a/modules/adagioBidAdapter.js b/modules/adagioBidAdapter.js
index b4c2a6ac0d6..65a35284d1b 100644
--- a/modules/adagioBidAdapter.js
+++ b/modules/adagioBidAdapter.js
@@ -1,5 +1,6 @@
import find from 'core-js-pure/features/array/find.js';
import * as utils from '../src/utils.js';
+import { config } from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import { loadExternalScript } from '../src/adloader.js'
import JSEncrypt from 'jsencrypt/bin/jsencrypt.js';
@@ -9,7 +10,7 @@ import { getRefererInfo } from '../src/refererDetection.js';
export const BIDDER_CODE = 'adagio';
export const LOG_PREFIX = 'Adagio:';
-export const VERSION = '2.3.0';
+export const VERSION = '2.4.0';
export const FEATURES_VERSION = '1';
export const ENDPOINT = 'https://mp.4dex.io/prebid';
export const SUPPORTED_MEDIA_TYPES = ['banner'];
@@ -555,6 +556,16 @@ function _getGdprConsent(bidderRequest) {
return consent;
}
+function _getCoppa() {
+ return {
+ required: config.getConfig('coppa') === true ? 1 : 0
+ };
+}
+
+function _getUspConsent(bidderRequest) {
+ return (utils.deepAccess(bidderRequest, 'uspConsent')) ? { uspConsent: bidderRequest.uspConsent } : false;
+}
+
function _getSchain(bidRequest) {
if (utils.deepAccess(bidRequest, 'schain')) {
return bidRequest.schain;
@@ -643,6 +654,8 @@ export const spec = {
const site = internal.getSite(bidderRequest);
const pageviewId = internal.getPageviewId();
const gdprConsent = _getGdprConsent(bidderRequest) || {};
+ const uspConsent = _getUspConsent(bidderRequest) || {};
+ const coppa = _getCoppa();
const schain = _getSchain(validBidRequests[0]);
const adUnits = utils._map(validBidRequests, (bidRequest) => {
bidRequest.features = internal.getFeatures(bidRequest, bidderRequest);
@@ -672,7 +685,11 @@ export const spec = {
site: site,
pageviewId: pageviewId,
adUnits: groupedAdUnits[organizationId],
- gdpr: gdprConsent,
+ regs: {
+ gdpr: gdprConsent,
+ coppa: coppa,
+ ccpa: uspConsent
+ },
schain: schain,
prebidVersion: '$prebid.version$',
adapterVersion: VERSION,
diff --git a/modules/adheseBidAdapter.js b/modules/adheseBidAdapter.js
index 606e56c13d5..80758668a95 100644
--- a/modules/adheseBidAdapter.js
+++ b/modules/adheseBidAdapter.js
@@ -150,8 +150,8 @@ function getAccount(validBidRequests) {
}
function getId5Id(validBidRequests) {
- if (validBidRequests[0] && validBidRequests[0].userId && validBidRequests[0].userId.id5id) {
- return validBidRequests[0].userId.id5id;
+ if (validBidRequests[0] && validBidRequests[0].userId && validBidRequests[0].userId.id5id && validBidRequests[0].userId.id5id.uid) {
+ return validBidRequests[0].userId.id5id.uid;
}
}
diff --git a/modules/adnowBidAdapter.js b/modules/adnowBidAdapter.js
new file mode 100644
index 00000000000..7412db8d7b6
--- /dev/null
+++ b/modules/adnowBidAdapter.js
@@ -0,0 +1,178 @@
+import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { NATIVE, BANNER } from '../src/mediaTypes.js';
+import * as utils from '../src/utils.js';
+import includes from 'core-js-pure/features/array/includes.js';
+
+const BIDDER_CODE = 'adnow';
+const ENDPOINT = 'https://n.ads3-adnow.com/a';
+
+/**
+ * @typedef {object} CommonBidData
+ *
+ * @property {string} requestId The specific BidRequest which this bid is aimed at.
+ * This should match the BidRequest.bidId which this Bid targets.
+ * @property {string} currency The currency code for the cpm value
+ * @property {number} cpm The bid price, in US cents per thousand impressions.
+ * @property {string} creativeId The id of ad content
+ * @property {number} ttl Time-to-live - how long (in seconds) Prebid can use this bid.
+ * @property {boolean} netRevenue Boolean defining whether the bid is Net or Gross. The default is true (Net).
+ * @property {object} [meta] Object for storing bid meta data
+ * @property {string} [meta.mediaType] banner or native
+ */
+
+/** @type {BidderSpec} */
+export const spec = {
+ code: BIDDER_CODE,
+ supportedMediaTypes: [ NATIVE, BANNER ],
+
+ /**
+ * @param {object} bid
+ * @return {boolean}
+ */
+ isBidRequestValid(bid) {
+ if (!bid || !bid.params) return false;
+
+ const codeId = parseInt(bid.params.codeId, 10);
+ if (!codeId) {
+ return false;
+ }
+
+ const mediaType = bid.params.mediaType || NATIVE;
+
+ return includes(this.supportedMediaTypes, mediaType);
+ },
+
+ /**
+ * @param {BidRequest[]} validBidRequests
+ * @param {*} bidderRequest
+ * @return {ServerRequest}
+ */
+ buildRequests(validBidRequests, bidderRequest) {
+ return validBidRequests.map(req => {
+ const mediaType = this._isBannerRequest(req) ? BANNER : NATIVE;
+ const codeId = parseInt(req.params.codeId, 10);
+
+ const data = {
+ Id: codeId,
+ mediaType: mediaType,
+ out: 'prebid',
+ d_user_agent: navigator.userAgent,
+ requestid: req.bidId
+ };
+
+ if (mediaType === BANNER) {
+ data.sizes = utils.parseSizesInput(
+ req.mediaTypes && req.mediaTypes.banner && req.mediaTypes.banner.sizes
+ ).join('|')
+ } else {
+ data.width = data.height = 200;
+
+ let sizes = utils.deepAccess(req, 'mediaTypes.native.image.sizes', []);
+
+ if (sizes.length > 0) {
+ const size = Array.isArray(sizes[0]) ? sizes[0] : sizes;
+
+ data.width = size[0] || data.width;
+ data.height = size[1] || data.height;
+ }
+ }
+
+ /** @type {ServerRequest} */
+ return {
+ method: 'GET',
+ url: ENDPOINT,
+ data: utils.parseQueryStringParameters(data),
+ options: {
+ withCredentials: false,
+ crossOrigin: true
+ },
+ bidRequest: req
+ };
+ });
+ },
+
+ /**
+ * @param {*} response
+ * @param {ServerRequest} request
+ * @return {Bid[]}
+ */
+ interpretResponse(response, request) {
+ const bidObj = request.bidRequest;
+ let bid = response.body;
+
+ if (!bid || !bid.currency || !bid.cpm) {
+ return [];
+ }
+
+ const mediaType = bid.meta.mediaType || NATIVE;
+ if (!includes(this.supportedMediaTypes, mediaType)) {
+ return [];
+ }
+
+ bid.requestId = bidObj.bidId;
+
+ if (mediaType === BANNER) {
+ return [ this._getBannerBid(bid) ];
+ }
+
+ if (mediaType === NATIVE) {
+ return [ this._getNativeBid(bid) ];
+ }
+
+ return [];
+ },
+
+ /**
+ * @private
+ * @param {object} bid
+ * @return {CommonBidData}
+ */
+ _commonBidData(bid) {
+ return {
+ requestId: bid.requestId,
+ currency: bid.currency || 'USD',
+ cpm: bid.cpm || 0.00,
+ creativeId: bid.creativeId || 'undefined-creative',
+ netRevenue: bid.netRevenue || true,
+ ttl: bid.ttl || 360,
+ meta: bid.meta || {}
+ };
+ },
+
+ /**
+ * @param {BidRequest} req
+ * @return {boolean}
+ * @private
+ */
+ _isBannerRequest(req) {
+ return !!(req.mediaTypes && req.mediaTypes.banner);
+ },
+
+ /**
+ * @private
+ * @param {object} bid
+ * @return {Bid}
+ */
+ _getBannerBid(bid) {
+ return {
+ ...this._commonBidData(bid),
+ width: bid.width || 300,
+ height: bid.height || 250,
+ ad: bid.ad || '
Empty Ad
'
+ };
+ },
+
+ /**
+ * @private
+ * @param {object} bid
+ * @return {Bid}
+ */
+ _getNativeBid(bid) {
+ return {
+ ...this._commonBidData(bid),
+ native: bid.native || {}
+ };
+ }
+}
+
+registerBidder(spec);
diff --git a/modules/adnowBidAdapter.md b/modules/adnowBidAdapter.md
new file mode 100644
index 00000000000..9ad99a67fc5
--- /dev/null
+++ b/modules/adnowBidAdapter.md
@@ -0,0 +1,46 @@
+# Overview
+
+```
+Module Name: AdNow Bidder Adapter
+Module Type: Bidder Adapter
+Maintainer: support@adnow.com
+```
+
+# Description
+
+AdNow Bidder Adapter for Prebid.js.
+Banner and Native format are supported.
+Please use ```adnow``` as the bidder code.
+
+# Test Parameters
+```javascript
+ const adUnits = [{
+ code: 'test',
+ mediaTypes: {
+ banner: {
+ sizes: [[300, 250]]
+ }
+ },
+ bids: [{
+ bidder: 'adnow',
+ params: {
+ codeId: 794934
+ }
+ }]
+ }, {
+ code: 'test',
+ mediaTypes: {
+ native: {
+ image: {
+ sizes: [200, 200]
+ }
+ }
+ },
+ bids: [{
+ bidder: 'adnow',
+ params: {
+ codeId: 794934
+ }
+ }]
+ }];
+```
diff --git a/modules/adotBidAdapter.js b/modules/adotBidAdapter.js
index 911da416cfe..3d0af864a31 100644
--- a/modules/adotBidAdapter.js
+++ b/modules/adotBidAdapter.js
@@ -1,14 +1,26 @@
import {Renderer} from '../src/Renderer.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
-import {isStr, isArray, isNumber, isPlainObject, isBoolean, logError} from '../src/utils.js';
+import {isStr, isArray, isNumber, isPlainObject, isBoolean, logError, replaceAuctionPrice} from '../src/utils.js';
import find from 'core-js-pure/features/array/find.js';
const ADAPTER_VERSION = 'v1.0.0';
const BID_METHOD = 'POST';
const BIDDER_URL = 'https://dsp.adotmob.com/headerbidding/bidrequest';
+const FIRST_PRICE = 1;
+const NET_REVENUE = true;
+// eslint-disable-next-line no-template-curly-in-string
+const AUCTION_PRICE = '${AUCTION_PRICE}';
+const TTL = 10;
+
const SUPPORTED_VIDEO_CONTEXTS = ['instream', 'outstream'];
const SUPPORTED_INSTREAM_CONTEXTS = ['pre-roll', 'mid-roll', 'post-roll'];
+const SUPPORTED_VIDEO_MIMES = ['video/mp4'];
+const BID_SUPPORTED_MEDIA_TYPES = ['banner', 'video', 'native'];
+
+const DOMAIN_REGEX = new RegExp('//([^/]*)');
+const OUTSTREAM_VIDEO_PLAYER_URL = 'https://adserver.adotmob.com/video/player.min.js';
+
const NATIVE_PLACEMENTS = {
title: {id: 1, name: 'title'},
icon: {id: 2, type: 1, name: 'img'},
@@ -18,15 +30,9 @@ const NATIVE_PLACEMENTS = {
cta: {id: 6, type: 12, name: 'data'}
};
const NATIVE_ID_MAPPING = {1: 'title', 2: 'icon', 3: 'image', 4: 'sponsoredBy', 5: 'body', 6: 'cta'};
-const SUPPORTED_VIDEO_MIMES = ['video/mp4'];
-const DOMAIN_REGEX = new RegExp('//([^/]*)');
-const FIRST_PRICE = 1;
-const BID_SUPPORTED_MEDIA_TYPES = ['banner', 'video', 'native'];
-const TTL = 10;
-const NET_REVENUE = true;
-// eslint-disable-next-line no-template-curly-in-string
-const AUCTION_PRICE = '${AUCTION_PRICE}';
-const OUTSTREAM_VIDEO_PLAYER_URL = 'https://adserver.adotmob.com/video/player.min.js';
+const NATIVE_PRESET_FORMATTERS = {
+ image: formatNativePresetImage
+}
function isNone(value) {
return (value === null) || (value === undefined);
@@ -183,6 +189,7 @@ function generateImpressionsFromAdUnit(acc, adUnit) {
const {bidId, mediaTypes, params} = adUnit;
const {placementId} = params;
const pmp = {};
+ const ext = {placementId};
if (placementId) pmp.deals = [{id: placementId}]
@@ -193,8 +200,8 @@ function generateImpressionsFromAdUnit(acc, adUnit) {
const impId = `${bidId}_${index}`;
if (mediaType === 'banner') return acc.concat(generateBannerFromAdUnit(impId, data, params));
- if (mediaType === 'video') return acc.concat({id: impId, video: generateVideoFromAdUnit(data, params), pmp});
- if (mediaType === 'native') return acc.concat({id: impId, native: generateNativeFromAdUnit(data, params), pmp});
+ if (mediaType === 'video') return acc.concat({id: impId, video: generateVideoFromAdUnit(data, params), pmp, ext});
+ if (mediaType === 'native') return acc.concat({id: impId, native: generateNativeFromAdUnit(data, params), pmp, ext});
}, []);
return acc.concat(imps);
@@ -208,10 +215,11 @@ function generateBannerFromAdUnit(impId, data, params) {
const {position, placementId} = params;
const pos = position || 0;
const pmp = {};
+ const ext = {placementId};
if (placementId) pmp.deals = [{id: placementId}]
- return data.sizes.map(([w, h], index) => ({id: `${impId}_${index}`, banner: {format: [{w, h}], w, h, pos}, pmp}));
+ return data.sizes.map(([w, h], index) => ({id: `${impId}_${index}`, banner: {format: [{w, h}], w, h, pos}, pmp, ext}));
}
function generateVideoFromAdUnit(data, params) {
@@ -254,19 +262,31 @@ function computeStartDelay(data, params) {
}
function generateNativeFromAdUnit(data, params) {
- const placements = NATIVE_PLACEMENTS;
+ const {type} = data;
+ const presetFormatter = type && NATIVE_PRESET_FORMATTERS[data.type];
+ const nativeFields = presetFormatter ? presetFormatter(data) : data;
+
const assets = Object
- .keys(data)
+ .keys(nativeFields)
.reduce((acc, placement) => {
- const placementData = data[placement];
- const assetInfo = placements[placement];
+ const placementData = nativeFields[placement];
+ const assetInfo = NATIVE_PLACEMENTS[placement];
if (!assetInfo) return acc;
const {id, name, type} = assetInfo;
- const {required, len, sizes} = placementData;
- const wmin = sizes && sizes[0];
- const hmin = sizes && sizes[1];
+ const {required, len, sizes = []} = placementData;
+ let wmin;
+ let hmin;
+
+ if (isArray(sizes[0])) {
+ wmin = sizes[0][0];
+ hmin = sizes[0][1];
+ } else {
+ wmin = sizes[0];
+ hmin = sizes[1];
+ }
+
const content = {};
if (type) content.type = type;
@@ -284,6 +304,32 @@ function generateNativeFromAdUnit(data, params) {
};
}
+function formatNativePresetImage(data) {
+ const sizes = data.sizes;
+
+ return {
+ image: {
+ required: true,
+ sizes
+ },
+ title: {
+ required: true
+ },
+ sponsoredBy: {
+ required: true
+ },
+ body: {
+ required: false
+ },
+ cta: {
+ required: false
+ },
+ icon: {
+ required: false
+ }
+ };
+}
+
function generateSiteFromAdUnitContext(adUnitContext) {
if (!adUnitContext || !adUnitContext.refererInfo) return null;
@@ -448,7 +494,7 @@ function generateAdFromBid(bid, bidResponse, serverRequest) {
mediaType: bid.ext.adot.media_type,
};
- if (isBidANative(bid)) return {...base, native: formatNativeData(bid.adm)};
+ if (isBidANative(bid)) return {...base, native: formatNativeData(bid)};
const size = getSizeFromBid(bid, impressionData);
const creative = getCreativeFromBid(bid, impressionData);
@@ -465,7 +511,7 @@ function generateAdFromBid(bid, bidResponse, serverRequest) {
};
}
-function formatNativeData(adm) {
+function formatNativeData({adm, price}) {
const parsedAdm = tryParse(adm);
const {assets, link: {url, clicktrackers}, imptrackers, jstracker} = parsedAdm.native;
const placements = NATIVE_PLACEMENTS;
@@ -480,7 +526,7 @@ function formatNativeData(adm) {
}, {
clickUrl: url,
clickTrackers: clicktrackers,
- impressionTrackers: imptrackers,
+ impressionTrackers: imptrackers && imptrackers.map(impTracker => replaceAuctionPrice(impTracker, price)),
javascriptTrackers: jstracker && [jstracker]
});
}
@@ -503,10 +549,11 @@ function getSizeFromBid(bid, impressionData) {
function getCreativeFromBid(bid, impressionData) {
const shouldUseAdMarkup = !!bid.adm;
+ const price = bid.price;
return {
- markup: shouldUseAdMarkup ? bid.adm : null,
- markupUrl: !shouldUseAdMarkup ? bid.nurl : null,
+ markup: shouldUseAdMarkup ? replaceAuctionPrice(bid.adm, price) : null,
+ markupUrl: !shouldUseAdMarkup ? replaceAuctionPrice(bid.nurl, price) : null,
renderer: getRendererFromBid(bid, impressionData)
};
}
diff --git a/modules/adotBidAdapter.md b/modules/adotBidAdapter.md
index 88c8fb0b936..7fc1d84ee60 100644
--- a/modules/adotBidAdapter.md
+++ b/modules/adotBidAdapter.md
@@ -114,39 +114,37 @@ const adUnit = {
code: 'test-div',
mediaTypes: {
native: {
- native: {
- image: {
- // Field required status
- required: false,
- // Image dimensions supported by the native ad unit.
- // Each ad unit size is formatted as follows: [width, height].
- sizes: [100, 50]
- },
- title: {
- // Field required status
- required: false,
- // Maximum length of the title
- len: 140
- },
- sponsoredBy: {
- // Field required status
- required: false
- },
- clickUrl: {
- // Field required status
- required: false
- },
- body: {
- // Field required status
- required: false
- },
- icon: {
- // Field required status
- required: false,
- // Icon dimensions supported by the native ad unit.
- // Each ad unit size is formatted as follows: [width, height].
- sizes: [50, 50]
- }
+ image: {
+ // Field required status
+ required: false,
+ // Image dimensions supported by the native ad unit.
+ // Each ad unit size is formatted as follows: [width, height].
+ sizes: [100, 50]
+ },
+ title: {
+ // Field required status
+ required: false,
+ // Maximum length of the title
+ len: 140
+ },
+ sponsoredBy: {
+ // Field required status
+ required: false
+ },
+ clickUrl: {
+ // Field required status
+ required: false
+ },
+ body: {
+ // Field required status
+ required: false
+ },
+ icon: {
+ // Field required status
+ required: false,
+ // Icon dimensions supported by the native ad unit.
+ // Each ad unit size is formatted as follows: [width, height].
+ sizes: [50, 50]
}
}
},
diff --git a/modules/adrelevantisBidAdapter.js b/modules/adrelevantisBidAdapter.js
new file mode 100644
index 00000000000..5da941c65ca
--- /dev/null
+++ b/modules/adrelevantisBidAdapter.js
@@ -0,0 +1,603 @@
+import { Renderer } from '../src/Renderer.js';
+import * as utils from '../src/utils.js';
+import { config } from '../src/config.js';
+import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
+import find from 'core-js-pure/features/array/find.js';
+import includes from 'core-js-pure/features/array/includes.js';
+import { OUTSTREAM, INSTREAM } from '../src/video.js';
+
+const BIDDER_CODE = 'adrelevantis';
+const URL = 'https://ssp.adrelevantis.com/prebid';
+const VIDEO_TARGETING = ['id', 'mimes', 'minduration', 'maxduration',
+ 'startdelay', 'skippable', 'playback_method', 'frameworks'];
+const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language'];
+const APP_DEVICE_PARAMS = ['geo', 'device_id']; // appid is collected separately
+const SOURCE = 'pbjs';
+const MAX_IMPS_PER_REQUEST = 15;
+
+const NATIVE_MAPPING = {
+ body: 'description',
+ body2: 'desc2',
+ cta: 'ctatext',
+ image: {
+ serverName: 'main_image',
+ requiredParams: { required: true }
+ },
+ icon: {
+ serverName: 'icon',
+ requiredParams: { required: true }
+ },
+ sponsoredBy: 'sponsored_by',
+ privacyLink: 'privacy_link',
+ salePrice: 'saleprice',
+ displayUrl: 'displayurl'
+};
+
+export const spec = {
+ code: BIDDER_CODE,
+ aliases: ['adr', 'adsmart', 'compariola'],
+ supportedMediaTypes: [BANNER, VIDEO, NATIVE],
+
+ /**
+ * Determines whether or not the given bid request is valid.
+ *
+ * @param {object} bid The bid to validate.
+ * @return boolean True if this is a valid bid, and false otherwise.
+ */
+ isBidRequestValid: function(bid) {
+ return !!(bid.params.placementId);
+ },
+
+ /**
+ * Make a server request from the list of BidRequests.
+ *
+ * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server.
+ * @return ServerRequest Info describing the request to the server.
+ */
+ buildRequests: function(bidRequests, bidderRequest) {
+ const tags = bidRequests.map(bidToTag);
+ const userObjBid = find(bidRequests, hasUserInfo);
+ let userObj;
+ if (config.getConfig('coppa') === true) {
+ userObj = {'coppa': true};
+ }
+ if (userObjBid) {
+ userObj = {};
+ Object.keys(userObjBid.params.user)
+ .filter(param => includes(USER_PARAMS, param))
+ .forEach(param => userObj[param] = userObjBid.params.user[param]);
+ }
+
+ const appDeviceObjBid = find(bidRequests, hasAppDeviceInfo);
+ let appDeviceObj;
+ if (appDeviceObjBid && appDeviceObjBid.params && appDeviceObjBid.params.app) {
+ appDeviceObj = {};
+ Object.keys(appDeviceObjBid.params.app)
+ .filter(param => includes(APP_DEVICE_PARAMS, param))
+ .forEach(param => appDeviceObj[param] = appDeviceObjBid.params.app[param]);
+ }
+
+ const appIdObjBid = find(bidRequests, hasAppId);
+ let appIdObj;
+ if (appIdObjBid && appIdObjBid.params && appDeviceObjBid.params.app && appDeviceObjBid.params.app.id) {
+ appIdObj = {
+ appid: appIdObjBid.params.app.id
+ };
+ }
+
+ const payload = {
+ tags: [...tags],
+ user: userObj,
+ sdk: {
+ source: SOURCE,
+ version: '$prebid.version$'
+ }
+ };
+
+ if (appDeviceObjBid) {
+ payload.device = appDeviceObj
+ }
+ if (appIdObjBid) {
+ payload.app = appIdObj;
+ }
+
+ if (bidderRequest && bidderRequest.gdprConsent) {
+ // note - objects for impbus use underscore instead of camelCase
+ payload.gdpr_consent = {
+ consent_string: bidderRequest.gdprConsent.consentString,
+ consent_required: bidderRequest.gdprConsent.gdprApplies
+ };
+ }
+
+ if (bidderRequest && bidderRequest.refererInfo) {
+ let refererinfo = {
+ rd_ref: encodeURIComponent(bidderRequest.refererInfo.referer),
+ rd_top: bidderRequest.refererInfo.reachedTop,
+ rd_ifs: bidderRequest.refererInfo.numIframes,
+ rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',')
+ }
+ payload.referrer_detection = refererinfo;
+ }
+
+ let fpdcfg = config.getConfig('fpd')
+ if (fpdcfg && fpdcfg.context) {
+ let fdata = {
+ keywords: fpdcfg.context.keywords,
+ category: fpdcfg.context.data.category
+ }
+ payload.fpd = fdata;
+ }
+
+ const request = formatRequest(payload, bidderRequest);
+ return request;
+ },
+
+ /**
+ * Unpack the response from the server into a list of bids.
+ *
+ * @param {*} serverResponse A successful response from the server.
+ * @return {Bid[]} An array of bids which were nested inside the server.
+ */
+ interpretResponse: function(serverResponse, {bidderRequest}) {
+ serverResponse = serverResponse.body;
+ const bids = [];
+ if (!serverResponse || serverResponse.error) {
+ let errorMessage = `in response for ${bidderRequest.bidderCode} adapter`;
+ if (serverResponse && serverResponse.error) { errorMessage += `: ${serverResponse.error}`; }
+ utils.logError(errorMessage);
+ return bids;
+ }
+
+ if (serverResponse.tags) {
+ serverResponse.tags.forEach(serverBid => {
+ const rtbBid = getRtbBid(serverBid);
+ if (rtbBid) {
+ if (rtbBid.cpm !== 0 && includes(this.supportedMediaTypes, rtbBid.ad_type)) {
+ const bid = newBid(serverBid, rtbBid, bidderRequest);
+ bid.mediaType = parseMediaType(rtbBid);
+ bids.push(bid);
+ }
+ }
+ });
+ }
+
+ return bids;
+ },
+
+ transformBidParams: function(params, isOpenRtb) {
+ params = utils.convertTypes({
+ 'placementId': 'number',
+ 'keywords': utils.transformBidderParamKeywords
+ }, params);
+
+ if (isOpenRtb) {
+ params.use_pmt_rule = (typeof params.usePaymentRule === 'boolean') ? params.usePaymentRule : false;
+ if (params.usePaymentRule) { delete params.usePaymentRule; }
+
+ if (isPopulatedArray(params.keywords)) {
+ params.keywords.forEach(deleteValues);
+ }
+
+ Object.keys(params).forEach(paramKey => {
+ let convertedKey = utils.convertCamelToUnderscore(paramKey);
+ if (convertedKey !== paramKey) {
+ params[convertedKey] = params[paramKey];
+ delete params[paramKey];
+ }
+ });
+ }
+
+ return params;
+ }
+}
+
+function isPopulatedArray(arr) {
+ return !!(utils.isArray(arr) && arr.length > 0);
+}
+
+function deleteValues(keyPairObj) {
+ if (isPopulatedArray(keyPairObj.value) && keyPairObj.value[0] === '') {
+ delete keyPairObj.value;
+ }
+}
+
+function formatRequest(payload, bidderRequest) {
+ let request = [];
+
+ if (payload.tags.length > MAX_IMPS_PER_REQUEST) {
+ const clonedPayload = utils.deepClone(payload);
+
+ utils.chunk(payload.tags, MAX_IMPS_PER_REQUEST).forEach(tags => {
+ clonedPayload.tags = tags;
+ const payloadString = JSON.stringify(clonedPayload);
+ request.push({
+ method: 'POST',
+ url: URL,
+ data: payloadString,
+ bidderRequest
+ });
+ });
+ } else {
+ const payloadString = JSON.stringify(payload);
+ request = {
+ method: 'POST',
+ url: URL,
+ data: payloadString,
+ bidderRequest
+ };
+ }
+
+ return request;
+}
+
+function newRenderer(adUnitCode, rtbBid, rendererOptions = {}) {
+ const renderer = Renderer.install({
+ id: rtbBid.renderer_id,
+ url: rtbBid.renderer_url,
+ config: rendererOptions,
+ loaded: false,
+ adUnitCode
+ });
+
+ try {
+ renderer.setRender(outstreamRender);
+ } catch (err) {
+ utils.logWarn('Prebid Error calling setRender on renderer', err);
+ }
+
+ renderer.setEventHandlers({
+ impression: () => utils.logMessage('AdRelevantis outstream video impression event'),
+ loaded: () => utils.logMessage('AdRelevantis outstream video loaded event'),
+ ended: () => {
+ utils.logMessage('AdRelevantis outstream renderer video event');
+ document.querySelector(`#${adUnitCode}`).style.display = 'none';
+ }
+ });
+ return renderer;
+}
+
+/**
+ * This function hides google div container for outstream bids to remove unwanted space on page. Appnexus renderer creates a new iframe outside of google iframe to render the outstream creative.
+ * @param {string} elementId element id
+ */
+function hidedfpContainer(elementId) {
+ var el = document.getElementById(elementId).querySelectorAll("div[id^='google_ads']");
+ if (el[0]) {
+ el[0].style.setProperty('display', 'none');
+ }
+}
+
+function outstreamRender(bid) {
+ // push to render queue because ANOutstreamVideo may not be loaded yet
+ hidedfpContainer(bid.adUnitCode);
+ bid.renderer.push(() => {
+ window.ANOutstreamVideo.renderAd({
+ tagId: bid.adResponse.tag_id,
+ sizes: [bid.getSize().split('x')],
+ targetId: bid.adUnitCode, // target div id to render video
+ uuid: bid.adResponse.uuid,
+ adResponse: bid.adResponse,
+ rendererOptions: bid.renderer.getConfig()
+ }, handleOutstreamRendererEvents.bind(null, bid));
+ });
+}
+
+function handleOutstreamRendererEvents(bid, id, eventName) {
+ bid.renderer.handleVideoEvent({ id, eventName });
+}
+
+/**
+ * Unpack the Server's Bid into a Prebid-compatible one.
+ * @param serverBid
+ * @param rtbBid
+ * @param bidderRequest
+ * @return Bid
+ */
+function newBid(serverBid, rtbBid, bidderRequest) {
+ const bidRequest = utils.getBidRequest(serverBid.uuid, [bidderRequest]);
+ const bid = {
+ requestId: serverBid.uuid,
+ cpm: rtbBid.cpm,
+ creativeId: rtbBid.creative_id,
+ dealId: rtbBid.deal_id,
+ currency: 'USD',
+ netRevenue: true,
+ ttl: 300,
+ adUnitCode: bidRequest.adUnitCode,
+ adrelevantis: {
+ buyerMemberId: rtbBid.buyer_member_id,
+ dealPriority: rtbBid.deal_priority,
+ dealCode: rtbBid.deal_code
+ }
+ };
+
+ if (rtbBid.advertiser_id) {
+ bid.meta = Object.assign({}, bid.meta, { advertiserId: rtbBid.advertiser_id });
+ }
+
+ if (rtbBid.rtb.video) {
+ Object.assign(bid, {
+ width: rtbBid.rtb.video.player_width,
+ height: rtbBid.rtb.video.player_height,
+ vastImpUrl: rtbBid.notify_url,
+ ttl: 3600
+ });
+
+ const videoContext = utils.deepAccess(bidRequest, 'mediaTypes.video.context');
+ switch (videoContext) {
+ case OUTSTREAM:
+ bid.adResponse = serverBid;
+ bid.adResponse.ad = bid.adResponse.ads[0];
+ bid.adResponse.ad.video = bid.adResponse.ad.rtb.video;
+ bid.vastXml = rtbBid.rtb.video.content;
+
+ if (rtbBid.renderer_url) {
+ const videoBid = find(bidderRequest.bids, bid => bid.bidId === serverBid.uuid);
+ const rendererOptions = utils.deepAccess(videoBid, 'renderer.options');
+ bid.renderer = newRenderer(bid.adUnitCode, rtbBid, rendererOptions);
+ }
+ break;
+ case INSTREAM:
+ bid.vastUrl = rtbBid.notify_url + '&redir=' + encodeURIComponent(rtbBid.rtb.video.asset_url);
+ break;
+ }
+ } else if (rtbBid.rtb[NATIVE]) {
+ const nativeAd = rtbBid.rtb[NATIVE];
+
+ // setting up the jsTracker:
+ // we put it as a data-src attribute so that the tracker isn't called
+ // until we have the adId (see onBidWon)
+ let jsTrackerDisarmed = rtbBid.viewability.config.replace('src=', 'data-src=');
+
+ let jsTrackers = nativeAd.javascript_trackers;
+
+ if (jsTrackers == undefined) {
+ jsTrackers = jsTrackerDisarmed;
+ } else if (utils.isStr(jsTrackers)) {
+ jsTrackers = [jsTrackers, jsTrackerDisarmed];
+ } else {
+ jsTrackers.push(jsTrackerDisarmed);
+ }
+
+ bid[NATIVE] = {
+ title: nativeAd.title,
+ body: nativeAd.desc,
+ body2: nativeAd.desc2,
+ cta: nativeAd.ctatext,
+ rating: nativeAd.rating,
+ sponsoredBy: nativeAd.sponsored,
+ privacyLink: nativeAd.privacy_link,
+ address: nativeAd.address,
+ downloads: nativeAd.downloads,
+ likes: nativeAd.likes,
+ phone: nativeAd.phone,
+ price: nativeAd.price,
+ salePrice: nativeAd.saleprice,
+ clickUrl: nativeAd.link.url,
+ displayUrl: nativeAd.displayurl,
+ clickTrackers: nativeAd.link.click_trackers,
+ impressionTrackers: nativeAd.impression_trackers,
+ javascriptTrackers: jsTrackers
+ };
+ if (nativeAd.main_img) {
+ bid['native'].image = {
+ url: nativeAd.main_img.url,
+ height: nativeAd.main_img.height,
+ width: nativeAd.main_img.width,
+ };
+ }
+ if (nativeAd.icon) {
+ bid['native'].icon = {
+ url: nativeAd.icon.url,
+ height: nativeAd.icon.height,
+ width: nativeAd.icon.width,
+ };
+ }
+ } else {
+ Object.assign(bid, {
+ width: rtbBid.rtb.banner.width,
+ height: rtbBid.rtb.banner.height,
+ ad: rtbBid.rtb.banner.content
+ });
+ try {
+ const url = rtbBid.rtb.trackers[0].impression_urls[0];
+ const tracker = utils.createTrackPixelHtml(url);
+ bid.ad += tracker;
+ } catch (error) {
+ utils.logError('Error appending tracking pixel', error);
+ }
+ }
+
+ return bid;
+}
+
+function bidToTag(bid) {
+ const tag = {};
+ tag.sizes = transformSizes(bid.sizes);
+ tag.primary_size = tag.sizes[0];
+ tag.ad_types = [];
+ tag.uuid = bid.bidId;
+ if (bid.params.placementId) {
+ tag.id = parseInt(bid.params.placementId, 10);
+ }
+ if (bid.params.cpm) {
+ tag.cpm = bid.params.cpm;
+ }
+ tag.allow_smaller_sizes = bid.params.allowSmallerSizes || false;
+ tag.use_pmt_rule = bid.params.usePaymentRule || false
+ tag.prebid = true;
+ tag.disable_psa = true;
+ if (bid.params.reserve) {
+ tag.reserve = bid.params.reserve;
+ }
+ if (bid.params.position) {
+ tag.position = {'above': 1, 'below': 2}[bid.params.position] || 0;
+ }
+ if (bid.params.trafficSourceCode) {
+ tag.traffic_source_code = bid.params.trafficSourceCode;
+ }
+ if (bid.params.privateSizes) {
+ tag.private_sizes = transformSizes(bid.params.privateSizes);
+ }
+ if (bid.params.supplyType) {
+ tag.supply_type = bid.params.supplyType;
+ }
+ if (bid.params.pubClick) {
+ tag.pubclick = bid.params.pubClick;
+ }
+ if (bid.params.extInvCode) {
+ tag.ext_inv_code = bid.params.extInvCode;
+ }
+ if (bid.params.externalImpId) {
+ tag.external_imp_id = bid.params.externalImpId;
+ }
+ if (!utils.isEmpty(bid.params.keywords)) {
+ let keywords = utils.transformBidderParamKeywords(bid.params.keywords);
+
+ if (keywords.length > 0) {
+ keywords.forEach(deleteValues);
+ }
+ tag.keywords = keywords;
+ }
+ if (bid.params.category) {
+ tag.category = bid.params.category;
+ }
+
+ if (bid.mediaType === NATIVE || utils.deepAccess(bid, `mediaTypes.${NATIVE}`)) {
+ tag.ad_types.push(NATIVE);
+ if (tag.sizes.length === 0) {
+ tag.sizes = transformSizes([1, 1]);
+ }
+
+ if (bid.nativeParams) {
+ const nativeRequest = buildNativeRequest(bid.nativeParams);
+ tag[NATIVE] = {layouts: [nativeRequest]};
+ }
+ }
+
+ const videoMediaType = utils.deepAccess(bid, `mediaTypes.${VIDEO}`);
+ const context = utils.deepAccess(bid, 'mediaTypes.video.context');
+
+ tag.hb_source = 1;
+ if (bid.mediaType === VIDEO || videoMediaType) {
+ tag.ad_types.push(VIDEO);
+ }
+
+ // instream gets vastUrl, outstream gets vastXml
+ if (bid.mediaType === VIDEO || (videoMediaType && context !== 'outstream')) {
+ tag.require_asset_url = true;
+ }
+
+ if (bid.params.video) {
+ tag.video = {};
+ // place any valid video params on the tag
+ Object.keys(bid.params.video)
+ .filter(param => includes(VIDEO_TARGETING, param))
+ .forEach(param => tag.video[param] = bid.params.video[param]);
+ }
+
+ if (bid.renderer) {
+ tag.video = Object.assign({}, tag.video, {custom_renderer_present: true});
+ }
+
+ if (
+ (utils.isEmpty(bid.mediaType) && utils.isEmpty(bid.mediaTypes)) ||
+ (bid.mediaType === BANNER || (bid.mediaTypes && bid.mediaTypes[BANNER]))
+ ) {
+ tag.ad_types.push(BANNER);
+ }
+
+ return tag;
+}
+
+/* Turn bid request sizes into ut-compatible format */
+function transformSizes(requestSizes) {
+ let sizes = [];
+ let sizeObj = {};
+
+ if (utils.isArray(requestSizes) && requestSizes.length === 2 &&
+ !utils.isArray(requestSizes[0])) {
+ sizeObj.width = parseInt(requestSizes[0], 10);
+ sizeObj.height = parseInt(requestSizes[1], 10);
+ sizes.push(sizeObj);
+ } else if (typeof requestSizes === 'object') {
+ for (let i = 0; i < requestSizes.length; i++) {
+ let size = requestSizes[i];
+ sizeObj = {};
+ sizeObj.width = parseInt(size[0], 10);
+ sizeObj.height = parseInt(size[1], 10);
+ sizes.push(sizeObj);
+ }
+ }
+
+ return sizes;
+}
+
+function hasUserInfo(bid) {
+ return !!bid.params.user;
+}
+
+function hasAppDeviceInfo(bid) {
+ if (bid.params) {
+ return !!bid.params.app
+ }
+}
+
+function hasAppId(bid) {
+ if (bid.params && bid.params.app) {
+ return !!bid.params.app.id
+ }
+ return !!bid.params.app
+}
+
+function getRtbBid(tag) {
+ return tag && tag.ads && tag.ads.length && find(tag.ads, ad => ad.rtb);
+}
+
+function buildNativeRequest(params) {
+ const request = {};
+
+ // map standard prebid native asset identifier to /ut parameters
+ // e.g., tag specifies `body` but /ut only knows `description`.
+ // mapping may be in form {tag: ''} or
+ // {tag: {serverName: '', requiredParams: {...}}}
+ Object.keys(params).forEach(key => {
+ // check if one of the forms is used, otherwise
+ // a mapping wasn't specified so pass the key straight through
+ const requestKey =
+ (NATIVE_MAPPING[key] && NATIVE_MAPPING[key].serverName) ||
+ NATIVE_MAPPING[key] ||
+ key;
+
+ // required params are always passed on request
+ const requiredParams = NATIVE_MAPPING[key] && NATIVE_MAPPING[key].requiredParams;
+ request[requestKey] = Object.assign({}, requiredParams, params[key]);
+
+ // convert the sizes of image/icon assets to proper format (if needed)
+ const isImageAsset = !!(requestKey === NATIVE_MAPPING.image.serverName || requestKey === NATIVE_MAPPING.icon.serverName);
+ if (isImageAsset && request[requestKey].sizes) {
+ let sizes = request[requestKey].sizes;
+ if (utils.isArrayOfNums(sizes) || (utils.isArray(sizes) && sizes.length > 0 && sizes.every(sz => utils.isArrayOfNums(sz)))) {
+ request[requestKey].sizes = transformSizes(request[requestKey].sizes);
+ }
+ }
+
+ if (requestKey === NATIVE_MAPPING.privacyLink) {
+ request.privacy_supported = true;
+ }
+ });
+
+ return request;
+}
+
+function parseMediaType(rtbBid) {
+ const adType = rtbBid.ad_type;
+ if (adType === VIDEO) {
+ return VIDEO;
+ } else {
+ return BANNER;
+ }
+}
+
+registerBidder(spec);
diff --git a/modules/adrelevantisBidAdapter.md b/modules/adrelevantisBidAdapter.md
new file mode 100644
index 00000000000..a60a47508ff
--- /dev/null
+++ b/modules/adrelevantisBidAdapter.md
@@ -0,0 +1,120 @@
+# Overview
+
+```
+Module Name: Adrelevantis Bid Adapter
+Module Type: Bidder Adapter
+Maintainer: info@adrelevantis.com
+```
+
+# Description
+
+Connects to Adrelevantis exchange for bids.
+
+Adrelevantis bid adapter supports Banner, Video (outstream) and Native.
+
+# Test Parameters
+```
+var adUnits = [
+ // Banner adUnit
+ {
+ code: 'banner-div',
+ mediaTypes: {
+ banner: {
+ sizes: [[300, 250], [300,600]]
+ }
+ },
+ bids: [{
+ bidder: 'adrelevantis',
+ params: {
+ placementId: 13144370,
+ cpm: 0.50
+ }
+ }]
+ },
+ // Native adUnit
+ {
+ code: 'native-div',
+ sizes: [[1, 1]],
+ mediaTypes: {
+ native: {
+ title: {
+ required: true
+ },
+ body: {
+ required: true
+ },
+ image: {
+ required: true
+ },
+ sponsoredBy: {
+ required: true
+ },
+ icon: {
+ required: false
+ }
+ }
+ },
+ bids: [{
+ bidder: 'adrelevantis',
+ params: {
+ placementId: 13232354,
+ allowSmallerSizes: true
+ }
+ }]
+ },
+ // Video outstream adUnit
+ {
+ code: 'video-outstream',
+ mediaTypes: {
+ video: {
+ playerSize: [[640, 360]],
+ context: 'outstream'
+ }
+ },
+ bids: [
+ {
+ bidder: 'adrelevantis',
+ params: {
+ placementId: 13232385,
+ video: {
+ skippable: true,
+ playback_method: ['auto_play_sound_off']
+ }
+ }
+ }
+ ]
+ },
+
+ // Banner adUnit in a App Webview
+ // Only use this for situations where prebid.js is in a webview of an App
+ // See Prebid Mobile for displaying ads via an SDK
+ {
+ code: 'banner-div',
+ mediaTypes: {
+ banner: {
+ sizes: [[300, 250], [300,600]]
+ }
+ }
+ bids: [{
+ bidder: 'adrelevantis',
+ params: {
+ placementId: 13144370,
+ app: {
+ id: "B1O2W3M4AN.com.prebid.webview",
+ geo: {
+ lat: 40.0964439,
+ lng: -75.3009142
+ },
+ device_id: {
+ idfa: "4D12078D-3246-4DA4-AD5E-7610481E7AE", // Apple advertising identifier
+ aaid: "38400000-8cf0-11bd-b23e-10b96e40000d", // Android advertising identifier
+ md5udid: "5756ae9022b2ea1e47d84fead75220c8", // MD5 hash of the ANDROID_ID
+ sha1udid: "4DFAA92388699AC6539885AEF1719293879985BF", // SHA1 hash of the ANDROID_ID
+ windowsadid: "750c6be243f1c4b5c9912b95a5742fc5" // Windows advertising identifier
+ }
+ }
+ }
+ }]
+ }
+];
+```
diff --git a/modules/adtelligentBidAdapter.js b/modules/adtelligentBidAdapter.js
index e22aafb73fc..51138a2cac7 100644
--- a/modules/adtelligentBidAdapter.js
+++ b/modules/adtelligentBidAdapter.js
@@ -6,12 +6,23 @@ import { Renderer } from '../src/Renderer.js';
import find from 'core-js-pure/features/array/find.js';
const subdomainSuffixes = ['', 1, 2];
-const getUri = (function () {
- let num = 0;
- return function () {
- return 'https://ghb' + subdomainSuffixes[num++ % subdomainSuffixes.length] + '.adtelligent.com/v2/auction/'
+const AUCTION_PATH = '/v2/auction/';
+const PROTOCOL = 'https://';
+const HOST_GETTERS = {
+ default: (function () {
+ let num = 0;
+ return function () {
+ return 'ghb' + subdomainSuffixes[num++ % subdomainSuffixes.length] + '.adtelligent.com'
+ }
+ }()),
+ appaloosa: function () {
+ return 'hb.appaloosa.media'
}
-}())
+}
+const getUri = function (bidderCode) {
+ let getter = HOST_GETTERS[bidderCode] || HOST_GETTERS['default'];
+ return PROTOCOL + getter() + AUCTION_PATH
+}
const OUTSTREAM_SRC = 'https://player.adtelligent.com/outstream-unit/2.01/outstream.min.js';
const BIDDER_CODE = 'adtelligent';
const OUTSTREAM = 'outstream';
@@ -21,7 +32,7 @@ const syncsCache = {};
export const spec = {
code: BIDDER_CODE,
gvlid: 410,
- aliases: ['onefiftytwomedia', 'selectmedia'],
+ aliases: ['onefiftytwomedia', 'selectmedia', 'appaloosa'],
supportedMediaTypes: [VIDEO, BANNER],
isBidRequestValid: function (bid) {
return !!utils.deepAccess(bid, 'params.aid');
@@ -82,7 +93,7 @@ export const spec = {
data: Object.assign({}, tag, { BidRequests: bids }),
adapterRequest,
method: 'POST',
- url: getUri()
+ url: getUri(adapterRequest.bidderCode)
};
})
},
diff --git a/modules/adxcgBidAdapter.js b/modules/adxcgBidAdapter.js
index 2d5c64dfe53..e61792288ed 100644
--- a/modules/adxcgBidAdapter.js
+++ b/modules/adxcgBidAdapter.js
@@ -170,8 +170,8 @@ export const spec = {
beaconParams.tdid = validBidRequests[0].userId.tdid;
}
- if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.id5id'))) {
- beaconParams.id5id = validBidRequests[0].userId.id5id;
+ if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.id5id.uid'))) {
+ beaconParams.id5id = validBidRequests[0].userId.id5id.uid;
}
if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.idl_env'))) {
diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js
index 725ee0f5626..40d3cf84369 100644
--- a/modules/adyoulikeBidAdapter.js
+++ b/modules/adyoulikeBidAdapter.js
@@ -1,5 +1,6 @@
import * as utils from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { config } from '../src/config.js';
import find from 'core-js-pure/features/array/find.js';
const VERSION = '1.0';
@@ -104,15 +105,6 @@ function getHostname(bidderRequest) {
return '';
}
-/* Get current page referrer url */
-function getReferrerUrl(bidderRequest) {
- let referer = '';
- if (bidderRequest && bidderRequest.refererInfo) {
- referer = bidderRequest.refererInfo.referer;
- }
- return referer;
-}
-
/* Get current page canonical url */
function getCanonicalUrl() {
let link;
@@ -155,9 +147,14 @@ function createEndpoint(bidRequests, bidderRequest) {
function createEndpointQS(bidderRequest) {
const qs = {};
- const ref = getReferrerUrl(bidderRequest);
- if (ref) {
- qs.RefererUrl = encodeURIComponent(ref);
+ if (bidderRequest) {
+ const ref = bidderRequest.refererInfo;
+ if (ref) {
+ qs.RefererUrl = encodeURIComponent(ref.referer);
+ if (ref.numIframes > 0) {
+ qs.SafeFrame = true;
+ }
+ }
}
const can = getCanonicalUrl();
@@ -165,6 +162,11 @@ function createEndpointQS(bidderRequest) {
qs.CanonicalUrl = encodeURIComponent(can);
}
+ const domain = config.getConfig('publisherDomain');
+ if (domain) {
+ qs.PublisherDomain = encodeURIComponent(domain);
+ }
+
return qs;
}
diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js
index 12bc6a8105c..ff0e3230007 100644
--- a/modules/appnexusBidAdapter.js
+++ b/modules/appnexusBidAdapter.js
@@ -157,6 +157,7 @@ export const spec = {
const memberIdBid = find(bidRequests, hasMemberId);
const member = memberIdBid ? parseInt(memberIdBid.params.member, 10) : 0;
const schain = bidRequests[0].schain;
+ const omidSupport = find(bidRequests, hasOmidSupport);
const payload = {
tags: [...tags],
@@ -168,6 +169,13 @@ export const spec = {
schain: schain
};
+ if (omidSupport) {
+ payload['iab_support'] = {
+ omidpn: 'Appnexus',
+ omidpv: '$prebid.version$'
+ }
+ }
+
if (member > 0) {
payload.member_id = member;
}
@@ -220,15 +228,17 @@ export const spec = {
});
}
- let eids = [];
const criteoId = utils.deepAccess(bidRequests[0], `userId.criteoId`);
if (criteoId) {
- eids.push({
- source: 'criteo.com',
- id: criteoId
+ let tpuids = [];
+ tpuids.push({
+ 'provider': 'criteo',
+ 'user_id': criteoId
});
+ payload.tpuids = tpuids;
}
+ let eids = [];
const tdid = utils.deepAccess(bidRequests[0], `userId.tdid`);
if (tdid) {
eids.push({
@@ -764,16 +774,27 @@ function bidToTag(bid) {
type = (utils.isArray(type)) ? type[0] : type;
tag.video[param] = VIDEO_MAPPING[param][type];
break;
+ // Deprecating tags[].video.frameworks in favor of tags[].video_frameworks
+ case 'frameworks':
+ break;
default:
tag.video[param] = bid.params.video[param];
}
});
+
+ if (bid.params.video.frameworks && utils.isArray(bid.params.video.frameworks)) {
+ tag['video_frameworks'] = bid.params.video.frameworks;
+ }
}
if (bid.renderer) {
tag.video = Object.assign({}, tag.video, { custom_renderer_present: true });
}
+ if (bid.params.frameworks && utils.isArray(bid.params.frameworks)) {
+ tag['banner_frameworks'] = bid.params.frameworks;
+ }
+
let adUnit = find(auctionManager.getAdUnits(), au => bid.transactionId === au.transactionId);
if (adUnit && adUnit.mediaTypes && adUnit.mediaTypes.banner) {
tag.ad_types.push(BANNER);
@@ -842,6 +863,19 @@ function hasAdPod(bid) {
);
}
+function hasOmidSupport(bid) {
+ let hasOmid = false;
+ const bidderParams = bid.params;
+ const videoParams = bid.params.video;
+ if (bidderParams.frameworks && utils.isArray(bidderParams.frameworks)) {
+ hasOmid = includes(bid.params.frameworks, 6);
+ }
+ if (!hasOmid && videoParams && videoParams.frameworks && utils.isArray(videoParams.frameworks)) {
+ hasOmid = includes(bid.params.video.frameworks, 6);
+ }
+ return hasOmid;
+}
+
/**
* Expand an adpod placement into a set of request objects according to the
* total adpod duration and the range of duration seconds. Sets minduration/
diff --git a/modules/avocetBidAdapter.js b/modules/avocetBidAdapter.js
index 1163ac830ba..7a9e5062c0f 100644
--- a/modules/avocetBidAdapter.js
+++ b/modules/avocetBidAdapter.js
@@ -77,8 +77,8 @@ export const spec = {
// ID5 identifier
let id5id;
- if (bidRequests[0].userId && bidRequests[0].userId.id5id) {
- id5id = bidRequests[0].userId.id5id;
+ if (bidRequests[0].userId && bidRequests[0].userId.id5id && bidRequests[0].userId.id5id.uid) {
+ id5id = bidRequests[0].userId.id5id.uid;
}
// Build the avocet ext object
diff --git a/modules/betweenBidAdapter.js b/modules/betweenBidAdapter.js
index c435a5a993e..fb3fcdb8d89 100644
--- a/modules/betweenBidAdapter.js
+++ b/modules/betweenBidAdapter.js
@@ -1,5 +1,7 @@
import {registerBidder} from '../src/adapters/bidderFactory.js';
import { getAdUnitSizes, parseSizesInput } from '../src/utils.js';
+import { getRefererInfo } from '../src/refererDetection.js';
+
const BIDDER_CODE = 'between';
export const spec = {
@@ -24,6 +26,7 @@ export const spec = {
buildRequests: function(validBidRequests, bidderRequest) {
let requests = [];
const gdprConsent = bidderRequest && bidderRequest.gdprConsent;
+ const refInfo = getRefererInfo();
validBidRequests.forEach(i => {
let params = {
@@ -56,6 +59,8 @@ export const spec = {
}
}
+ if (refInfo && refInfo.referer) params.ref = refInfo.referer;
+
if (gdprConsent) {
if (typeof gdprConsent.gdprApplies !== 'undefined') {
params.gdprApplies = !!gdprConsent.gdprApplies;
diff --git a/modules/bridgewellBidAdapter.js b/modules/bridgewellBidAdapter.js
index 0303e4f74bd..5fca9acc0b3 100644
--- a/modules/bridgewellBidAdapter.js
+++ b/modules/bridgewellBidAdapter.js
@@ -5,7 +5,7 @@ import find from 'core-js-pure/features/array/find.js';
const BIDDER_CODE = 'bridgewell';
const REQUEST_ENDPOINT = 'https://prebid.scupio.com/recweb/prebid.aspx?cb=' + Math.random();
-const BIDDER_VERSION = '0.0.2';
+const BIDDER_VERSION = '0.0.3';
export const spec = {
code: BIDDER_CODE,
@@ -19,11 +19,13 @@ export const spec = {
*/
isBidRequestValid: function (bid) {
let valid = false;
-
- if (bid && bid.params && bid.params.ChannelID) {
- valid = true;
+ if (bid && bid.params) {
+ if ((bid.params.cid) && (typeof bid.params.cid === 'number')) {
+ valid = true;
+ } else if (bid.params.ChannelID) {
+ valid = true;
+ }
}
-
return valid;
},
@@ -36,15 +38,29 @@ export const spec = {
buildRequests: function (validBidRequests, bidderRequest) {
const adUnits = [];
utils._each(validBidRequests, function (bid) {
- adUnits.push({
- ChannelID: bid.params.ChannelID,
- adUnitCode: bid.adUnitCode,
- mediaTypes: bid.mediaTypes || {
- banner: {
- sizes: bid.sizes
+ if (bid.params.cid) {
+ adUnits.push({
+ cid: bid.params.cid,
+ adUnitCode: bid.adUnitCode,
+ requestId: bid.bidId,
+ mediaTypes: bid.mediaTypes || {
+ banner: {
+ sizes: bid.sizes
+ }
}
- }
- });
+ });
+ } else {
+ adUnits.push({
+ ChannelID: bid.params.ChannelID,
+ adUnitCode: bid.adUnitCode,
+ requestId: bid.bidId,
+ mediaTypes: bid.mediaTypes || {
+ banner: {
+ sizes: bid.sizes
+ }
+ }
+ });
+ }
});
let topUrl = '';
@@ -63,7 +79,8 @@ export const spec = {
inIframe: utils.inIframe(),
url: topUrl,
referrer: getTopWindowReferrer(),
- adUnits: adUnits
+ adUnits: adUnits,
+ refererInfo: bidderRequest.refererInfo,
},
validBidRequests: validBidRequests
};
diff --git a/modules/bridgewellBidAdapter.md b/modules/bridgewellBidAdapter.md
index 6bcab4b8820..97e11f6eaf9 100644
--- a/modules/bridgewellBidAdapter.md
+++ b/modules/bridgewellBidAdapter.md
@@ -20,7 +20,7 @@ Module that connects to Bridgewell demand source to fetch bids.
bids: [{
bidder: 'bridgewell',
params: {
- ChannelID: 'CgUxMjMzOBIBNiIFcGVubnkqCQisAhD6ARoBOQ'
+ cid: 12345
}
}]
}, {
@@ -33,7 +33,7 @@ Module that connects to Bridgewell demand source to fetch bids.
bids: [{
bidder: 'bridgewell',
params: {
- ChannelID: 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ'
+ cid: 56789
}
}]
}, {
@@ -70,7 +70,7 @@ Module that connects to Bridgewell demand source to fetch bids.
bids: [{
bidder: 'bridgewell',
params: {
- ChannelID: 'CgUxMjMzOBIBNiIGcGVubnkzKggI2AUQWhoBOQ'
+ cid: 2394
}
}]
}];
diff --git a/modules/brightMountainMediaBidAdapter.js b/modules/brightMountainMediaBidAdapter.js
index 5a285be71c0..aa1076e798a 100644
--- a/modules/brightMountainMediaBidAdapter.js
+++ b/modules/brightMountainMediaBidAdapter.js
@@ -79,7 +79,7 @@ export const spec = {
if (syncOptions.iframeEnabled) {
return [{
type: 'iframe',
- url: 'https://console.brightmountainmedia.com:4444/cookieSync'
+ url: 'https://console.brightmountainmedia.com:8443/cookieSync'
}];
}
},
diff --git a/modules/britepoolIdSystem.js b/modules/britepoolIdSystem.js
index 17a39e96aad..3bf416957d2 100644
--- a/modules/britepoolIdSystem.js
+++ b/modules/britepoolIdSystem.js
@@ -8,6 +8,7 @@
import * as utils from '../src/utils.js'
import {ajax} from '../src/ajax.js';
import {submodule} from '../src/hook.js';
+const PIXEL = 'https://px.britepool.com/new?partner_id=t';
/** @type {Submodule} */
export const britepoolIdSubmodule = {
@@ -28,10 +29,12 @@ export const britepoolIdSubmodule = {
/**
* Performs action to obtain id and return a value in the callback's response argument
* @function
- * @param {SubmoduleParams} [configParams]
+ * @param {SubmoduleConfig} [submoduleConfig]
+ * @param {ConsentData|undefined} consentData
* @returns {function(callback:function)}
*/
- getId(submoduleConfigParams, consentData) {
+ getId(submoduleConfig, consentData) {
+ const submoduleConfigParams = (submoduleConfig && submoduleConfig.params) || {};
const { params, headers, url, getter, errors } = britepoolIdSubmodule.createParams(submoduleConfigParams, consentData);
let getterResponse = null;
if (typeof getter === 'function') {
@@ -44,6 +47,9 @@ export const britepoolIdSubmodule = {
};
}
}
+ if (utils.isEmpty(params)) {
+ utils.triggerPixel(PIXEL);
+ }
// Return for async operation
return {
callback: function(callback) {
@@ -79,13 +85,17 @@ export const britepoolIdSubmodule = {
},
/**
* Helper method to create params for our API call
- * @param {SubmoduleParams} [configParams]
+ * @param {SubmoduleParams} [submoduleConfigParams]
+ * @param {ConsentData|undefined} consentData
* @returns {object} Object with parsed out params
*/
createParams(submoduleConfigParams, consentData) {
+ const hasGdprData = consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies;
+ const gdprConsentString = hasGdprData ? consentData.consentString : undefined;
let errors = [];
const headers = {};
- let params = Object.assign({}, submoduleConfigParams);
+ const dynamicVars = typeof britepool_pubparams !== 'undefined' ? britepool_pubparams : {}; // eslint-disable-line camelcase, no-undef
+ let params = Object.assign({}, submoduleConfigParams, dynamicVars);
if (params.getter) {
// Custom getter will not require other params
if (typeof params.getter !== 'function') {
@@ -98,7 +108,7 @@ export const britepoolIdSubmodule = {
headers['x-api-key'] = params.api_key;
}
}
- const url = params.url || 'https://api.britepool.com/v1/britepool/id';
+ const url = params.url || `https://api.britepool.com/v1/britepool/id${gdprConsentString ? '?gdprString=' + encodeURIComponent(gdprConsentString) : ''}`;
const getter = params.getter;
delete params.api_key;
delete params.url;
diff --git a/modules/cointrafficBidAdapter.js b/modules/cointrafficBidAdapter.js
index aa6860d1fc6..43f5cc01ccf 100644
--- a/modules/cointrafficBidAdapter.js
+++ b/modules/cointrafficBidAdapter.js
@@ -1,9 +1,15 @@
import * as utils from '../src/utils.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'
+import { config } from '../src/config.js'
const BIDDER_CODE = 'cointraffic';
const ENDPOINT_URL = 'https://appspb.cointraffic.io/pb/tmp';
+const DEFAULT_CURRENCY = 'EUR';
+const ALLOWED_CURRENCIES = [
+ 'EUR', 'USD', 'JPY', 'BGN', 'CZK', 'DKK', 'GBP', 'HUF', 'PLN', 'RON', 'SEK', 'CHF', 'ISK', 'NOK', 'HRK', 'RUB', 'TRY',
+ 'AUD', 'BRL', 'CAD', 'CNY', 'HKD', 'IDR', 'ILS', 'INR', 'KRW', 'MXN', 'MYR', 'NZD', 'PHP', 'SGD', 'THB', 'ZAR',
+];
export const spec = {
code: BIDDER_CODE,
@@ -29,9 +35,19 @@ export const spec = {
buildRequests: function (validBidRequests, bidderRequest) {
return validBidRequests.map(bidRequest => {
const sizes = utils.parseSizesInput(bidRequest.params.size || bidRequest.sizes);
+ const currency =
+ config.getConfig(`currency.bidderCurrencyDefault.${BIDDER_CODE}`) ||
+ config.getConfig('currency.adServerCurrency') ||
+ DEFAULT_CURRENCY;
+
+ if (ALLOWED_CURRENCIES.indexOf(currency) === -1) {
+ utils.logError('Currency is not supported - ' + currency);
+ return;
+ }
const payload = {
placementId: bidRequest.params.placementId,
+ currency: currency,
sizes: sizes,
bidId: bidRequest.bidId,
referer: bidderRequest.refererInfo.referer,
diff --git a/modules/cointrafficBidAdapter.md b/modules/cointrafficBidAdapter.md
index ad608a1319e..fcbcad1cad7 100644
--- a/modules/cointrafficBidAdapter.md
+++ b/modules/cointrafficBidAdapter.md
@@ -7,7 +7,10 @@ Maintainer: tech@cointraffic.io
```
# Description
-The Cointraffic client module makes it easy to implement Cointraffic directly into your website. To get started, simply replace the ``placementId`` with your assigned tracker key. This is dependent on the size required by your account dashboard. For additional information on this module, please contact us at ``support@cointraffic.io``.
+The Cointraffic client module makes it easy to implement Cointraffic directly into your website. To get started, simply replace the ``placementId`` with your assigned tracker key. This is dependent on the size required by your account dashboard.
+We support response in different currencies. Supported currencies listed [here](https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/index.en.html).
+
+For additional information on this module, please contact us at ``support@cointraffic.io``.
# Test Parameters
```
diff --git a/modules/colossussspBidAdapter.js b/modules/colossussspBidAdapter.js
index baa60a76a0d..a3beb723528 100644
--- a/modules/colossussspBidAdapter.js
+++ b/modules/colossussspBidAdapter.js
@@ -102,7 +102,7 @@ export const spec = {
if (bid.userId) {
getUserId(placement.eids, bid.userId.britepoolid, 'britepool.com');
getUserId(placement.eids, bid.userId.idl_env, 'identityLink');
- getUserId(placement.eids, bid.userId.id5id, 'id5-sync.com')
+ getUserId(placement.eids, utils.deepAccess(bid, 'userId.id5id.uid'), 'id5-sync.com', utils.deepAccess(bid, 'userId.id5id.ext'));
getUserId(placement.eids, bid.userId.tdid, 'adserver.org', {
rtiPartner: 'TDID'
});
diff --git a/modules/connectadBidAdapter.js b/modules/connectadBidAdapter.js
index 04459ec1f09..d1811a1b7d1 100644
--- a/modules/connectadBidAdapter.js
+++ b/modules/connectadBidAdapter.js
@@ -11,6 +11,7 @@ const SUPPORTED_MEDIA_TYPES = [BANNER];
export const spec = {
code: BIDDER_CODE,
+ gvlid: 138,
aliases: [ BIDDER_CODE_ALIAS ],
supportedMediaTypes: SUPPORTED_MEDIA_TYPES,
@@ -81,8 +82,10 @@ export const spec = {
pisze: bid.mediaTypes.banner.sizes[0] || bid.sizes[0],
sizes: bid.mediaTypes.banner.sizes,
adTypes: getSize(bid.mediaTypes.banner.sizes || bid.sizes),
- floor: getBidFloor(bid)
- }, bid.params);
+ bidfloor: getBidFloor(bid),
+ siteId: bid.params.siteId,
+ networkId: bid.params.networkId
+ });
if (placement.networkId && placement.siteId) {
data.placements.push(placement);
@@ -134,6 +137,13 @@ export const spec = {
return bidResponses;
},
+ transformBidParams: function (params, isOpenRtb) {
+ return utils.convertTypes({
+ 'siteId': 'number',
+ 'networkId': 'number'
+ }, params);
+ },
+
getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) {
let syncEndpoint = 'https://cdn.connectad.io/connectmyusers.php?';
@@ -227,7 +237,7 @@ function getBidFloor(bidRequest) {
});
}
- let floor = floorInfo.floor || 0;
+ let floor = floorInfo.floor || bidRequest.params.bidfloor || bidRequest.params.floorprice || 0;
return floor;
}
diff --git a/modules/criteoIdSystem.js b/modules/criteoIdSystem.js
index c44f0c843ae..30641b6c225 100644
--- a/modules/criteoIdSystem.js
+++ b/modules/criteoIdSystem.js
@@ -11,7 +11,9 @@ import { getRefererInfo } from '../src/refererDetection.js'
import { submodule } from '../src/hook.js';
import { getStorageManager } from '../src/storageManager.js';
-export const storage = getStorageManager();
+const gvlid = 91;
+const bidderCode = 'criteo';
+export const storage = getStorageManager(gvlid, bidderCode);
const bididStorageKey = 'cto_bidid';
const bundleStorageKey = 'cto_bundle';
@@ -101,7 +103,9 @@ function callCriteoUserSync(parsedCriteoData, gdprString) {
} else if (jsonResponse.bundle) {
saveOnAllStorages(bundleStorageKey, jsonResponse.bundle);
}
- }
+ },
+ undefined,
+ { method: 'GET', contentType: 'application/json', withCredentials: true }
);
}
@@ -111,7 +115,8 @@ export const criteoIdSubmodule = {
* used to link submodule with config
* @type {string}
*/
- name: 'criteo',
+ name: bidderCode,
+ gvlid: gvlid,
/**
* decode the stored id value for passing to bid requests
* @function
@@ -123,11 +128,11 @@ export const criteoIdSubmodule = {
/**
* get the Criteo Id from local storages and initiate a new user sync
* @function
- * @param {SubmoduleParams} [configParams]
+ * @param {SubmoduleConfig} [config]
* @param {ConsentData} [consentData]
* @returns {{id: {criteoId: string} | undefined}}}
*/
- getId(configParams, consentData) {
+ getId(config, consentData) {
const hasGdprData = consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies;
const gdprConsentString = hasGdprData ? consentData.consentString : undefined;
diff --git a/modules/dfpAdServerVideo.js b/modules/dfpAdServerVideo.js
index 9fe8c26e4f6..554c44aa708 100644
--- a/modules/dfpAdServerVideo.js
+++ b/modules/dfpAdServerVideo.js
@@ -8,6 +8,8 @@ import { deepAccess, isEmpty, logError, parseSizesInput, formatQS, parseUrl, bui
import { config } from '../src/config.js';
import { getHook, submodule } from '../src/hook.js';
import { auctionManager } from '../src/auctionManager.js';
+import events from '../src/events.js';
+import CONSTANTS from '../src/constants.json';
/**
* @typedef {Object} DfpVideoParams
@@ -245,17 +247,20 @@ function getCustParams(bid, options) {
allTargetingData = (allTargeting) ? allTargeting[adUnit.code] : {};
}
- const optCustParams = deepAccess(options, 'params.cust_params');
- let customParams = Object.assign({},
+ const prebidTargetingSet = Object.assign({},
// Why are we adding standard keys here ? Refer https://github.com/prebid/Prebid.js/issues/3664
{ hb_uuid: bid && bid.videoCacheKey },
// hb_uuid will be deprecated and replaced by hb_cache_id
{ hb_cache_id: bid && bid.videoCacheKey },
allTargetingData,
adserverTargeting,
- optCustParams,
);
- return encodeURIComponent(formatQS(customParams));
+ events.emit(CONSTANTS.EVENTS.SET_TARGETING, {[adUnit.code]: prebidTargetingSet});
+
+ // merge the prebid + publisher targeting sets
+ const publisherTargetingSet = deepAccess(options, 'params.cust_params');
+ const targetingSet = Object.assign({}, prebidTargetingSet, publisherTargetingSet);
+ return encodeURIComponent(formatQS(targetingSet));
}
registerVideoSupport('dfp', {
diff --git a/modules/districtmDMXBidAdapter.js b/modules/districtmDMXBidAdapter.js
index 21f3b7b3586..bcb2bb97210 100644
--- a/modules/districtmDMXBidAdapter.js
+++ b/modules/districtmDMXBidAdapter.js
@@ -106,7 +106,7 @@ export const spec = {
let eids = [];
if (bidRequest[0] && bidRequest[0].userId) {
bindUserId(eids, utils.deepAccess(bidRequest[0], `userId.idl_env`), 'liveramp.com', 1);
- bindUserId(eids, utils.deepAccess(bidRequest[0], `userId.id5id`), 'id5-sync.com', 1);
+ bindUserId(eids, utils.deepAccess(bidRequest[0], `userId.id5id.uid`), 'id5-sync.com', 1);
bindUserId(eids, utils.deepAccess(bidRequest[0], `userId.pubcid`), 'pubcid.org', 1);
bindUserId(eids, utils.deepAccess(bidRequest[0], `userId.tdid`), 'adserver.org', 1);
bindUserId(eids, utils.deepAccess(bidRequest[0], `userId.criteoId`), 'criteo.com', 1);
diff --git a/modules/fabrickIdSystem.js b/modules/fabrickIdSystem.js
new file mode 100644
index 00000000000..e61b377eefa
--- /dev/null
+++ b/modules/fabrickIdSystem.js
@@ -0,0 +1,147 @@
+/**
+ * This module adds neustar's fabrickId to the User ID module
+ * The {@link module:modules/userId} module is required
+ * @module modules/fabrickIdSystem
+ * @requires module:modules/userId
+ */
+
+import * as utils from '../src/utils.js'
+import { ajax } from '../src/ajax.js';
+import { submodule } from '../src/hook.js';
+import { getRefererInfo } from '../src/refererDetection.js';
+
+/** @type {Submodule} */
+export const fabrickIdSubmodule = {
+ /**
+ * used to link submodule with config
+ * @type {string}
+ */
+ name: 'fabrickId',
+
+ /**
+ * decode the stored id value for passing to bid requests
+ * @function decode
+ * @param {(Object|string)} value
+ * @returns {(Object|undefined)}
+ */
+ decode(value) {
+ if (value && value.fabrickId) {
+ return { 'fabrickId': value.fabrickId };
+ } else {
+ return undefined;
+ }
+ },
+
+ /**
+ * performs action to obtain id and return a value in the callback's response argument
+ * @function getId
+ * @param {SubmoduleConfig} [config]
+ * @param {ConsentData}
+ * @param {Object} cacheIdObj - existing id, if any consentData]
+ * @returns {IdResponse|undefined}
+ */
+ getId(config, consentData, cacheIdObj) {
+ try {
+ const configParams = (config && config.params) || {};
+ if (window.fabrickMod1) {
+ window.fabrickMod1(configParams, consentData, cacheIdObj);
+ }
+ if (!configParams || typeof configParams.apiKey !== 'string') {
+ utils.logError('fabrick submodule requires an apiKey.');
+ return;
+ }
+ try {
+ let url = _getBaseUrl(configParams);
+ let keysArr = Object.keys(configParams);
+ for (let i in keysArr) {
+ let k = keysArr[i];
+ if (k === 'url' || k === 'refererInfo') {
+ continue;
+ }
+ let v = configParams[k];
+ if (Array.isArray(v)) {
+ for (let j in v) {
+ url += `${k}=${v[j]}&`;
+ }
+ } else {
+ url += `${k}=${v}&`;
+ }
+ }
+ // pull off the trailing &
+ url = url.slice(0, -1)
+ const referer = _getRefererInfo(configParams);
+ const urls = new Set();
+ url = truncateAndAppend(urls, url, 'r', referer.referer);
+ if (referer.stack && referer.stack[0]) {
+ url = truncateAndAppend(urls, url, 'r', referer.stack[0]);
+ }
+ url = truncateAndAppend(urls, url, 'r', referer.canonicalUrl);
+ url = truncateAndAppend(urls, url, 'r', window.location.href);
+
+ const resp = function (callback) {
+ const callbacks = {
+ success: response => {
+ if (window.fabrickMod2) {
+ return window.fabrickMod2(
+ callback, response, configParams, consentData, cacheIdObj);
+ } else {
+ let responseObj;
+ if (response) {
+ try {
+ responseObj = JSON.parse(response);
+ } catch (error) {
+ utils.logError(error);
+ responseObj = {};
+ }
+ }
+ callback(responseObj);
+ }
+ },
+ error: error => {
+ utils.logError(`fabrickId fetch encountered an error`, error);
+ callback();
+ }
+ };
+ ajax(url, callbacks, null, {method: 'GET', withCredentials: true});
+ };
+ return {callback: resp};
+ } catch (e) {
+ utils.logError(`fabrickIdSystem encountered an error`, e);
+ }
+ } catch (e) {
+ utils.logError(`fabrickIdSystem encountered an error`, e);
+ }
+ }
+};
+
+function _getRefererInfo(configParams) {
+ if (configParams.refererInfo) {
+ return configParams.refererInfo;
+ } else {
+ return getRefererInfo();
+ }
+}
+
+function _getBaseUrl(configParams) {
+ if (configParams.url) {
+ return configParams.url;
+ } else {
+ return `https://fid.agkn.com/f?`;
+ }
+}
+
+function truncateAndAppend(urls, url, paramName, s) {
+ if (s && url.length < 2000) {
+ if (s.length > 200) {
+ s = s.substring(0, 200);
+ }
+ // Don't send the same url in multiple params
+ if (!urls.has(s)) {
+ urls.add(s);
+ return `${url}&${paramName}=${s}`
+ }
+ }
+ return url;
+}
+
+submodule('userId', fabrickIdSubmodule);
diff --git a/modules/fabrickIdSystem.md b/modules/fabrickIdSystem.md
new file mode 100644
index 00000000000..268c861710a
--- /dev/null
+++ b/modules/fabrickIdSystem.md
@@ -0,0 +1,24 @@
+## Neustar Fabrick User ID Submodule
+
+Fabrick ID Module - https://www.home.neustar/fabrick
+Product and Sales Inquiries: 1-855-898-0036
+
+## Example configuration for publishers:
+```
+pbjs.setConfig({
+ userSync: {
+ userIds: [{
+ name: 'fabrickId',
+ storage: {
+ name: 'pbjs_fabrickId',
+ type: 'cookie',
+ expires: 7
+ },
+ params: {
+ apiKey: 'your apiKey', // provided to you by Neustar
+ e: '31c5543c1734d25c7206f5fd591525d0295bec6fe84ff82f946a34fe970a1e66' // example hash identifier (sha256)
+ }
+ }]
+ }
+});
+```
diff --git a/modules/gamoshiBidAdapter.js b/modules/gamoshiBidAdapter.js
index 1316d74e430..2e09cf55d0a 100644
--- a/modules/gamoshiBidAdapter.js
+++ b/modules/gamoshiBidAdapter.js
@@ -157,7 +157,7 @@ export const spec = {
let eids = [];
if (bidRequest && bidRequest.userId) {
- addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.id5id`), 'id5-sync.com', 'ID5ID');
+ addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.id5id.uid`), 'id5-sync.com', 'ID5ID');
addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.tdid`), 'adserver.org', 'TDID');
}
if (eids.length > 0) {
diff --git a/modules/gjirafaBidAdapter.js b/modules/gjirafaBidAdapter.js
index ca7fb4af32d..48496b52c05 100644
--- a/modules/gjirafaBidAdapter.js
+++ b/modules/gjirafaBidAdapter.js
@@ -1,4 +1,5 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { BANNER, VIDEO } from '../src/mediaTypes.js';
const BIDDER_CODE = 'gjirafa';
const ENDPOINT_URL = 'https://central.gjirafa.com/bid';
@@ -7,6 +8,7 @@ const SIZE_SEPARATOR = ';';
export const spec = {
code: BIDDER_CODE,
+ supportedMediaTypes: [BANNER, VIDEO],
/**
* Determines whether or not the given bid request is valid.
*
@@ -23,31 +25,48 @@ export const spec = {
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (validBidRequests, bidderRequest) {
- let response = validBidRequests.map(bidRequest => {
- let sizes = generateSizeParam(bidRequest.sizes);
- let propertyId = bidRequest.params.propertyId;
- let placementId = bidRequest.params.placementId;
+ let propertyId = '';
+ let pageViewGuid = '';
+ let storageId = '';
+ let bidderRequestId = '';
+ let url = '';
+ let contents = [];
+
+ let placements = validBidRequests.map(bidRequest => {
+ if (!propertyId) { propertyId = bidRequest.params.propertyId; }
+ if (!pageViewGuid && bidRequest.params) { pageViewGuid = bidRequest.params.pageViewGuid || ''; }
+ if (!storageId && bidRequest.params) { storageId = bidRequest.params.storageId || ''; }
+ if (!bidderRequestId) { bidderRequestId = bidRequest.bidderRequestId; }
+ if (!url && bidderRequest) { url = bidderRequest.refererInfo.referer; }
+ if (!contents.length && bidRequest.params.contents && bidRequest.params.contents.length) { contents = bidRequest.params.contents }
+
let adUnitId = bidRequest.adUnitCode;
- let pageViewGuid = bidRequest.params.pageViewGuid || '';
- let contents = bidRequest.params.contents || [];
- const body = {
+ let placementId = bidRequest.params.placementId;
+ let sizes = generateSizeParam(bidRequest.sizes);
+
+ return {
sizes: sizes,
adUnitId: adUnitId,
placementId: placementId,
- propertyId: propertyId,
- pageViewGuid: pageViewGuid,
- url: bidderRequest ? bidderRequest.refererInfo.referer : '',
- requestid: bidRequest.bidderRequestId,
bidid: bidRequest.bidId,
- contents: contents
- };
- return {
- method: 'POST',
- url: ENDPOINT_URL,
- data: body
};
});
- return response
+
+ let body = {
+ propertyId: propertyId,
+ pageViewGuid: pageViewGuid,
+ storageId: storageId,
+ url: url,
+ requestid: bidderRequestId,
+ placements: placements,
+ contents: contents
+ }
+
+ return [{
+ method: 'POST',
+ url: ENDPOINT_URL,
+ data: body
+ }];
},
/**
* Unpack the response from the server into a list of bids.
@@ -55,13 +74,12 @@ export const spec = {
* @param {ServerResponse} serverResponse A successful response from the server.
* @return {Bid[]} An array of bids which were nested inside the server.
*/
- interpretResponse: function (serverResponse, bidRequest) {
- window.adnResponse = serverResponse;
+ interpretResponse: function (serverResponse) {
const responses = serverResponse.body;
const bidResponses = [];
for (var i = 0; i < responses.length; i++) {
const bidResponse = {
- requestId: bidRequest.data.bidid,
+ requestId: responses[i].BidId,
cpm: responses[i].CPM,
width: responses[i].Width,
height: responses[i].Height,
@@ -70,7 +88,9 @@ export const spec = {
netRevenue: responses[i].NetRevenue,
ttl: responses[i].TTL,
referrer: responses[i].Referrer,
- ad: responses[i].Ad
+ ad: responses[i].Ad,
+ vastUrl: responses[i].VastUrl,
+ mediaType: responses[i].MediaType
};
bidResponses.push(bidResponse);
}
diff --git a/modules/gjirafaBidAdapter.md b/modules/gjirafaBidAdapter.md
index 53d3a76c5ed..deb06e74a27 100644
--- a/modules/gjirafaBidAdapter.md
+++ b/modules/gjirafaBidAdapter.md
@@ -28,22 +28,16 @@ var adUnits = [
{
code: 'test-div',
mediaTypes: {
- banner: {
- sizes: [[300, 250]]
- }
+ video: {
+ context: 'instream'
+ }
},
bids: [
{
bidder: 'gjirafa',
params: {
propertyId: '105227',
- placementId: '846848',
- contents: [ //optional
- {
- type: 'article',
- id: '123'
- }
- ]
+ placementId: '846836'
}
}
]
diff --git a/modules/gridBidAdapter.js b/modules/gridBidAdapter.js
index b4b741ac783..378fc5a7efe 100644
--- a/modules/gridBidAdapter.js
+++ b/modules/gridBidAdapter.js
@@ -351,10 +351,10 @@ function buildNewRequest(validBidRequests, bidderRequest) {
}
if (realTimeData && realTimeData.jwTargeting) {
if (!jwpseg && realTimeData.jwTargeting.segments) {
- jwpseg = realTimeData.segments;
+ jwpseg = realTimeData.jwTargeting.segments;
}
- if (!content && realTimeData.content) {
- content = realTimeData.content;
+ if (!content && realTimeData.jwTargeting.content) {
+ content = realTimeData.jwTargeting.content;
}
}
let impObj = {
@@ -431,8 +431,8 @@ function buildNewRequest(validBidRequests, bidderRequest) {
if (userId.tdid) {
userExt.unifiedid = userId.tdid;
}
- if (userId.id5id) {
- userExt.id5id = userId.id5id;
+ if (userId.id5id && userId.id5id.uid) {
+ userExt.id5id = userId.id5id.uid;
}
if (userId.digitrustid && userId.digitrustid.data && userId.digitrustid.data.id) {
userExt.digitrustid = userId.digitrustid.data.id;
diff --git a/modules/gumgumBidAdapter.js b/modules/gumgumBidAdapter.js
index f8e17e0fe71..3206b7e1727 100644
--- a/modules/gumgumBidAdapter.js
+++ b/modules/gumgumBidAdapter.js
@@ -135,7 +135,8 @@ function isBidRequestValid (bid) {
params,
adUnitCode
} = bid;
- const id = params.inScreen || params.inScreenPubID || params.inSlot || params.ICV || params.video || params.inVideo;
+ const legacyParamID = params.inScreen || params.inScreenPubID || params.inSlot || params.ICV || params.video || params.inVideo;
+ const id = legacyParamID || params.slot || params.native || params.zone || params.pubID;
if (invalidRequestIds[id]) {
utils.logWarn(`[GumGum] Please check the implementation for ${id} for the placement ${adUnitCode}`);
@@ -143,6 +144,8 @@ function isBidRequestValid (bid) {
}
switch (true) {
+ case !!(params.zone): break;
+ case !!(params.pubId): break;
case !!(params.inScreen): break;
case !!(params.inScreenPubID): break;
case !!(params.inSlot): break;
@@ -217,8 +220,8 @@ function _getFloor (mediaTypes, bidfloor, bid) {
});
if (typeof floorInfo === 'object' &&
- floorInfo.currency === 'USD' &&
- !isNaN(parseFloat(floorInfo.floor))) {
+ floorInfo.currency === 'USD' &&
+ !isNaN(parseFloat(floorInfo.floor))) {
floor = Math.max(floor, parseFloat(floorInfo.floor));
}
}
@@ -255,6 +258,7 @@ function buildRequests (validBidRequests, bidderRequest) {
sizes = mediaTypes.banner.sizes;
} else if (mediaTypes.video) {
sizes = mediaTypes.video.playerSize;
+ data = _getVidParams(mediaTypes.video);
}
if (pageViewId) {
@@ -265,48 +269,31 @@ function buildRequests (validBidRequests, bidderRequest) {
data.fp = bidFloor;
}
- if (params.inScreenPubID) {
- data.pubId = params.inScreenPubID;
- data.pi = 2;
+ if (params.iriscat && typeof params.iriscat === 'string') {
+ data.iriscat = params.iriscat;
}
- if (params.inScreen) {
- data.t = params.inScreen;
- data.pi = 2;
- }
- if (params.inSlot) {
- data.si = parseInt(params.inSlot, 10);
- // check for sizes and type
- if (params.sizes && Array.isArray(params.sizes)) {
- const bf = params.sizes.reduce(function(r, i) {
- // only push if it's an array of length 2
- if (Array.isArray(i) && i.length === 2) {
- r.push(`${i[0]}x${i[1]}`);
- }
- return r;
- }, []);
- data.bf = bf.toString();
+
+ if (params.zone) {
+ data.t = params.zone;
+ data.pi = 2; // inscreen
+ // override pi if the following is found
+ if (params.slot) {
+ data.si = parseInt(params.slot, 10);
+ data.pi = 3;
+ data.bf = sizes.reduce((acc, curSlotDim) => `${acc}${acc && ','}${curSlotDim[0]}x${curSlotDim[1]}`, '');
+ } else if (params.native) {
+ data.ni = parseInt(params.native, 10);
+ data.pi = 5;
+ } else if (mediaTypes.video) {
+ data.pi = mediaTypes.video.linearity === 1 ? 7 : 6; // video : invideo
}
- data.pi = 3;
- }
- if (params.ICV) {
- data.ni = parseInt(params.ICV, 10);
- data.pi = 5;
- }
- if (params.videoPubID) {
- data = Object.assign(data, _getVidParams(mediaTypes.video));
- data.pubId = params.videoPubID;
- data.pi = 7;
- }
- if (params.video) {
- data = Object.assign(data, _getVidParams(mediaTypes.video));
- data.t = params.video;
- data.pi = 7;
- }
- if (params.inVideo) {
- data = Object.assign(data, _getVidParams(mediaTypes.video));
- data.t = params.inVideo;
- data.pi = 6;
+ } else if (params.pubId) {
+ data.pubId = params.pubId
+ data.pi = mediaTypes.video ? 7 : 2; // video : inscreen
+ } else { // legacy params
+ data = { ...data, ...handleLegacyParams(params, sizes) }
}
+
if (gdprConsent) {
data.gdprApplies = gdprConsent.gdprApplies ? 1 : 0;
}
@@ -335,6 +322,40 @@ function buildRequests (validBidRequests, bidderRequest) {
return bids;
}
+function handleLegacyParams (params, sizes) {
+ const data = {};
+ if (params.inScreenPubID) {
+ data.pubId = params.inScreenPubID;
+ data.pi = 2;
+ }
+ if (params.inScreen) {
+ data.t = params.inScreen;
+ data.pi = 2;
+ }
+ if (params.inSlot) {
+ data.si = parseInt(params.inSlot, 10);
+ data.pi = 3;
+ data.bf = sizes.reduce((acc, curSlotDim) => `${acc}${acc && ','}${curSlotDim[0]}x${curSlotDim[1]}`, '');
+ }
+ if (params.ICV) {
+ data.ni = parseInt(params.ICV, 10);
+ data.pi = 5;
+ }
+ if (params.videoPubID) {
+ data.pubId = params.videoPubID;
+ data.pi = 7;
+ }
+ if (params.video) {
+ data.t = params.video;
+ data.pi = 7;
+ }
+ if (params.inVideo) {
+ data.t = params.inVideo;
+ data.pi = 6;
+ }
+ return data;
+}
+
/**
* Unpack the response from the server into a list of bids.
*
@@ -347,7 +368,7 @@ function interpretResponse (serverResponse, bidRequest) {
if (!serverResponseBody || serverResponseBody.err) {
const data = bidRequest.data || {}
- const id = data.t || data.si || data.ni || data.pubId;
+ const id = data.si || data.ni || data.t || data.pubId;
const delayTime = serverResponseBody ? serverResponseBody.err.drt : DELAY_REQUEST_TIME;
invalidRequestIds[id] = { productId: data.pi, timestamp: new Date().getTime() };
@@ -403,7 +424,7 @@ function interpretResponse (serverResponse, bidRequest) {
bidResponses.push({
// dealId: DEAL_ID,
// referrer: REFERER,
- ...(product === 7 && { vastXml: markup }),
+ ...(product === 7 && { vastXml: markup, mediaType: VIDEO }),
ad: wrapper ? getWrapperCode(wrapper, Object.assign({}, serverResponseBody, { bidRequest })) : markup,
...(product === 6 && {ad: markup}),
cpm: isTestUnit ? 0.1 : cpm,
diff --git a/modules/haloIdSystem.js b/modules/haloIdSystem.js
new file mode 100644
index 00000000000..d0eb79d4ac2
--- /dev/null
+++ b/modules/haloIdSystem.js
@@ -0,0 +1,63 @@
+/**
+ * This module adds HaloID to the User ID module
+ * The {@link module:modules/userId} module is required
+ * @module modules/haloIdSystem
+ * @requires module:modules/userId
+ */
+
+import * as utils from '../src/utils.js';
+import {ajax} from '../src/ajax.js';
+import {submodule} from '../src/hook.js';
+
+const MODULE_NAME = 'haloId';
+
+/** @type {Submodule} */
+export const haloIdSubmodule = {
+ /**
+ * used to link submodule with config
+ * @type {string}
+ */
+ name: MODULE_NAME,
+ /**
+ * decode the stored id value for passing to bid requests
+ * @function
+ * @param {{value:string}} value
+ * @returns {{haloId:Object}}
+ */
+ decode(value) {
+ return (value && typeof value['haloId'] === 'string') ? { 'haloId': value['haloId'] } : undefined;
+ },
+ /**
+ * performs action to obtain id and return a value in the callback's response argument
+ * @function
+ * @param {SubmoduleConfig} [config]
+ * @returns {IdResponse|undefined}
+ */
+ getId(config) {
+ const url = `https://id.halo.ad.gt/api/v1/pbhid`;
+
+ const resp = function (callback) {
+ const callbacks = {
+ success: response => {
+ let responseObj;
+ if (response) {
+ try {
+ responseObj = JSON.parse(response);
+ } catch (error) {
+ utils.logError(error);
+ }
+ }
+ callback(responseObj);
+ },
+ error: error => {
+ utils.logError(`${MODULE_NAME}: ID fetch encountered an error`, error);
+ callback();
+ }
+ };
+ ajax(url, callbacks, undefined, {method: 'GET'});
+ };
+ return {callback: resp};
+ }
+};
+
+submodule('userId', haloIdSubmodule);
diff --git a/modules/haloIdSystem.md b/modules/haloIdSystem.md
new file mode 100644
index 00000000000..0be0be27f5d
--- /dev/null
+++ b/modules/haloIdSystem.md
@@ -0,0 +1,32 @@
+## Audigent Halo User ID Submodule
+
+Audigent Halo ID Module. For assistance setting up your module please contact us at [prebid@audigent.com](prebid@audigent.com).
+
+### Prebid Params
+
+Individual params may be set for the Audigent Halo ID Submodule. At least one identifier must be set in the params.
+
+```
+pbjs.setConfig({
+ usersync: {
+ userIds: [{
+ name: 'haloId',
+ storage: {
+ name: 'haloId',
+ type: 'html5'
+ }
+ }]
+ }
+});
+```
+## Parameter Descriptions for the `usersync` Configuration Section
+The below parameters apply only to the HaloID User ID Module integration.
+
+| Param under usersync.userIds[] | Scope | Type | Description | Example |
+| --- | --- | --- | --- | --- |
+| name | Required | String | ID value for the HaloID module - `"haloId"` | `"haloId"` |
+| storage | Required | Object | The publisher must specify the local storage in which to store the results of the call to get the user ID. This can be either cookie or HTML5 storage. | |
+| storage.type | Required | String | This is where the results of the user ID will be stored. The recommended method is `localStorage` by specifying `html5`. | `"html5"` |
+| storage.name | Required | String | The name of the cookie or html5 local storage where the user ID will be stored. | `"haloid"` |
+| storage.expires | Optional | Integer | How long (in days) the user ID information will be stored. | `365` |
+| value | Optional | Object | Used only if the page has a separate mechanism for storing the Halo ID. The value is an object containing the values to be sent to the adapters. In this scenario, no URL is called and nothing is added to local storage | `{"haloId": "eb33b0cb-8d35-4722-b9c0-1a31d4064888"}` |
diff --git a/modules/id5IdSystem.js b/modules/id5IdSystem.js
index ae3c7e55863..f8ff50f52a3 100644
--- a/modules/id5IdSystem.js
+++ b/modules/id5IdSystem.js
@@ -39,25 +39,39 @@ export const id5IdSubmodule = {
* @returns {(Object|undefined)}
*/
decode(value) {
+ let uid;
+ let linkType = 0;
+
if (value && typeof value.ID5ID === 'string') {
// don't lose our legacy value from cache
- return { 'id5id': value.ID5ID };
+ uid = value.ID5ID;
} else if (value && typeof value.universal_uid === 'string') {
- return { 'id5id': value.universal_uid };
+ uid = value.universal_uid;
+ linkType = value.link_type || linkType;
} else {
return undefined;
}
+
+ return {
+ 'id5id': {
+ 'uid': uid,
+ 'ext': {
+ 'linkType': linkType
+ }
+ }
+ };
},
/**
* performs action to obtain id and return a value in the callback's response argument
* @function getId
- * @param {SubmoduleParams} [configParams]
- * @param {ConsentData} [consentData]
+ * @param {SubmoduleConfig} config
+ * @param {ConsentData} consentData
* @param {(Object|undefined)} cacheIdObj
* @returns {IdResponse|undefined}
*/
- getId(configParams, consentData, cacheIdObj) {
+ getId(config, consentData, cacheIdObj) {
+ const configParams = (config && config.params) || {};
if (!hasRequiredParams(configParams)) {
return undefined;
}
@@ -110,11 +124,12 @@ export const id5IdSubmodule = {
* If IdResponse#callback is defined, then it'll called at the end of auction.
* It's permissible to return neither, one, or both fields.
* @function extendId
- * @param {SubmoduleParams} configParams
+ * @param {SubmoduleConfig} config
* @param {Object} cacheIdObj - existing id, if any
* @return {(IdResponse|function(callback:function))} A response object that contains id and/or callback.
*/
- extendId(configParams, cacheIdObj) {
+ extendId(config, cacheIdObj) {
+ const configParams = (config && config.params) || {};
incrementNb(configParams);
return cacheIdObj;
}
diff --git a/modules/identityLinkIdSystem.js b/modules/identityLinkIdSystem.js
index 14c33329b2d..73fc6408581 100644
--- a/modules/identityLinkIdSystem.js
+++ b/modules/identityLinkIdSystem.js
@@ -34,10 +34,11 @@ export const identityLinkSubmodule = {
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {ConsentData} [consentData]
- * @param {SubmoduleParams} [configParams]
+ * @param {SubmoduleConfig} [config]
* @returns {IdResponse|undefined}
*/
- getId(configParams, consentData) {
+ getId(config, consentData) {
+ const configParams = (config && config.params) || {};
if (!configParams || typeof configParams.pid !== 'string') {
utils.logError('identityLink submodule requires partner id to be defined');
return;
diff --git a/modules/idxIdSystem.js b/modules/idxIdSystem.js
new file mode 100644
index 00000000000..00e8a8bc5e5
--- /dev/null
+++ b/modules/idxIdSystem.js
@@ -0,0 +1,61 @@
+/**
+ * This module adds IDx to the User ID module
+ * The {@link module:modules/userId} module is required
+ * @module modules/idxIdSystem
+ * @requires module:modules/userId
+ */
+import * as utils from '../src/utils.js'
+import { submodule } from '../src/hook.js';
+import { getStorageManager } from '../src/storageManager.js';
+
+const IDX_MODULE_NAME = 'idx';
+const IDX_COOKIE_NAME = '_idx';
+export const storage = getStorageManager();
+
+function readIDxFromCookie() {
+ return storage.cookiesAreEnabled ? storage.getCookie(IDX_COOKIE_NAME) : null;
+}
+
+function readIDxFromLocalStorage() {
+ return storage.localStorageIsEnabled ? storage.getDataFromLocalStorage(IDX_COOKIE_NAME) : null;
+}
+
+/** @type {Submodule} */
+export const idxIdSubmodule = {
+ /**
+ * used to link submodule with config
+ * @type {string}
+ */
+ name: IDX_MODULE_NAME,
+ /**
+ * decode the stored id value for passing to bid requests
+ * @function
+ * @param { Object | string | undefined } value
+ * @return { Object | string | undefined }
+ */
+ decode(value) {
+ const idxVal = value ? utils.isStr(value) ? value : utils.isPlainObject(value) ? value.id : undefined : undefined;
+ return idxVal ? {
+ 'idx': idxVal
+ } : undefined;
+ },
+ /**
+ * performs action to obtain id and return a value in the callback's response argument
+ * @function
+ * @param {SubmoduleConfig} config
+ * @return {{id: string | undefined } | undefined}
+ */
+ getId() {
+ const idxString = readIDxFromLocalStorage() || readIDxFromCookie();
+ if (typeof idxString == 'string' && idxString) {
+ try {
+ const idxObj = JSON.parse(idxString);
+ return idxObj && idxObj.idx ? { id: idxObj.idx } : undefined;
+ } catch (error) {
+ utils.logError(error);
+ }
+ }
+ return undefined;
+ }
+};
+submodule('userId', idxIdSubmodule);
diff --git a/modules/idxIdSystem.md b/modules/idxIdSystem.md
new file mode 100644
index 00000000000..363120899cb
--- /dev/null
+++ b/modules/idxIdSystem.md
@@ -0,0 +1,22 @@
+## IDx User ID Submodule
+
+For assistance setting up your module please contact us at [prebid@idx.lat](prebid@idx.lat).
+
+### Prebid Params
+
+Individual params may be set for the IDx Submodule.
+```
+pbjs.setConfig({
+ userSync: {
+ userIds: [{
+ name: 'idx',
+ }]
+ }
+});
+```
+## Parameter Descriptions for the `userSync` Configuration Section
+The below parameters apply only to the IDx integration.
+
+| Param under usersync.userIds[] | Scope | Type | Description | Example |
+| --- | --- | --- | --- | --- |
+| name | Required | String | ID of the module - `"idx"` | `"idx"` |
diff --git a/modules/inmarBidAdapter.js b/modules/inmarBidAdapter.js
new file mode 100755
index 00000000000..b5ab72266fc
--- /dev/null
+++ b/modules/inmarBidAdapter.js
@@ -0,0 +1,113 @@
+import * as utils from '../src/utils.js';
+import { config } from '../src/config.js';
+import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { BANNER, VIDEO } from '../src/mediaTypes.js';
+
+const BIDDER_CODE = 'inmar';
+
+export const spec = {
+ code: BIDDER_CODE,
+ aliases: ['inm'],
+ supportedMediaTypes: [BANNER, VIDEO],
+
+ /**
+ * Determines whether or not the given bid request is valid
+ *
+ * @param {bidRequest} bid The bid params to validate.
+ * @returns {boolean} True if this is a valid bid, and false otherwise
+ */
+ isBidRequestValid: function(bid) {
+ return !!(bid.params && bid.params.partnerId && bid.params.adnetId);
+ },
+
+ /**
+ * Build a server request from the list of valid BidRequests
+ * @param {validBidRequests} is an array of the valid bids
+ * @param {bidderRequest} bidder request object
+ * @returns {ServerRequest} Info describing the request to the server
+ */
+ buildRequests: function(validBidRequests, bidderRequest) {
+ var payload = {
+ bidderCode: bidderRequest.bidderCode,
+ auctionId: bidderRequest.auctionId,
+ bidderRequestId: bidderRequest.bidderRequestId,
+ bidRequests: validBidRequests,
+ auctionStart: bidderRequest.auctionStart,
+ timeout: bidderRequest.timeout,
+ refererInfo: bidderRequest.refererInfo,
+ start: bidderRequest.start,
+ gdprConsent: bidderRequest.gdprConsent,
+ uspConsent: bidderRequest.uspConsent,
+ currencyCode: config.getConfig('currency.adServerCurrency'),
+ coppa: config.getConfig('coppa'),
+ firstPartyData: config.getConfig('fpd'),
+ prebidVersion: '$prebid.version$'
+ };
+
+ var payloadString = JSON.stringify(payload);
+
+ return {
+ method: 'POST',
+ url: 'https://prebid.owneriq.net:8443/bidder/pb/bid',
+ options: {
+ withCredentials: false
+ },
+ data: payloadString,
+ };
+ },
+
+ /**
+ * Read the response from the server and build a list of bids
+ * @param {serverResponse} Response from the server.
+ * @param {bidRequest} Bid request object
+ * @returns {bidResponses} Array of bids which were nested inside the server
+ */
+ interpretResponse: function(serverResponse, bidRequest) {
+ const bidResponses = [];
+ var response = serverResponse.body;
+
+ try {
+ if (response) {
+ var bidResponse = {
+ requestId: response.requestId,
+ cpm: response.cpm,
+ currency: response.currency,
+ width: response.width,
+ height: response.height,
+ ad: response.ad,
+ ttl: response.ttl,
+ creativeId: response.creativeId,
+ netRevenue: response.netRevenue,
+ vastUrl: response.vastUrl,
+ dealId: response.dealId,
+ meta: response.meta
+ };
+
+ bidResponses.push(bidResponse);
+ }
+ } catch (error) {
+ utils.logError('Error while parsing inmar response', error);
+ }
+ return bidResponses;
+ },
+
+ /**
+ * User Syncs
+ *
+ * @param {syncOptions} Publisher prebid configuration
+ * @param {serverResponses} Response from the server
+ * @returns {Array}
+ */
+ getUserSyncs: function(syncOptions, serverResponses) {
+ const syncs = [];
+ if (syncOptions.pixelEnabled) {
+ syncs.push({
+ type: 'image',
+ url: 'https://px.owneriq.net/eucm/p/pb'
+ });
+ }
+ return syncs;
+ }
+};
+
+registerBidder(spec);
diff --git a/modules/inmarBidAdapter.md b/modules/inmarBidAdapter.md
new file mode 100644
index 00000000000..1bacb30f2dd
--- /dev/null
+++ b/modules/inmarBidAdapter.md
@@ -0,0 +1,46 @@
+# Overview
+
+```
+Module Name: Inmar Bidder Adapter
+Module Type: Bidder Adapter
+Maintainer: oiq_rtb@inmar.com
+```
+
+# Description
+
+Connects to Inmar for bids. This adapter supports Display and Video.
+
+The Inmar adapter requires setup and approval from the Inmar team.
+Please reach out to your account manager for more information.
+
+# Test Parameters
+
+## Web
+```
+ var adUnits = [
+ {
+ code: 'test-div1',
+ sizes: [[300, 250],[300, 600]],
+ bids: [{
+ bidder: 'inmar',
+ params: {
+ partnerId: 12345,
+ adnetId: 'ADb1f40rmi',
+ position: 1
+ }
+ }]
+ },
+ {
+ code: 'test-div2',
+ sizes: [[728, 90],[970, 250]],
+ bids: [{
+ bidder: 'inmar',
+ params: {
+ partnerId: 12345,
+ adnetId: 'ADb1f40rmo',
+ position: 0
+ }
+ }]
+ }
+ ];
+```
diff --git a/modules/instreamTracking.js b/modules/instreamTracking.js
new file mode 100644
index 00000000000..68bb4be79de
--- /dev/null
+++ b/modules/instreamTracking.js
@@ -0,0 +1,114 @@
+import { config } from '../src/config.js';
+import { auctionManager } from '../src/auctionManager.js';
+import { INSTREAM } from '../src/video.js';
+import * as events from '../src/events.js';
+import * as utils from '../src/utils.js';
+import { BID_STATUS, EVENTS, TARGETING_KEYS } from '../src/constants.json';
+
+const {CACHE_ID, UUID} = TARGETING_KEYS;
+const {BID_WON, AUCTION_END} = EVENTS;
+const {RENDERED} = BID_STATUS;
+
+const INSTREAM_TRACKING_DEFAULT_CONFIG = {
+ enabled: false,
+ maxWindow: 1000 * 60, // the time in ms after which polling for instream delivery stops
+ pollingFreq: 500 // the frequency of polling
+};
+
+// Set instreamTracking default values
+config.setDefaults({
+ 'instreamTracking': utils.deepClone(INSTREAM_TRACKING_DEFAULT_CONFIG)
+});
+
+const whitelistedResources = /video|fetch|xmlhttprequest|other/;
+
+/**
+ * Here the idea is
+ * find all network entries via performance.getEntriesByType()
+ * filter it by video cache key in the url
+ * and exclude the ad server urls so that we dont match twice
+ * eg:
+ * dfp ads call: https://securepubads.g.doubleclick.net/gampad/ads?...hb_cache_id%3D55e85cd3-6ea4-4469-b890-84241816b131%26...
+ * prebid cache url: https://prebid.adnxs.com/pbc/v1/cache?uuid=55e85cd3-6ea4-4469-b890-84241816b131
+ *
+ * if the entry exists, emit the BID_WON
+ *
+ * Note: this is a workaround till a better approach is engineered.
+ *
+ * @param {Array} adUnits
+ * @param {Array} bidsReceived
+ * @param {Array} bidderRequests
+ *
+ * @return {boolean} returns TRUE if tracking started
+ */
+export function trackInstreamDeliveredImpressions({adUnits, bidsReceived, bidderRequests}) {
+ const instreamTrackingConfig = config.getConfig('instreamTracking') || {};
+ // check if instreamTracking is enabled and performance api is available
+ if (!instreamTrackingConfig.enabled || !window.performance || !window.performance.getEntriesByType) {
+ return false;
+ }
+
+ // filter for video bids
+ const instreamBids = bidsReceived.filter(bid => {
+ const bidderRequest = utils.getBidRequest(bid.requestId, bidderRequests);
+ return bidderRequest && utils.deepAccess(bidderRequest, 'mediaTypes.video.context') === INSTREAM && bid.videoCacheKey;
+ });
+ if (!instreamBids.length) {
+ return false;
+ }
+
+ // find unique instream ad units
+ const instreamAdUnitMap = {};
+ adUnits.forEach(adUnit => {
+ if (!instreamAdUnitMap[adUnit.code] && utils.deepAccess(adUnit, 'mediaTypes.video.context') === INSTREAM) {
+ instreamAdUnitMap[adUnit.code] = true;
+ }
+ });
+ const instreamAdUnitsCount = Object.keys(instreamAdUnitMap).length;
+
+ const start = Date.now();
+ const {maxWindow, pollingFreq, urlPattern} = instreamTrackingConfig;
+
+ let instreamWinningBidsCount = 0;
+ let lastRead = 0; // offset for performance.getEntriesByType
+
+ function poll() {
+ // get network entries using the last read offset
+ const entries = window.performance.getEntriesByType('resource').splice(lastRead);
+ for (const resource of entries) {
+ const url = resource.name;
+ // check if the resource is of whitelisted resource to avoid checking img or css or script urls
+ if (!whitelistedResources.test(resource.initiatorType)) {
+ continue;
+ }
+
+ instreamBids.forEach((bid) => {
+ // match the video cache key excluding ad server call
+ const matches = !(url.indexOf(CACHE_ID) !== -1 || url.indexOf(UUID) !== -1) && url.indexOf(bid.videoCacheKey) !== -1;
+ if (urlPattern && urlPattern instanceof RegExp && !urlPattern.test(url)) {
+ return;
+ }
+ if (matches && bid.status !== RENDERED) {
+ // video found
+ instreamWinningBidsCount++;
+ auctionManager.addWinningBid(bid);
+ events.emit(BID_WON, bid);
+ }
+ });
+ }
+ // update offset
+ lastRead += entries.length;
+
+ const timeElapsed = Date.now() - start;
+ if (timeElapsed < maxWindow && instreamWinningBidsCount < instreamAdUnitsCount) {
+ setTimeout(poll, pollingFreq);
+ }
+ }
+
+ // start polling for network entries
+ setTimeout(poll, pollingFreq);
+
+ return true;
+}
+
+events.on(AUCTION_END, trackInstreamDeliveredImpressions)
diff --git a/modules/intentIqIdSystem.js b/modules/intentIqIdSystem.js
index 7d497ea9b1a..c22a6dbc7aa 100644
--- a/modules/intentIqIdSystem.js
+++ b/modules/intentIqIdSystem.js
@@ -1,68 +1,94 @@
-/**
- * This module adds IntentIqId to the User ID module
- * The {@link module:modules/userId} module is required
- * @module modules/intentIqIdSystem
- * @requires module:modules/userId
- */
-
-import * as utils from '../src/utils.js'
-import {ajax} from '../src/ajax.js';
-import {submodule} from '../src/hook.js'
-
-const MODULE_NAME = 'intentIqId';
-
-/** @type {Submodule} */
-export const intentIqIdSubmodule = {
- /**
- * used to link submodule with config
- * @type {string}
- */
- name: MODULE_NAME,
- /**
- * decode the stored id value for passing to bid requests
- * @function
- * @param {{ctrid:string}} value
- * @returns {{intentIqId:string}}
- */
- decode(value) {
- return (value && typeof value['ctrid'] === 'string') ? { 'intentIqId': value['ctrid'] } : undefined;
- },
- /**
- * performs action to obtain id and return a value in the callback's response argument
- * @function
- * @param {SubmoduleParams} [configParams]
- * @returns {IdResponse|undefined}
- */
- getId(configParams) {
- if (!configParams || typeof configParams.partner !== 'number') {
- utils.logError('User ID - intentIqId submodule requires a valid partner to be defined');
- return;
- }
-
- // use protocol relative urls for http or https
- const url = `https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=${configParams.partner}&pt=17&dpn=1`;
- const resp = function (callback) {
- const callbacks = {
- success: response => {
- let responseObj;
- if (response) {
- try {
- responseObj = JSON.parse(response);
- } catch (error) {
- utils.logError(error);
- }
- }
- callback(responseObj);
- },
- error: error => {
- utils.logError(`${MODULE_NAME}: ID fetch encountered an error`, error);
- callback();
- }
- };
- ajax(url, callbacks, undefined, {method: 'GET', withCredentials: true});
- };
- return {callback: resp};
- }
-};
-
-submodule('userId', intentIqIdSubmodule);
+/**
+ * This module adds IntentIqId to the User ID module
+ * The {@link module:modules/userId} module is required
+ * @module modules/intentIqIdSystem
+ * @requires module:modules/userId
+ */
+
+import * as utils from '../src/utils.js'
+import {ajax} from '../src/ajax.js';
+import {submodule} from '../src/hook.js'
+
+const MODULE_NAME = 'intentIqId';
+
+const NOT_AVAILABLE = 'NA';
+
+/**
+ * Verify the id is valid - Id value or Not Found (ignore not available response)
+ * @param id
+ * @returns {boolean|*|boolean}
+ */
+function isValidId(id) {
+ return id && id != '' && id != NOT_AVAILABLE && isValidResponse(id);
+}
+
+/**
+ * Ignore not available response JSON
+ * @param obj
+ * @returns {boolean}
+ */
+function isValidResponse(obj) {
+ try {
+ obj = JSON.parse(obj);
+ return obj && obj['RESULT'] != NOT_AVAILABLE;
+ } catch (error) {
+ utils.logError(error);
+ return true;
+ }
+}
+
+/** @type {Submodule} */
+export const intentIqIdSubmodule = {
+ /**
+ * used to link submodule with config
+ * @type {string}
+ */
+ name: MODULE_NAME,
+ /**
+ * decode the stored id value for passing to bid requests
+ * @function
+ * @param {{string}} value
+ * @returns {{intentIqId: {string}}|undefined}
+ */
+ decode(value) {
+ return isValidId(value) ? { 'intentIqId': value } : undefined;
+ },
+ /**
+ * performs action to obtain id and return a value in the callback's response argument
+ * @function
+ * @param {SubmoduleConfig} [config]
+ * @returns {IdResponse|undefined}
+ */
+ getId(config) {
+ const configParams = (config && config.params) || {};
+ if (!configParams || typeof configParams.partner !== 'number') {
+ utils.logError('User ID - intentIqId submodule requires a valid partner to be defined');
+ return;
+ }
+
+ // use protocol relative urls for http or https
+ let url = `https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=${configParams.partner}&pt=17&dpn=1`;
+ url += configParams.pcid ? '&pcid=' + encodeURIComponent(configParams.pcid) : '';
+ url += configParams.pai ? '&pai=' + encodeURIComponent(configParams.pai) : '';
+
+ const resp = function (callback) {
+ const callbacks = {
+ success: response => {
+ if (isValidId(response)) {
+ callback(response);
+ } else {
+ callback();
+ }
+ },
+ error: error => {
+ utils.logError(`${MODULE_NAME}: ID fetch encountered an error`, error);
+ callback();
+ }
+ };
+ ajax(url, callbacks, undefined, {method: 'GET', withCredentials: true});
+ };
+ return {callback: resp};
+ }
+};
+
+submodule('userId', intentIqIdSubmodule);
diff --git a/modules/ironsourceBidAdapter.js b/modules/ironsourceBidAdapter.js
index 34650d46a0f..922e7b94c5b 100644
--- a/modules/ironsourceBidAdapter.js
+++ b/modules/ironsourceBidAdapter.js
@@ -7,7 +7,11 @@ const SUPPORTED_AD_TYPES = [VIDEO];
const BIDDER_CODE = 'ironsource';
const BIDDER_VERSION = '4.0.0';
const TTL = 360;
-const SELLER_ENDPOINT = 'https://hb.yellowblue.io/hb';
+const SELLER_ENDPOINT = 'https://hb.yellowblue.io/';
+const MODES = {
+ PRODUCTION: 'hb',
+ TEST: 'hb-test'
+}
const SUPPORTED_SYNC_METHODS = {
IFRAME: 'iframe',
PIXEL: 'pixel'
@@ -86,9 +90,10 @@ registerBidder(spec);
*/
function buildVideoRequest(bid, bidderRequest) {
const sellerParams = generateParameters(bid, bidderRequest);
+ const {params} = bid;
return {
method: 'GET',
- url: SELLER_ENDPOINT,
+ url: getEndpoint(params.testMode),
data: sellerParams
};
}
@@ -169,6 +174,17 @@ function isSyncMethodAllowed(syncRule, bidderCode) {
return isInclude && utils.contains(bidders, bidderCode);
}
+/**
+ * Get the seller endpoint
+ * @param testMode {boolean}
+ * @returns {string}
+ */
+function getEndpoint(testMode) {
+ return testMode
+ ? SELLER_ENDPOINT + MODES.TEST
+ : SELLER_ENDPOINT + MODES.PRODUCTION;
+}
+
/**
* Generate query parameters for the request
* @param bid {bid}
diff --git a/modules/ironsourceBidAdapter.md b/modules/ironsourceBidAdapter.md
index 2f9e38b69e8..86756b08809 100644
--- a/modules/ironsourceBidAdapter.md
+++ b/modules/ironsourceBidAdapter.md
@@ -23,6 +23,7 @@ The adapter supports Video(instream). For the integration, IronSource returns co
| `isOrg` | required | String | IronSource publisher Id provided by your IronSource representative | "56f91cd4d3e3660002000033"
| `floorPrice` | optional | Number | Minimum price in USD. Misuse of this parameter can impact revenue | 2.00
| `ifa` | optional | String | The ID for advertisers (also referred to as "IDFA") | "XXX-XXX"
+| `testMode` | optional | Boolean | This activates the test mode | false
# Test Parameters
```javascript
@@ -42,6 +43,7 @@ var adUnits = [
isOrg: '56f91cd4d3e3660002000033', // Required
floorPrice: 2.00, // Optional
ifa: 'XXX-XXX', // Optional
+ testMode: false // Optional
}
}]
}
diff --git a/modules/jixieBidAdapter.js b/modules/jixieBidAdapter.js
new file mode 100644
index 00000000000..d3ae090964c
--- /dev/null
+++ b/modules/jixieBidAdapter.js
@@ -0,0 +1,254 @@
+import * as utils from '../src/utils.js';
+import { config } from '../src/config.js';
+import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { getStorageManager } from '../src/storageManager.js';
+import { BANNER, VIDEO } from '../src/mediaTypes.js';
+import { ajax } from '../src/ajax.js';
+import { getRefererInfo } from '../src/refererDetection.js';
+import { Renderer } from '../src/Renderer.js';
+export const storage = getStorageManager();
+
+const BIDDER_CODE = 'jixie';
+const EVENTS_URL = 'https://jxhbtrackers.azurewebsites.net/sync/evt?';
+const JX_OUTSTREAM_RENDERER_URL = 'https://scripts.jixie.io/jxhboutstream.js';
+const REQUESTS_URL = 'https://hb.jixie.io/v2/hbpost';
+const sidTTLMins_ = 30;
+
+/**
+ * Own miscellaneous support functions:
+ */
+
+function setIds_(clientId, sessionId) {
+ let dd = null;
+ try {
+ dd = window.location.hostname.match(/[^.]*\.[^.]{2,3}(?:\.[^.]{2,3})?$/mg);
+ } catch (err1) {}
+ try {
+ let expC = (new Date(new Date().setFullYear(new Date().getFullYear() + 1))).toUTCString();
+ let expS = (new Date(new Date().setMinutes(new Date().getMinutes() + sidTTLMins_))).toUTCString();
+
+ storage.setCookie('_jx', clientId, expC, 'None', null);
+ storage.setCookie('_jx', clientId, expC, 'None', dd);
+
+ storage.setCookie('_jxs', sessionId, expS, 'None', null);
+ storage.setCookie('_jxs', sessionId, expS, 'None', dd);
+
+ storage.setDataInLocalStorage('_jx', clientId);
+ storage.setDataInLocalStorage('_jxs', sessionId);
+ } catch (error) {}
+}
+
+function fetchIds_() {
+ let ret = {
+ client_id_c: '',
+ client_id_ls: '',
+ session_id_c: '',
+ session_id_ls: ''
+ };
+ try {
+ let tmp = storage.getCookie('_jx');
+ if (tmp) ret.client_id_c = tmp;
+ tmp = storage.getCookie('_jxs');
+ if (tmp) ret.session_id_c = tmp;
+
+ tmp = storage.getDataFromLocalStorage('_jx');
+ if (tmp) ret.client_id_ls = tmp;
+ tmp = storage.getDataFromLocalStorage('_jxs');
+ if (tmp) ret.session_id_ls = tmp;
+ } catch (error) {}
+ return ret;
+}
+
+function getDevice_() {
+ return ((/(ios|ipod|ipad|iphone|android|blackberry|iemobile|opera mini|webos)/i).test(navigator.userAgent)
+ ? 'mobile' : 'desktop');
+}
+
+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({
+ sizes: [bidAd.width, bidAd.height],
+ width: bidAd.width,
+ height: bidAd.height,
+ targetId: bidAd.adUnitCode,
+ adResponse: bidAd.adResponse
+ });
+ });
+}
+
+function createRenderer_(bidAd, scriptUrl, createFcn) {
+ const renderer = Renderer.install({
+ id: bidAd.adUnitCode,
+ url: scriptUrl,
+ loaded: false,
+ config: {'player_height': bidAd.height, 'player_width': bidAd.width},
+ adUnitCode: bidAd.adUnitCode
+ });
+ try {
+ renderer.setRender(createFcn);
+ } catch (err) {
+ utils.logWarn('Prebid Error calling setRender on renderer', err);
+ }
+ return renderer;
+}
+
+function getMiscDims_() {
+ let ret = {
+ pageurl: '',
+ domain: '',
+ device: 'unknown'
+ }
+ try {
+ let refererInfo_ = getRefererInfo();
+ let url_ = ((refererInfo_ && refererInfo_.referer) ? refererInfo_.referer : window.location.href);
+ ret.pageurl = url_;
+ ret.domain = utils.parseUrl(url_).host;
+ ret.device = getDevice_();
+ } catch (error) {}
+ return ret;
+}
+
+// easier for replacement in the unit test
+export const internal = {
+ getDevice: getDevice_,
+ getRefererInfo: getRefererInfo,
+ ajax: ajax,
+ getMiscDims: getMiscDims_
+};
+
+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') {
+ return false;
+ }
+ if (typeof bid.params.unit === 'undefined') {
+ return false;
+ }
+ return true;
+ },
+ buildRequests: function(validBidRequests, bidderRequest) {
+ const currencyObj = config.getConfig('currency');
+ const currency = (currencyObj && currencyObj.adServerCurrency) || 'USD';
+
+ let bids = [];
+ validBidRequests.forEach(function(one) {
+ bids.push({
+ bidId: one.bidId,
+ adUnitCode: one.adUnitCode,
+ mediaTypes: (one.mediaTypes === 'undefined' ? {} : one.mediaTypes),
+ sizes: (one.sizes === 'undefined' ? [] : one.sizes),
+ params: one.params,
+ });
+ });
+
+ let jixieCfgBlob = config.getConfig('jixie');
+ if (!jixieCfgBlob) {
+ jixieCfgBlob = {};
+ }
+
+ let ids = fetchIds_();
+ let miscDims = internal.getMiscDims();
+ let transformedParams = Object.assign({}, {
+ auctionid: bidderRequest.auctionId,
+ timeout: bidderRequest.timeout,
+ currency: currency,
+ timestamp: (new Date()).getTime(),
+ device: miscDims.device,
+ domain: miscDims.domain,
+ pageurl: miscDims.pageurl,
+ bids: bids,
+ cfg: jixieCfgBlob
+ }, ids);
+ return Object.assign({}, {
+ method: 'POST',
+ url: REQUESTS_URL,
+ data: JSON.stringify(transformedParams),
+ currency: currency
+ });
+ },
+
+ 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: utils.deepAccess(timeoutData, '0.auctionId'),
+ timeout: utils.deepAccess(timeoutData, '0.timeout'),
+ count: timeoutData.length
+ });
+ },
+
+ 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
+ });
+ }
+ },
+
+ interpretResponse: function(response, bidRequest) {
+ if (response && response.body && utils.isArray(response.body.bids)) {
+ const bidResponses = [];
+ response.body.bids.forEach(function(oneBid) {
+ let bnd = {};
+
+ Object.assign(bnd, oneBid);
+ if (oneBid.osplayer) {
+ bnd.adResponse = {
+ content: oneBid.vastXml,
+ parameters: oneBid.osparams,
+ height: oneBid.height,
+ width: oneBid.width
+ };
+ let rendererScript = (oneBid.osparams.script ? oneBid.osparams.script : JX_OUTSTREAM_RENDERER_URL);
+ bnd.renderer = createRenderer_(oneBid, rendererScript, jxOutstreamRender_);
+ }
+ bidResponses.push(bnd);
+ });
+ if (response.body.setids) {
+ setIds_(response.body.setids.client_id,
+ response.body.setids.session_id);
+ }
+ return bidResponses;
+ } else { return []; }
+ }
+}
+
+registerBidder(spec);
diff --git a/modules/jixieBidAdapter.md b/modules/jixieBidAdapter.md
new file mode 100644
index 00000000000..d9c1f19541d
--- /dev/null
+++ b/modules/jixieBidAdapter.md
@@ -0,0 +1,73 @@
+# Overview
+
+Module Name: Jixie Bidder Adapter
+Module Type: Bidder Adapter
+Maintainer: contact@jixie.io
+
+# Description
+
+Module that connects to Jixie demand source to fetch bids.
+
+# Test Parameters
+```
+ var adUnits = [
+ {
+ code: 'demoslot1-div',
+ mediaTypes: {
+ banner: {
+ sizes: [
+ [300, 250]
+ ]
+ }
+ },
+ bids: [
+ {
+ bidder: 'jixie',
+ params: {
+ unit: "prebidsampleunit"
+ }
+ }
+ ]
+ },
+ {
+ code: 'demoslot2-div',
+ sizes: [640, 360],
+ mediaTypes: {
+ video: {
+ playerSize: [
+ [640, 360]
+ ],
+ context: "outstream"
+ }
+ },
+ bids: [
+ {
+ bidder: 'jixie',
+ params: {
+ unit: "prebidsampleunit"
+ }
+ }
+ ]
+ },
+ {
+ code: 'demoslot3-div',
+ sizes: [640, 360],
+ mediaTypes: {
+ video: {
+ playerSize: [
+ [640, 360]
+ ],
+ context: "instream"
+ }
+ },
+ bids: [
+ {
+ bidder: 'jixie',
+ params: {
+ unit: "prebidsampleunit"
+ }
+ }
+ ]
+ }
+ ];
+```
\ No newline at end of file
diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js
index bd2638e5936..7981b62dc51 100644
--- a/modules/liveIntentIdSystem.js
+++ b/modules/liveIntentIdSystem.js
@@ -100,10 +100,11 @@ export const liveIntentIdSubmodule = {
* `publisherId` params.
* @function
* @param {{unifiedId:string}} value
- * @param {SubmoduleParams|undefined} [configParams]
+ * @param {SubmoduleConfig|undefined} config
* @returns {{lipb:Object}}
*/
- decode(value, configParams) {
+ decode(value, config) {
+ const configParams = (config && config.params) || {};
function composeIdObject(value) {
const base = { 'lipbid': value['unifiedId'] };
delete value.unifiedId;
@@ -121,10 +122,11 @@ export const liveIntentIdSubmodule = {
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
- * @param {SubmoduleParams} [configParams]
+ * @param {SubmoduleConfig} [config]
* @returns {IdResponse|undefined}
*/
- getId(configParams) {
+ getId(config) {
+ const configParams = (config && config.params) || {};
const liveConnect = initializeLiveConnect(configParams);
if (!liveConnect) {
return;
diff --git a/modules/livewrappedAnalyticsAdapter.js b/modules/livewrappedAnalyticsAdapter.js
index 4b1c162c67c..9f571cb5ae0 100644
--- a/modules/livewrappedAnalyticsAdapter.js
+++ b/modules/livewrappedAnalyticsAdapter.js
@@ -62,7 +62,7 @@ let livewrappedAnalyticsAdapter = Object.assign(adapter({EMPTYURL, ANALYTICSTYPE
bidResponse.cpm = args.cpm;
bidResponse.ttr = args.timeToRespond;
bidResponse.readyToSend = 1;
- bidResponse.mediaType = args.mediaType == 'native' ? 2 : 1;
+ bidResponse.mediaType = args.mediaType == 'native' ? 2 : (args.mediaType == 'video' ? 4 : 1);
if (!bidResponse.ttr) {
bidResponse.ttr = time - bidResponse.start;
}
diff --git a/modules/livewrappedBidAdapter.js b/modules/livewrappedBidAdapter.js
index 78b29ab5016..0a5464fd21f 100644
--- a/modules/livewrappedBidAdapter.js
+++ b/modules/livewrappedBidAdapter.js
@@ -2,18 +2,18 @@ import * as utils from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import find from 'core-js-pure/features/array/find.js';
-import { BANNER, NATIVE } from '../src/mediaTypes.js';
+import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { getStorageManager } from '../src/storageManager.js';
export const storage = getStorageManager();
const BIDDER_CODE = 'livewrapped';
export const URL = 'https://lwadm.com/ad';
-const VERSION = '1.3';
+const VERSION = '1.4';
export const spec = {
code: BIDDER_CODE,
- supportedMediaTypes: [BANNER, NATIVE],
+ supportedMediaTypes: [BANNER, NATIVE, VIDEO],
/**
* Determines whether or not the given bid request is valid.
@@ -129,7 +129,12 @@ export const spec = {
if (ad.native) {
bidResponse.native = ad.native;
- bidResponse.mediaType = NATIVE
+ bidResponse.mediaType = NATIVE;
+ }
+
+ if (ad.video) {
+ bidResponse.mediaType = VIDEO;
+ bidResponse.vastXml = ad.tag;
}
bidResponses.push(bidResponse);
@@ -218,7 +223,9 @@ function bidToAdRequest(bid) {
adRequest.native = utils.deepAccess(bid, 'mediaTypes.native');
- if (adRequest.native && utils.deepAccess(bid, 'mediaTypes.banner')) {
+ adRequest.video = utils.deepAccess(bid, 'mediaTypes.video');
+
+ if ((adRequest.native || adRequest.video) && utils.deepAccess(bid, 'mediaTypes.banner')) {
adRequest.banner = true;
}
@@ -270,7 +277,7 @@ function handleEids(bidRequests) {
const bidRequest = bidRequests[0];
if (bidRequest && bidRequest.userId) {
AddExternalUserId(eids, utils.deepAccess(bidRequest, `userId.pubcid`), 'pubcommon', 1); // Also add this to eids
- AddExternalUserId(eids, utils.deepAccess(bidRequest, `userId.id5id`), 'id5-sync.com', 1);
+ AddExternalUserId(eids, utils.deepAccess(bidRequest, `userId.id5id.uid`), 'id5-sync.com', 1);
}
if (eids.length > 0) {
return {user: {ext: {eids}}};
diff --git a/modules/livewrappedBidAdapter.md b/modules/livewrappedBidAdapter.md
index 15e3e8d533a..c5d867af8fe 100644
--- a/modules/livewrappedBidAdapter.md
+++ b/modules/livewrappedBidAdapter.md
@@ -8,7 +8,7 @@
Connects to Livewrapped Header Bidding wrapper for bids.
-Livewrapped supports banner.
+Livewrapped supports banner, native and video.
# Test Parameters
diff --git a/modules/logicadBidAdapter.js b/modules/logicadBidAdapter.js
index 74c00ee39d6..0bf6b886dee 100644
--- a/modules/logicadBidAdapter.js
+++ b/modules/logicadBidAdapter.js
@@ -1,12 +1,12 @@
import {registerBidder} from '../src/adapters/bidderFactory.js';
-import {BANNER} from '../src/mediaTypes.js';
+import {BANNER, NATIVE} from '../src/mediaTypes.js';
const BIDDER_CODE = 'logicad';
const ENDPOINT_URL = 'https://pb.ladsp.com/adrequest/prebid';
export const spec = {
code: BIDDER_CODE,
- supportedMediaTypes: [BANNER],
+ supportedMediaTypes: [BANNER, NATIVE],
isBidRequestValid: function (bid) {
return !!(bid.params && bid.params.tid);
},
diff --git a/modules/logicadBidAdapter.md b/modules/logicadBidAdapter.md
index 32d40a7d3cd..de439f3f8c2 100644
--- a/modules/logicadBidAdapter.md
+++ b/modules/logicadBidAdapter.md
@@ -11,15 +11,48 @@ Currently module supports only banner mediaType.
# Test Parameters
```
- var adUnits = [{
- code: 'test-code',
- sizes: [[300, 250],[300, 600]],
- bids: [{
- bidder: 'logicad',
- params: {
- tid: 'test',
- page: 'url',
- }
- }]
- }];
+var adUnits = [
+ // Banner adUnit
+ {
+ code: 'test-code',
+ sizes: [[300, 250], [300, 600]],
+ mediaTypes: {
+ banner: {
+ sizes: [[300, 250], [300, 600]]
+ }
+ },
+ bids: [{
+ bidder: 'logicad',
+ params: {
+ tid: 'lfp-test-banner',
+ page: 'url'
+ }
+ }]
+ },
+ // Native adUnit
+ {
+ code: 'test-native-code',
+ sizes: [[1, 1]],
+ mediaTypes: {
+ native: {
+ title: {
+ required: true
+ },
+ image: {
+ required: true
+ },
+ sponsoredBy: {
+ required: true
+ }
+ }
+ },
+ bids: [{
+ bidder: 'logicad',
+ params: {
+ tid: 'lfp-test-native',
+ page: 'url'
+ }
+ }]
+ }
+];
```
diff --git a/modules/lotamePanoramaIdSystem.js b/modules/lotamePanoramaIdSystem.js
index cdf9131dd68..5c3a9a16b3a 100644
--- a/modules/lotamePanoramaIdSystem.js
+++ b/modules/lotamePanoramaIdSystem.js
@@ -152,21 +152,22 @@ export const lotamePanoramaIdSubmodule = {
* Decode the stored id value for passing to bid requests
* @function decode
* @param {(Object|string)} value
+ * @param {SubmoduleConfig|undefined} config
* @returns {(Object|undefined)}
*/
- decode(value, configParams) {
+ decode(value, config) {
return utils.isStr(value) ? { 'lotamePanoramaId': value } : undefined;
},
/**
* Retrieve the Lotame Panorama Id
* @function
- * @param {SubmoduleParams} [configParams]
+ * @param {SubmoduleConfig} [config]
* @param {ConsentData} [consentData]
* @param {(Object|undefined)} cacheIdObj
* @returns {IdResponse|undefined}
*/
- getId(configParams, consentData, cacheIdObj) {
+ getId(config, consentData, cacheIdObj) {
let localCache = getLotameLocalCache();
let refreshNeeded = Date.now() > localCache.expiryTimestampMs;
diff --git a/modules/luponmediaBidAdapter.js b/modules/luponmediaBidAdapter.js
index 0a2eed0ad13..4f7fd2ae1a0 100644
--- a/modules/luponmediaBidAdapter.js
+++ b/modules/luponmediaBidAdapter.js
@@ -2,6 +2,7 @@ import * as utils from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {config} from '../src/config.js';
import {BANNER} from '../src/mediaTypes.js';
+import { ajax } from '../src/ajax.js';
const BIDDER_CODE = 'luponmedia';
const ENDPOINT_URL = 'https://rtb.adxpremium.services/openrtb2/auction';
@@ -113,6 +114,19 @@ export const spec = {
hasSynced = true;
return allUserSyncs;
},
+ onBidWon: bid => {
+ const bidString = JSON.stringify(bid);
+ spec.sendWinningsToServer(bidString);
+ },
+ sendWinningsToServer: data => {
+ let mutation = `mutation {createWin(input: {win: {eventData: "${window.btoa(data)}"}}) {win {createTime } } }`;
+ let dataToSend = JSON.stringify({ query: mutation });
+
+ ajax('https://analytics.adxpremium.services/graphql', null, dataToSend, {
+ contentType: 'application/json',
+ method: 'POST'
+ });
+ }
};
function newOrtbBidRequest(bidRequest, bidderRequest, currentImps) {
diff --git a/modules/malltvBidAdapter.js b/modules/malltvBidAdapter.js
index 4cdb5d45328..846935a5522 100644
--- a/modules/malltvBidAdapter.js
+++ b/modules/malltvBidAdapter.js
@@ -1,4 +1,5 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';
+import { BANNER, VIDEO } from '../src/mediaTypes.js';
const BIDDER_CODE = 'malltv';
const ENDPOINT_URL = 'https://central.mall.tv/bid';
@@ -7,6 +8,7 @@ const SIZE_SEPARATOR = ';';
export const spec = {
code: BIDDER_CODE,
+ supportedMediaTypes: [BANNER, VIDEO],
/**
* Determines whether or not the given bid request is valid.
*
@@ -23,31 +25,48 @@ export const spec = {
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (validBidRequests, bidderRequest) {
- let response = validBidRequests.map(bidRequest => {
- let sizes = generateSizeParam(bidRequest.sizes);
- let propertyId = bidRequest.params.propertyId;
- let placementId = bidRequest.params.placementId;
+ let propertyId = '';
+ let pageViewGuid = '';
+ let storageId = '';
+ let bidderRequestId = '';
+ let url = '';
+ let contents = [];
+
+ let placements = validBidRequests.map(bidRequest => {
+ if (!propertyId) { propertyId = bidRequest.params.propertyId; }
+ if (!pageViewGuid && bidRequest.params) { pageViewGuid = bidRequest.params.pageViewGuid || ''; }
+ if (!storageId && bidRequest.params) { storageId = bidRequest.params.storageId || ''; }
+ if (!bidderRequestId) { bidderRequestId = bidRequest.bidderRequestId; }
+ if (!url && bidderRequest) { url = bidderRequest.refererInfo.referer; }
+ if (!contents.length && bidRequest.params.contents && bidRequest.params.contents.length) { contents = bidRequest.params.contents }
+
let adUnitId = bidRequest.adUnitCode;
- let pageViewGuid = bidRequest.params.pageViewGuid || '';
- let contents = bidRequest.params.contents || [];
- const body = {
+ let placementId = bidRequest.params.placementId;
+ let sizes = generateSizeParam(bidRequest.sizes);
+
+ return {
sizes: sizes,
adUnitId: adUnitId,
placementId: placementId,
- propertyId: propertyId,
- pageViewGuid: pageViewGuid,
- url: bidderRequest ? bidderRequest.refererInfo.referer : '',
- requestid: bidRequest.bidderRequestId,
bidid: bidRequest.bidId,
- contents: contents
- };
- return {
- method: 'POST',
- url: ENDPOINT_URL,
- data: body
};
});
- return response
+
+ let body = {
+ propertyId: propertyId,
+ pageViewGuid: pageViewGuid,
+ storageId: storageId,
+ url: url,
+ requestid: bidderRequestId,
+ placements: placements,
+ contents: contents
+ }
+
+ return [{
+ method: 'POST',
+ url: ENDPOINT_URL,
+ data: body
+ }];
},
/**
* Unpack the response from the server into a list of bids.
@@ -55,13 +74,12 @@ export const spec = {
* @param {ServerResponse} serverResponse A successful response from the server.
* @return {Bid[]} An array of bids which were nested inside the server.
*/
- interpretResponse: function (serverResponse, bidRequest) {
- window.adnResponse = serverResponse;
+ interpretResponse: function (serverResponse) {
const responses = serverResponse.body;
const bidResponses = [];
for (var i = 0; i < responses.length; i++) {
const bidResponse = {
- requestId: bidRequest.data.bidid,
+ requestId: responses[i].BidId,
cpm: responses[i].CPM,
width: responses[i].Width,
height: responses[i].Height,
@@ -70,7 +88,9 @@ export const spec = {
netRevenue: responses[i].NetRevenue,
ttl: responses[i].TTL,
referrer: responses[i].Referrer,
- ad: responses[i].Ad
+ ad: responses[i].Ad,
+ vastUrl: responses[i].VastUrl,
+ mediaType: responses[i].MediaType
};
bidResponses.push(bidResponse);
}
diff --git a/modules/malltvBidAdapter.md b/modules/malltvBidAdapter.md
index 72db0cef6c7..3d419fa0916 100644
--- a/modules/malltvBidAdapter.md
+++ b/modules/malltvBidAdapter.md
@@ -28,22 +28,16 @@ var adUnits = [
{
code: 'test-div',
mediaTypes: {
- banner: {
- sizes: [[300, 250], [300, 300]]
- }
+ video: {
+ context: 'instream'
+ }
},
bids: [
{
bidder: 'malltv',
params: {
propertyId: '105134',
- placementId: '846832',
- contents: [ //optional
- {
- type: 'video',
- id: '123'
- }
- ]
+ placementId: '846841'
}
}
]
diff --git a/modules/mediagoBidAdapter.js b/modules/mediagoBidAdapter.js
index 68eb95ddae3..022d216a84a 100644
--- a/modules/mediagoBidAdapter.js
+++ b/modules/mediagoBidAdapter.js
@@ -9,7 +9,8 @@ import {
} from '../src/adapters/bidderFactory.js';
const BIDDER_CODE = 'mediago';
-// const PROTOCOL = window.document.location.protocol;
+const PROTOCOL = window.document.location.protocol;
+const IS_SECURE = (PROTOCOL === 'https:') ? 1 : 0;
const ENDPOINT_URL =
// ((PROTOCOL === 'https:') ? 'https' : 'http') +
'https://rtb-us.mediago.io/api/bid?tn=';
@@ -163,8 +164,9 @@ function transformSizes(requestSizes) {
*/
function getItems(validBidRequests, bidderRequest) {
let items = [];
- items = validBidRequests.map((req, i) => {
- let ret = {};
+ for (let i in validBidRequests) {
+ let req = validBidRequests[i];
+ let ret;
let mediaTypes = getProperty(req, 'mediaTypes');
let sizes = transformSizes(getProperty(req, 'sizes'));
@@ -178,27 +180,33 @@ function getItems(validBidRequests, bidderRequest) {
}
}
- // if (mediaTypes.native) {}
- // banner广告类型
- if (mediaTypes.banner) {
- let id = '' + (i + 1);
- ret = {
- id: id,
- // bidFloor: 0, // todo
- banner: {
- h: matchSize.height,
- w: matchSize.width,
- pos: 1,
- }
- };
- itemMaps[id] = {
- req,
- ret
- };
+ // Continue only if there is a matching size
+ if (matchSize) {
+ // banner广告类型
+ if (mediaTypes.banner) {
+ let id = '' + (+i + 1);
+ ret = {
+ id: id,
+ // bidFloor: 0, // todo
+ banner: {
+ h: matchSize.height,
+ w: matchSize.width,
+ pos: 1,
+ },
+ secure: IS_SECURE // for server-side to check if it's secure page
+ };
+ itemMaps[id] = {
+ req,
+ ret
+ };
+ }
}
- return ret;
- });
+ if (ret) {
+ items.push(ret);
+ }
+ }
+
return items;
}
@@ -288,12 +296,17 @@ export const spec = {
buildRequests: function(validBidRequests, bidderRequest) {
let payload = getParam(validBidRequests, bidderRequest);
- const payloadString = JSON.stringify(payload);
- return {
- method: 'POST',
- url: ENDPOINT_URL + globals['token'],
- data: payloadString,
- };
+ // request ad only if there is a matching size
+ if (payload) {
+ const payloadString = JSON.stringify(payload);
+ return {
+ method: 'POST',
+ url: ENDPOINT_URL + globals['token'],
+ data: payloadString,
+ };
+ } else {
+ return null;
+ }
},
/**
diff --git a/modules/medianetAnalyticsAdapter.js b/modules/medianetAnalyticsAdapter.js
index 62958cfbfd2..35c9273f951 100644
--- a/modules/medianetAnalyticsAdapter.js
+++ b/modules/medianetAnalyticsAdapter.js
@@ -11,6 +11,7 @@ const ENDPOINT = 'https://pb-logs.media.net/log?logid=kfk&evtid=prebid_analytics
const CONFIG_URL = 'https://prebid.media.net/rtb/prebid/analytics/config';
const EVENT_PIXEL_URL = 'https://qsearch-a.akamaihd.net/log';
const DEFAULT_LOGGING_PERCENT = 50;
+const ANALYTICS_VERSION = '1.0.0';
const PRICE_GRANULARITY = {
'auto': 'pbAg',
@@ -39,6 +40,18 @@ const CONFIG_ERROR = 3;
const VALID_URL_KEY = ['canonical_url', 'og_url', 'twitter_url'];
const DEFAULT_URL_KEY = 'page';
+const LOG_TYPE = {
+ AP: 'AP',
+ PR: 'PR',
+ APPR: 'APPR',
+ RA: 'RA'
+};
+
+const BATCHING = {
+ SINGLE: 'SINGLE',
+ MULTI: 'MULTI'
+}
+
let auctions = {};
let config;
let pageDetails;
@@ -73,7 +86,14 @@ class Configure {
this.urlToConsume = DEFAULT_URL_KEY;
this.debug = false;
this.gdprConsent = undefined;
+ this.gdprApplies = undefined;
this.uspConsent = undefined;
+ this.pixelWaitTime = 0;
+ this.apLoggingPct = 0;
+ this.prLoggingPct = 0;
+ this.batching = BATCHING.SINGLE;
+ this.shouldBeLogged = {};
+ this.mnetDebugConfig = '';
}
set publisherLper(plper) {
@@ -85,10 +105,12 @@ class Configure {
cid: this.cid,
lper: Math.round(100 / this.loggingPercent),
plper: this.pubLper,
- gdpr: this.gdprConsent,
+ gdpr: this.gdprApplies ? '1' : '0',
+ gdprConsent: this.gdprConsent,
ccpa: this.uspConsent,
ajx: this.ajaxState,
pbv: PREBID_VERSION,
+ pbav: ANALYTICS_VERSION,
flt: 1,
}
}
@@ -100,10 +122,9 @@ class Configure {
_parseResponse(response) {
try {
response = JSON.parse(response);
- if (isNaN(response.percentage)) {
- throw new Error('not a number');
- }
- this.loggingPercent = response.percentage;
+ this.setDataFromResponse(response);
+ this.overrideDomainLevelData(response);
+ this.overrideToDebug(this.mnetDebugConfig);
this.urlToConsume = VALID_URL_KEY.includes(response.urlKey) ? response.urlKey : this.urlToConsume;
this.ajaxState = CONFIG_PASS;
} catch (e) {
@@ -113,6 +134,41 @@ class Configure {
}
}
+ setDataFromResponse(response) {
+ if (!isNaN(parseInt(response.percentage, 10))) {
+ this.loggingPercent = response.percentage;
+ }
+
+ if (!isNaN(parseInt(response.pixelwaittime, 10))) {
+ this.pixelWaitTime = response.pixelwaittime;
+ }
+
+ if (!isNaN(parseInt(response.aplper, 10))) {
+ this.apLoggingPct = response.aplper;
+ this.batching = BATCHING.MULTI;
+ }
+
+ if (!isNaN(parseInt(response.prlper, 10))) {
+ this.prLoggingPct = response.prlper;
+ this.batching = BATCHING.MULTI;
+ }
+ }
+
+ overrideDomainLevelData(response) {
+ const domain = utils.deepAccess(response, 'domain.' + pageDetails.domain);
+ if (domain) {
+ this.setDataFromResponse(domain);
+ }
+ }
+
+ overrideToDebug(response) {
+ if (response === '') return;
+ try {
+ this.setDataFromResponse(JSON.parse(decodeURIComponent(response)));
+ } catch (e) {
+ }
+ }
+
_errorFetch() {
this.ajaxState = CONFIG_ERROR;
/* eslint no-new: "error" */
@@ -128,6 +184,9 @@ class Configure {
this.debug = true;
return;
}
+ if (utils.deepAccess(urlObj, 'search.mnet_setconfig')) {
+ this.mnetDebugConfig = utils.deepAccess(urlObj, 'search.mnet_setconfig');
+ }
ajax(
this._configURL(),
{
@@ -145,7 +204,7 @@ class PageDetail {
const twitterUrl = this._getUrlFromSelector('meta[name="twitter:url"]', 'content');
const refererInfo = getRefererInfo();
- this.domain = URL.parseUrl(refererInfo.referer).host;
+ this.domain = URL.parseUrl(refererInfo.referer).hostname;
this.page = refererInfo.referer;
this.is_top = refererInfo.reachedTop;
this.referrer = this._getTopWindowReferrer();
@@ -202,39 +261,34 @@ class PageDetail {
}
class AdSlot {
- constructor(mediaTypes, allMediaTypeSizes, tmax, supplyAdCode, adext, context, adSize) {
- this.mediaTypes = mediaTypes;
- this.allMediaTypeSizes = allMediaTypeSizes;
+ constructor(tmax, supplyAdCode, context, adext) {
this.tmax = tmax;
this.supplyAdCode = supplyAdCode;
+ this.context = context;
this.adext = adext;
- this.logged = false;
+ this.logged = {};
+ this.logged[LOG_TYPE.PR] = false;
+ this.logged[LOG_TYPE.AP] = false;
+ this.logged[LOG_TYPE.APPR] = false;
this.targeting = undefined;
this.medianetPresent = 0;
- // shouldBeLogged is assigned when requested,
- // since we are waiting for logging percent response
- this.shouldBeLogged = undefined;
- this.context = context;
- this.adSize = adSize; // old ad unit sizes
}
- getShouldBeLogged() {
- if (this.shouldBeLogged === undefined) {
- this.shouldBeLogged = isSampled();
+ getShouldBeLogged(logType) {
+ if (!config.shouldBeLogged.hasOwnProperty(logType)) {
+ config.shouldBeLogged[logType] = isSampled(logType);
}
- return this.shouldBeLogged;
+ config.shouldBeLogged[logType] = isSampled(logType);
+ return config.shouldBeLogged[logType];
}
getLoggingData() {
return Object.assign({
supcrid: this.supplyAdCode,
- mediaTypes: this.mediaTypes && this.mediaTypes.join('|'),
- szs: this.allMediaTypeSizes.map(sz => sz.join('x')).join('|'),
tmax: this.tmax,
targ: JSON.stringify(this.targeting),
ismn: this.medianetPresent,
vplcmtt: this.context,
- sz2: this.adSize.map(sz => sz.join('x')).join('|'),
},
this.adext && {'adext': JSON.stringify(this.adext)},
);
@@ -242,12 +296,13 @@ class AdSlot {
}
class Bid {
- constructor(bidId, bidder, src, start, supplyAdCode) {
+ constructor(bidId, bidder, src, start, adUnitCode, mediaType, allMediaTypeSizes) {
this.bidId = bidId;
this.bidder = bidder;
this.src = src;
this.start = start;
- this.supplyAdCode = supplyAdCode;
+ this.adUnitCode = adUnitCode;
+ this.allMediaTypeSizes = allMediaTypeSizes;
this.iwb = 0;
this.winner = 0;
this.status = bidder === DUMMY_BIDDER ? BID_SUCCESS : BID_TIMEOUT;
@@ -257,7 +312,7 @@ class Bid {
this.dfpbd = undefined;
this.width = undefined;
this.height = undefined;
- this.mediaType = undefined;
+ this.mediaType = mediaType;
this.timeToRespond = undefined;
this.dealId = undefined;
this.creativeId = undefined;
@@ -268,6 +323,7 @@ class Bid {
this.mpvid = undefined;
this.floorPrice = undefined;
this.floorRule = undefined;
+ this.serverLatencyMillis = undefined;
}
get size() {
@@ -286,6 +342,7 @@ class Bid {
bdp: this.cpm,
cbdp: this.dfpbd,
dfpbd: this.dfpbd,
+ szs: this.allMediaTypeSizes.map(sz => sz.join('x')).join('|'),
size: this.size,
mtype: this.mediaType,
dId: this.dealId,
@@ -299,7 +356,8 @@ class Bid {
mpvid: this.mpvid,
bidflr: this.floorPrice,
flrrule: this.floorRule,
- ext: JSON.stringify(this.ext)
+ ext: JSON.stringify(this.ext),
+ rtime: this.serverLatencyMillis,
}
}
}
@@ -342,12 +400,10 @@ class Auction {
}
}
- addSlot(supplyAdCode, { mediaTypes, allMediaTypeSizes, tmax, adext, context, adSize }) {
- if (supplyAdCode && this.adSlots[supplyAdCode] === undefined) {
- this.adSlots[supplyAdCode] = new AdSlot(mediaTypes, allMediaTypeSizes, tmax, supplyAdCode, adext, context, adSize);
- this.addBid(
- new Bid('-1', DUMMY_BIDDER, 'client', '-1', supplyAdCode)
- );
+ addSlot({ adUnitCode, supplyAdCode, mediaTypes, allMediaTypeSizes, tmax, adext, context }) {
+ if (adUnitCode && this.adSlots[adUnitCode] === undefined) {
+ this.adSlots[adUnitCode] = new AdSlot(tmax, supplyAdCode, context, adext);
+ this.addBid(new Bid('-1', DUMMY_BIDDER, 'client', '-1', adUnitCode, mediaTypes, allMediaTypeSizes));
}
}
@@ -363,7 +419,7 @@ class Auction {
getAdslotBids(adslot) {
return this.bids
- .filter((bid) => bid.supplyAdCode === adslot)
+ .filter((bid) => bid.adUnitCode === adslot)
.map((bid) => bid.getLoggingData());
}
@@ -382,46 +438,68 @@ class Auction {
}
}
-function auctionInitHandler({auctionId, timestamp, bidderRequests}) {
+function auctionInitHandler({auctionId, adUnits, timeout, timestamp, bidderRequests}) {
if (auctionId && auctions[auctionId] === undefined) {
auctions[auctionId] = new Auction(auctionId);
auctions[auctionId].auctionInitTime = timestamp;
}
+ addAddSlots(auctionId, adUnits, timeout);
const floorData = utils.deepAccess(bidderRequests, '0.bids.0.floorData');
if (floorData) {
auctions[auctionId].floorData = {...floorData};
}
}
-function bidRequestedHandler({ auctionId, auctionStart, bids, start, timeout, uspConsent, gdpr }) {
+function addAddSlots(auctionId, adUnits, tmax) {
+ adUnits = adUnits || [];
+ const groupedAdUnits = utils.groupBy(adUnits, 'code');
+ Object.keys(groupedAdUnits).forEach((adUnitCode) => {
+ const adUnits = groupedAdUnits[adUnitCode];
+ const supplyAdCode = utils.deepAccess(adUnits, '0.adUnitCode') || adUnitCode;
+ let context = '';
+ let adext = {};
+
+ const mediaTypeMap = {};
+ const oSizes = {banner: [], video: []};
+ adUnits.forEach(({mediaTypes, sizes, ext}) => {
+ mediaTypes = mediaTypes || {};
+ adext = Object.assign(adext, ext || utils.deepAccess(mediaTypes, 'banner.ext'));
+ context = utils.deepAccess(mediaTypes, 'video.context') || context;
+ Object.keys(mediaTypes).forEach((mediaType) => mediaTypeMap[mediaType] = 1);
+ const sizeObject = _getSizes(mediaTypes, sizes);
+ sizeObject.banner.forEach(size => oSizes.banner.push(size));
+ sizeObject.video.forEach(size => oSizes.video.push(size));
+ });
+
+ adext = utils.isEmpty(adext) ? undefined : adext;
+ oSizes.banner = oSizes.banner.filter(utils.uniques);
+ oSizes.video = oSizes.video.filter(utils.uniques);
+ oSizes.native = mediaTypeMap.native === 1 ? [[1, 1]] : [];
+ const allMediaTypeSizes = [].concat(oSizes.banner, oSizes.native, oSizes.video);
+ const mediaTypes = Object.keys(mediaTypeMap).join('|');
+
+ auctions[auctionId].addSlot({adUnitCode, supplyAdCode, mediaTypes, allMediaTypeSizes, context, tmax, adext});
+ });
+}
+
+function bidRequestedHandler({ auctionId, auctionStart, bids, start, uspConsent, gdpr }) {
if (!(auctions[auctionId] instanceof Auction)) {
return;
}
- if (gdpr && gdpr.gdprApplies) {
+ config.gdprApplies = !!(gdpr && gdpr.gdprApplies);
+ if (config.gdprApplies) {
config.gdprConsent = gdpr.consentString || '';
}
config.uspConsent = config.uspConsent || uspConsent;
+ auctions[auctionId].auctionStartTime = auctionStart;
bids.forEach(bid => {
- const { adUnitCode, bidder, mediaTypes, sizes, bidId, src } = bid;
- if (!auctions[auctionId].adSlots[adUnitCode]) {
- auctions[auctionId].auctionStartTime = auctionStart;
- const sizeObject = _getSizes(mediaTypes, sizes);
- auctions[auctionId].addSlot(
- adUnitCode,
- Object.assign({},
- (mediaTypes instanceof Object) && { mediaTypes: Object.keys(mediaTypes) },
- { allMediaTypeSizes: [].concat(sizeObject.banner, sizeObject.native, sizeObject.video) },
- { adext: utils.deepAccess(mediaTypes, 'banner.ext') || '' },
- { tmax: timeout },
- { context: utils.deepAccess(mediaTypes, 'video.context') || '' },
- { adSize: sizeObject.banner }
- )
- );
- }
- let bidObj = new Bid(bidId, bidder, src, start, adUnitCode);
+ const { adUnitCode, bidder, bidId, src, mediaTypes, sizes } = bid;
+ const sizeObject = _getSizes(mediaTypes, sizes);
+ const requestSizes = [].concat(sizeObject.banner, sizeObject.native, sizeObject.video);
+ const bidObj = new Bid(bidId, bidder, src, start, adUnitCode, mediaTypes && Object.keys(mediaTypes).join('|'), requestSizes);
auctions[auctionId].addBid(bidObj);
if (bidder === MEDIANET_BIDDER_CODE) {
bidObj.crid = utils.deepAccess(bid, 'params.crid');
@@ -482,6 +560,9 @@ function bidResponseHandler(bid) {
bid.ext.crid && { 'crid': bid.ext.crid }
);
}
+ if (typeof bid.serverResponseTimeMs !== 'undefined') {
+ bidObj.serverLatencyMillis = bid.serverResponseTimeMs;
+ }
}
function noBidResponseHandler({ auctionId, bidId }) {
@@ -511,12 +592,18 @@ function bidTimeoutHandler(timedOutBids) {
})
}
-function auctionEndHandler({ auctionId, auctionEnd }) {
+function auctionEndHandler({auctionId, auctionEnd, adUnitCodes}) {
if (!(auctions[auctionId] instanceof Auction)) {
return;
}
auctions[auctionId].status = AUCTION_COMPLETED;
auctions[auctionId].auctionEndTime = auctionEnd;
+
+ if (config.batching === BATCHING.MULTI) {
+ adUnitCodes.forEach(function (adUnitCode) {
+ sendEvent(auctionId, adUnitCode, LOG_TYPE.PR);
+ });
+ }
}
function setTargetingHandler(params) {
@@ -530,20 +617,51 @@ function setTargetingHandler(params) {
adunitObj.targeting = params[adunit];
auctionObj.setTargetingTime = Date.now();
let targetingObj = Object.keys(params[adunit]).reduce((result, key) => {
- if (key.indexOf('hb_adid') !== -1) {
+ if (key.indexOf(CONSTANTS.TARGETING_KEYS.AD_ID) !== -1) {
result[key] = params[adunit][key]
}
return result;
}, {});
+ const winnerAdId = params[adunit][CONSTANTS.TARGETING_KEYS.AD_ID];
+ let winningBid;
let bidAdIds = Object.keys(targetingObj).map(k => targetingObj[k]);
auctionObj.bids.filter((bid) => bidAdIds.indexOf(bid.adId) !== -1).map(function(bid) {
bid.iwb = 1;
+ if (bid.adId === winnerAdId) {
+ winningBid = bid;
+ }
+ });
+ auctionObj.bids.forEach(bid => {
+ if (bid.bidder === DUMMY_BIDDER && bid.adUnitCode === adunit) {
+ bid.iwb = bidAdIds.length === 0 ? 0 : 1;
+ bid.width = utils.deepAccess(winningBid, 'width');
+ bid.height = utils.deepAccess(winningBid, 'height');
+ }
});
- sendEvent(auctionId, adunit, false);
+ sendEvent(auctionId, adunit, getLogType());
}
}
}
+function getLogType() {
+ if (config.batching === BATCHING.SINGLE) {
+ return LOG_TYPE.APPR;
+ }
+ return LOG_TYPE.AP;
+}
+
+function setBidderDone(params) {
+ if (config.pixelWaitTime != null && config.pixelWaitTime > 0) {
+ setTimeout(fireApAfterWait, config.pixelWaitTime, params)
+ }
+}
+
+function fireApAfterWait(params) {
+ params.bids.forEach(function (adUnit) {
+ sendEvent(params.auctionId, adUnit.adUnitCode, LOG_TYPE.AP);
+ });
+}
+
function bidWonHandler(bid) {
const { requestId, auctionId, adUnitCode } = bid;
if (!(auctions[auctionId] instanceof Auction)) {
@@ -555,26 +673,50 @@ function bidWonHandler(bid) {
}
auctions[auctionId].bidWonTime = Date.now();
bidObj.winner = 1;
- sendEvent(auctionId, adUnitCode, true);
+ sendEvent(auctionId, adUnitCode, LOG_TYPE.RA);
+}
+
+function isSampled(logType) {
+ return Math.random() * 100 < parseFloat(getLogPercentage(logType));
}
-function isSampled() {
- return Math.random() * 100 < parseFloat(config.loggingPercent);
+function getLogPercentage(logType) {
+ let logPercentage = config.loggingPercent;
+ if (config.batching === BATCHING.MULTI) {
+ if (logType === LOG_TYPE.AP) {
+ logPercentage = config.apLoggingPct;
+ } else if (logType === LOG_TYPE.PR) {
+ logPercentage = config.prLoggingPct;
+ }
+ }
+ return logPercentage;
}
function isValidAuctionAdSlot(acid, adtag) {
return (auctions[acid] instanceof Auction) && (auctions[acid].adSlots[adtag] instanceof AdSlot);
}
-function sendEvent(id, adunit, isBidWonEvent) {
+function sendEvent(id, adunit, logType) {
if (!isValidAuctionAdSlot(id, adunit)) {
return;
}
- if (isBidWonEvent) {
- fireAuctionLog(id, adunit, isBidWonEvent);
- } else if (auctions[id].adSlots[adunit].getShouldBeLogged() && !auctions[id].adSlots[adunit].logged) {
- auctions[id].adSlots[adunit].logged = true;
- fireAuctionLog(id, adunit, isBidWonEvent);
+ if (logType === LOG_TYPE.RA) {
+ fireAuctionLog(id, adunit, logType);
+ } else {
+ fireApPrLog(id, adunit, logType)
+ }
+}
+
+function fireApPrLog(auctionId, adUnitName, logType) {
+ const adSlot = auctions[auctionId].adSlots[adUnitName];
+ if (adSlot.getShouldBeLogged(logType) && !adSlot.logged[logType]) {
+ if (config.batching === BATCHING.SINGLE) {
+ adSlot.logged[LOG_TYPE.AP] = true;
+ adSlot.logged[LOG_TYPE.PR] = true;
+ } else {
+ adSlot.logged[logType] = true;
+ }
+ fireAuctionLog(auctionId, adUnitName, logType);
}
}
@@ -585,8 +727,9 @@ function getCommonLoggingData(acid, adtag) {
return Object.assign(commonParams, adunitParams, auctionParams);
}
-function fireAuctionLog(acid, adtag, isBidWonEvent) {
+function fireAuctionLog(acid, adtag, logType) {
let commonParams = getCommonLoggingData(acid, adtag);
+ commonParams.lgtp = logType;
let targeting = utils.deepAccess(commonParams, 'targ');
Object.keys(commonParams).forEach((key) => (commonParams[key] == null) && delete commonParams[key]);
@@ -594,7 +737,7 @@ function fireAuctionLog(acid, adtag, isBidWonEvent) {
let bidParams;
- if (isBidWonEvent) {
+ if (logType === LOG_TYPE.RA) {
bidParams = auctions[acid].getWinnerAdslotBid(adtag);
commonParams.lper = 1;
} else {
@@ -700,6 +843,10 @@ let medianetAnalytics = Object.assign(adapter({URL, analyticsType}), {
setTargetingHandler(args);
break;
}
+ case CONSTANTS.EVENTS.BIDDER_DONE : {
+ setBidderDone(args);
+ break;
+ }
case CONSTANTS.EVENTS.BID_WON: {
bidWonHandler(args);
break;
@@ -728,7 +875,8 @@ medianetAnalytics.enableAnalytics = function (configuration) {
adapterManager.registerAnalyticsAdapter({
adapter: medianetAnalytics,
- code: 'medianetAnalytics'
+ code: 'medianetAnalytics',
+ gvlid: 142,
});
export default medianetAnalytics;
diff --git a/modules/medianetBidAdapter.js b/modules/medianetBidAdapter.js
index 5decaa148e3..49e2bdc225f 100644
--- a/modules/medianetBidAdapter.js
+++ b/modules/medianetBidAdapter.js
@@ -113,8 +113,15 @@ function getWindowSize() {
}
}
-function getCoordinates(id) {
- const element = document.getElementById(id);
+function getCoordinates(adUnitCode) {
+ let element = document.getElementById(adUnitCode);
+ if (!element && adUnitCode.indexOf('/') !== -1) {
+ // now it means that adUnitCode is GAM AdUnitPath
+ const {divId} = utils.getGptSlotInfoForAdUnitCode(adUnitCode);
+ if (utils.isStr(divId)) {
+ element = document.getElementById(divId);
+ }
+ }
if (element && element.getBoundingClientRect) {
const rect = element.getBoundingClientRect();
let coordinates = {};
diff --git a/modules/merkleIdSystem.js b/modules/merkleIdSystem.js
index d6bf96618df..c55233af6a0 100644
--- a/modules/merkleIdSystem.js
+++ b/modules/merkleIdSystem.js
@@ -31,11 +31,12 @@ export const merkleIdSubmodule = {
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
- * @param {SubmoduleParams} [configParams]
+ * @param {SubmoduleConfig} [config]
* @param {ConsentData} [consentData]
* @returns {IdResponse|undefined}
*/
- getId(configParams, consentData) {
+ getId(config, consentData) {
+ const configParams = (config && config.params) || {};
if (!configParams || typeof configParams.pubid !== 'string') {
utils.logError('User ID - merkleId submodule requires a valid pubid to be defined');
return;
diff --git a/modules/netIdSystem.js b/modules/netIdSystem.js
index cfe78d9f488..90c8735c993 100644
--- a/modules/netIdSystem.js
+++ b/modules/netIdSystem.js
@@ -26,12 +26,12 @@ export const netIdSubmodule = {
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
- * @param {SubmoduleParams} [configParams]
+ * @param {SubmoduleConfig} [config]
* @param {ConsentData} [consentData]
* @param {(Object|undefined)} cacheIdObj
* @returns {IdResponse|undefined}
*/
- getId(configParams) {
+ getId(config) {
/* currently not possible */
return {};
}
diff --git a/modules/nobidBidAdapter.js b/modules/nobidBidAdapter.js
index f1a9092e31d..00cb14dc01d 100644
--- a/modules/nobidBidAdapter.js
+++ b/modules/nobidBidAdapter.js
@@ -6,7 +6,7 @@ import { getStorageManager } from '../src/storageManager.js';
const storage = getStorageManager();
const BIDDER_CODE = 'nobid';
-window.nobidVersion = '1.2.6';
+window.nobidVersion = '1.2.8';
window.nobid = window.nobid || {};
window.nobid.bidResponses = window.nobid.bidResponses || {};
window.nobid.timeoutTotal = 0;
@@ -24,6 +24,15 @@ function nobidSetCookie(cname, cvalue, hours) {
function nobidGetCookie(cname) {
return storage.getCookie(cname);
}
+function nobidHasPurpose1Consent(bidderRequest) {
+ let result = true;
+ if (bidderRequest && bidderRequest.gdprConsent) {
+ if (bidderRequest.gdprConsent.gdprApplies && bidderRequest.gdprConsent.apiVersion === 2) {
+ result = !!(utils.deepAccess(bidderRequest.gdprConsent, 'vendorData.purpose.consents.1') === true);
+ }
+ }
+ return result;
+}
function nobidBuildRequests(bids, bidderRequest) {
var serializeState = function(divIds, siteId, adunits) {
var filterAdUnitsByIds = function(divIds, adUnits) {
@@ -296,19 +305,7 @@ window.addEventListener('message', function (event) {
if (window.nobid && window.nobid.bidResponses) {
var bid = window.nobid.bidResponses['' + adId];
if (bid && bid.adm2) {
- var markup = null;
- if (bid.is_combo && bid.adm_combo) {
- for (var i in bid.adm_combo) {
- var combo = bid.adm_combo[i];
- if (!combo.done) {
- markup = combo.adm;
- combo.done = true;
- break;
- }
- }
- } else {
- markup = bid.adm2;
- }
+ var markup = bid.adm2;
if (markup) {
event.source.postMessage('nbTagRenderer.renderAdInSafeFrame|' + markup, '*');
}
@@ -358,11 +355,18 @@ export const spec = {
window.nobid.refreshCount++;
const payloadString = JSON.stringify(payload).replace(/'|&|#/g, '')
const endpoint = buildEndpoint();
+
+ let options = {};
+ if (!nobidHasPurpose1Consent(bidderRequest)) {
+ options = { withCredentials: false };
+ }
+
return {
method: 'POST',
url: endpoint,
data: payloadString,
- bidderRequest
+ bidderRequest,
+ options
};
},
/**
diff --git a/modules/openxAnalyticsAdapter.js b/modules/openxAnalyticsAdapter.js
index 3ee8ab588a9..07966e9e401 100644
--- a/modules/openxAnalyticsAdapter.js
+++ b/modules/openxAnalyticsAdapter.js
@@ -170,14 +170,15 @@ function isValidConfig({options: analyticsOptions}) {
}
function buildCampaignFromUtmCodes() {
+ const location = utils.getWindowLocation();
+ const queryParams = utils.parseQS(location && location.search);
let campaign = {};
- let queryParams = utils.parseQS(utils.getWindowLocation() && utils.getWindowLocation().search);
UTM_TAGS.forEach(function(utmKey) {
let utmValue = queryParams[utmKey];
if (utmValue) {
let key = UTM_TO_CAMPAIGN_PROPERTIES[utmKey];
- campaign[key] = utmValue;
+ campaign[key] = decodeURIComponent(utmValue);
}
});
return campaign;
@@ -326,7 +327,7 @@ function onAuctionInit({auctionId, timestamp: startTime, timeout, adUnitCodes})
* @param {PbBidRequest} bidRequest
*/
function onBidRequested(bidRequest) {
- const {auctionId, bids: bidderRequests, start} = bidRequest;
+ const {auctionId, bids: bidderRequests, start, timeout} = bidRequest;
const auction = auctionMap[auctionId];
const adUnitCodeToAdUnitMap = auction.adUnitCodeToAdUnitMap;
@@ -341,6 +342,7 @@ function onBidRequested(bidRequest) {
source: src,
startTime: start,
timedOut: false,
+ timeLimit: timeout,
bids: {}
};
});
@@ -640,13 +642,14 @@ function buildAuctionPayload(auction) {
function buildBidRequestPayload(bidRequestsMap) {
return utils._map(bidRequestsMap, (bidRequest) => {
- let {bidder, source, bids, mediaTypes, timedOut} = bidRequest;
+ let {bidder, source, bids, mediaTypes, timeLimit, timedOut} = bidRequest;
return {
bidder,
source,
hasBidderResponded: Object.keys(bids).length > 0,
availableAdSizes: getMediaTypeSizes(mediaTypes),
availableMediaTypes: getMediaTypes(mediaTypes),
+ timeLimit,
timedOut,
bidResponses: utils._map(bidRequest.bids, (bidderBidResponse) => {
let {
diff --git a/modules/openxBidAdapter.js b/modules/openxBidAdapter.js
index f4b6288cd55..bbf3d6fdea1 100644
--- a/modules/openxBidAdapter.js
+++ b/modules/openxBidAdapter.js
@@ -281,6 +281,9 @@ function appendUserIdsToQueryParams(queryParams, userIds) {
case 'parrableId':
queryParams[key] = userIdObjectOrValue.eid;
break;
+ case 'id5id':
+ queryParams[key] = userIdObjectOrValue.uid;
+ break;
default:
queryParams[key] = userIdObjectOrValue;
}
diff --git a/modules/ozoneBidAdapter.js b/modules/ozoneBidAdapter.js
index 451ab654c53..4246a39bc69 100644
--- a/modules/ozoneBidAdapter.js
+++ b/modules/ozoneBidAdapter.js
@@ -539,7 +539,7 @@ export const spec = {
*/
findAllUserIds(bidRequest) {
var ret = {};
- let searchKeysSingle = ['pubcid', 'tdid', 'id5id', 'parrableId', 'idl_env', 'digitrustid', 'criteortus'];
+ let searchKeysSingle = ['pubcid', 'tdid', 'parrableId', 'idl_env', 'digitrustid', 'criteortus'];
if (bidRequest.hasOwnProperty('userId')) {
for (let arrayId in searchKeysSingle) {
let key = searchKeysSingle[arrayId];
@@ -551,6 +551,10 @@ export const spec = {
if (lipbid) {
ret['lipb'] = {'lipbid': lipbid};
}
+ var id5id = utils.deepAccess(bidRequest.userId, 'id5id.uid');
+ if (id5id) {
+ ret['id5id'] = id5id;
+ }
}
if (!ret.hasOwnProperty('pubcid')) {
var pubcid = utils.deepAccess(bidRequest, 'crumbs.pubcid');
@@ -675,7 +679,7 @@ export const spec = {
if (bidRequest && bidRequest.userId) {
this.addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.pubcid`), 'pubcid', 1);
this.addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.pubcid`), 'pubcommon', 1);
- this.addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.id5id`), 'id5-sync.com', 1);
+ this.addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.id5id.uid`), 'id5-sync.com', 1);
this.addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.criteortus.${BIDDER_CODE}.userid`), 'criteortus', 1);
this.addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.idl_env`), 'liveramp.com', 1);
this.addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.lipb.lipbid`), 'liveintent.com', 1);
diff --git a/modules/parrableIdSystem.js b/modules/parrableIdSystem.js
index 2d6a2d6d6e5..7587962c62b 100644
--- a/modules/parrableIdSystem.js
+++ b/modules/parrableIdSystem.js
@@ -261,11 +261,12 @@ export const parrableIdSubmodule = {
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
- * @param {SubmoduleParams} [configParams]
+ * @param {SubmoduleConfig} [config]
* @param {ConsentData} [consentData]
* @returns {function(callback:function), id:ParrableId}
*/
- getId(configParams, gdprConsentData, currentStoredId) {
+ getId(config, gdprConsentData, currentStoredId) {
+ const configParams = (config && config.params) || {};
return fetchId(configParams);
}
};
diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js
index 0ff967f1da9..b153d0bf8db 100644
--- a/modules/prebidServerBidAdapter/index.js
+++ b/modules/prebidServerBidAdapter/index.js
@@ -825,9 +825,9 @@ const OPEN_RTB_PROTOCOL = {
bidObject.meta = bidObject.meta || {};
if (bid.adomain) { bidObject.meta.advertiserDomains = bid.adomain; }
- // TODO: Remove when prebid-server returns ttl and netRevenue
const configTtl = _s2sConfig.defaultTtl || DEFAULT_S2S_TTL;
- bidObject.ttl = (bid.ttl) ? bid.ttl : configTtl;
+ // the OpenRTB location for "TTL" as understood by Prebid.js is "exp" (expiration).
+ bidObject.ttl = (bid.exp) ? bid.exp : configTtl;
bidObject.netRevenue = (bid.netRevenue) ? bid.netRevenue : DEFAULT_S2S_NETREVENUE;
bids.push({ adUnit: bid.impid, bid: bidObject });
diff --git a/modules/pubCommonIdSystem.js b/modules/pubCommonIdSystem.js
index 9516934de42..cb60a1b559c 100644
--- a/modules/pubCommonIdSystem.js
+++ b/modules/pubCommonIdSystem.js
@@ -54,10 +54,10 @@ export const pubCommonIdSubmodule = {
/**
* performs action to obtain id
* @function
- * @param {SubmoduleParams} [configParams]
+ * @param {SubmoduleConfig} [config]
* @returns {IdResponse}
*/
- getId: function ({create = true, pixelUrl} = {}) {
+ getId: function ({params: {create = true, pixelUrl} = {}} = {}) {
try {
if (typeof window[PUB_COMMON_ID] === 'object') {
// If the page includes its own pubcid module, then save a copy of id.
@@ -75,11 +75,11 @@ export const pubCommonIdSubmodule = {
/**
* performs action to extend an id
* @function
- * @param {SubmoduleParams} [configParams]
+ * @param {SubmoduleParams} [config]
* @param {Object} storedId existing id
* @returns {IdResponse|undefined}
*/
- extendId: function({extend = false, pixelUrl} = {}, storedId) {
+ extendId: function({params: {extend = false, pixelUrl} = {}} = {}, storedId) {
try {
if (typeof window[PUB_COMMON_ID] === 'object') {
// If the page includes its onw pubcid module, then there is nothing to do.
diff --git a/modules/pubProvidedSystem.js b/modules/pubProvidedSystem.js
new file mode 100644
index 00000000000..0b2175f57cb
--- /dev/null
+++ b/modules/pubProvidedSystem.js
@@ -0,0 +1,54 @@
+/**
+ * This module adds Publisher Provided ids support to the User ID module
+ * The {@link module:modules/userId} module is required.
+ * @module modules/pubProvidedSystem
+ * @requires module:modules/userId
+ */
+
+import {submodule} from '../src/hook.js';
+import * as utils from '../src/utils.js';
+
+const MODULE_NAME = 'pubProvidedId';
+
+/** @type {Submodule} */
+export const pubProvidedIdSubmodule = {
+
+ /**
+ * used to link submodule with config
+ * @type {string}
+ */
+ name: MODULE_NAME,
+
+ /**
+ * decode the stored id value for passing to bid request
+ * @function
+ * @param {string} value
+ * @returns {{pubProvidedId: array}} or undefined if value doesn't exists
+ */
+ decode(value) {
+ const res = value ? {pubProvidedId: value} : undefined;
+ utils.logInfo('PubProvidedId: Decoded value ' + JSON.stringify(res));
+ return res;
+ },
+
+ /**
+ * performs action to obtain id and return a value.
+ * @function
+ * @param {SubmoduleConfig} [config]
+ * @returns {{id: array}}
+ */
+ getId(config) {
+ const configParams = (config && config.params) || {};
+ let res = [];
+ if (utils.isArray(configParams.eids)) {
+ res = res.concat(configParams.eids);
+ }
+ if (typeof configParams.eidsFunction === 'function') {
+ res = res.concat(configParams.eidsFunction());
+ }
+ return {id: res};
+ }
+};
+
+// Register submodule for userId
+submodule('userId', pubProvidedIdSubmodule);
diff --git a/modules/pubmaticAnalyticsAdapter.js b/modules/pubmaticAnalyticsAdapter.js
index d94c098db5d..04c6606a299 100755
--- a/modules/pubmaticAnalyticsAdapter.js
+++ b/modules/pubmaticAnalyticsAdapter.js
@@ -228,13 +228,6 @@ function executeBidsLoggerCall(e, highestCpmBids) {
return 0;
})();
- // GDPR support
- if (auctionCache.gdprConsent) {
- outputObj['cns'] = auctionCache.gdprConsent.consentString || '';
- outputObj['gdpr'] = auctionCache.gdprConsent.gdprApplies === true ? 1 : 0;
- pixelURL += '&gdEn=1';
- }
-
outputObj.s = Object.keys(auctionCache.adUnitCodes).reduce(function(slotsArray, adUnitId) {
let adUnit = auctionCache.adUnitCodes[adUnitId];
let slotObject = {
@@ -307,7 +300,6 @@ function auctionInitHandler(args) {
}
function bidRequestedHandler(args) {
- cache.auctions[args.auctionId].gdprConsent = args.gdprConsent || undefined;
args.bids.forEach(function(bid) {
if (!cache.auctions[args.auctionId].adUnitCodes.hasOwnProperty(bid.adUnitCode)) {
cache.auctions[args.auctionId].adUnitCodes[bid.adUnitCode] = {
diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js
index d21854a57c4..b5514ab0344 100644
--- a/modules/pubmaticBidAdapter.js
+++ b/modules/pubmaticBidAdapter.js
@@ -847,7 +847,7 @@ export const spec = {
isBidRequestValid: bid => {
if (bid && bid.params) {
if (!utils.isStr(bid.params.publisherId)) {
- utils.logWarn(LOG_WARN_PREFIX + 'Error: publisherId is mandatory and cannot be numeric. Call to OpenBid will not be sent for ad unit: ' + JSON.stringify(bid));
+ utils.logWarn(LOG_WARN_PREFIX + 'Error: publisherId is mandatory and cannot be numeric (wrap it in quotes in your config). Call to OpenBid will not be sent for ad unit: ' + JSON.stringify(bid));
return false;
}
// video ad validation
@@ -938,7 +938,7 @@ export const spec = {
payload.ext.wrapper = {};
payload.ext.wrapper.profile = parseInt(conf.profId) || UNDEFINED;
payload.ext.wrapper.version = parseInt(conf.verId) || UNDEFINED;
- payload.ext.wrapper.wiid = conf.wiid || UNDEFINED;
+ payload.ext.wrapper.wiid = conf.wiid || bidderRequest.auctionId;
// eslint-disable-next-line no-undef
payload.ext.wrapper.wv = $$REPO_AND_VERSION$$;
payload.ext.wrapper.transactionId = conf.transactionId;
diff --git a/modules/pubmaticBidAdapter.md b/modules/pubmaticBidAdapter.md
index cd9398477f4..0ef89a22cbd 100644
--- a/modules/pubmaticBidAdapter.md
+++ b/modules/pubmaticBidAdapter.md
@@ -24,7 +24,7 @@ var adUnits = [
bids: [{
bidder: 'pubmatic',
params: {
- publisherId: '156209', // required
+ publisherId: '156209', // required, must be wrapped in quotes
oustreamAU: 'renderer_test_pubmatic', // required if mediaTypes-> video-> context is 'outstream'. This value can be get by BlueBillyWig Team.
adSlot: 'pubmatic_test2', // optional
pmzoneid: 'zone1, zone11', // optional
diff --git a/modules/pubwiseAnalyticsAdapter.js b/modules/pubwiseAnalyticsAdapter.js
index 74b56c21a2b..fe217454b88 100644
--- a/modules/pubwiseAnalyticsAdapter.js
+++ b/modules/pubwiseAnalyticsAdapter.js
@@ -330,7 +330,8 @@ pubwiseAnalytics.enableAnalytics = function (config) {
adapterManager.registerAnalyticsAdapter({
adapter: pubwiseAnalytics,
- code: 'pubwise'
+ code: 'pubwise',
+ gvlid: 842
});
export default pubwiseAnalytics;
diff --git a/modules/pulsepointBidAdapter.js b/modules/pulsepointBidAdapter.js
index 33fdaa44100..12937dbec9d 100644
--- a/modules/pulsepointBidAdapter.js
+++ b/modules/pulsepointBidAdapter.js
@@ -420,7 +420,7 @@ function user(bidRequest, bidderRequest) {
addExternalUserId(ext.eids, bidRequest.userId.britepoolid, 'britepool.com');
addExternalUserId(ext.eids, bidRequest.userId.criteoId, 'criteo');
addExternalUserId(ext.eids, bidRequest.userId.idl_env, 'identityLink');
- addExternalUserId(ext.eids, bidRequest.userId.id5id, 'id5-sync.com');
+ addExternalUserId(ext.eids, utils.deepAccess(bidRequest, 'userId.id5id.uid'), 'id5-sync.com', utils.deepAccess(bidRequest, 'userId.id5id.ext'));
addExternalUserId(ext.eids, utils.deepAccess(bidRequest, 'userId.parrableId.eid'), 'parrable.com');
// liveintent
if (bidRequest.userId.lipb && bidRequest.userId.lipb.lipbid) {
diff --git a/modules/quantcastIdSystem.js b/modules/quantcastIdSystem.js
new file mode 100644
index 00000000000..e86c130dc5b
--- /dev/null
+++ b/modules/quantcastIdSystem.js
@@ -0,0 +1,44 @@
+/**
+ * This module adds QuantcastID to the User ID module
+ * The {@link module:modules/userId} module is required
+ * @module modules/quantcastIdSystem
+ * @requires module:modules/userId
+ */
+
+import {submodule} from '../src/hook.js'
+import { getStorageManager } from '../src/storageManager.js';
+
+const QUANTCAST_FPA = '__qca';
+
+export const storage = getStorageManager();
+
+/** @type {Submodule} */
+export const quantcastIdSubmodule = {
+ /**
+ * used to link submodule with config
+ * @type {string}
+ */
+ name: 'quantcastId',
+
+ /**
+ * decode the stored id value for passing to bid requests
+ * @function
+ * @returns {{quantcastId: string} | undefined}
+ */
+ decode(value) {
+ return value;
+ },
+
+ /**
+ * read Quantcast first party cookie and pass it along in quantcastId
+ * @function
+ * @returns {{id: {quantcastId: string} | undefined}}}
+ */
+ getId() {
+ // Consent signals are currently checked on the server side.
+ let fpa = storage.getCookie(QUANTCAST_FPA);
+ return { id: fpa ? { quantcastId: fpa } : undefined }
+ }
+};
+
+submodule('userId', quantcastIdSubmodule);
diff --git a/modules/quantumdexBidAdapter.js b/modules/quantumdexBidAdapter.js
index 9b7a79755e3..738b6165f79 100644
--- a/modules/quantumdexBidAdapter.js
+++ b/modules/quantumdexBidAdapter.js
@@ -85,14 +85,14 @@ export const spec = {
// Apply GDPR parameters to request.
payload.gdpr = {};
if (bidderRequest && bidderRequest.gdprConsent) {
- payload.gdpr.gdprApplies = bidderRequest.gdprConsent.gdprApplies ? 'true' : 'false';
+ payload.gdpr.gdprApplies = !!bidderRequest.gdprConsent.gdprApplies;
if (bidderRequest.gdprConsent.consentString) {
payload.gdpr.consentString = bidderRequest.gdprConsent.consentString;
}
}
// Apply schain.
if (bids[0].schain) {
- payload.schain = JSON.stringify(bids[0].schain)
+ payload.schain = bids[0].schain
}
// Apply us_privacy.
if (bidderRequest && bidderRequest.uspConsent) {
diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js
index e51cc79eb82..3b899e2179d 100755
--- a/modules/richaudienceBidAdapter.js
+++ b/modules/richaudienceBidAdapter.js
@@ -201,7 +201,7 @@ function raiSetEids(bid) {
let eids = [];
if (bid && bid.userId) {
- raiSetUserId(bid, eids, 'id5-sync.com', utils.deepAccess(bid, `userId.id5id`));
+ raiSetUserId(bid, eids, 'id5-sync.com', utils.deepAccess(bid, `userId.id5id.uid`));
raiSetUserId(bid, eids, 'pubcommon', utils.deepAccess(bid, `userId.pubcid`));
raiSetUserId(bid, eids, 'criteo.com', utils.deepAccess(bid, `userId.criteoId`));
raiSetUserId(bid, eids, 'liveramp.com', utils.deepAccess(bid, `userId.idl_env`));
diff --git a/modules/rubiconAnalyticsAdapter.js b/modules/rubiconAnalyticsAdapter.js
index 00fcd6ba8ff..f6d30e06e9a 100644
--- a/modules/rubiconAnalyticsAdapter.js
+++ b/modules/rubiconAnalyticsAdapter.js
@@ -5,7 +5,15 @@ import { ajax } from '../src/ajax.js';
import { config } from '../src/config.js';
import * as utils from '../src/utils.js';
import { getGlobal } from '../src/prebidGlobal.js';
+import { getStorageManager } from '../src/storageManager.js';
+const RUBICON_GVL_ID = 52;
+export const storage = getStorageManager(RUBICON_GVL_ID, 'rubicon');
+const COOKIE_NAME = 'rpaSession';
+const LAST_SEEN_EXPIRE_TIME = 1800000; // 30 mins
+const END_EXPIRE_TIME = 21600000; // 6 hours
+
+let prebidGlobal = getGlobal();
const {
EVENTS: {
AUCTION_INIT,
@@ -38,8 +46,23 @@ const cache = {
auctions: {},
targeting: {},
timeouts: {},
+ gpt: {},
};
+const BID_REJECTED_IPF = 'rejected-ipf';
+
+export let rubiConf = {
+ pvid: utils.generateUUID().slice(0, 8)
+};
+// we are saving these as global to this module so that if a pub accidentally overwrites the entire
+// rubicon object, then we do not lose other data
+config.getConfig('rubicon', config => {
+ utils.mergeDeep(rubiConf, config.rubicon);
+ if (utils.deepAccess(config, 'rubicon.updatePageView') === true) {
+ rubiConf.pvid = utils.generateUUID().slice(0, 8)
+ }
+});
+
export function getHostNameFromReferer(referer) {
try {
rubiconAdapter.referrerHostname = utils.parseUrl(referer, {noDecodeWholeURL: true}).hostname;
@@ -126,18 +149,17 @@ function sendMessage(auctionId, bidWonId) {
});
}
let auctionCache = cache.auctions[auctionId];
- let referrer = config.getConfig('pageUrl') || auctionCache.referrer;
+ let referrer = config.getConfig('pageUrl') || (auctionCache && auctionCache.referrer);
let message = {
eventTimeMillis: Date.now(),
- integration: config.getConfig('rubicon.int_type') || DEFAULT_INTEGRATION,
+ integration: rubiConf.int_type || DEFAULT_INTEGRATION,
+ ruleId: rubiConf.rule_name,
version: '$prebid.version$',
referrerUri: referrer,
- referrerHostname: rubiconAdapter.referrerHostname || getHostNameFromReferer(referrer)
+ referrerHostname: rubiconAdapter.referrerHostname || getHostNameFromReferer(referrer),
+ channel: 'web',
+ wrapperName: rubiConf.wrapperName
};
- const wrapperName = config.getConfig('rubicon.wrapperName');
- if (wrapperName) {
- message.wrapperName = wrapperName;
- }
if (auctionCache && !auctionCache.sent) {
let adUnitMap = Object.keys(auctionCache.bids).reduce((adUnits, bidId) => {
let bid = auctionCache.bids[bidId];
@@ -149,7 +171,8 @@ function sendMessage(auctionId, bidWonId) {
'mediaTypes',
'dimensions',
'adserverTargeting', () => stringProperties(cache.targeting[bid.adUnit.adUnitCode] || {}),
- 'adSlot'
+ 'gam',
+ 'pbAdSlot'
]);
adUnit.bids = [];
adUnit.status = 'no-bid'; // default it to be no bid
@@ -215,6 +238,30 @@ function sendMessage(auctionId, bidWonId) {
}
}
+ // gather gdpr info
+ if (auctionCache.gdprConsent) {
+ auction.gdpr = utils.pick(auctionCache.gdprConsent, [
+ 'gdprApplies as applies',
+ 'consentString',
+ 'apiVersion as version'
+ ]);
+ }
+
+ // gather session info
+ if (auctionCache.session) {
+ message.session = utils.pick(auctionCache.session, [
+ 'id',
+ 'pvid',
+ 'start',
+ 'expires'
+ ]);
+ if (!utils.isEmpty(auctionCache.session.fpkvs)) {
+ message.fpkvs = Object.keys(auctionCache.session.fpkvs).map(key => {
+ return { key, value: auctionCache.session.fpkvs[key] };
+ });
+ }
+ }
+
if (serverConfig) {
auction.serverTimeoutMillis = serverConfig.timeout;
}
@@ -272,7 +319,7 @@ function getBidPrice(bid) {
}
// otherwise we convert and return
try {
- return Number(getGlobal().convertCurrency(cpm, currency, 'USD'));
+ return Number(prebidGlobal.convertCurrency(cpm, currency, 'USD'));
} catch (err) {
utils.logWarn('Rubicon Analytics Adapter: Could not determine the bidPriceUSD of the bid ', bid);
}
@@ -290,16 +337,22 @@ export function parseBidResponse(bid, previousBidResponse, auctionFloorData) {
'dealId',
'status',
'mediaType',
- 'dimensions', () => utils.pick(bid, [
- 'width',
- 'height'
- ]),
+ 'dimensions', () => {
+ const width = bid.width || bid.playerWidth;
+ const height = bid.height || bid.playerHeight;
+ return (width && height) ? {width, height} : undefined;
+ },
'seatBidId',
'floorValue', () => utils.deepAccess(bid, 'floorData.floorValue'),
'floorRule', () => utils.debugTurnedOn() ? utils.deepAccess(bid, 'floorData.floorRule') : undefined
]);
}
+function getFpkvs() {
+ const isValid = rubiConf.fpkvs && typeof rubiConf.fpkvs === 'object' && Object.keys(rubiConf.fpkvs).every(key => typeof rubiConf.fpkvs[key] === 'string');
+ return isValid ? rubiConf.fpkvs : {};
+}
+
let samplingFactor = 1;
let accountId;
// List of known rubicon aliases
@@ -318,6 +371,74 @@ function setRubiconAliases(aliasRegistry) {
});
}
+function getRpaCookie() {
+ let encodedCookie = storage.getDataFromLocalStorage(COOKIE_NAME);
+ if (encodedCookie) {
+ try {
+ return JSON.parse(window.atob(encodedCookie));
+ } catch (e) {
+ utils.logError(`Rubicon Analytics: Unable to decode ${COOKIE_NAME} value: `, e);
+ }
+ }
+ return {};
+}
+
+function setRpaCookie(decodedCookie) {
+ try {
+ storage.setDataInLocalStorage(COOKIE_NAME, window.btoa(JSON.stringify(decodedCookie)));
+ } catch (e) {
+ utils.logError(`Rubicon Analytics: Unable to encode ${COOKIE_NAME} value: `, e);
+ }
+}
+
+function updateRpaCookie() {
+ const currentTime = Date.now();
+ let decodedRpaCookie = getRpaCookie();
+ if (
+ !Object.keys(decodedRpaCookie).length ||
+ (currentTime - decodedRpaCookie.lastSeen) > LAST_SEEN_EXPIRE_TIME ||
+ decodedRpaCookie.expires < currentTime
+ ) {
+ decodedRpaCookie = {
+ id: utils.generateUUID(),
+ start: currentTime,
+ expires: currentTime + END_EXPIRE_TIME, // six hours later,
+ }
+ }
+ // possible that decodedRpaCookie is undefined, and if it is, we probably are blocked by storage or some other exception
+ if (Object.keys(decodedRpaCookie).length) {
+ decodedRpaCookie.lastSeen = currentTime;
+ decodedRpaCookie.fpkvs = {...decodedRpaCookie.fpkvs, ...getFpkvs()};
+ decodedRpaCookie.pvid = rubiConf.pvid;
+ setRpaCookie(decodedRpaCookie)
+ }
+ return decodedRpaCookie;
+}
+
+function subscribeToGamSlots() {
+ window.googletag.pubads().addEventListener('slotRenderEnded', event => {
+ const isMatchingAdSlot = utils.isAdUnitCodeMatchingSlot(event.slot);
+ // loop through auctions and adUnits and mark the info
+ Object.keys(cache.auctions).forEach(auctionId => {
+ (Object.keys(cache.auctions[auctionId].bids) || []).forEach(bidId => {
+ let bid = cache.auctions[auctionId].bids[bidId];
+ // if this slot matches this bids adUnit, add the adUnit info
+ if (isMatchingAdSlot(bid.adUnit.adUnitCode)) {
+ bid.adUnit.gam = utils.pick(event, [
+ // these come in as `null` from Gpt, which when stringified does not get removed
+ // so set explicitly to undefined when not a number
+ 'advertiserId', advertiserId => utils.isNumber(advertiserId) ? advertiserId : undefined,
+ 'creativeId', creativeId => utils.isNumber(creativeId) ? creativeId : undefined,
+ 'lineItemId', lineItemId => utils.isNumber(lineItemId) ? lineItemId : undefined,
+ 'adSlot', () => event.slot.getAdUnitPath(),
+ 'isSlotEmpty', () => event.isEmpty || undefined
+ ]);
+ }
+ });
+ });
+ });
+}
+
let baseAdapter = adapter({analyticsType: 'endpoint'});
let rubiconAdapter = Object.assign({}, baseAdapter, {
referrerHostname: '',
@@ -362,7 +483,9 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
},
disableAnalytics() {
this.getUrl = baseAdapter.getUrl;
- accountId = null;
+ accountId = undefined;
+ rubiConf = {};
+ cache.gpt.registered = false;
baseAdapter.disableAnalytics.apply(this, arguments);
},
track({eventType, args}) {
@@ -376,12 +499,19 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
]);
cacheEntry.bids = {};
cacheEntry.bidsWon = {};
- cacheEntry.referrer = args.bidderRequests[0].refererInfo.referer;
+ cacheEntry.referrer = utils.deepAccess(args, 'bidderRequests.0.refererInfo.referer');
const floorData = utils.deepAccess(args, 'bidderRequests.0.bids.0.floorData');
if (floorData) {
cacheEntry.floorData = {...floorData};
}
+ cacheEntry.gdprConsent = utils.deepAccess(args, 'bidderRequests.0.gdprConsent');
+ cacheEntry.session = storage.localStorageIsEnabled() && updateRpaCookie();
cache.auctions[args.auctionId] = cacheEntry;
+ // register to listen to gpt events if not done yet
+ if (!cache.gpt.registered && utils.isGptPubadsDefined()) {
+ subscribeToGamSlots();
+ cache.gpt.registered = true;
+ }
break;
case BID_REQUESTED:
Object.assign(cache.auctions[args.auctionId].bids, args.bids.reduce((memo, bid) => {
@@ -452,6 +582,12 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
}
return ['banner'];
},
+ 'gam', () => {
+ if (utils.deepAccess(bid, 'fpd.context.adServer.name') === 'gam') {
+ return {adSlot: bid.fpd.context.adServer.adSlot}
+ }
+ },
+ 'pbAdSlot', () => utils.deepAccess(bid, 'fpd.context.pbAdSlot')
])
]);
return memo;
@@ -461,8 +597,8 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
let auctionEntry = cache.auctions[args.auctionId];
let bid = auctionEntry.bids[args.requestId];
// If floor resolved gptSlot but we have not yet, then update the adUnit to have the adSlot name
- if (!utils.deepAccess(bid, 'adUnit.adSlot') && utils.deepAccess(args, 'floorData.matchedFields.gptSlot')) {
- bid.adUnit.adSlot = args.floorData.matchedFields.gptSlot;
+ if (!utils.deepAccess(bid, 'adUnit.gam.adSlot') && utils.deepAccess(args, 'floorData.matchedFields.gptSlot')) {
+ utils.deepSetValue(bid, 'adUnit.gam.adSlot', args.floorData.matchedFields.gptSlot);
}
// if we have not set enforcements yet set it
if (!utils.deepAccess(auctionEntry, 'floorData.enforcements') && utils.deepAccess(args, 'floorData.enforcements')) {
@@ -479,7 +615,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
delete bid.error; // it's possible for this to be set by a previous timeout
break;
case NO_BID:
- bid.status = args.status === BID_REJECTED ? 'rejected' : 'no-bid';
+ bid.status = args.status === BID_REJECTED ? BID_REJECTED_IPF : 'no-bid';
delete bid.error;
break;
default:
@@ -488,7 +624,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
code: 'request-error'
};
}
- bid.clientLatencyMillis = Date.now() - cache.auctions[args.auctionId].timestamp;
+ bid.clientLatencyMillis = bid.timeToRespond || Date.now() - cache.auctions[args.auctionId].timestamp;
bid.bidResponse = parseBidResponse(args, bid.bidResponse);
break;
case BIDDER_DONE:
@@ -549,7 +685,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
adapterManager.registerAnalyticsAdapter({
adapter: rubiconAdapter,
code: 'rubicon',
- gvlid: 52
+ gvlid: RUBICON_GVL_ID
});
export default rubiconAdapter;
diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js
index 979cc430f15..d4411a82e8f 100644
--- a/modules/rubiconBidAdapter.js
+++ b/modules/rubiconBidAdapter.js
@@ -7,23 +7,14 @@ import find from 'core-js-pure/features/array/find.js';
const DEFAULT_INTEGRATION = 'pbjs_lite';
const DEFAULT_PBS_INTEGRATION = 'pbjs';
-// always use https, regardless of whether or not current page is secure
-export const FASTLANE_ENDPOINT = 'https://fastlane.rubiconproject.com/a/api/fastlane.json';
-export const VIDEO_ENDPOINT = 'https://prebid-server.rubiconproject.com/openrtb2/auction';
-export const SYNC_ENDPOINT = 'https://eus.rubiconproject.com/usync.html';
+let rubiConf = {};
+// we are saving these as global to this module so that if a pub accidentally overwrites the entire
+// rubicon object, then we do not lose other data
+config.getConfig('rubicon', config => {
+ utils.mergeDeep(rubiConf, config.rubicon);
+});
const GVLID = 52;
-const DIGITRUST_PROP_NAMES = {
- FASTLANE: {
- id: 'dt.id',
- keyv: 'dt.keyv',
- pref: 'dt.pref'
- },
- PREBID_SERVER: {
- id: 'id',
- keyv: 'keyv'
- }
-};
var sizeMap = {
1: '468x60',
@@ -163,9 +154,9 @@ export const spec = {
source: {
tid: bidRequest.transactionId
},
- tmax: config.getConfig('TTL') || 1000,
+ tmax: bidderRequest.timeout,
imp: [{
- exp: 300,
+ exp: config.getConfig('s2sConfig.defaultTtl'),
id: bidRequest.adUnitCode,
secure: 1,
ext: {
@@ -177,7 +168,7 @@ export const spec = {
prebid: {
cache: {
vastxml: {
- returnCreative: false // don't return the VAST
+ returnCreative: rubiConf.returnVast === true
}
},
targeting: {
@@ -188,7 +179,7 @@ export const spec = {
},
bidders: {
rubicon: {
- integration: config.getConfig('rubicon.int_type') || DEFAULT_PBS_INTEGRATION
+ integration: rubiConf.int_type || DEFAULT_PBS_INTEGRATION
}
}
}
@@ -203,7 +194,7 @@ export const spec = {
}
let bidFloor;
- if (typeof bidRequest.getFloor === 'function' && !config.getConfig('rubicon.disableFloors')) {
+ if (typeof bidRequest.getFloor === 'function' && !rubiConf.disableFloors) {
let floorInfo;
try {
floorInfo = bidRequest.getFloor({
@@ -228,11 +219,6 @@ export const spec = {
addVideoParameters(data, bidRequest);
- const digiTrust = _getDigiTrustQueryParams(bidRequest, 'PREBID_SERVER');
- if (digiTrust) {
- utils.deepSetValue(data, 'user.ext.digitrust', digiTrust);
- }
-
if (bidderRequest.gdprConsent) {
// note - gdprApplies & consentString may be undefined in certain use-cases for consentManagement module
let gdprApplies;
@@ -250,8 +236,7 @@ export const spec = {
const eids = utils.deepAccess(bidderRequest, 'bids.0.userIdAsEids');
if (eids && eids.length) {
- // filter out unsupported id systems
- utils.deepSetValue(data, 'user.ext.eids', eids.filter(eid => ['adserver.org', 'pubcid.org', 'liveintent.com', 'liveramp.com', 'sharedid.org'].indexOf(eid.source) !== -1));
+ utils.deepSetValue(data, 'user.ext.eids', eids);
// liveintent requires additional props to be set
const liveIntentEid = find(data.user.ext.eids, eid => eid.source === 'liveintent.com');
@@ -328,19 +313,19 @@ export const spec = {
return {
method: 'POST',
- url: VIDEO_ENDPOINT,
+ url: `https://${rubiConf.videoHost || 'prebid-server'}.rubiconproject.com/openrtb2/auction`,
data,
bidRequest
}
});
- if (config.getConfig('rubicon.singleRequest') !== true) {
+ if (rubiConf.singleRequest !== true) {
// bids are not grouped if single request mode is not enabled
requests = videoRequests.concat(bidRequests.filter(bidRequest => bidType(bidRequest) === 'banner').map(bidRequest => {
const bidParams = spec.createSlotParams(bidRequest, bidderRequest);
return {
method: 'GET',
- url: FASTLANE_ENDPOINT,
+ url: `https://${rubiConf.bannerHost || 'fastlane'}.rubiconproject.com/a/api/fastlane.json`,
data: spec.getOrderedParams(bidParams).reduce((paramString, key) => {
const propValue = bidParams[key];
return ((utils.isStr(propValue) && propValue !== '') || utils.isNumber(propValue)) ? `${paramString}${encodeParam(key, propValue)}&` : paramString;
@@ -371,7 +356,7 @@ export const spec = {
// SRA request returns grouped bidRequest arrays not a plain bidRequest
aggregate.push({
method: 'GET',
- url: FASTLANE_ENDPOINT,
+ url: `https://${rubiConf.bannerHost || 'fastlane'}.rubiconproject.com/a/api/fastlane.json`,
data: spec.getOrderedParams(combinedSlotParams).reduce((paramString, key) => {
const propValue = combinedSlotParams[key];
return ((utils.isStr(propValue) && propValue !== '') || utils.isNumber(propValue)) ? `${paramString}${encodeParam(key, propValue)}&` : paramString;
@@ -403,9 +388,10 @@ export const spec = {
'tpid_tdid',
'tpid_liveintent.com',
'tg_v.LIseg',
- 'dt.id',
- 'dt.keyv',
- 'dt.pref',
+ 'ppuid',
+ 'eid_pubcid.org',
+ 'eid_sharedid.org',
+ 'eid_criteo.com',
'rf',
'p_geo.latitude',
'p_geo.longitude',
@@ -478,8 +464,6 @@ export const spec = {
const [latitude, longitude] = params.latLong || [];
- const configIntType = config.getConfig('rubicon.int_type');
-
const data = {
'account_id': params.accountId,
'site_id': params.siteId,
@@ -488,7 +472,7 @@ export const spec = {
'alt_size_ids': parsedSizes.slice(1).join(',') || undefined,
'rp_floor': (params.floor = parseFloat(params.floor)) > 0.01 ? params.floor : 0.01,
'rp_secure': '1',
- 'tk_flint': `${configIntType || DEFAULT_INTEGRATION}_v$prebid.version$`,
+ 'tk_flint': `${rubiConf.int_type || DEFAULT_INTEGRATION}_v$prebid.version$`,
'x_source.tid': bidRequest.transactionId,
'x_source.pchain': params.pchain,
'p_screen_res': _getScreenResolution(),
@@ -500,7 +484,7 @@ export const spec = {
};
// If floors module is enabled and we get USD floor back, send it in rp_hard_floor else undfined
- if (typeof bidRequest.getFloor === 'function' && !config.getConfig('rubicon.disableFloors')) {
+ if (typeof bidRequest.getFloor === 'function' && !rubiConf.disableFloors) {
let floorInfo;
try {
floorInfo = bidRequest.getFloor({
@@ -538,12 +522,31 @@ export const spec = {
if (sharedId) {
data['eid_sharedid.org'] = `${sharedId.uids[0].id}^${sharedId.uids[0].atype}^${sharedId.uids[0].ext.third}`;
}
+ const pubcid = find(bidRequest.userIdAsEids, eid => eid.source === 'pubcid.org');
+ if (pubcid) {
+ data['eid_pubcid.org'] = `${pubcid.uids[0].id}^${pubcid.uids[0].atype}`;
+ }
+ const criteoId = find(bidRequest.userIdAsEids, eid => eid.source === 'criteo.com');
+ if (criteoId) {
+ data['eid_criteo.com'] = `${criteoId.uids[0].id}^${criteoId.uids[0].atype}`;
+ }
}
// set ppuid value from config value
const configUserId = config.getConfig('user.id');
if (configUserId) {
data['ppuid'] = configUserId;
+ } else {
+ // if config.getConfig('user.id') doesn't return anything, then look for the first eid.uids[*].ext.stype === 'ppuid'
+ for (let i = 0; bidRequest.userIdAsEids && i < bidRequest.userIdAsEids.length; i++) {
+ if (bidRequest.userIdAsEids[i].uids) {
+ const pubProvidedId = find(bidRequest.userIdAsEids[i].uids, uid => uid.ext && uid.ext.stype === 'ppuid');
+ if (pubProvidedId && pubProvidedId.id) {
+ data['ppuid'] = pubProvidedId.id;
+ break;
+ }
+ }
+ }
}
if (bidderRequest.gdprConsent) {
@@ -602,10 +605,6 @@ export const spec = {
data['tg_i.dfp_ad_unit_code'] = gamAdUnit.replace(/^\/+/, '');
}
- // digitrust properties
- const digitrustParams = _getDigiTrustQueryParams(bidRequest, 'FASTLANE');
- Object.assign(data, digitrustParams);
-
if (config.getConfig('coppa') === true) {
data['coppa'] = 1;
}
@@ -672,7 +671,7 @@ export const spec = {
cpm: bid.price || 0,
bidderCode: seatbid.seat,
ttl: 300,
- netRevenue: config.getConfig('rubicon.netRevenue') !== false, // If anything other than false, netRev is true
+ netRevenue: rubiConf.netRevenue !== false, // If anything other than false, netRev is true
width: bid.w || utils.deepAccess(bidRequest, 'mediaTypes.video.w') || utils.deepAccess(bidRequest, 'params.video.playerWidth'),
height: bid.h || utils.deepAccess(bidRequest, 'mediaTypes.video.h') || utils.deepAccess(bidRequest, 'params.video.playerHeight'),
};
@@ -752,7 +751,7 @@ export const spec = {
cpm: ad.cpm || 0,
dealId: ad.deal,
ttl: 300, // 5 minutes
- netRevenue: config.getConfig('rubicon.netRevenue') !== false, // If anything other than false, netRev is true
+ netRevenue: rubiConf.netRevenue !== false, // If anything other than false, netRev is true
rubicon: {
advertiserId: ad.advertiser, networkId: ad.network
},
@@ -795,7 +794,7 @@ export const spec = {
},
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) {
if (!hasSynced && syncOptions.iframeEnabled) {
- // data is only assigned if params are available to pass to SYNC_ENDPOINT
+ // data is only assigned if params are available to pass to syncEndpoint
let params = '';
if (gdprConsent && typeof gdprConsent.consentString === 'string') {
@@ -814,7 +813,7 @@ export const spec = {
hasSynced = true;
return {
type: 'iframe',
- url: SYNC_ENDPOINT + params
+ url: `https://${rubiConf.syncHost || 'eus'}.rubiconproject.com/usync.html` + params
};
}
},
@@ -837,38 +836,6 @@ function _getScreenResolution() {
return [window.screen.width, window.screen.height].join('x');
}
-function _getDigiTrustQueryParams(bidRequest = {}, endpointName) {
- if (!endpointName || !DIGITRUST_PROP_NAMES[endpointName]) {
- return null;
- }
- const propNames = DIGITRUST_PROP_NAMES[endpointName];
-
- function getDigiTrustId() {
- const bidRequestDigitrust = utils.deepAccess(bidRequest, 'userId.digitrustid.data');
- if (bidRequestDigitrust) {
- return bidRequestDigitrust;
- }
-
- let digiTrustUser = (window.DigiTrust && (config.getConfig('digiTrustId') || window.DigiTrust.getUser({member: 'T9QSFKPDN9'})));
- return (digiTrustUser && digiTrustUser.success && digiTrustUser.identity) || null;
- }
-
- let digiTrustId = getDigiTrustId();
- // Verify there is an ID and this user has not opted out
- if (!digiTrustId || (digiTrustId.privacy && digiTrustId.privacy.optout)) {
- return null;
- }
-
- const digiTrustQueryParams = {
- [propNames.id]: digiTrustId.id,
- [propNames.keyv]: digiTrustId.keyv
- };
- if (propNames.pref) {
- digiTrustQueryParams[propNames.pref] = 0;
- }
- return digiTrustQueryParams;
-}
-
/**
* @param {BidRequest} bidRequest
* @param bidderRequest
@@ -1060,6 +1027,7 @@ function bidType(bid, log = false) {
}
}
+export const resetRubiConf = () => rubiConf = {};
export function masSizeOrdering(sizes) {
const MAS_SIZE_PRIORITY = [15, 2, 9];
diff --git a/modules/sharedIdSystem.js b/modules/sharedIdSystem.js
index 5c2a3df0595..cdd840c4f54 100644
--- a/modules/sharedIdSystem.js
+++ b/modules/sharedIdSystem.js
@@ -296,10 +296,10 @@ export const sharedIdSubmodule = {
/**
* performs action to obtain id and return a value.
* @function
- * @param {SubmoduleParams} [configParams]
+ * @param {SubmoduleConfig} [config]
* @returns {sharedId}
*/
- getId(configParams) {
+ getId(config) {
const resp = function (callback) {
utils.logInfo('SharedId: Sharedid doesnt exists, new cookie creation');
ajax(ID_SVC, idGenerationCallback(callback), undefined, {method: 'GET', withCredentials: true});
@@ -309,11 +309,12 @@ export const sharedIdSubmodule = {
/**
* performs actions even if the id exists and returns a value
- * @param configParams
+ * @param config
* @param storedId
* @returns {{callback: *}}
*/
- extendId(configParams, storedId) {
+ extendId(config, storedId) {
+ const configParams = (config && config.params) || {};
utils.logInfo('SharedId: Existing shared id ' + storedId.id);
const resp = function (callback) {
const needSync = isIdSynced(configParams, storedId);
diff --git a/modules/smaatoBidAdapter.js b/modules/smaatoBidAdapter.js
index ce0edb1e19c..49b4ed6aa34 100644
--- a/modules/smaatoBidAdapter.js
+++ b/modules/smaatoBidAdapter.js
@@ -110,6 +110,13 @@ const buildOpenRtbBidRequestPayload = (validBidRequests, bidderRequest) => {
utils.deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent);
}
+ if (utils.deepAccess(validBidRequests[0], 'params.app')) {
+ const geo = utils.deepAccess(validBidRequests[0], 'params.app.geo');
+ utils.deepSetValue(request, 'device.geo', geo);
+ const ifa = utils.deepAccess(validBidRequests[0], 'params.app.ifa')
+ utils.deepSetValue(request, 'device.ifa', ifa);
+ }
+
utils.logInfo('[SMAATO] OpenRTB Request:', request);
return JSON.stringify(request);
}
@@ -185,7 +192,7 @@ export const spec = {
ttl: ttlSec,
creativeId: b.crid,
dealId: b.dealid || null,
- netRevenue: true,
+ netRevenue: utils.deepAccess(b, 'ext.net', true),
currency: res.cur,
meta: {
advertiserDomains: b.adomain,
diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js
index 97dd43fc5ba..8462e749b91 100644
--- a/modules/smartadserverBidAdapter.js
+++ b/modules/smartadserverBidAdapter.js
@@ -83,10 +83,11 @@ export const spec = {
w: size[0],
h: size[1]
}));
- } else if (videoMediaType && videoMediaType.context === 'instream') {
+ } else if (videoMediaType && (videoMediaType.context === 'instream' || videoMediaType.context === 'outstream')) {
// Specific attributes for instream.
let playerSize = videoMediaType.playerSize[0];
- payload.isVideo = true;
+ payload.isVideo = videoMediaType.context === 'instream';
+ payload.mediaType = VIDEO;
payload.videoData = {
videoProtocol: bid.params.video.protocol,
playerWidth: playerSize[0],
@@ -146,10 +147,11 @@ export const spec = {
ttl: response.ttl
};
- if (bidRequest.isVideo) {
+ if (bidRequest.mediaType === VIDEO) {
bidResponse.mediaType = VIDEO;
bidResponse.vastUrl = response.adUrl;
bidResponse.vastXml = response.ad;
+ bidResponse.content = response.ad;
} else {
bidResponse.adUrl = response.adUrl;
bidResponse.ad = response.ad;
diff --git a/modules/smartadserverBidAdapter.md b/modules/smartadserverBidAdapter.md
index c6f68363d7c..05e29359fd2 100644
--- a/modules/smartadserverBidAdapter.md
+++ b/modules/smartadserverBidAdapter.md
@@ -94,4 +94,43 @@ Please reach out to your Technical account manager for more information.
}
}]
};
+```
+
+## Outstream Video
+
+```
+ var outstreamVideoAdUnit = {
+ code: 'test-div',
+ mediaTypes: {
+ video: {
+ context: 'outstream',
+ playerSize: [640, 480]
+ }
+ },
+ renderer: {
+ url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js',
+ render: function (bid) {
+ bid.renderer.push(() => {
+ ANOutstreamVideo.renderAd({
+ targetId: bid.adUnitCode,
+ adResponse: bid
+ });
+ });
+ }
+ },
+ bids: [{
+ bidder: "smart",
+ params: {
+ domain: 'https://prg.smartadserver.com',
+ siteId: 207435,
+ pageId: 896536,
+ formatId: 85089,
+ bidfloor: 5,
+ video: {
+ protocol: 6,
+ startDelay: 1
+ }
+ }
+ }]
+ };
```
\ No newline at end of file
diff --git a/modules/spotxBidAdapter.js b/modules/spotxBidAdapter.js
index 9a3779dc65c..6104fce1d97 100644
--- a/modules/spotxBidAdapter.js
+++ b/modules/spotxBidAdapter.js
@@ -1,4 +1,5 @@
import * as utils from '../src/utils.js';
+import { config } from '../src/config.js';
import { Renderer } from '../src/Renderer.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { VIDEO } from '../src/mediaTypes.js';
@@ -19,7 +20,7 @@ export const spec = {
* From Prebid.js: isBidRequestValid - Verify the the AdUnits.bids, respond with true (valid) or false (invalid).
*
* @param {object} bid The bid to validate.
- * @return boolean True if this is a valid bid, and false otherwise.
+ * @return {boolean} True if this is a valid bid, and false otherwise.
*/
isBidRequestValid: function(bid) {
if (bid && typeof bid.params !== 'object') {
@@ -64,14 +65,24 @@ export const spec = {
* from Prebid.js: buildRequests - Takes an array of valid bid requests, all of which are guaranteed to have passed the isBidRequestValid() test.
*
* @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server.
- * @return ServerRequest Info describing the request to the server.
+ * @param {object} bidderRequest - The master bidRequest object.
+ * @return {ServerRequest} Info describing the request to the server.
*/
buildRequests: function(bidRequests, bidderRequest) {
- const page = bidderRequest.refererInfo.referer;
- const isPageSecure = !!page.match(/^https:/)
+ const referer = bidderRequest.refererInfo.referer;
+ const isPageSecure = !!referer.match(/^https:/);
const siteId = '';
const spotxRequests = bidRequests.map(function(bid) {
+ let page;
+ if (utils.getBidIdParameter('page', bid.params)) {
+ page = utils.getBidIdParameter('page', bid.params);
+ } else if (config.getConfig('pageUrl')) {
+ page = config.getConfig('pageUrl');
+ } else {
+ page = referer;
+ }
+
const channelId = utils.getBidIdParameter('channel_id', bid.params);
let pubcid = null;
@@ -228,14 +239,15 @@ export const spec = {
}
// ID5 fied
- if (bid && bid.userId && bid.userId.id5id) {
+ if (utils.deepAccess(bid, 'userId.id5id.uid')) {
userExt.eids = userExt.eids || [];
userExt.eids.push(
{
source: 'id5-sync.com',
uids: [{
- id: bid.userId.id5id
- }]
+ id: bid.userId.id5id.uid
+ }],
+ ext: bid.userId.id5id.ext || {}
}
)
}
@@ -320,6 +332,7 @@ export const spec = {
currency: serverResponseBody.cur || 'USD',
cpm: spotxBid.price,
creativeId: spotxBid.crid || '',
+ dealId: spotxBid.dealid || '',
ttl: 360,
netRevenue: true,
channel_id: serverResponseBody.id,
@@ -434,11 +447,11 @@ function createOutstreamScript(bid) {
const customOverride = utils.getBidIdParameter('custom_override', bid.renderer.config.outstream_options);
if (customOverride && utils.isPlainObject(customOverride)) {
- utils.logMessage('[SPOTX][renderer] Custom beahavior.');
+ utils.logMessage('[SPOTX][renderer] Custom behavior.');
for (let name in customOverride) {
if (customOverride.hasOwnProperty(name)) {
if (name === 'channel_id' || name === 'vast_url' || name === 'content_page_url' || name === 'ad_unit') {
- utils.logWarn('[SPOTX][renderer] Custom beahavior: following option cannot be overrided: ' + name);
+ utils.logWarn('[SPOTX][renderer] Custom behavior: following option cannot be overridden: ' + name);
} else {
dataSpotXParams['data-spotx_' + name] = customOverride[name];
}
diff --git a/modules/stroeerCoreBidAdapter.js b/modules/stroeerCoreBidAdapter.js
new file mode 100644
index 00000000000..ec442f5125a
--- /dev/null
+++ b/modules/stroeerCoreBidAdapter.js
@@ -0,0 +1,196 @@
+import {registerBidder} from '../src/adapters/bidderFactory.js';
+import {BANNER} from '../src/mediaTypes.js';
+import * as utils from '../src/utils.js';
+
+const GVL_ID = 136;
+const BIDDER_CODE = 'stroeerCore';
+const DEFAULT_HOST = 'hb.adscale.de';
+const DEFAULT_PATH = '/dsh';
+const DEFAULT_PORT = '';
+const FIVE_MINUTES_IN_SECONDS = 300;
+const USER_SYNC_IFRAME_URL = 'https://js.adscale.de/pbsync.html';
+
+const isSecureWindow = () => utils.getWindowSelf().location.protocol === 'https:';
+const isMainPageAccessible = () => getMostAccessibleTopWindow() === utils.getWindowTop();
+
+function getTopWindowReferrer() {
+ try {
+ return utils.getWindowTop().document.referrer;
+ } catch (e) {
+ return utils.getWindowSelf().referrer;
+ }
+}
+
+function getMostAccessibleTopWindow() {
+ let res = utils.getWindowSelf();
+
+ try {
+ while (utils.getWindowTop().top !== res && res.parent.location.href.length) {
+ res = res.parent;
+ }
+ } catch (ignore) {
+ }
+
+ return res;
+}
+
+function elementInView(elementId) {
+ const resolveElement = (elId) => {
+ const win = utils.getWindowSelf();
+
+ return win.document.getElementById(elId);
+ };
+
+ const visibleInWindow = (el, win) => {
+ const rect = el.getBoundingClientRect();
+ const inView = (rect.top + rect.height >= 0) && (rect.top <= win.innerHeight);
+
+ if (win !== win.parent) {
+ return inView && visibleInWindow(win.frameElement, win.parent);
+ }
+
+ return inView;
+ };
+
+ try {
+ return visibleInWindow(resolveElement(elementId), utils.getWindowSelf());
+ } catch (e) {
+ // old browser, element not found, cross-origin etc.
+ }
+ return undefined;
+}
+
+function buildUrl({host: hostname = DEFAULT_HOST, port = DEFAULT_PORT, securePort, path: pathname = DEFAULT_PATH}) {
+ if (securePort) {
+ port = securePort;
+ }
+
+ return utils.buildUrl({protocol: 'https', hostname, port, pathname});
+}
+
+function getGdprParams(gdprConsent) {
+ if (gdprConsent) {
+ const consentString = encodeURIComponent(gdprConsent.consentString || '')
+ const isGdpr = gdprConsent.gdprApplies ? 1 : 0;
+
+ return `?gdpr=${isGdpr}&gdpr_consent=${consentString}`
+ } else {
+ return '';
+ }
+}
+
+export const spec = {
+ code: BIDDER_CODE,
+ gvlid: GVL_ID,
+ supportedMediaTypes: [BANNER],
+
+ isBidRequestValid: (function () {
+ const validators = [];
+
+ const createValidator = (checkFn, errorMsgFn) => {
+ return (bidRequest) => {
+ if (checkFn(bidRequest)) {
+ return true;
+ } else {
+ utils.logError(`invalid bid: ${errorMsgFn(bidRequest)}`, 'ERROR');
+ return false;
+ }
+ }
+ };
+
+ function isBanner(bidReq) {
+ return (!bidReq.mediaTypes && !bidReq.mediaType) ||
+ (bidReq.mediaTypes && bidReq.mediaTypes.banner) ||
+ bidReq.mediaType === BANNER;
+ }
+
+ validators.push(createValidator((bidReq) => isBanner(bidReq),
+ bidReq => `bid request ${bidReq.bidId} is not a banner`));
+ validators.push(createValidator((bidReq) => typeof bidReq.params === 'object',
+ bidReq => `bid request ${bidReq.bidId} does not have custom params`));
+ validators.push(createValidator((bidReq) => utils.isStr(bidReq.params.sid),
+ bidReq => `bid request ${bidReq.bidId} does not have a sid string field`));
+
+ return function (bidRequest) {
+ return validators.every(f => f(bidRequest));
+ }
+ }()),
+
+ buildRequests: function (validBidRequests = [], bidderRequest) {
+ const anyBid = bidderRequest.bids[0];
+
+ const payload = {
+ id: bidderRequest.auctionId,
+ bids: [],
+ ref: getTopWindowReferrer(),
+ ssl: isSecureWindow(),
+ mpa: isMainPageAccessible(),
+ timeout: bidderRequest.timeout - (Date.now() - bidderRequest.auctionStart)
+ };
+
+ const userIds = anyBid.userId;
+
+ if (!utils.isEmpty(userIds)) {
+ payload.user = {
+ euids: userIds
+ };
+ }
+
+ const gdprConsent = bidderRequest.gdprConsent;
+
+ if (gdprConsent && gdprConsent.consentString != null && gdprConsent.gdprApplies != null) {
+ payload.gdpr = {
+ consent: bidderRequest.gdprConsent.consentString, applies: bidderRequest.gdprConsent.gdprApplies
+ };
+ }
+
+ function bidSizes(bid) {
+ return utils.deepAccess(bid, 'mediaTypes.banner.sizes') || bid.sizes /* for prebid < 3 */ || [];
+ }
+
+ validBidRequests.forEach(bid => {
+ payload.bids.push({
+ bid: bid.bidId, sid: bid.params.sid, siz: bidSizes(bid), viz: elementInView(bid.adUnitCode)
+ });
+ });
+
+ return {
+ method: 'POST', url: buildUrl(anyBid.params), data: payload
+ }
+ },
+
+ interpretResponse: function (serverResponse) {
+ const bids = [];
+
+ if (serverResponse.body && typeof serverResponse.body === 'object') {
+ serverResponse.body.bids.forEach(bidResponse => {
+ bids.push({
+ requestId: bidResponse.bidId,
+ cpm: bidResponse.cpm || 0,
+ width: bidResponse.width || 0,
+ height: bidResponse.height || 0,
+ ad: bidResponse.ad,
+ ttl: FIVE_MINUTES_IN_SECONDS,
+ currency: 'EUR',
+ netRevenue: true,
+ creativeId: '',
+ });
+ });
+ }
+
+ return bids;
+ },
+
+ getUserSyncs: function (syncOptions, serverResponses, gdprConsent) {
+ if (serverResponses.length > 0 && syncOptions.iframeEnabled) {
+ return [{
+ type: 'iframe',
+ url: USER_SYNC_IFRAME_URL + getGdprParams(gdprConsent)
+ }];
+ }
+
+ return [];
+ }
+};
+
+registerBidder(spec);
diff --git a/modules/stroeerCoreBidAdapter.md b/modules/stroeerCoreBidAdapter.md
new file mode 100644
index 00000000000..fe6e92057c6
--- /dev/null
+++ b/modules/stroeerCoreBidAdapter.md
@@ -0,0 +1,31 @@
+## Overview
+
+```
+Module Name: Stroeer Bidder Adapter
+Module Type: Bidder Adapter
+Maintainer: help@cz.stroeer-labs.com
+```
+
+
+## Ad unit configuration for publishers
+
+```javascript
+const adUnits = [{
+ code: 'div-gpt-ad-1460505748561-0',
+ mediaTypes: {
+ banner: {
+ sizes: [[300, 250]],
+ }
+ },
+ bids: [{
+ bidder: 'stroeerCore',
+ params: {
+ sid: "06b782cc-091b-4f53-9cd2-0291679aa1ac"
+ }
+ }]
+}];
+```
+### Config Notes
+
+* Slot id (`sid`) is required. The adapter will ignore bid requests from prebid if `sid` is not provided. This must be in the decoded form. For example, "1234" as opposed to "MTM0ODA=".
+* The server ignores dimensions that are not supported by the slot or by the platform (such as 987x123).
diff --git a/modules/sublimeBidAdapter.js b/modules/sublimeBidAdapter.js
index 1f8cb59f442..e9f7cf19033 100644
--- a/modules/sublimeBidAdapter.js
+++ b/modules/sublimeBidAdapter.js
@@ -9,7 +9,7 @@ const DEFAULT_CURRENCY = 'EUR';
const DEFAULT_PROTOCOL = 'https';
const DEFAULT_TTL = 600;
const SUBLIME_ANTENNA = 'antenna.ayads.co';
-const SUBLIME_VERSION = '0.5.2';
+const SUBLIME_VERSION = '0.6.0';
/**
* Debug log message
@@ -23,7 +23,8 @@ export function log(msg, obj) {
// Default state
export const state = {
zoneId: '',
- transactionId: ''
+ transactionId: '',
+ notifyId: ''
};
/**
@@ -47,8 +48,8 @@ export function sendEvent(eventName) {
z: state.zoneId,
e: eventName,
src: 'pa',
- puid: state.transactionId,
- trId: state.transactionId,
+ puid: state.transactionId || state.notifyId,
+ trId: state.transactionId || state.notifyId,
ver: SUBLIME_VERSION,
};
@@ -101,6 +102,7 @@ function buildRequests(validBidRequests, bidderRequest) {
setState({
transactionId: bid.transactionId,
+ notifyId: bid.params.notifyId,
zoneId: bid.params.zoneId,
debug: bid.params.debug || false,
});
@@ -117,6 +119,7 @@ function buildRequests(validBidRequests, bidderRequest) {
h: size[1],
})),
transactionId: bid.transactionId,
+ notifyId: bid.params.notifyId,
zoneId: bid.params.zoneId,
};
diff --git a/modules/sublimeBidAdapter.md b/modules/sublimeBidAdapter.md
index e57f4a1fdb0..5cd1c95b682 100644
--- a/modules/sublimeBidAdapter.md
+++ b/modules/sublimeBidAdapter.md
@@ -9,7 +9,7 @@ Maintainer: pbjs@sublimeskinz.com
# Description
Connects to Sublime for bids.
-Sublime bid adapter supports Skinz and M-Skinz formats.
+Sublime bid adapter supports Skinz.
# Nota Bene
@@ -53,10 +53,13 @@ var adUnits = [{
bids: [{
bidder: 'sublime',
params: {
- zoneId:
+ zoneId: ,
+ notifyId:
}
}]
}];
```
-Where you replace `` by your Sublime Zone id
+Where you replace:
+- `` by your Sublime Zone id;
+- `` by your Sublime Notify id
diff --git a/modules/teadsBidAdapter.js b/modules/teadsBidAdapter.js
index 08ae1854669..6d55aabbfb5 100644
--- a/modules/teadsBidAdapter.js
+++ b/modules/teadsBidAdapter.js
@@ -133,8 +133,8 @@ function getTimeToFirstByte(win) {
performance.getEntriesByType('navigation')[0] &&
performance.getEntriesByType('navigation')[0].responseStart &&
performance.getEntriesByType('navigation')[0].requestStart &&
- performance.getEntriesByType('navigation')[0].responseStart >= 0 &&
- performance.getEntriesByType('navigation')[0].requestStart >= 0 &&
+ performance.getEntriesByType('navigation')[0].responseStart > 0 &&
+ performance.getEntriesByType('navigation')[0].requestStart > 0 &&
Math.round(
performance.getEntriesByType('navigation')[0].responseStart - performance.getEntriesByType('navigation')[0].requestStart
);
@@ -146,8 +146,8 @@ function getTimeToFirstByte(win) {
const ttfbWithTimingV1 = performance &&
performance.timing.responseStart &&
performance.timing.requestStart &&
- performance.timing.responseStart >= 0 &&
- performance.timing.requestStart >= 0 &&
+ performance.timing.responseStart > 0 &&
+ performance.timing.requestStart > 0 &&
performance.timing.responseStart - performance.timing.requestStart;
return ttfbWithTimingV1 ? ttfbWithTimingV1.toString() : '';
diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js
index d6b1f95351d..b003de7785f 100644
--- a/modules/tripleliftBidAdapter.js
+++ b/modules/tripleliftBidAdapter.js
@@ -111,6 +111,8 @@ function _getSyncType(syncOptions) {
function _buildPostBody(bidRequests) {
let data = {};
let { schain } = bidRequests[0];
+ const globalFpd = _getGlobalFpd();
+
data.imp = bidRequests.map(function(bidRequest, index) {
let imp = {
id: index,
@@ -137,10 +139,10 @@ function _buildPostBody(bidRequests) {
};
}
- if (schain) {
- data.ext = {
- schain
- }
+ let ext = _getExt(schain, globalFpd);
+
+ if (!utils.isEmpty(ext)) {
+ data.ext = ext;
}
return data;
}
@@ -172,6 +174,38 @@ function _getFloor (bid) {
return floor !== null ? floor : bid.params.floor;
}
+function _getGlobalFpd() {
+ let fpd = {};
+ const fpdContext = Object.assign({}, config.getConfig('fpd.context'));
+ const fpdUser = Object.assign({}, config.getConfig('fpd.user'));
+
+ _addEntries(fpd, fpdContext);
+ _addEntries(fpd, fpdUser);
+
+ return fpd;
+}
+
+function _addEntries(target, source) {
+ if (!utils.isEmpty(source)) {
+ Object.keys(source).forEach(key => {
+ if (source[key] != null) {
+ target[key] = source[key];
+ }
+ });
+ }
+}
+
+function _getExt(schain, fpd) {
+ let ext = {};
+ if (!utils.isEmpty(schain)) {
+ ext.schain = { ...schain };
+ }
+ if (!utils.isEmpty(fpd)) {
+ ext.fpd = { ...fpd };
+ }
+ return ext;
+}
+
function getUnifiedIdEids(bidRequests) {
return getEids(bidRequests, 'tdid', 'adserver.org', 'TDID');
}
@@ -239,13 +273,18 @@ function _buildResponseObject(bidderRequest, bid) {
dealId: dealId,
currency: 'USD',
ttl: 300,
- tl_source: bid.tl_source
+ tl_source: bid.tl_source,
+ meta: {}
};
if (breq.mediaTypes.video) {
bidResponse.vastXml = bid.ad;
bidResponse.mediaType = 'video';
};
+
+ if (bid.advertiser_name) {
+ bidResponse.meta.advertiserName = bid.advertiser_name;
+ }
};
return bidResponse;
}
diff --git a/modules/unifiedIdSystem.js b/modules/unifiedIdSystem.js
index f916030d643..3db4003c424 100644
--- a/modules/unifiedIdSystem.js
+++ b/modules/unifiedIdSystem.js
@@ -30,10 +30,11 @@ export const unifiedIdSubmodule = {
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
- * @param {SubmoduleParams} [configParams]
+ * @param {SubmoduleConfig} [config]
* @returns {IdResponse|undefined}
*/
- getId(configParams) {
+ getId(config) {
+ const configParams = (config && config.params) || {};
if (!configParams || (typeof configParams.partner !== 'string' && typeof configParams.url !== 'string')) {
utils.logError('User ID - unifiedId submodule requires either partner or url to be defined');
return;
diff --git a/modules/userId/eids.js b/modules/userId/eids.js
index 15399b9b980..f6c58a5a0bf 100644
--- a/modules/userId/eids.js
+++ b/modules/userId/eids.js
@@ -30,8 +30,16 @@ const USER_IDS_CONFIG = {
// id5Id
'id5id': {
+ getValue: function(data) {
+ return data.uid
+ },
source: 'id5-sync.com',
- atype: 1
+ atype: 1,
+ getEidExt: function(data) {
+ if (data.ext) {
+ return data.ext;
+ }
+ }
},
// parrableId
@@ -111,6 +119,7 @@ const USER_IDS_CONFIG = {
source: 'netid.de',
atype: 1
},
+
// sharedid
'sharedid': {
source: 'sharedid.org',
@@ -123,7 +132,31 @@ const USER_IDS_CONFIG = {
third: data.third
} : undefined;
}
- }
+ },
+
+ // zeotapIdPlus
+ 'IDP': {
+ source: 'zeotap.com',
+ atype: 1
+ },
+
+ // haloId
+ 'haloId': {
+ source: 'audigent.com',
+ atype: 1
+ },
+
+ // quantcastId
+ 'quantcastId': {
+ source: 'quantcast.com',
+ atype: 1
+ },
+
+ // IDx
+ 'idx': {
+ source: 'idx.lat',
+ atype: 1
+ },
};
// this function will create an eid object for the given UserId sub-module
@@ -163,9 +196,13 @@ export function createEidsArray(bidRequestUserId) {
let eids = [];
for (const subModuleKey in bidRequestUserId) {
if (bidRequestUserId.hasOwnProperty(subModuleKey)) {
- const eid = createEidObject(bidRequestUserId[subModuleKey], subModuleKey);
- if (eid) {
- eids.push(eid);
+ if (subModuleKey === 'pubProvidedId') {
+ eids = eids.concat(bidRequestUserId['pubProvidedId']);
+ } else {
+ const eid = createEidObject(bidRequestUserId[subModuleKey], subModuleKey);
+ if (eid) {
+ eids.push(eid);
+ }
}
}
}
diff --git a/modules/userId/eids.md b/modules/userId/eids.md
index 846b9b19207..7dc149cd47a 100644
--- a/modules/userId/eids.md
+++ b/modules/userId/eids.md
@@ -1,7 +1,8 @@
## Example of eids array generated by UserId Module.
+
```
userIdAsEids = [
- {
+ {
source: 'pubcid.org',
uids: [{
id: 'some-random-id-value',
@@ -25,6 +26,9 @@ userIdAsEids = [
uids: [{
id: 'some-random-id-value',
atype: 1
+ },
+ ext: {
+ linkType: 2
}]
},
@@ -91,10 +95,31 @@ userIdAsEids = [
uids: [{
id: 'some-random-id-value',
atype: 1,
- ext: {
+ ext: {
third: 'some-random-id-value'
}
}]
+ },
+ {
+ source: 'zeotap.com',
+ uids: [{
+ id: 'some-random-id-value',
+ atype: 1
+ }]
+ },
+ {
+ source: 'audigent.com',
+ uids: [{
+ id: 'some-random-id-value',
+ atype: 1
+ }]
+ },
+ {
+ source: 'quantcast.com',
+ uids: [{
+ id: 'some-random-id-value',
+ atype: 1
+ }]
}
]
```
diff --git a/modules/userId/index.js b/modules/userId/index.js
index 14f7ad3599b..ce442d4a2d3 100644
--- a/modules/userId/index.js
+++ b/modules/userId/index.js
@@ -14,7 +14,7 @@
* If IdResponse#callback is defined, then it'll called at the end of auction.
* It's permissible to return neither, one, or both fields.
* @name Submodule#getId
- * @param {SubmoduleParams} configParams
+ * @param {SubmoduleConfig} config
* @param {ConsentData|undefined} consentData
* @param {(Object|undefined)} cacheIdObj
* @return {(IdResponse|undefined)} A response object that contains id and/or callback.
@@ -27,7 +27,7 @@
* If IdResponse#callback is defined, then it'll called at the end of auction.
* It's permissible to return neither, one, or both fields.
* @name Submodule#extendId
- * @param {SubmoduleParams} configParams
+ * @param {SubmoduleConfig} config
* @param {Object} storedId - existing id, if any
* @return {(IdResponse|function(callback:function))} A response object that contains id and/or callback.
*/
@@ -37,7 +37,7 @@
* @summary decode a stored value for passing to bid requests
* @name Submodule#decode
* @param {Object|string} value
- * @param {SubmoduleParams|undefined} configParams
+ * @param {SubmoduleConfig|undefined} config
* @return {(Object|undefined)}
*/
@@ -85,6 +85,7 @@
* @property {(array|undefined)} identifiersToResolve - the identifiers from either ls|cookie to be attached to the getId query
* @property {(string|undefined)} providedIdentifierName - defines the name of an identifier that can be found in local storage or in the cookie jar that can be sent along with the getId request. This parameter should be used whenever a customer is able to provide the most stable identifier possible
* @property {(LiveIntentCollectConfig|undefined)} liCollectConfig - the config for LiveIntent's collect requests
+ * @property {(string|undefined)} pd - publisher provided data for reconciling ID5 IDs
*/
/**
@@ -322,7 +323,7 @@ function processSubmoduleCallbacks(submodules, cb) {
setStoredValue(submodule, idObj);
}
// cache decoded value (this is copied to every adUnit bid)
- submodule.idObj = submodule.submodule.decode(idObj);
+ submodule.idObj = submodule.submodule.decode(idObj, submodule.config);
} else {
utils.logInfo(`${MODULE_NAME}: ${submodule.submodule.name} - request id responded with an empty value`);
}
@@ -505,10 +506,10 @@ function initSubmodules(submodules, consentData) {
if (!storedId || refreshNeeded || !storedConsentDataMatchesConsentData(storedConsentData, consentData)) {
// No id previously saved, or a refresh is needed, or consent has changed. Request a new id from the submodule.
- response = submodule.submodule.getId(submodule.config.params, consentData, storedId);
+ response = submodule.submodule.getId(submodule.config, consentData, storedId);
} else if (typeof submodule.submodule.extendId === 'function') {
// If the id exists already, give submodule a chance to decide additional actions that need to be taken
- response = submodule.submodule.extendId(submodule.config.params, storedId);
+ response = submodule.submodule.extendId(submodule.config, storedId);
}
if (utils.isPlainObject(response)) {
@@ -526,16 +527,16 @@ function initSubmodules(submodules, consentData) {
if (storedId) {
// cache decoded value (this is copied to every adUnit bid)
- submodule.idObj = submodule.submodule.decode(storedId, submodule.config.params);
+ submodule.idObj = submodule.submodule.decode(storedId, submodule.config);
}
} else if (submodule.config.value) {
// cache decoded value (this is copied to every adUnit bid)
submodule.idObj = submodule.config.value;
} else {
- const response = submodule.submodule.getId(submodule.config.params, consentData, undefined);
+ const response = submodule.submodule.getId(submodule.config, consentData, undefined);
if (utils.isPlainObject(response)) {
if (typeof response.callback === 'function') { submodule.callback = response.callback; }
- if (response.id) { submodule.idObj = submodule.submodule.decode(response.id, submodule.config.params); }
+ if (response.id) { submodule.idObj = submodule.submodule.decode(response.id, submodule.config); }
}
}
carry.push(submodule);
diff --git a/modules/userId/userId.md b/modules/userId/userId.md
index a47ecd9f08c..a9ab6ccc483 100644
--- a/modules/userId/userId.md
+++ b/modules/userId/userId.md
@@ -26,7 +26,7 @@ pbjs.setConfig({
name: "id5Id",
params: {
partner: 173, // Set your real ID5 partner ID here for production, please ask for one at https://id5.io/universal-id
- pd: "some-pd-string" // See https://wiki.id5.io/display/PD/Prebid.js+UserId+Module for details
+ pd: "some-pd-string" // See https://wiki.id5.io/x/BIAZ for details
},
storage: {
type: "cookie",
@@ -43,7 +43,7 @@ pbjs.setConfig({
}, {
name: 'identityLink',
params: {
- pid: '999' // Set your real identityLink placement ID here
+ pid: '999' // Set your real identityLink placement ID here
},
storage: {
type: 'cookie',
@@ -53,7 +53,7 @@ pbjs.setConfig({
}, {
name: 'liveIntentId',
params: {
- publisherId: '7798696' // Set an identifier of a publisher know to your systems
+ publisherId: '7798696' // Set an identifier of a publisher know to your systems
},
storage: {
type: 'cookie',
@@ -102,7 +102,7 @@ pbjs.setConfig({
}, {
name: 'identityLink',
params: {
- pid: '999' // Set your real identityLink placement ID here
+ pid: '999' // Set your real identityLink placement ID here
},
storage: {
type: 'html5',
@@ -110,25 +110,37 @@ pbjs.setConfig({
expires: 30
}
}, {
- name: 'liveIntentId',
- params: {
- publisherId: '7798696' // Set an identifier of a publisher know to your systems
- },
- storage: {
- type: 'html5',
- name: '_li_pbid',
- expires: 60
- }
+ name: 'liveIntentId',
+ params: {
+ publisherId: '7798696' // Set an identifier of a publisher know to your systems
+ },
+ storage: {
+ type: 'html5',
+ name: '_li_pbid',
+ expires: 60
+ }
}, {
- name: 'sharedId',
+ name: 'sharedId',
params: {
syncTime: 60 // in seconds, default is 24 hours
},
storage: {
- type: 'cookie',
+ type: 'html5',
name: 'sharedid',
expires: 28
}
+ }, {
+ name: 'id5Id',
+ params: {
+ partner: 173, // Set your real ID5 partner ID here for production, please ask for one at https://id5.io/universal-id
+ pd: 'some-pd-string' // See https://wiki.id5.io/x/BIAZ for details
+ },
+ storage: {
+ type: 'html5',
+ name: 'id5id.1st',
+ expires: 90, // Expiration of cookies in days
+ refreshInSeconds: 8*3600 // User Id cache lifetime in seconds, defaulting to 'expires'
+ },
}],
syncDelay: 5000
}
diff --git a/modules/vidazooBidAdapter.js b/modules/vidazooBidAdapter.js
index 0718f22d0d2..4b3b1767cec 100644
--- a/modules/vidazooBidAdapter.js
+++ b/modules/vidazooBidAdapter.js
@@ -117,6 +117,9 @@ function appendUserIdsToRequestPayload(payloadRef, userIds) {
case 'parrableId':
payloadRef[key] = userId.eid;
break;
+ case 'id5id':
+ payloadRef[key] = userId.uid;
+ break;
default:
payloadRef[key] = userId;
}
diff --git a/modules/visxBidAdapter.js b/modules/visxBidAdapter.js
index 511e658c947..725482d07c3 100644
--- a/modules/visxBidAdapter.js
+++ b/modules/visxBidAdapter.js
@@ -100,8 +100,8 @@ export const spec = {
if (payloadUserId.tdid) {
payload.tdid = payloadUserId.tdid;
}
- if (payloadUserId.id5id) {
- payload.id5 = payloadUserId.id5id;
+ if (payloadUserId.id5id && payloadUserId.id5id.uid) {
+ payload.id5 = payloadUserId.id5id.uid;
}
if (payloadUserId.digitrustid && payloadUserId.digitrustid.data && payloadUserId.digitrustid.data.id) {
payload.dtid = payloadUserId.digitrustid.data.id;
diff --git a/modules/vuukleBidAdapter.js b/modules/vuukleBidAdapter.js
new file mode 100644
index 00000000000..e9770b5e62e
--- /dev/null
+++ b/modules/vuukleBidAdapter.js
@@ -0,0 +1,63 @@
+import * as utils from '../src/utils.js';
+import { registerBidder } from '../src/adapters/bidderFactory.js';
+
+const BIDDER_CODE = 'vuukle';
+const URL = 'https://pb.vuukle.com/adapter';
+const TIME_TO_LIVE = 360;
+
+export const spec = {
+ code: BIDDER_CODE,
+
+ isBidRequestValid: function(bid) {
+ return true
+ },
+
+ buildRequests: function(bidRequests) {
+ const requests = bidRequests.map(function (bid) {
+ const parseSized = utils.parseSizesInput(bid.sizes);
+ const arrSize = parseSized[0].split('x');
+ const params = {
+ url: encodeURIComponent(window.location.href),
+ sizes: JSON.stringify(parseSized),
+ width: arrSize[0],
+ height: arrSize[1],
+ params: JSON.stringify(bid.params),
+ rnd: Math.random(),
+ bidId: bid.bidId,
+ source: 'pbjs',
+ version: '$prebid.version$',
+ v: 1,
+ };
+
+ return {
+ method: 'GET',
+ url: URL,
+ data: params,
+ options: {withCredentials: false}
+ }
+ });
+
+ return requests;
+ },
+
+ interpretResponse: function(serverResponse, bidRequest) {
+ if (!serverResponse || !serverResponse.body || !serverResponse.body.ad) {
+ return [];
+ }
+
+ const res = serverResponse.body;
+ const bidResponse = {
+ requestId: bidRequest.data.bidId,
+ cpm: res.cpm,
+ width: res.width,
+ height: res.height,
+ creativeId: res.creative_id,
+ currency: res.currency || 'USD',
+ netRevenue: true,
+ ttl: TIME_TO_LIVE,
+ ad: res.ad
+ };
+ return [bidResponse];
+ },
+}
+registerBidder(spec);
diff --git a/modules/vuukleBidAdapter.md b/modules/vuukleBidAdapter.md
new file mode 100644
index 00000000000..ee7b54c6262
--- /dev/null
+++ b/modules/vuukleBidAdapter.md
@@ -0,0 +1,26 @@
+# Overview
+```
+Module Name: Vuukle Bid Adapter
+Module Type: Bidder Adapter
+Maintainer: support@vuukle.com
+```
+
+# Description
+Module that connects to Vuukle's server for bids.
+Currently module supports only banner mediaType.
+
+# Test Parameters
+```
+ var adUnits = [{
+ code: '/test/div',
+ mediaTypes: {
+ banner: {
+ sizes: [[300, 250]]
+ }
+ },
+ bids: [{
+ bidder: 'vuukle',
+ params: {}
+ }]
+ }];
+```
diff --git a/modules/welectBidAdapter.js b/modules/welectBidAdapter.js
index 3913cfde6a0..f9fc57a4834 100644
--- a/modules/welectBidAdapter.js
+++ b/modules/welectBidAdapter.js
@@ -7,6 +7,7 @@ const DEFAULT_DOMAIN = 'www.welect.de';
export const spec = {
code: BIDDER_CODE,
aliases: ['wlt'],
+ gvlid: 282,
supportedMediaTypes: ['video'],
// short code
@@ -17,7 +18,10 @@ export const spec = {
* @return boolean True if this is a valid bid, and false otherwise.
*/
isBidRequestValid: function (bid) {
- return utils.deepAccess(bid, 'mediaTypes.video.context') === 'instream' && !!(bid.params.placementId);
+ return (
+ utils.deepAccess(bid, 'mediaTypes.video.context') === 'instream' &&
+ !!bid.params.placementId
+ );
},
/**
* Make a server request from the list of BidRequests.
@@ -26,9 +30,11 @@ export const spec = {
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (validBidRequests) {
- return validBidRequests.map(bidRequest => {
- let rawSizes = utils.deepAccess(bidRequest, 'mediaTypes.video.playerSize') || bidRequest.sizes;
- let size = rawSizes[0]
+ return validBidRequests.map((bidRequest) => {
+ let rawSizes =
+ utils.deepAccess(bidRequest, 'mediaTypes.video.playerSize') ||
+ bidRequest.sizes;
+ let size = rawSizes[0];
let domain = bidRequest.params.domain || DEFAULT_DOMAIN;
@@ -38,20 +44,19 @@ export const spec = {
if (bidRequest && bidRequest.gdprConsent) {
gdprConsent = {
- gdpr_consent:
- {
- gdpr_applies: bidRequest.gdprConsent.gdprApplies,
- gdpr_consent: bidRequest.gdprConsent.gdprConsent
- }
- }
+ gdpr_consent: {
+ gdprApplies: bidRequest.gdprConsent.gdprApplies,
+ tcString: bidRequest.gdprConsent.gdprConsent,
+ },
+ };
}
const data = {
width: size[0],
height: size[1],
bid_id: bidRequest.bidId,
- ...gdprConsent
- }
+ ...gdprConsent,
+ };
return {
method: 'POST',
@@ -61,8 +66,8 @@ export const spec = {
contentType: 'application/json',
withCredentials: false,
crossOrigin: true,
- }
- }
+ },
+ };
});
},
/**
@@ -82,6 +87,6 @@ export const spec = {
const bidResponse = responseBody.bidResponse;
bidResponses.push(bidResponse);
return bidResponses;
- }
-}
+ },
+};
registerBidder(spec);
diff --git a/modules/yieldlabBidAdapter.js b/modules/yieldlabBidAdapter.js
index 1d1636bda69..b252c0db2ee 100644
--- a/modules/yieldlabBidAdapter.js
+++ b/modules/yieldlabBidAdapter.js
@@ -47,6 +47,9 @@ export const spec = {
query[prop] = bid.params.customParams[prop]
}
}
+ if (bid.schain && utils.isPlainObject(bid.schain) && Array.isArray(bid.schain.nodes)) {
+ query.schain = createSchainString(bid.schain)
+ }
})
if (bidderRequest) {
@@ -202,7 +205,12 @@ function createQueryString (obj) {
let str = []
for (var p in obj) {
if (obj.hasOwnProperty(p)) {
- str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]))
+ let val = obj[p]
+ if (p !== 'schain') {
+ str.push(encodeURIComponent(p) + '=' + encodeURIComponent(val))
+ } else {
+ str.push(p + '=' + val)
+ }
}
}
return str.join('&')
@@ -225,6 +233,30 @@ function createTargetingString (obj) {
return str.join('&')
}
+/**
+ * Creates a string out of a schain object
+ * @param {Object} schain
+ * @returns {String}
+ */
+function createSchainString (schain) {
+ const ver = schain.ver || ''
+ const complete = schain.complete || ''
+ const keys = ['asi', 'sid', 'hp', 'rid', 'name', 'domain', 'ext']
+ const nodesString = schain.nodes.reduce((acc, node) => {
+ return acc += `!${keys.map(key => node[key] ? encodeURIComponentWithBangIncluded(node[key]) : '').join(',')}`
+ }, '')
+ return `${ver},${complete}${nodesString}`
+}
+
+/**
+ * Encodes URI Component with exlamation mark included. Needed for schain object.
+ * @param {String} str
+ * @returns {String}
+ */
+function encodeURIComponentWithBangIncluded(str) {
+ return encodeURIComponent(str).replace(/!/g, '%21')
+}
+
/**
* Handles an outstream response after the library is loaded
* @param {Object} bid
diff --git a/modules/zeotapIdPlusIdSystem.js b/modules/zeotapIdPlusIdSystem.js
new file mode 100644
index 00000000000..d800286b00e
--- /dev/null
+++ b/modules/zeotapIdPlusIdSystem.js
@@ -0,0 +1,52 @@
+/**
+ * This module adds Zeotap to the User ID module
+ * The {@link module:modules/userId} module is required
+ * @module modules/zeotapIdPlusIdSystem
+ * @requires module:modules/userId
+ */
+import * as utils from '../src/utils.js'
+import {submodule} from '../src/hook.js';
+import { getStorageManager } from '../src/storageManager.js';
+
+const ZEOTAP_COOKIE_NAME = 'IDP';
+export const storage = getStorageManager();
+
+function readCookie() {
+ return storage.cookiesAreEnabled ? storage.getCookie(ZEOTAP_COOKIE_NAME) : null;
+}
+
+function readFromLocalStorage() {
+ return storage.localStorageIsEnabled ? storage.getDataFromLocalStorage(ZEOTAP_COOKIE_NAME) : null;
+}
+
+/** @type {Submodule} */
+export const zeotapIdPlusSubmodule = {
+ /**
+ * used to link submodule with config
+ * @type {string}
+ */
+ name: 'zeotapIdPlus',
+ /**
+ * decode the stored id value for passing to bid requests
+ * @function
+ * @param { Object | string | undefined } value
+ * @return { Object | string | undefined }
+ */
+ decode(value) {
+ const id = value ? utils.isStr(value) ? value : utils.isPlainObject(value) ? value.id : undefined : undefined;
+ return id ? {
+ 'IDP': JSON.parse(atob(id))
+ } : undefined;
+ },
+ /**
+ * performs action to obtain id and return a value in the callback's response argument
+ * @function
+ * @param {SubmoduleConfig} config
+ * @return {{id: string | undefined} | undefined}
+ */
+ getId() {
+ const id = readCookie() || readFromLocalStorage();
+ return id ? { id } : undefined;
+ }
+};
+submodule('userId', zeotapIdPlusSubmodule);
diff --git a/package-lock.json b/package-lock.json
index 4f3d2120d72..1784b885be9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "prebid.js",
- "version": "3.27.0-pre",
+ "version": "4.8.0-pre",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index 7ad0781d648..686d47f53e9 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "prebid.js",
- "version": "4.8.0-pre",
+ "version": "4.12.0-pre",
"description": "Header Bidding Management Library",
"main": "src/prebid.js",
"scripts": {
diff --git a/src/prebid.js b/src/prebid.js
index bd85f416883..8d1d7ca1253 100644
--- a/src/prebid.js
+++ b/src/prebid.js
@@ -1,7 +1,7 @@
/** @module pbjs */
import { getGlobal } from './prebidGlobal.js';
-import { flatten, uniques, isGptPubadsDefined, adUnitsFilter, isArrayOfNums } from './utils.js';
+import { adUnitsFilter, flatten, isArrayOfNums, isGptPubadsDefined, uniques } from './utils.js';
import { listenMessagesFromCreative } from './secureCreatives.js';
import { userSync } from './userSync.js';
import { config } from './config.js';
@@ -11,7 +11,7 @@ import { hook } from './hook.js';
import { sessionLoader } from './debugging.js';
import includes from 'core-js-pure/features/array/includes.js';
import { adunitCounter } from './adUnits.js';
-import { isRendererRequired, executeRenderer } from './Renderer.js';
+import { executeRenderer, isRendererRequired } from './Renderer.js';
import { createBid } from './bidfactory.js';
import { storageCallbacks } from './storageManager.js';
@@ -342,7 +342,7 @@ function emitAdRenderFail({ reason, message, bid, id }) {
* @param {string} id bid id to locate the ad
* @alias module:pbjs.renderAd
*/
-$$PREBID_GLOBAL$$.renderAd = function (doc, id) {
+$$PREBID_GLOBAL$$.renderAd = function (doc, id, options) {
utils.logInfo('Invoking $$PREBID_GLOBAL$$.renderAd', arguments);
utils.logMessage('Calling renderAd with adId :' + id);
@@ -354,6 +354,14 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id) {
// replace macros according to openRTB with price paid = bid.cpm
bid.ad = utils.replaceAuctionPrice(bid.ad, bid.cpm);
bid.adUrl = utils.replaceAuctionPrice(bid.adUrl, bid.cpm);
+
+ // replacing clickthrough if submitted
+ if (options && options.clickThrough) {
+ const { clickThrough } = options;
+ bid.ad = utils.replaceClickThrough(bid.ad, clickThrough);
+ bid.adUrl = utils.replaceClickThrough(bid.adUrl, clickThrough);
+ }
+
// save winning bids
auctionManager.addWinningBid(bid);
@@ -540,6 +548,7 @@ export function executeCallbacks(fn, reqBidsConfigObj) {
runAll(storageCallbacks);
runAll(enableAnalyticsCallbacks);
fn.call(this, reqBidsConfigObj);
+
function runAll(queue) {
var queued;
while ((queued = queue.shift())) {
@@ -614,6 +623,16 @@ $$PREBID_GLOBAL$$.offEvent = function (event, handler, id) {
events.off(event, handler, id);
};
+/**
+ * Return a copy of all events emitted
+ *
+ * @alias module:pbjs.getEvents
+ */
+$$PREBID_GLOBAL$$.getEvents = function () {
+ utils.logInfo('Invoking $$PREBID_GLOBAL$$.getEvents');
+ return events.getEvents();
+};
+
/*
* Wrapper to register bidderAdapter externally (adapterManager.registerBidAdapter())
* @param {Function} bidderAdaptor [description]
@@ -730,12 +749,12 @@ $$PREBID_GLOBAL$$.aliasBidder = function (bidderCode, alias, options) {
* @property {string} adserverTargeting.hb_adid The ad ID of the creative, as understood by the ad server.
* @property {string} adserverTargeting.hb_pb The price paid to show the creative, as logged in the ad server.
* @property {string} adserverTargeting.hb_bidder The winning bidder whose ad creative will be served by the ad server.
-*/
+ */
/**
* Get all of the bids that have been rendered. Useful for [troubleshooting your integration](http://prebid.org/dev-docs/prebid-troubleshooting-guide.html).
* @return {Array} A list of bids that have been rendered.
-*/
+ */
$$PREBID_GLOBAL$$.getAllWinningBids = function () {
return auctionManager.getAllWinningBids();
};
@@ -767,7 +786,7 @@ $$PREBID_GLOBAL$$.getHighestCpmBids = function (adUnitCode) {
* @property {string} adId The id representing the ad we want to mark
*
* @alias module:pbjs.markWinningBidAsUsed
-*/
+ */
$$PREBID_GLOBAL$$.markWinningBidAsUsed = function (markBidRequest) {
let bids = [];
diff --git a/src/refererDetection.js b/src/refererDetection.js
index 60198678666..da68313736b 100644
--- a/src/refererDetection.js
+++ b/src/refererDetection.js
@@ -10,153 +10,48 @@
import { logWarn } from './utils.js';
+/**
+ * @param {Window} win Window
+ * @returns {Function}
+ */
export function detectReferer(win) {
- /**
- * Returns number of frames to reach top from current frame where prebid.js sits
- * @returns {Array} levels
- */
- function getLevels() {
- let levels = walkUpWindows();
- let ancestors = getAncestorOrigins();
-
- if (ancestors) {
- for (let i = 0, l = ancestors.length; i < l; i++) {
- levels[i].ancestor = ancestors[i];
- }
- }
- return levels;
- }
-
/**
* This function would return a read-only array of hostnames for all the parent frames.
* win.location.ancestorOrigins is only supported in webkit browsers. For non-webkit browsers it will return undefined.
+ *
+ * @param {Window} win Window object
* @returns {(undefined|Array)} Ancestor origins or undefined
*/
- function getAncestorOrigins() {
+ function getAncestorOrigins(win) {
try {
if (!win.location.ancestorOrigins) {
return;
}
+
return win.location.ancestorOrigins;
} catch (e) {
// Ignore error
}
}
- /**
- * This function would try to get referer and urls for all parent frames in case of win.location.ancestorOrigins undefined.
- * @param {Array} levels
- * @returns {Object} urls for all parent frames and top most detected referer url
- */
- function getPubUrlStack(levels) {
- let stack = [];
- let defUrl = null;
- let frameLocation = null;
- let prevFrame = null;
- let prevRef = null;
- let ancestor = null;
- let detectedRefererUrl = null;
-
- let i;
- for (i = levels.length - 1; i >= 0; i--) {
- try {
- frameLocation = levels[i].location;
- } catch (e) {
- // Ignore error
- }
-
- if (frameLocation) {
- stack.push(frameLocation);
- if (!detectedRefererUrl) {
- detectedRefererUrl = frameLocation;
- }
- } else if (i !== 0) {
- prevFrame = levels[i - 1];
- try {
- prevRef = prevFrame.referrer;
- ancestor = prevFrame.ancestor;
- } catch (e) {
- // Ignore error
- }
-
- if (prevRef) {
- stack.push(prevRef);
- if (!detectedRefererUrl) {
- detectedRefererUrl = prevRef;
- }
- } else if (ancestor) {
- stack.push(ancestor);
- if (!detectedRefererUrl) {
- detectedRefererUrl = ancestor;
- }
- } else {
- stack.push(defUrl);
- }
- } else {
- stack.push(defUrl);
- }
- }
- return {
- stack,
- detectedRefererUrl
- };
- }
-
/**
* This function returns canonical URL which refers to an HTML link element, with the attribute of rel="canonical", found in the element of your webpage
+ *
* @param {Object} doc document
+ * @returns {string|null}
*/
function getCanonicalUrl(doc) {
try {
- let element = doc.querySelector("link[rel='canonical']");
+ const element = doc.querySelector("link[rel='canonical']");
+
if (element !== null) {
return element.href;
}
} catch (e) {
+ // Ignore error
}
- return null;
- }
- /**
- * Walk up to the top of the window to detect origin, number of iframes, ancestor origins and canonical url
- */
- function walkUpWindows() {
- let acc = [];
- let currentWindow;
- do {
- try {
- currentWindow = currentWindow ? currentWindow.parent : win;
- try {
- let isTop = (currentWindow == win.top);
- let refData = {
- referrer: currentWindow.document.referrer || null,
- location: currentWindow.location.href || null,
- isTop
- }
- if (isTop) {
- refData = Object.assign(refData, {
- canonicalUrl: getCanonicalUrl(currentWindow.document)
- })
- }
- acc.push(refData);
- } catch (e) {
- acc.push({
- referrer: null,
- location: null,
- isTop: (currentWindow == win.top)
- });
- logWarn('Trying to access cross domain iframe. Continuing without referrer and location');
- }
- } catch (e) {
- acc.push({
- referrer: null,
- location: null,
- isTop: false
- });
- return acc;
- }
- } while (currentWindow != win.top);
- return acc;
+ return null;
}
/**
@@ -170,31 +65,114 @@ export function detectReferer(win) {
*/
/**
- * Get referer info
+ * Walk up the windows to get the origin stack and best available referrer, canonical URL, etc.
+ *
* @returns {refererInfo}
*/
function refererInfo() {
- try {
- let levels = getLevels();
- let numIframes = levels.length - 1;
- let reachedTop = (levels[numIframes].location !== null ||
- (numIframes > 0 && levels[numIframes - 1].referrer !== null));
- let stackInfo = getPubUrlStack(levels);
- let canonicalUrl;
- if (levels[levels.length - 1].canonicalUrl) {
- canonicalUrl = levels[levels.length - 1].canonicalUrl;
+ const stack = [];
+ const ancestors = getAncestorOrigins(win);
+ let currentWindow;
+ let bestReferrer;
+ let bestCanonicalUrl;
+ let reachedTop = false;
+ let level = 0;
+ let valuesFromAmp = false;
+ let inAmpFrame = false;
+
+ do {
+ const previousWindow = currentWindow;
+ const wasInAmpFrame = inAmpFrame;
+ let currentLocation;
+ let crossOrigin = false;
+ let foundReferrer = null;
+
+ inAmpFrame = false;
+ currentWindow = currentWindow ? currentWindow.parent : win;
+
+ try {
+ currentLocation = currentWindow.location.href || null;
+ } catch (e) {
+ crossOrigin = true;
}
- return {
- referer: stackInfo.detectedRefererUrl,
- reachedTop,
- numIframes,
- stack: stackInfo.stack,
- canonicalUrl
- };
- } catch (e) {
- // Ignore error
- }
+ if (crossOrigin) {
+ if (wasInAmpFrame) {
+ const context = previousWindow.context;
+
+ try {
+ foundReferrer = context.sourceUrl;
+ bestReferrer = foundReferrer;
+
+ valuesFromAmp = true;
+
+ if (currentWindow === win.top) {
+ reachedTop = true;
+ }
+
+ if (context.canonicalUrl) {
+ bestCanonicalUrl = context.canonicalUrl;
+ }
+ } catch (e) { /* Do nothing */ }
+ } else {
+ logWarn('Trying to access cross domain iframe. Continuing without referrer and location');
+
+ try {
+ const referrer = previousWindow.document.referrer;
+
+ if (referrer) {
+ foundReferrer = referrer;
+
+ if (currentWindow === win.top) {
+ reachedTop = true;
+ }
+ }
+ } catch (e) { /* Do nothing */ }
+
+ if (!foundReferrer && ancestors && ancestors[level - 1]) {
+ foundReferrer = ancestors[level - 1];
+ }
+
+ if (foundReferrer && !valuesFromAmp) {
+ bestReferrer = foundReferrer;
+ }
+ }
+ } else {
+ if (currentLocation) {
+ foundReferrer = currentLocation;
+ bestReferrer = foundReferrer;
+ valuesFromAmp = false;
+
+ if (currentWindow === win.top) {
+ reachedTop = true;
+
+ const canonicalUrl = getCanonicalUrl(currentWindow.document);
+
+ if (canonicalUrl) {
+ bestCanonicalUrl = canonicalUrl;
+ }
+ }
+ }
+
+ if (currentWindow.context && currentWindow.context.sourceUrl) {
+ inAmpFrame = true;
+ }
+ }
+
+ stack.push(foundReferrer);
+ level++;
+ } while (currentWindow !== win.top);
+
+ stack.reverse();
+
+ return {
+ referer: bestReferrer || null,
+ reachedTop,
+ isAmp: valuesFromAmp,
+ numIframes: level - 1,
+ stack,
+ canonicalUrl: bestCanonicalUrl || null
+ };
}
return refererInfo;
diff --git a/src/storageManager.js b/src/storageManager.js
index 0d88a8ccea1..60e5a7706d0 100644
--- a/src/storageManager.js
+++ b/src/storageManager.js
@@ -154,7 +154,7 @@ export function newStorageManager({gvlid, moduleName, moduleType} = {}) {
*/
const setDataInLocalStorage = function (key, value, done) {
let cb = function (result) {
- if (result && result.valid) {
+ if (result && result.valid && hasLocalStorage()) {
window.localStorage.setItem(key, value);
}
}
@@ -174,7 +174,7 @@ export function newStorageManager({gvlid, moduleName, moduleType} = {}) {
*/
const getDataFromLocalStorage = function (key, done) {
let cb = function (result) {
- if (result && result.valid) {
+ if (result && result.valid && hasLocalStorage()) {
return window.localStorage.getItem(key);
}
return null;
@@ -194,7 +194,7 @@ export function newStorageManager({gvlid, moduleName, moduleType} = {}) {
*/
const removeDataFromLocalStorage = function (key, done) {
let cb = function (result) {
- if (result && result.valid) {
+ if (result && result.valid && hasLocalStorage()) {
window.localStorage.removeItem(key);
}
}
diff --git a/src/targeting.js b/src/targeting.js
index 1b1e14fd4a6..8176bc9caff 100644
--- a/src/targeting.js
+++ b/src/targeting.js
@@ -181,6 +181,48 @@ export function newTargeting(auctionManager) {
return [];
};
+ /**
+ * Returns filtered ad server targeting for custom and allowed keys.
+ * @param {targetingArray} targeting
+ * @param {string[]} allowedKeys
+ * @return {targetingArray} filtered targeting
+ */
+ function getAllowedTargetingKeyValues(targeting, allowedKeys) {
+ const defaultKeyring = Object.assign({}, CONSTANTS.TARGETING_KEYS, CONSTANTS.NATIVE_KEYS);
+ const defaultKeys = Object.keys(defaultKeyring);
+ const keyDispositions = {};
+ logInfo(`allowTargetingKeys - allowed keys [ ${allowedKeys.map(k => defaultKeyring[k]).join(', ')} ]`);
+ targeting.map(adUnit => {
+ const adUnitCode = Object.keys(adUnit)[0];
+ const keyring = adUnit[adUnitCode];
+ const keys = keyring.filter(kvPair => {
+ const key = Object.keys(kvPair)[0];
+ // check if key is in default keys, if not, it's custom, we won't remove it.
+ const isCustom = defaultKeys.filter(defaultKey => key.indexOf(defaultKeyring[defaultKey]) === 0).length === 0;
+ // check if key explicitly allowed, if not, we'll remove it.
+ const found = isCustom || allowedKeys.find(allowedKey => {
+ const allowedKeyName = defaultKeyring[allowedKey];
+ // we're looking to see if the key exactly starts with one of our default keys.
+ // (which hopefully means it's not custom)
+ const found = key.indexOf(allowedKeyName) === 0;
+ return found;
+ });
+ keyDispositions[key] = !found;
+ return found;
+ });
+ adUnit[adUnitCode] = keys;
+ });
+ const removedKeys = Object.keys(keyDispositions).filter(d => keyDispositions[d]);
+ logInfo(`allowTargetingKeys - removed keys [ ${removedKeys.join(', ')} ]`);
+ // remove any empty targeting objects, as they're unnecessary.
+ const filteredTargeting = targeting.filter(adUnit => {
+ const adUnitCode = Object.keys(adUnit)[0];
+ const keyring = adUnit[adUnitCode];
+ return keyring.length > 0;
+ });
+ return filteredTargeting
+ }
+
/**
* Returns all ad server targeting for all ad units.
* @param {string=} adUnitCode
@@ -206,6 +248,11 @@ export function newTargeting(auctionManager) {
});
});
+ const allowedKeys = config.getConfig('targetingControls.allowTargetingKeys');
+ if (Array.isArray(allowedKeys) && allowedKeys.length > 0) {
+ targeting = getAllowedTargetingKeyValues(targeting, allowedKeys);
+ }
+
targeting = flattenTargeting(targeting);
const auctionKeysThreshold = config.getConfig('targetingControls.auctionKeyMaxChars');
diff --git a/src/utils.js b/src/utils.js
index 9426308daf4..8af7a25668d 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -718,6 +718,11 @@ export function replaceAuctionPrice(str, cpm) {
return str.replace(/\$\{AUCTION_PRICE\}/g, cpm);
}
+export function replaceClickThrough(str, clicktag) {
+ if (!str || !clicktag || typeof clicktag !== 'string') return;
+ return str.replace(/\${CLICKTHROUGH}/g, clicktag);
+}
+
export function timestamp() {
return new Date().getTime();
}
diff --git a/test/mocks/fabrickId.json b/test/mocks/fabrickId.json
new file mode 100644
index 00000000000..a8723ec88ec
--- /dev/null
+++ b/test/mocks/fabrickId.json
@@ -0,0 +1,3 @@
+{
+ "fabrickId": 1980
+}
diff --git a/test/spec/integration/faker/googletag.js b/test/spec/integration/faker/googletag.js
index a0ce04402f7..9d91bf315d9 100644
--- a/test/spec/integration/faker/googletag.js
+++ b/test/spec/integration/faker/googletag.js
@@ -43,18 +43,52 @@ export function makeSlot() {
return slot;
}
-window.googletag = {
- _slots: [],
- pubads: function () {
- var self = this;
- return {
- getSlots: function () {
- return self._slots;
- },
-
- setSlots: function (slots) {
- self._slots = slots;
- }
- };
- }
-};
+export function emitEvent(eventName, params) {
+ (window.googletag._callbackMap[eventName] || []).forEach(eventCb => eventCb({...params, eventName}));
+}
+
+export function enable() {
+ window.googletag = {
+ _slots: [],
+ _callbackMap: {},
+ pubads: function () {
+ var self = this;
+ return {
+ getSlots: function () {
+ return self._slots;
+ },
+
+ setSlots: function (slots) {
+ self._slots = slots;
+ },
+
+ setTargeting: function(key, arrayOfValues) {
+ self._targeting[key] = Array.isArray(arrayOfValues) ? arrayOfValues : [arrayOfValues];
+ },
+
+ getTargeting: function(key) {
+ return self._targeting[key] || [];
+ },
+
+ getTargetingKeys: function() {
+ return Object.getOwnPropertyNames(self._targeting);
+ },
+
+ clearTargeting: function() {
+ self._targeting = {};
+ },
+
+ addEventListener: function (eventName, cb) {
+ self._callbackMap[eventName] = self._callbackMap[eventName] || [];
+ self._callbackMap[eventName].push(cb);
+ }
+ };
+ }
+ };
+}
+
+export function disable() {
+ window.googletag = undefined;
+}
+
+enable();
diff --git a/test/spec/modules/ablidaBidAdapter_spec.js b/test/spec/modules/ablidaBidAdapter_spec.js
index e32531b1eac..73109d8cf16 100644
--- a/test/spec/modules/ablidaBidAdapter_spec.js
+++ b/test/spec/modules/ablidaBidAdapter_spec.js
@@ -9,17 +9,23 @@ describe('ablidaBidAdapter', function () {
const adapter = newBidder(spec);
describe('isBidRequestValid', function () {
let bid = {
+ adUnitCode: 'adunit-code',
+ auctionId: '69e8fef8-5105-4a99-b011-d5669f3bc7f0',
+ bidRequestsCount: 1,
bidder: 'ablida',
+ bidderRequestId: '14d2939272a26a',
+ bidderRequestsCount: 1,
+ bidderWinsCount: 0,
+ bidId: '1234asdf1234',
+ mediaTypes: {banner: {sizes: [[300, 250]]}},
params: {
placementId: 123
},
- adUnitCode: 'adunit-code',
sizes: [
[300, 250]
],
- bidId: '1234asdf1234',
- bidderRequestId: '1234asdf1234asdf',
- auctionId: '69e8fef8-5105-4a99-b011-d5669f3bc7f0'
+ src: 'client',
+ transactionId: '4781e6ac-93c4-42ba-86fe-ab5f278863cf'
};
it('should return true where required params found', function () {
expect(spec.isBidRequestValid(bid)).to.equal(true);
@@ -28,22 +34,29 @@ describe('ablidaBidAdapter', function () {
describe('buildRequests', function () {
let bidRequests = [
{
+ adUnitCode: 'adunit-code',
+ auctionId: '69e8fef8-5105-4a99-b011-d5669f3bc7f0',
+ bidId: '23beaa6af6cdde',
+ bidRequestsCount: 1,
bidder: 'ablida',
+ bidderRequestId: '14d2939272a26a',
+ bidderRequestsCount: 1,
+ bidderWinsCount: 0,
+ mediaTypes: {banner: {sizes: [[300, 250]]}},
params: {
placementId: 123
},
sizes: [
[300, 250]
],
- adUnitCode: 'adunit-code',
- bidId: '23beaa6af6cdde',
- bidderRequestId: '14d2939272a26a',
- auctionId: '69e8fef8-5105-4a99-b011-d5669f3bc7f0',
+ src: 'client',
+ transactionId: '4781e6ac-93c4-42ba-86fe-ab5f278863cf'
}
];
let bidderRequests = {
refererInfo: {
+ canonicalUrl: '',
numIframes: 0,
reachedTop: true,
referer: 'http://example.com',
@@ -62,42 +75,53 @@ describe('ablidaBidAdapter', function () {
method: 'POST',
url: ENDPOINT_URL,
data: {
+ adapterVersion: 5,
+ bidId: '2b8c4de0116e54',
+ categories: undefined,
+ device: 'desktop',
+ gdprConsent: undefined,
+ jaySupported: true,
+ mediaTypes: {banner: {sizes: [[300, 250]]}},
placementId: 'testPlacementId',
width: 300,
height: 200,
- bidId: '2b8c4de0116e54',
- jaySupported: true,
- device: 'desktop',
- referer: 'www.example.com',
- adapterVersion: 2
+ referer: 'www.example.com'
}
};
let serverResponse = {
body: [{
- requestId: '2b8c4de0116e54',
+ ad: '',
cpm: 1.00,
- width: 300,
- height: 250,
creativeId: '2b8c4de0116e54',
currency: 'EUR',
+ height: 250,
+ mediaType: 'banner',
+ meta: {},
netRevenue: true,
+ nurl: 'https://example.com/some-tracker',
+ originalCpm: '0.10',
+ originalCurrency: 'EUR',
+ requestId: '2b8c4de0116e54',
ttl: 3000,
- ad: '',
- nurl: 'https://example.com/some-tracker'
+ width: 300
}]
};
it('should get the correct bid response', function () {
let expectedResponse = [{
- requestId: '2b8c4de0116e54',
+ ad: '',
cpm: 1.00,
- width: 300,
- height: 250,
creativeId: '2b8c4de0116e54',
currency: 'EUR',
+ height: 250,
+ mediaType: 'banner',
+ meta: {},
netRevenue: true,
+ nurl: 'https://example.com/some-tracker',
+ originalCpm: '0.10',
+ originalCurrency: 'EUR',
+ requestId: '2b8c4de0116e54',
ttl: 3000,
- ad: '',
- nurl: 'https://example.com/some-tracker'
+ width: 300
}];
let result = spec.interpretResponse(serverResponse, bidRequest[0]);
expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse));
diff --git a/test/spec/modules/adagioBidAdapter_spec.js b/test/spec/modules/adagioBidAdapter_spec.js
index 52b99f274d5..a18cd797d68 100644
--- a/test/spec/modules/adagioBidAdapter_spec.js
+++ b/test/spec/modules/adagioBidAdapter_spec.js
@@ -3,6 +3,7 @@ import { expect } from 'chai';
import { _features, internal as adagio, adagioScriptFromLocalStorageCb, getAdagioScript, storage, spec, ENDPOINT, VERSION } from '../../../modules/adagioBidAdapter.js';
import { loadExternalScript } from '../../../src/adloader.js';
import * as utils from '../../../src/utils.js';
+import { config } from 'src/config.js';
const BidRequestBuilder = function BidRequestBuilder(options) {
const defaults = {
@@ -285,7 +286,7 @@ describe('Adagio bid adapter', () => {
'site',
'pageviewId',
'adUnits',
- 'gdpr',
+ 'regs',
'schain',
'prebidVersion',
'adapterVersion',
@@ -450,7 +451,7 @@ describe('Adagio bid adapter', () => {
const requests = spec.buildRequests([bid01], bidderRequest);
- expect(requests[0].data.gdpr).to.deep.equal(expected);
+ expect(requests[0].data.regs.gdpr).to.deep.equal(expected);
});
it('send data.gdpr object to the server from TCF v.2 cmp', function() {
@@ -466,7 +467,7 @@ describe('Adagio bid adapter', () => {
const requests = spec.buildRequests([bid01], bidderRequest);
- expect(requests[0].data.gdpr).to.deep.equal(expected);
+ expect(requests[0].data.regs.gdpr).to.deep.equal(expected);
});
});
@@ -485,7 +486,7 @@ describe('Adagio bid adapter', () => {
const requests = spec.buildRequests([bid01], bidderRequest);
- expect(requests[0].data.gdpr).to.deep.equal(expected);
+ expect(requests[0].data.regs.gdpr).to.deep.equal(expected);
});
it('send data.gdpr object to the server from TCF v.2 cmp', function() {
@@ -501,7 +502,7 @@ describe('Adagio bid adapter', () => {
const requests = spec.buildRequests([bid01], bidderRequest);
- expect(requests[0].data.gdpr).to.deep.equal(expected);
+ expect(requests[0].data.regs.gdpr).to.deep.equal(expected);
});
});
@@ -510,10 +511,68 @@ describe('Adagio bid adapter', () => {
const bidderRequest = new BidderRequestBuilder().build();
const requests = spec.buildRequests([bid01], bidderRequest);
- expect(requests[0].data.gdpr).to.be.empty;
+ expect(requests[0].data.regs.gdpr).to.be.empty;
});
});
});
+
+ describe('with COPPA', function() {
+ const bid01 = new BidRequestBuilder().withParams().build();
+
+ it('should send the Coppa "required" flag set to "1" in the request', function () {
+ const bidderRequest = new BidderRequestBuilder().build();
+
+ sinon.stub(config, 'getConfig')
+ .withArgs('coppa')
+ .returns(true);
+
+ const requests = spec.buildRequests([bid01], bidderRequest);
+
+ expect(requests[0].data.regs.coppa.required).to.equal(1);
+
+ config.getConfig.restore();
+ });
+ });
+
+ describe('without COPPA', function() {
+ const bid01 = new BidRequestBuilder().withParams().build();
+
+ it('should send the Coppa "required" flag set to "0" in the request', function () {
+ const bidderRequest = new BidderRequestBuilder().build();
+
+ const requests = spec.buildRequests([bid01], bidderRequest);
+
+ expect(requests[0].data.regs.coppa.required).to.equal(0);
+ });
+ });
+
+ describe('with USPrivacy', function() {
+ const bid01 = new BidRequestBuilder().withParams().build();
+
+ const consent = 'Y11N'
+
+ it('should send the USPrivacy "ccpa.uspConsent" in the request', function () {
+ const bidderRequest = new BidderRequestBuilder({
+ uspConsent: consent
+ }).build();
+
+ const requests = spec.buildRequests([bid01], bidderRequest);
+
+ expect(requests[0].data.regs.ccpa.uspConsent).to.equal(consent);
+ });
+ });
+
+ describe('without USPrivacy', function() {
+ const bid01 = new BidRequestBuilder().withParams().build();
+
+ it('should have an empty "ccpa" field in the request', function () {
+ const bidderRequest = new BidderRequestBuilder().build();
+
+ const requests = spec.buildRequests([bid01], bidderRequest);
+
+ expect(requests[0].data.regs.ccpa).to.be.empty;
+ });
+ });
});
describe('interpretResponse()', function() {
diff --git a/test/spec/modules/adheseBidAdapter_spec.js b/test/spec/modules/adheseBidAdapter_spec.js
index aa4872641b4..4d888db269d 100644
--- a/test/spec/modules/adheseBidAdapter_spec.js
+++ b/test/spec/modules/adheseBidAdapter_spec.js
@@ -116,7 +116,7 @@ describe('AdheseAdapter', function () {
});
it('should include id5 id as /x5 param', function () {
- let req = spec.buildRequests([ bidWithParams({}, { 'id5id': 'ID5-1234567890' }) ], bidderRequest);
+ let req = spec.buildRequests([ bidWithParams({}, { 'id5id': { 'uid': 'ID5-1234567890' } }) ], bidderRequest);
expect(JSON.parse(req.data).parameters).to.deep.include({ 'x5': [ 'ID5-1234567890' ] });
});
diff --git a/test/spec/modules/adnowBidAdapter_spec.js b/test/spec/modules/adnowBidAdapter_spec.js
new file mode 100644
index 00000000000..a8013e3fa04
--- /dev/null
+++ b/test/spec/modules/adnowBidAdapter_spec.js
@@ -0,0 +1,163 @@
+import { expect } from 'chai';
+import { spec } from 'modules/adnowBidAdapter.js';
+
+describe('adnowBidAdapter', function () {
+ describe('isBidRequestValid', function () {
+ it('Should return true', function() {
+ expect(spec.isBidRequestValid({
+ bidder: 'adnow',
+ params: {
+ codeId: 12345
+ }
+ })).to.equal(true);
+ });
+
+ it('Should return false when required params is not passed', function() {
+ expect(spec.isBidRequestValid({
+ bidder: 'adnow',
+ params: {}
+ })).to.equal(false);
+ });
+ });
+
+ describe('buildRequests', function() {
+ it('Common settings', function() {
+ const bidRequestData = [{
+ bidId: 'bid12345',
+ params: {
+ codeId: 12345
+ }
+ }];
+
+ const req = spec.buildRequests(bidRequestData);
+ const reqData = req[0].data;
+
+ expect(reqData)
+ .to.match(/Id=12345/)
+ .to.match(/mediaType=native/)
+ .to.match(/out=prebid/)
+ .to.match(/requestid=bid12345/)
+ .to.match(/d_user_agent=.+/);
+ });
+
+ it('Banner sizes', function () {
+ const bidRequestData = [{
+ bidId: 'bid12345',
+ params: {
+ codeId: 12345
+ },
+ mediaTypes: {
+ banner: {
+ sizes: [[300, 250]]
+ }
+ }
+ }];
+
+ const req = spec.buildRequests(bidRequestData);
+ const reqData = req[0].data;
+
+ expect(reqData).to.match(/sizes=300x250/);
+ });
+
+ it('Native sizes', function () {
+ const bidRequestData = [{
+ bidId: 'bid12345',
+ params: {
+ codeId: 12345
+ },
+ mediaTypes: {
+ native: {
+ image: {
+ sizes: [100, 100]
+ }
+ }
+ }
+ }];
+
+ const req = spec.buildRequests(bidRequestData);
+ const reqData = req[0].data;
+
+ expect(reqData)
+ .to.match(/width=100/)
+ .to.match(/height=100/);
+ });
+ });
+
+ describe('interpretResponse', function() {
+ const request = {
+ bidRequest: {
+ bidId: 'bid12345'
+ }
+ };
+
+ it('Response with native bid', function() {
+ const response = {
+ currency: 'USD',
+ cpm: 0.5,
+ native: {
+ title: 'Title',
+ body: 'Body',
+ sponsoredBy: 'AdNow',
+ clickUrl: '//click.url',
+ image: {
+ url: '//img.url',
+ height: 200,
+ width: 200
+ }
+ },
+ meta: {
+ mediaType: 'native'
+ }
+ };
+
+ const bids = spec.interpretResponse({ body: response }, request);
+ expect(bids).to.be.an('array').that.is.not.empty;
+
+ const bid = bids[0];
+ expect(bid).to.have.keys('requestId', 'cpm', 'currency', 'native', 'creativeId', 'netRevenue', 'meta', 'ttl');
+
+ const nativePart = bid.native;
+
+ expect(nativePart.title).to.be.equal('Title');
+ expect(nativePart.body).to.be.equal('Body');
+ expect(nativePart.clickUrl).to.be.equal('//click.url');
+ expect(nativePart.image.url).to.be.equal('//img.url');
+ expect(nativePart.image.height).to.be.equal(200);
+ expect(nativePart.image.width).to.be.equal(200);
+ });
+
+ it('Response with banner bid', function() {
+ const response = {
+ currency: 'USD',
+ cpm: 0.5,
+ ad: 'Banner
',
+ meta: {
+ mediaType: 'banner'
+ }
+ };
+
+ const bids = spec.interpretResponse({ body: response }, request);
+ expect(bids).to.be.an('array').that.is.not.empty;
+
+ const bid = bids[0];
+ expect(bid).to.have.keys(
+ 'requestId', 'cpm', 'currency', 'ad', 'creativeId', 'netRevenue', 'meta', 'ttl', 'width', 'height'
+ );
+
+ expect(bid.ad).to.be.equal('Banner
');
+ });
+
+ it('Response with no bid should return an empty array', function() {
+ const noBidResponses = [
+ false,
+ {},
+ {body: false},
+ {body: {}}
+ ];
+
+ noBidResponses.forEach(response => {
+ return expect(spec.interpretResponse(response, request)).to.be.an('array').that.is.empty;
+ });
+ });
+ });
+});
diff --git a/test/spec/modules/adotBidAdapter_spec.js b/test/spec/modules/adotBidAdapter_spec.js
index 594fc4ac7b7..d580cd763a4 100644
--- a/test/spec/modules/adotBidAdapter_spec.js
+++ b/test/spec/modules/adotBidAdapter_spec.js
@@ -2062,10 +2062,11 @@ describe('Adot Adapter', function () {
serverResponse.body.cur = 'USD';
const ads = spec.interpretResponse(serverResponse, serverRequest);
+ const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price);
expect(ads).to.be.an('array').and.to.have.length(1);
expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId);
- expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced);
expect(ads[0].adUrl).to.equal(null);
expect(ads[0].vastXml).to.equal(null);
expect(ads[0].vastUrl).to.equal(null);
@@ -2087,10 +2088,13 @@ describe('Adot Adapter', function () {
const ads = spec.interpretResponse(serverResponse, serverRequest);
+ const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price);
+ const adm2WithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[1].adm, serverResponse.body.seatbid[0].bid[1].price);
+
expect(ads).to.be.an('array').and.to.have.length(2);
expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId);
- expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced);
expect(ads[0].adUrl).to.equal(null);
expect(ads[0].vastXml).to.equal(null);
expect(ads[0].vastUrl).to.equal(null);
@@ -2104,7 +2108,7 @@ describe('Adot Adapter', function () {
expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner');
expect(ads[0].renderer).to.equal(null);
expect(ads[1].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[1].bidId);
- expect(ads[1].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[1].adm);
+ expect(ads[1].ad).to.exist.and.to.be.a('string').and.to.have.string(adm2WithAuctionPriceReplaced);
expect(ads[1].adUrl).to.equal(null);
expect(ads[1].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[1].crid);
expect(ads[1].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[1].price);
@@ -2592,10 +2596,11 @@ describe('Adot Adapter', function () {
const serverResponse = examples.serverResponse_banner;
const ads = spec.interpretResponse(serverResponse, serverRequest);
+ const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price);
expect(ads).to.be.an('array').and.to.have.length(1);
expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId);
- expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced);
expect(ads[0].adUrl).to.equal(null);
expect(ads[0].vastXml).to.equal(null);
expect(ads[0].vastUrl).to.equal(null);
@@ -2617,10 +2622,11 @@ describe('Adot Adapter', function () {
serverResponse.body.seatbid[0].bid[0].nurl = undefined;
const ads = spec.interpretResponse(serverResponse, serverRequest);
+ const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price);
expect(ads).to.be.an('array').and.to.have.length(1);
expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId);
- expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.equal(admWithAuctionPriceReplaced);
expect(ads[0].adUrl).to.equal(null);
expect(ads[0].vastXml).to.equal(null);
expect(ads[0].vastUrl).to.equal(null);
@@ -2642,11 +2648,12 @@ describe('Adot Adapter', function () {
serverResponse.body.seatbid[0].bid[0].adm = undefined;
const ads = spec.interpretResponse(serverResponse, serverRequest);
+ const nurlWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].nurl, serverResponse.body.seatbid[0].bid[0].price);
expect(ads).to.be.an('array').and.to.have.length(1);
expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId);
expect(ads[0].ad).to.equal(null);
- expect(ads[0].adUrl).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].nurl);
+ expect(ads[0].adUrl).to.exist.and.to.be.a('string').and.to.equal(nurlWithAuctionPriceReplaced);
expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid);
expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price);
expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur);
@@ -2721,12 +2728,13 @@ describe('Adot Adapter', function () {
const serverResponse = examples.serverResponse_video_instream;
const ads = spec.interpretResponse(serverResponse, serverRequest);
+ const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price);
expect(ads).to.be.an('array').and.to.have.length(1);
expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId);
- expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced);
expect(ads[0].adUrl).to.equal(null);
- expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].vastXml).to.equal(admWithAuctionPriceReplaced);
expect(ads[0].vastUrl).to.equal(null);
expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid);
expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price);
@@ -2745,12 +2753,13 @@ describe('Adot Adapter', function () {
const serverResponse = examples.serverResponse_video_outstream;
const ads = spec.interpretResponse(serverResponse, serverRequest);
+ const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price);
expect(ads).to.be.an('array').and.to.have.length(1);
expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId);
- expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced);
expect(ads[0].adUrl).to.equal(null);
- expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].vastXml).to.equal(admWithAuctionPriceReplaced);
expect(ads[0].vastUrl).to.equal(null);
expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid);
expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price);
@@ -2769,12 +2778,14 @@ describe('Adot Adapter', function () {
const serverResponse = examples.serverResponse_video_instream_outstream;
const ads = spec.interpretResponse(serverResponse, serverRequest);
+ const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price);
+ const adm2WithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[1].adm, serverResponse.body.seatbid[0].bid[1].price);
expect(ads).to.be.an('array').and.to.have.length(2);
expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId);
- expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced);
expect(ads[0].adUrl).to.equal(null);
- expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].vastXml).to.equal(admWithAuctionPriceReplaced);
expect(ads[0].vastUrl).to.equal(null);
expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid);
expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price);
@@ -2786,9 +2797,9 @@ describe('Adot Adapter', function () {
expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('video');
expect(ads[0].renderer).to.equal(null);
expect(ads[1].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[1].bidId);
- expect(ads[1].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[1].adm);
+ expect(ads[1].ad).to.exist.and.to.be.a('string').and.to.have.string(adm2WithAuctionPriceReplaced);
expect(ads[1].adUrl).to.equal(null);
- expect(ads[1].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[1].vastXml).to.equal(adm2WithAuctionPriceReplaced);
expect(ads[1].vastUrl).to.equal(null);
expect(ads[1].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[1].crid);
expect(ads[1].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[1].price);
@@ -2808,12 +2819,13 @@ describe('Adot Adapter', function () {
serverResponse.body.seatbid[0].bid[0].nurl = undefined;
const ads = spec.interpretResponse(serverResponse, serverRequest);
+ const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price);
expect(ads).to.be.an('array').and.to.have.length(1);
expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId);
- expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced);
expect(ads[0].adUrl).to.equal(null);
- expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].vastXml).to.equal(admWithAuctionPriceReplaced);
expect(ads[0].vastUrl).to.equal(null);
expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid);
expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price);
@@ -2833,13 +2845,14 @@ describe('Adot Adapter', function () {
serverResponse.body.seatbid[0].bid[0].adm = undefined;
const ads = spec.interpretResponse(serverResponse, serverRequest);
+ const nurlWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].nurl, serverResponse.body.seatbid[0].bid[0].price);
expect(ads).to.be.an('array').and.to.have.length(1);
expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId);
expect(ads[0].ad).to.equal(null);
- expect(ads[0].adUrl).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].nurl);
+ expect(ads[0].adUrl).to.exist.and.to.be.a('string').and.to.have.string(nurlWithAuctionPriceReplaced);
expect(ads[0].vastXml).to.equal(null);
- expect(ads[0].vastUrl).to.equal(serverResponse.body.seatbid[0].bid[0].nurl);
+ expect(ads[0].vastUrl).to.equal(nurlWithAuctionPriceReplaced);
expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid);
expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price);
expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur);
@@ -2858,12 +2871,13 @@ describe('Adot Adapter', function () {
serverResponse.body.seatbid[0].bid[0].h = 500;
const ads = spec.interpretResponse(serverResponse, serverRequest);
+ const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price);
expect(ads).to.be.an('array').and.to.have.length(1);
expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId);
- expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced);
expect(ads[0].adUrl).to.equal(null);
- expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].vastXml).to.equal(admWithAuctionPriceReplaced);
expect(ads[0].vastUrl).to.equal(null);
expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid);
expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price);
@@ -2883,12 +2897,13 @@ describe('Adot Adapter', function () {
serverResponse.body.seatbid[0].bid[0].w = 500;
const ads = spec.interpretResponse(serverResponse, serverRequest);
+ const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price);
expect(ads).to.be.an('array').and.to.have.length(1);
expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId);
- expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced);
expect(ads[0].adUrl).to.equal(null);
- expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].vastXml).to.equal(admWithAuctionPriceReplaced);
expect(ads[0].vastUrl).to.equal(null);
expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid);
expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price);
@@ -2909,12 +2924,13 @@ describe('Adot Adapter', function () {
serverResponse.body.seatbid[0].bid[0].h = 400;
const ads = spec.interpretResponse(serverResponse, serverRequest);
+ const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price);
expect(ads).to.be.an('array').and.to.have.length(1);
expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId);
- expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced);
expect(ads[0].adUrl).to.equal(null);
- expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].vastXml).to.equal(admWithAuctionPriceReplaced);
expect(ads[0].vastUrl).to.equal(null);
expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid);
expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price);
@@ -2934,12 +2950,13 @@ describe('Adot Adapter', function () {
const serverResponse = utils.deepClone(examples.serverResponse_video_instream);
const ads = spec.interpretResponse(serverResponse, serverRequest);
+ const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price);
expect(ads).to.be.an('array').and.to.have.length(1);
expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId);
- expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced);
expect(ads[0].adUrl).to.equal(null);
- expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].vastXml).to.equal(admWithAuctionPriceReplaced);
expect(ads[0].vastUrl).to.equal(null);
expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid);
expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price);
@@ -2959,12 +2976,13 @@ describe('Adot Adapter', function () {
const serverResponse = utils.deepClone(examples.serverResponse_video_instream);
const ads = spec.interpretResponse(serverResponse, serverRequest);
+ const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price);
expect(ads).to.be.an('array').and.to.have.length(1);
expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId);
- expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced);
expect(ads[0].adUrl).to.equal(null);
- expect(ads[0].vastXml).to.equal(serverResponse.body.seatbid[0].bid[0].adm);
+ expect(ads[0].vastXml).to.equal(admWithAuctionPriceReplaced);
expect(ads[0].vastUrl).to.equal(null);
expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid);
expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price);
diff --git a/test/spec/modules/adrelevantisBidAdapter_spec.js b/test/spec/modules/adrelevantisBidAdapter_spec.js
new file mode 100644
index 00000000000..11a6a14a353
--- /dev/null
+++ b/test/spec/modules/adrelevantisBidAdapter_spec.js
@@ -0,0 +1,769 @@
+import { expect } from 'chai';
+import { spec } from 'modules/adrelevantisBidAdapter.js';
+import { newBidder } from 'src/adapters/bidderFactory.js';
+import * as bidderFactory from 'src/adapters/bidderFactory.js';
+import { deepClone } from 'src/utils.js';
+import { config } from 'src/config.js';
+
+const ENDPOINT = 'https://ssp.adrelevantis.com/prebid';
+
+describe('AdrelevantisAdapter', function () {
+ const adapter = newBidder(spec);
+
+ 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 = {
+ 'bidder': 'adrelevantis',
+ 'params': {
+ 'placementId': '10433394'
+ },
+ 'adUnitCode': 'adunit-code',
+ 'sizes': [[300, 250], [300, 600]],
+ 'bidId': '30b31c1838de1e',
+ 'bidderRequestId': '22edbae2733bf6',
+ 'auctionId': '1d1a030790a475',
+ };
+
+ it('should return true when required params found', function () {
+ expect(spec.isBidRequestValid(bid)).to.equal(true);
+ });
+
+ it('should return false when required params are not passed', function () {
+ let bid = Object.assign({}, bid);
+ delete bid.params;
+ bid.params = {
+ 'placementId': 0
+ };
+ expect(spec.isBidRequestValid(bid)).to.equal(false);
+ });
+ });
+
+ describe('buildRequests', function () {
+ let bidRequests = [
+ {
+ 'bidder': 'adrelevantis',
+ 'params': {
+ 'placementId': '10433394'
+ },
+ 'adUnitCode': 'adunit-code',
+ 'sizes': [[300, 250], [300, 600]],
+ 'bidId': '30b31c1838de1e',
+ 'bidderRequestId': '22edbae2733bf6',
+ 'auctionId': '1d1a030790a475',
+ }
+ ];
+
+ it('should parse out private sizes', function () {
+ let bidRequest = Object.assign({},
+ bidRequests[0],
+ {
+ params: {
+ placementId: '10433394',
+ privateSizes: [300, 250]
+ }
+ }
+ );
+
+ const request = spec.buildRequests([bidRequest]);
+ const payload = JSON.parse(request.data);
+
+ expect(payload.tags[0].private_sizes).to.exist;
+ expect(payload.tags[0].private_sizes).to.deep.equal([{width: 300, height: 250}]);
+ });
+
+ it('should add source and verison to the tag', function () {
+ const request = spec.buildRequests(bidRequests);
+ const payload = JSON.parse(request.data);
+ expect(payload.sdk).to.exist;
+ expect(payload.sdk).to.deep.equal({
+ source: 'pbjs',
+ version: '$prebid.version$'
+ });
+ });
+
+ it('should populate the ad_types array on all requests', function () {
+ ['banner', 'video', 'native'].forEach(type => {
+ const bidRequest = Object.assign({}, bidRequests[0]);
+ bidRequest.mediaTypes = {};
+ bidRequest.mediaTypes[type] = {};
+
+ const request = spec.buildRequests([bidRequest]);
+ const payload = JSON.parse(request.data);
+
+ expect(payload.tags[0].ad_types).to.deep.equal([type]);
+ });
+ });
+
+ it('should populate the ad_types array on outstream requests', function () {
+ const bidRequest = Object.assign({}, bidRequests[0]);
+ bidRequest.mediaTypes = {};
+ bidRequest.mediaTypes.video = {context: 'outstream'};
+
+ const request = spec.buildRequests([bidRequest]);
+ const payload = JSON.parse(request.data);
+
+ expect(payload.tags[0].ad_types).to.deep.equal(['video']);
+ });
+
+ it('sends bid request to ENDPOINT via POST', function () {
+ const request = spec.buildRequests(bidRequests);
+ expect(request.url).to.equal(ENDPOINT);
+ expect(request.method).to.equal('POST');
+ });
+
+ it('should attach valid video params to the tag', function () {
+ let bidRequest = Object.assign({},
+ bidRequests[0],
+ {
+ params: {
+ placementId: '10433394',
+ video: {
+ id: 123,
+ minduration: 100,
+ foobar: 'invalid'
+ }
+ }
+ }
+ );
+
+ const request = spec.buildRequests([bidRequest]);
+ const payload = JSON.parse(request.data);
+ expect(payload.tags[0].video).to.deep.equal({
+ id: 123,
+ minduration: 100
+ });
+ });
+
+ it('should add video property when adUnit includes a renderer', function () {
+ const videoData = {
+ mediaTypes: {
+ video: {
+ context: 'outstream',
+ mimes: ['video/mp4']
+ }
+ },
+ params: {
+ placementId: '10433394',
+ video: {
+ skippable: true,
+ playback_method: ['auto_play_sound_off']
+ }
+ }
+ };
+
+ let bidRequest1 = deepClone(bidRequests[0]);
+ bidRequest1 = Object.assign({}, bidRequest1, videoData, {
+ renderer: {
+ url: 'http://test.renderer.url',
+ render: function () {}
+ }
+ });
+
+ let bidRequest2 = deepClone(bidRequests[0]);
+ bidRequest2.adUnitCode = 'adUnit_code_2';
+ bidRequest2 = Object.assign({}, bidRequest2, videoData);
+
+ const request = spec.buildRequests([bidRequest1, bidRequest2]);
+ const payload = JSON.parse(request.data);
+ expect(payload.tags[0].video).to.deep.equal({
+ skippable: true,
+ playback_method: ['auto_play_sound_off'],
+ custom_renderer_present: true
+ });
+ expect(payload.tags[1].video).to.deep.equal({
+ skippable: true,
+ playback_method: ['auto_play_sound_off']
+ });
+ });
+
+ it('should attach valid user params to the tag', function () {
+ let bidRequest = Object.assign({},
+ bidRequests[0],
+ {
+ params: {
+ placementId: '10433394',
+ user: {
+ externalUid: '123',
+ foobar: 'invalid'
+ }
+ }
+ }
+ );
+
+ const request = spec.buildRequests([bidRequest]);
+ const payload = JSON.parse(request.data);
+
+ expect(payload.user).to.exist;
+ expect(payload.user).to.deep.equal({
+ externalUid: '123',
+ });
+ });
+
+ it('should contain hb_source value for other media', function() {
+ let bidRequest = Object.assign({},
+ bidRequests[0],
+ {
+ mediaType: 'banner',
+ params: {
+ sizes: [[300, 250], [300, 600]],
+ placementId: 10433394
+ }
+ }
+ );
+ const request = spec.buildRequests([bidRequest]);
+ const payload = JSON.parse(request.data);
+ expect(payload.tags[0].hb_source).to.deep.equal(1);
+ });
+
+ it('adds context data (category and keywords) to request when set', function() {
+ let bidRequest = Object.assign({}, bidRequests[0]);
+ sinon
+ .stub(config, 'getConfig')
+ .withArgs('fpd')
+ .returns({
+ context: {
+ keywords: 'US Open',
+ data: {
+ category: 'sports/tennis'
+ }
+ }
+ });
+
+ const request = spec.buildRequests([bidRequest]);
+ const payload = JSON.parse(request.data);
+
+ expect(payload.fpd.keywords).to.equal('US Open');
+ expect(payload.fpd.category).to.equal('sports/tennis');
+
+ config.getConfig.restore();
+ });
+
+ it('should attach native params to the request', function () {
+ let bidRequest = Object.assign({},
+ bidRequests[0],
+ {
+ mediaType: 'native',
+ nativeParams: {
+ title: {required: true},
+ body: {required: true},
+ body2: {required: true},
+ image: {required: true, sizes: [100, 100]},
+ icon: {required: true},
+ cta: {required: false},
+ rating: {required: true},
+ sponsoredBy: {required: true},
+ privacyLink: {required: true},
+ displayUrl: {required: true},
+ address: {required: true},
+ downloads: {required: true},
+ likes: {required: true},
+ phone: {required: true},
+ price: {required: true},
+ salePrice: {required: true}
+ }
+ }
+ );
+
+ const request = spec.buildRequests([bidRequest]);
+ const payload = JSON.parse(request.data);
+
+ expect(payload.tags[0].native.layouts[0]).to.deep.equal({
+ title: {required: true},
+ description: {required: true},
+ desc2: {required: true},
+ main_image: {required: true, sizes: [{ width: 100, height: 100 }]},
+ icon: {required: true},
+ ctatext: {required: false},
+ rating: {required: true},
+ sponsored_by: {required: true},
+ privacy_link: {required: true},
+ displayurl: {required: true},
+ address: {required: true},
+ downloads: {required: true},
+ likes: {required: true},
+ phone: {required: true},
+ price: {required: true},
+ saleprice: {required: true},
+ privacy_supported: true
+ });
+ expect(payload.tags[0].hb_source).to.equal(1);
+ });
+
+ it('should always populated tags[].sizes with 1,1 for native if otherwise not defined', function () {
+ let bidRequest = Object.assign({},
+ bidRequests[0],
+ {
+ mediaType: 'native',
+ nativeParams: {
+ image: { required: true }
+ }
+ }
+ );
+ bidRequest.sizes = [[150, 100], [300, 250]];
+
+ let request = spec.buildRequests([bidRequest]);
+ let payload = JSON.parse(request.data);
+ expect(payload.tags[0].sizes).to.deep.equal([{width: 150, height: 100}, {width: 300, height: 250}]);
+
+ delete bidRequest.sizes;
+
+ request = spec.buildRequests([bidRequest]);
+ payload = JSON.parse(request.data);
+
+ expect(payload.tags[0].sizes).to.deep.equal([{width: 1, height: 1}]);
+ });
+
+ it('should convert keyword params to proper form and attaches to request', function () {
+ let bidRequest = Object.assign({},
+ bidRequests[0],
+ {
+ params: {
+ placementId: '10433394',
+ keywords: {
+ single: 'val',
+ singleArr: ['val'],
+ singleArrNum: [5],
+ multiValMixed: ['value1', 2, 'value3'],
+ singleValNum: 123,
+ emptyStr: '',
+ emptyArr: [''],
+ badValue: {'foo': 'bar'} // should be dropped
+ }
+ }
+ }
+ );
+
+ const request = spec.buildRequests([bidRequest]);
+ const payload = JSON.parse(request.data);
+
+ expect(payload.tags[0].keywords).to.deep.equal([{
+ 'key': 'single',
+ 'value': ['val']
+ }, {
+ 'key': 'singleArr',
+ 'value': ['val']
+ }, {
+ 'key': 'singleArrNum',
+ 'value': ['5']
+ }, {
+ 'key': 'multiValMixed',
+ 'value': ['value1', '2', 'value3']
+ }, {
+ 'key': 'singleValNum',
+ 'value': ['123']
+ }, {
+ 'key': 'emptyStr'
+ }, {
+ 'key': 'emptyArr'
+ }]);
+ });
+
+ it('should add payment rules to the request', function () {
+ let bidRequest = Object.assign({},
+ bidRequests[0],
+ {
+ params: {
+ placementId: '10433394',
+ usePaymentRule: true
+ }
+ }
+ );
+
+ const request = spec.buildRequests([bidRequest]);
+ const payload = JSON.parse(request.data);
+
+ expect(payload.tags[0].use_pmt_rule).to.equal(true);
+ });
+
+ it('should add gdpr consent information to the request', function () {
+ let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==';
+ let bidderRequest = {
+ 'bidderCode': 'adrelevantis',
+ 'auctionId': '1d1a030790a475',
+ 'bidderRequestId': '22edbae2733bf6',
+ 'timeout': 3000,
+ 'gdprConsent': {
+ consentString: consentString,
+ gdprApplies: true
+ }
+ };
+ bidderRequest.bids = bidRequests;
+
+ const request = spec.buildRequests(bidRequests, bidderRequest);
+ const payload = JSON.parse(request.data);
+
+ expect(payload.gdpr_consent).to.exist;
+ expect(payload.gdpr_consent.consent_string).to.exist.and.to.equal(consentString);
+ expect(payload.gdpr_consent.consent_required).to.exist.and.to.be.true;
+ });
+
+ it('supports sending hybrid mobile app parameters', function () {
+ let appRequest = Object.assign({},
+ bidRequests[0],
+ {
+ params: {
+ placementId: '10433394',
+ app: {
+ id: 'B1O2W3M4AN.com.prebid.webview',
+ geo: {
+ lat: 40.0964439,
+ lng: -75.3009142
+ },
+ device_id: {
+ idfa: '4D12078D-3246-4DA4-AD5E-7610481E7AE', // Apple advertising identifier
+ aaid: '38400000-8cf0-11bd-b23e-10b96e40000d', // Android advertising identifier
+ md5udid: '5756ae9022b2ea1e47d84fead75220c8', // MD5 hash of the ANDROID_ID
+ sha1udid: '4DFAA92388699AC6539885AEF1719293879985BF', // SHA1 hash of the ANDROID_ID
+ windowsadid: '750c6be243f1c4b5c9912b95a5742fc5' // Windows advertising identifier
+ }
+ }
+ }
+ }
+ );
+ const request = spec.buildRequests([appRequest]);
+ const payload = JSON.parse(request.data);
+ expect(payload.app).to.exist;
+ expect(payload.app).to.deep.equal({
+ appid: 'B1O2W3M4AN.com.prebid.webview'
+ });
+ expect(payload.device.device_id).to.exist;
+ expect(payload.device.device_id).to.deep.equal({
+ aaid: '38400000-8cf0-11bd-b23e-10b96e40000d',
+ idfa: '4D12078D-3246-4DA4-AD5E-7610481E7AE',
+ md5udid: '5756ae9022b2ea1e47d84fead75220c8',
+ sha1udid: '4DFAA92388699AC6539885AEF1719293879985BF',
+ windowsadid: '750c6be243f1c4b5c9912b95a5742fc5'
+ });
+ expect(payload.device.geo).to.exist;
+ expect(payload.device.geo).to.deep.equal({
+ lat: 40.0964439,
+ lng: -75.3009142
+ });
+ });
+
+ it('should add referer info to payload', function () {
+ const bidRequest = Object.assign({}, bidRequests[0])
+ const bidderRequest = {
+ refererInfo: {
+ referer: 'http://example.com/page.html',
+ reachedTop: true,
+ numIframes: 2,
+ stack: [
+ 'http://example.com/page.html',
+ 'http://example.com/iframe1.html',
+ 'http://example.com/iframe2.html'
+ ]
+ }
+ }
+ const request = spec.buildRequests([bidRequest], bidderRequest);
+ const payload = JSON.parse(request.data);
+
+ expect(payload.referrer_detection).to.exist;
+ expect(payload.referrer_detection).to.deep.equal({
+ rd_ref: 'http%3A%2F%2Fexample.com%2Fpage.html',
+ rd_top: true,
+ rd_ifs: 2,
+ rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',')
+ });
+ });
+
+ it('should populate coppa if set in config', function () {
+ let bidRequest = Object.assign({}, bidRequests[0]);
+ sinon.stub(config, 'getConfig')
+ .withArgs('coppa')
+ .returns(true);
+
+ const request = spec.buildRequests([bidRequest]);
+ const payload = JSON.parse(request.data);
+
+ expect(payload.user.coppa).to.equal(true);
+
+ config.getConfig.restore();
+ });
+ })
+
+ describe('interpretResponse', function () {
+ let bfStub;
+ before(function() {
+ bfStub = sinon.stub(bidderFactory, 'getIabSubCategory');
+ });
+
+ after(function() {
+ bfStub.restore();
+ });
+
+ let response = {
+ 'version': '3.0.0',
+ 'tags': [
+ {
+ 'uuid': '3db3773286ee59',
+ 'tag_id': 10433394,
+ 'auction_id': '4534722592064951574',
+ 'nobid': false,
+ 'no_ad_url': 'http://lax1-ib.adnxs.com/no-ad',
+ 'timeout_ms': 10000,
+ 'ad_profile_id': 27079,
+ 'ads': [
+ {
+ 'content_source': 'rtb',
+ 'ad_type': 'banner',
+ 'buyer_member_id': 958,
+ 'creative_id': 29681110,
+ 'media_type_id': 1,
+ 'media_subtype_id': 1,
+ 'cpm': 0.5,
+ 'cpm_publisher_currency': 0.5,
+ 'publisher_currency_code': '$',
+ 'client_initiated_ad_counting': true,
+ 'viewability': {
+ 'config': ''
+ },
+ 'rtb': {
+ 'banner': {
+ 'content': '',
+ 'width': 300,
+ 'height': 250
+ },
+ 'trackers': [
+ {
+ 'impression_urls': [
+ 'http://lax1-ib.adnxs.com/impression'
+ ],
+ 'video_events': {}
+ }
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ };
+
+ it('should get correct bid response', function () {
+ let expectedResponse = [
+ {
+ 'requestId': '3db3773286ee59',
+ 'cpm': 0.5,
+ 'creativeId': 29681110,
+ 'dealId': undefined,
+ 'width': 300,
+ 'height': 250,
+ 'ad': '',
+ 'mediaType': 'banner',
+ 'currency': 'USD',
+ 'ttl': 300,
+ 'netRevenue': true,
+ 'adUnitCode': 'code',
+ 'adrelevantis': {
+ 'buyerMemberId': 958
+ }
+ }
+ ];
+ let bidderRequest = {
+ bids: [{
+ bidId: '3db3773286ee59',
+ adUnitCode: 'code'
+ }]
+ }
+ let result = spec.interpretResponse({ body: response }, {bidderRequest});
+ expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0]));
+ });
+
+ it('handles nobid responses', function () {
+ let response = {
+ 'version': '0.0.1',
+ 'tags': [{
+ 'uuid': '84ab500420319d',
+ 'tag_id': 5976557,
+ 'auction_id': '297492697822162468',
+ 'nobid': true
+ }]
+ };
+ let bidderRequest;
+
+ let result = spec.interpretResponse({ body: response }, {bidderRequest});
+ expect(result.length).to.equal(0);
+ });
+
+ it('handles outstream video responses', function () {
+ let response = {
+ 'tags': [{
+ 'uuid': '84ab500420319d',
+ 'ads': [{
+ 'ad_type': 'video',
+ 'cpm': 0.500000,
+ 'notify_url': 'imptracker.com',
+ 'rtb': {
+ 'video': {
+ 'content': ''
+ }
+ },
+ 'javascriptTrackers': ''
+ }]
+ }]
+ };
+ let bidderRequest = {
+ bids: [{
+ bidId: '84ab500420319d',
+ adUnitCode: 'code',
+ mediaTypes: {
+ video: {
+ context: 'outstream'
+ }
+ }
+ }]
+ }
+
+ let result = spec.interpretResponse({ body: response }, {bidderRequest});
+ expect(result[0]).to.have.property('vastXml');
+ expect(result[0]).to.have.property('vastImpUrl');
+ expect(result[0]).to.have.property('mediaType', 'video');
+ });
+
+ it('handles instream video responses', function () {
+ let response = {
+ 'tags': [{
+ 'uuid': '84ab500420319d',
+ 'ads': [{
+ 'ad_type': 'video',
+ 'cpm': 0.500000,
+ 'notify_url': 'imptracker.com',
+ 'rtb': {
+ 'video': {
+ 'asset_url': 'https://sample.vastURL.com/here/vid'
+ }
+ },
+ 'javascriptTrackers': ''
+ }]
+ }]
+ };
+ let bidderRequest = {
+ bids: [{
+ bidId: '84ab500420319d',
+ adUnitCode: 'code',
+ mediaTypes: {
+ video: {
+ context: 'instream'
+ }
+ }
+ }]
+ }
+
+ let result = spec.interpretResponse({ body: response }, {bidderRequest});
+ expect(result[0]).to.have.property('vastUrl');
+ expect(result[0]).to.have.property('vastImpUrl');
+ expect(result[0]).to.have.property('mediaType', 'video');
+ });
+
+ it('handles native responses', function () {
+ let response1 = deepClone(response);
+ response1.tags[0].ads[0].ad_type = 'native';
+ response1.tags[0].ads[0].rtb.native = {
+ 'title': 'Native Creative',
+ 'desc': 'Cool description great stuff',
+ 'desc2': 'Additional body text',
+ 'ctatext': 'Do it',
+ 'sponsored': 'AppNexus',
+ 'icon': {
+ 'width': 0,
+ 'height': 0,
+ 'url': 'https://cdn.adnxs.com/icon.png'
+ },
+ 'main_img': {
+ 'width': 2352,
+ 'height': 1516,
+ 'url': 'https://cdn.adnxs.com/img.png'
+ },
+ 'link': {
+ 'url': 'https://www.appnexus.com',
+ 'fallback_url': '',
+ 'click_trackers': ['https://nym1-ib.adnxs.com/click']
+ },
+ 'impression_trackers': ['https://example.com'],
+ 'rating': '5',
+ 'displayurl': 'https://AppNexus.com/?url=display_url',
+ 'likes': '38908320',
+ 'downloads': '874983',
+ 'price': '9.99',
+ 'saleprice': 'FREE',
+ 'phone': '1234567890',
+ 'address': '28 W 23rd St, New York, NY 10010',
+ 'privacy_link': 'https://appnexus.com/?url=privacy_url',
+ 'javascriptTrackers': ''
+ };
+ let bidderRequest = {
+ bids: [{
+ bidId: '3db3773286ee59',
+ adUnitCode: 'code'
+ }]
+ }
+
+ let result = spec.interpretResponse({ body: response1 }, {bidderRequest});
+ expect(result[0].native.title).to.equal('Native Creative');
+ expect(result[0].native.body).to.equal('Cool description great stuff');
+ expect(result[0].native.cta).to.equal('Do it');
+ expect(result[0].native.image.url).to.equal('https://cdn.adnxs.com/img.png');
+ });
+
+ it('supports configuring outstream renderers', function () {
+ const outstreamResponse = deepClone(response);
+ outstreamResponse.tags[0].ads[0].rtb.video = {};
+ outstreamResponse.tags[0].ads[0].renderer_url = 'renderer.js';
+
+ const bidderRequest = {
+ bids: [{
+ bidId: '3db3773286ee59',
+ renderer: {
+ options: {
+ adText: 'configured'
+ }
+ },
+ mediaTypes: {
+ video: {
+ context: 'outstream'
+ }
+ }
+ }]
+ };
+
+ const result = spec.interpretResponse({ body: outstreamResponse }, {bidderRequest});
+ expect(result[0].renderer.config).to.deep.equal(
+ bidderRequest.bids[0].renderer.options
+ );
+ });
+
+ it('should add deal_priority and deal_code', function() {
+ let responseWithDeal = deepClone(response);
+ responseWithDeal.tags[0].ads[0].deal_priority = 'high';
+ responseWithDeal.tags[0].ads[0].deal_code = '123';
+
+ let bidderRequest = {
+ bids: [{
+ bidId: '3db3773286ee59',
+ adUnitCode: 'code'
+ }]
+ }
+ let result = spec.interpretResponse({ body: responseWithDeal }, {bidderRequest});
+ expect(Object.keys(result[0].adrelevantis)).to.include.members(['buyerMemberId', 'dealPriority', 'dealCode']);
+ });
+
+ it('should add advertiser id', function() {
+ let responseAdvertiserId = deepClone(response);
+ responseAdvertiserId.tags[0].ads[0].advertiser_id = '123';
+
+ let bidderRequest = {
+ bids: [{
+ bidId: '3db3773286ee59',
+ adUnitCode: 'code'
+ }]
+ }
+ let result = spec.interpretResponse({ body: responseAdvertiserId }, {bidderRequest});
+ expect(Object.keys(result[0].meta)).to.include.members(['advertiserId']);
+ })
+ });
+});
diff --git a/test/spec/modules/adtelligentBidAdapter_spec.js b/test/spec/modules/adtelligentBidAdapter_spec.js
index 9c694668703..62449771416 100644
--- a/test/spec/modules/adtelligentBidAdapter_spec.js
+++ b/test/spec/modules/adtelligentBidAdapter_spec.js
@@ -2,6 +2,7 @@ import { expect } from 'chai';
import { spec } from 'modules/adtelligentBidAdapter.js';
import { newBidder } from 'src/adapters/bidderFactory.js';
import { config } from 'src/config.js';
+import { deepClone } from 'src/utils.js';
const EXPECTED_ENDPOINTS = [
'https://ghb.adtelligent.com/v2/auction/',
@@ -9,7 +10,9 @@ const EXPECTED_ENDPOINTS = [
'https://ghb2.adtelligent.com/v2/auction/',
'https://ghb.adtelligent.com/v2/auction/'
];
-
+const aliasEP = {
+ appaloosa: 'https://hb.appaloosa.media/v2/auction/'
+};
const DISPLAY_REQUEST = {
'bidder': 'adtelligent',
'params': {
@@ -250,6 +253,15 @@ describe('adtelligentBidAdapter', () => {
expect(bidReqUrls).to.deep.equal(EXPECTED_ENDPOINTS);
})
+ it('makes correct host for aliases', () => {
+ for (const alias in aliasEP) {
+ const bidReq = deepClone(DISPLAY_REQUEST)
+ bidReq.bidder = alias;
+ const [bidderRequest] = spec.buildRequests([bidReq], { bidderCode: alias });
+ expect(bidderRequest.url).to.equal(aliasEP[alias]);
+ }
+ })
+
it('building requests as arrays', () => {
expect(videoRequest).to.be.a('array');
expect(displayRequest).to.be.a('array');
diff --git a/test/spec/modules/adxcgBidAdapter_spec.js b/test/spec/modules/adxcgBidAdapter_spec.js
index 306914960c3..f9aaea308a7 100644
--- a/test/spec/modules/adxcgBidAdapter_spec.js
+++ b/test/spec/modules/adxcgBidAdapter_spec.js
@@ -281,7 +281,7 @@ describe('AdxcgAdapter', function () {
let bid = deepClone([bidBanner]);
let bidderRequests = {};
- bid[0].userId = {id5id: 'id5idsample'};
+ bid[0].userId = {id5id: {uid: 'id5idsample'}};
it('should send pubcid if available', function () {
let request = spec.buildRequests(bid, bidderRequests);
diff --git a/test/spec/modules/adyoulikeBidAdapter_spec.js b/test/spec/modules/adyoulikeBidAdapter_spec.js
index d2d4e10c17f..ec8f2f00923 100644
--- a/test/spec/modules/adyoulikeBidAdapter_spec.js
+++ b/test/spec/modules/adyoulikeBidAdapter_spec.js
@@ -306,6 +306,7 @@ describe('Adyoulike Adapter', function () {
expect(request.method).to.equal('POST');
expect(request.url).to.contains('CanonicalUrl=' + encodeURIComponent(canonicalUrl));
expect(request.url).to.contains('RefererUrl=' + encodeURIComponent(referrerUrl));
+ expect(request.url).to.contains('PublisherDomain=http%3A%2F%2Flocalhost%3A9876');
expect(payload.Version).to.equal('1.0');
expect(payload.Bids['bid_id_0'].PlacementID).to.be.equal('placement_0');
diff --git a/test/spec/modules/amxBidAdapter_spec.js b/test/spec/modules/amxBidAdapter_spec.js
index 4b21244501d..91315da8801 100644
--- a/test/spec/modules/amxBidAdapter_spec.js
+++ b/test/spec/modules/amxBidAdapter_spec.js
@@ -224,7 +224,7 @@ describe('AmxBidAdapter', () => {
britepoolid: 'sample-britepool',
criteoId: 'sample-criteo',
digitrustid: {data: {id: 'sample-digitrust'}},
- id5id: 'sample-id5',
+ id5id: {uid: 'sample-id5'},
idl_env: 'sample-liveramp',
lipb: {lipbid: 'sample-liveintent'},
netId: 'sample-netid',
diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js
index 7e985045c45..4102896ba94 100644
--- a/test/spec/modules/appnexusBidAdapter_spec.js
+++ b/test/spec/modules/appnexusBidAdapter_spec.js
@@ -808,7 +808,7 @@ describe('AppNexusAdapter', function () {
expect(request.options).to.deep.equal({withCredentials: false});
});
- it('should populate eids array when ttd id and criteo is available', function () {
+ it('should populate eids and tpuids when ttd id and criteo is available', function () {
const bidRequest = Object.assign({}, bidRequests[0], {
userId: {
tdid: 'sample-userid',
@@ -824,10 +824,56 @@ describe('AppNexusAdapter', function () {
rti_partner: 'TDID'
});
- expect(payload.eids).to.deep.include({
- source: 'criteo.com',
- id: 'sample-criteo-userid',
+ expect(payload.tpuids).to.deep.include({
+ provider: 'criteo',
+ user_id: 'sample-criteo-userid',
+ });
+ });
+
+ it('should populate iab_support object at the root level if omid support is detected', function () {
+ // with bid.params.frameworks
+ let bidRequest_A = Object.assign({}, bidRequests[0], {
+ params: {
+ frameworks: [1, 2, 5, 6],
+ video: {
+ frameworks: [1, 2, 5, 6]
+ }
+ }
+ });
+ let request = spec.buildRequests([bidRequest_A]);
+ let payload = JSON.parse(request.data);
+ expect(payload.iab_support).to.be.an('object');
+ expect(payload.iab_support).to.deep.equal({
+ omidpn: 'Appnexus',
+ omidpv: '$prebid.version$'
});
+ expect(payload.tags[0].banner_frameworks).to.be.an('array');
+ expect(payload.tags[0].banner_frameworks).to.deep.equal([1, 2, 5, 6]);
+ expect(payload.tags[0].video_frameworks).to.be.an('array');
+ expect(payload.tags[0].video_frameworks).to.deep.equal([1, 2, 5, 6]);
+ expect(payload.tags[0].video.frameworks).to.not.exist;
+
+ // without bid.params.frameworks
+ const bidRequest_B = Object.assign({}, bidRequests[0]);
+ request = spec.buildRequests([bidRequest_B]);
+ payload = JSON.parse(request.data);
+ expect(payload.iab_support).to.not.exist;
+ expect(payload.tags[0].banner_frameworks).to.not.exist;
+ expect(payload.tags[0].video_frameworks).to.not.exist;
+
+ // with video.frameworks but it is not an array
+ const bidRequest_C = Object.assign({}, bidRequests[0], {
+ params: {
+ video: {
+ frameworks: "'1', '2', '3', '6'"
+ }
+ }
+ });
+ request = spec.buildRequests([bidRequest_C]);
+ payload = JSON.parse(request.data);
+ expect(payload.iab_support).to.not.exist;
+ expect(payload.tags[0].banner_frameworks).to.not.exist;
+ expect(payload.tags[0].video_frameworks).to.not.exist;
});
})
diff --git a/test/spec/modules/avocetBidAdapter_spec.js b/test/spec/modules/avocetBidAdapter_spec.js
index 4cfd8ab89d4..2a2f29e48d2 100644
--- a/test/spec/modules/avocetBidAdapter_spec.js
+++ b/test/spec/modules/avocetBidAdapter_spec.js
@@ -69,7 +69,9 @@ describe('Avocet adapter', function () {
placement: '012345678901234567890123',
},
userId: {
- id5id: 'test'
+ id5id: {
+ uid: 'test'
+ }
}
},
{
diff --git a/test/spec/modules/bridgewellBidAdapter_spec.js b/test/spec/modules/bridgewellBidAdapter_spec.js
index 644f468abe8..24ec523ac67 100644
--- a/test/spec/modules/bridgewellBidAdapter_spec.js
+++ b/test/spec/modules/bridgewellBidAdapter_spec.js
@@ -22,6 +22,16 @@ describe('bridgewellBidAdapter', function () {
expect(spec.isBidRequestValid(validTag)).to.equal(true);
});
+ it('should return true when required params found', function () {
+ const validTag = {
+ 'bidder': 'bridgewell',
+ 'params': {
+ 'cid': 1234
+ },
+ };
+ expect(spec.isBidRequestValid(validTag)).to.equal(true);
+ });
+
it('should return false when required params not found', function () {
const invalidTag = {
'bidder': 'bridgewell',
@@ -39,6 +49,26 @@ describe('bridgewellBidAdapter', function () {
};
expect(spec.isBidRequestValid(invalidTag)).to.equal(false);
});
+
+ it('should return false when required params are empty', function () {
+ const invalidTag = {
+ 'bidder': 'bridgewell',
+ 'params': {
+ 'cid': '',
+ },
+ };
+ expect(spec.isBidRequestValid(invalidTag)).to.equal(false);
+ });
+
+ it('should return false when required param cid is not a number', function () {
+ const invalidTag = {
+ 'bidder': 'bridgewell',
+ 'params': {
+ 'cid': 'bad_cid',
+ },
+ };
+ expect(spec.isBidRequestValid(invalidTag)).to.equal(false);
+ });
});
describe('buildRequests', function () {
@@ -113,12 +143,58 @@ describe('bridgewellBidAdapter', function () {
expect(payload.url).to.exist.and.to.equal('https://www.bridgewell.com/');
for (let i = 0, max_i = payload.adUnits.length; i < max_i; i++) {
expect(payload.adUnits[i]).to.have.property('ChannelID').that.is.a('string');
+ expect(payload.adUnits[i]).to.not.have.property('cid');
expect(payload.adUnits[i]).to.have.property('adUnitCode').and.to.equal('adunit-code-2');
+ expect(payload.adUnits[i]).to.have.property('requestId').and.to.equal('3150ccb55da321');
+ }
+ });
+
+ it('should attach valid params to the tag, part2', function() {
+ const bidderRequest = {
+ refererInfo: {
+ referer: 'https://www.bridgewell.com/'
+ }
+ }
+ const bidRequests2 = [
+ {
+ 'bidder': 'bridgewell',
+ 'params': {
+ 'cid': 1234,
+ },
+ 'adUnitCode': 'adunit-code-2',
+ 'mediaTypes': {
+ 'banner': {
+ 'sizes': [728, 90]
+ }
+ },
+ 'bidId': '3150ccb55da321',
+ 'bidderRequestId': '22edbae2733bf6',
+ 'auctionId': '1d1a030790a475',
+ },
+ ];
+
+ const request = spec.buildRequests(bidRequests2, bidderRequest);
+ const payload = request.data;
+
+ expect(payload).to.be.an('object');
+ expect(payload.adUnits).to.be.an('array');
+ expect(payload.url).to.exist.and.to.equal('https://www.bridgewell.com/');
+ for (let i = 0, max_i = payload.adUnits.length; i < max_i; i++) {
+ expect(payload.adUnits[i]).to.have.property('cid').that.is.a('number');
+ expect(payload.adUnits[i]).to.not.have.property('ChannelID');
+ expect(payload.adUnits[i]).to.have.property('adUnitCode').and.to.equal('adunit-code-2');
+ expect(payload.adUnits[i]).to.have.property('requestId').and.to.equal('3150ccb55da321');
}
});
it('should attach validBidRequests to the tag', function () {
- const request = spec.buildRequests(bidRequests);
+ const bidderRequest = {
+ refererInfo: {
+ referer: 'https://www.bridgewell.com/'
+ }
+ }
+
+ const request = spec.buildRequests(bidRequests, bidderRequest);
const validBidRequests = request.validBidRequests;
expect(validBidRequests).to.deep.equal(bidRequests);
});
diff --git a/test/spec/modules/brightMountainMediaBidAdapter_spec.js b/test/spec/modules/brightMountainMediaBidAdapter_spec.js
index 3b7e46e55a7..f6312253722 100644
--- a/test/spec/modules/brightMountainMediaBidAdapter_spec.js
+++ b/test/spec/modules/brightMountainMediaBidAdapter_spec.js
@@ -133,7 +133,7 @@ describe('brightMountainMediaBidAdapter_spec', function () {
expect(spec.getUserSyncs(syncoptionsIframe)[0].type).to.exist;
expect(spec.getUserSyncs(syncoptionsIframe)[0].url).to.exist;
expect(spec.getUserSyncs(syncoptionsIframe)[0].type).to.equal('iframe')
- expect(spec.getUserSyncs(syncoptionsIframe)[0].url).to.equal('https://console.brightmountainmedia.com:4444/cookieSync')
+ expect(spec.getUserSyncs(syncoptionsIframe)[0].url).to.equal('https://console.brightmountainmedia.com:8443/cookieSync')
});
});
});
diff --git a/test/spec/modules/britepoolIdSystem_spec.js b/test/spec/modules/britepoolIdSystem_spec.js
index 2c6dd234a90..ddb61806006 100644
--- a/test/spec/modules/britepoolIdSystem_spec.js
+++ b/test/spec/modules/britepoolIdSystem_spec.js
@@ -1,5 +1,5 @@
-import { expect } from 'chai';
import {britepoolIdSubmodule} from 'modules/britepoolIdSystem.js';
+import * as utils from '../../../src/utils.js';
describe('BritePool Submodule', () => {
const api_key = '1111';
@@ -16,6 +16,32 @@ describe('BritePool Submodule', () => {
};
};
+ let triggerPixelStub;
+
+ beforeEach(function (done) {
+ triggerPixelStub = sinon.stub(utils, 'triggerPixel');
+ done();
+ });
+
+ afterEach(function () {
+ triggerPixelStub.restore();
+ });
+
+ it('trigger id resolution pixel when no identifiers set', () => {
+ britepoolIdSubmodule.getId({ params: {} });
+ expect(triggerPixelStub.called).to.be.true;
+ });
+
+ it('trigger id resolution pixel when no identifiers set with api_key param', () => {
+ britepoolIdSubmodule.getId({ params: { api_key } });
+ expect(triggerPixelStub.called).to.be.true;
+ });
+
+ it('does not trigger id resolution pixel when identifiers set', () => {
+ britepoolIdSubmodule.getId({ params: { api_key, aaid } });
+ expect(triggerPixelStub.called).to.be.false;
+ });
+
it('sends x-api-key in header and one identifier', () => {
const { params, headers, url, errors } = britepoolIdSubmodule.createParams({ api_key, aaid });
assert(errors.length === 0, errors);
@@ -43,12 +69,48 @@ describe('BritePool Submodule', () => {
expect(params.url).to.be.undefined;
});
+ it('test gdpr consent string in url', () => {
+ const { params, headers, url, errors } = britepoolIdSubmodule.createParams({ api_key, aaid }, { gdprApplies: true, consentString: 'expectedConsentString' });
+ expect(url).to.equal('https://api.britepool.com/v1/britepool/id?gdprString=expectedConsentString');
+ });
+
+ it('test gdpr consent string not in url if gdprApplies false', () => {
+ const { params, headers, url, errors } = britepoolIdSubmodule.createParams({ api_key, aaid }, { gdprApplies: false, consentString: 'expectedConsentString' });
+ expect(url).to.equal('https://api.britepool.com/v1/britepool/id');
+ });
+
+ it('test gdpr consent string not in url if consent string undefined', () => {
+ const { params, headers, url, errors } = britepoolIdSubmodule.createParams({ api_key, aaid }, { gdprApplies: true, consentString: undefined });
+ expect(url).to.equal('https://api.britepool.com/v1/britepool/id');
+ });
+
+ it('dynamic pub params should be added to params', () => {
+ window.britepool_pubparams = { ppid: '12345' };
+ const { params, headers, url, errors } = britepoolIdSubmodule.createParams({ api_key, aaid });
+ expect(params).to.eql({ aaid, ppid: '12345' });
+ window.britepool_pubparams = undefined;
+ });
+
+ it('dynamic pub params should override submodule params', () => {
+ window.britepool_pubparams = { ppid: '67890' };
+ const { params, headers, url, errors } = britepoolIdSubmodule.createParams({ api_key, ppid: '12345' });
+ expect(params).to.eql({ ppid: '67890' });
+ window.britepool_pubparams = undefined;
+ });
+
+ it('if dynamic pub params undefined do nothing', () => {
+ window.britepool_pubparams = undefined;
+ const { params, headers, url, errors } = britepoolIdSubmodule.createParams({ api_key, aaid });
+ expect(params).to.eql({ aaid });
+ window.britepool_pubparams = undefined;
+ });
+
it('test getter override with value', () => {
const { params, headers, url, getter, errors } = britepoolIdSubmodule.createParams({ api_key, aaid, url: url_override, getter: getter_override });
expect(getter).to.equal(getter_override);
// Making sure it did not become part of params
expect(params.getter).to.be.undefined;
- const response = britepoolIdSubmodule.getId({ api_key, aaid, url: url_override, getter: getter_override });
+ const response = britepoolIdSubmodule.getId({ params: { api_key, aaid, url: url_override, getter: getter_override } });
assert.deepEqual(response, { id: { 'primaryBPID': bpid } });
});
@@ -57,7 +119,7 @@ describe('BritePool Submodule', () => {
expect(getter).to.equal(getter_callback_override);
// Making sure it did not become part of params
expect(params.getter).to.be.undefined;
- const response = britepoolIdSubmodule.getId({ api_key, aaid, url: url_override, getter: getter_callback_override });
+ const response = britepoolIdSubmodule.getId({ params: { api_key, aaid, url: url_override, getter: getter_callback_override } });
expect(response.callback).to.not.be.undefined;
response.callback(result => {
assert.deepEqual(result, { 'primaryBPID': bpid });
diff --git a/test/spec/modules/cointrafficBidAdapter_spec.js b/test/spec/modules/cointrafficBidAdapter_spec.js
index 6d948e36cb9..a2ce4cedea0 100644
--- a/test/spec/modules/cointrafficBidAdapter_spec.js
+++ b/test/spec/modules/cointrafficBidAdapter_spec.js
@@ -1,5 +1,7 @@
import { expect } from 'chai';
import { spec } from 'modules/cointrafficBidAdapter.js';
+import { config } from 'src/config.js'
+import * as utils from 'src/utils.js'
const ENDPOINT_URL = 'https://appspb.cointraffic.io/pb/tmp';
@@ -37,7 +39,7 @@ describe('cointrafficBidAdapter', function () {
],
bidId: 'bidId12345',
bidderRequestId: 'bidderRequestId12345',
- auctionId: 'auctionId12345',
+ auctionId: 'auctionId12345'
},
{
bidder: 'cointraffic',
@@ -50,7 +52,7 @@ describe('cointrafficBidAdapter', function () {
],
bidId: 'bidId67890"',
bidderRequestId: 'bidderRequestId67890',
- auctionId: 'auctionId12345',
+ auctionId: 'auctionId12345'
}
];
@@ -65,34 +67,71 @@ describe('cointrafficBidAdapter', function () {
}
};
- const request = spec.buildRequests(bidRequests, bidderRequests);
+ it('replaces currency with EUR if there is no currency provided', function () {
+ const request = spec.buildRequests(bidRequests, bidderRequests);
+
+ expect(request[0].data.currency).to.equal('EUR');
+ expect(request[1].data.currency).to.equal('EUR');
+ });
+
+ it('replaces currency with EUR if there is no currency provided', function () {
+ const getConfigStub = sinon.stub(config, 'getConfig').callsFake(
+ arg => arg === 'currency.bidderCurrencyDefault.cointraffic' ? 'USD' : 'EUR'
+ );
+
+ const request = spec.buildRequests(bidRequests, bidderRequests);
+
+ expect(request[0].data.currency).to.equal('USD');
+ expect(request[1].data.currency).to.equal('USD');
+
+ getConfigStub.restore();
+ });
+
+ it('throws an error if currency provided in params is not allowed', function () {
+ const utilsMock = sinon.mock(utils).expects('logError').twice()
+ const getConfigStub = sinon.stub(config, 'getConfig').callsFake(
+ arg => arg === 'currency.bidderCurrencyDefault.cointraffic' ? 'BTC' : 'EUR'
+ );
+
+ const request = spec.buildRequests(bidRequests, bidderRequests);
+
+ expect(request[0]).to.undefined;
+ expect(request[1]).to.undefined;
+
+ utilsMock.restore()
+ getConfigStub.restore();
+ });
it('sends bid request to our endpoint via POST', function () {
+ const request = spec.buildRequests(bidRequests, bidderRequests);
+
expect(request[0].method).to.equal('POST');
expect(request[1].method).to.equal('POST');
});
+
it('attaches source and version to endpoint URL as query params', function () {
+ const request = spec.buildRequests(bidRequests, bidderRequests);
+
expect(request[0].url).to.equal(ENDPOINT_URL);
expect(request[1].url).to.equal(ENDPOINT_URL);
});
});
describe('interpretResponse', function () {
- let bidRequest = [
- {
+ it('should get the correct bid response', function () {
+ let bidRequest = [{
method: 'POST',
url: ENDPOINT_URL,
data: {
placementId: 'testPlacementId',
device: 'desktop',
+ currency: 'EUR',
sizes: ['300x250'],
bidId: 'bidId12345',
referer: 'www.example.com'
}
- }
- ];
+ }];
- it('should get the correct bid response', function () {
let serverResponse = {
body: {
requestId: 'bidId12345',
@@ -103,7 +142,7 @@ describe('cointrafficBidAdapter', function () {
height: 250,
creativeId: 'creativeId12345',
ttl: 90,
- ad: 'I am an ad
',
+ ad: 'I am an ad
'
}
};
@@ -118,22 +157,99 @@ describe('cointrafficBidAdapter', function () {
ttl: 90,
ad: 'I am an ad
'
}];
+
let result = spec.interpretResponse(serverResponse, bidRequest[0]);
expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse));
});
- it('should get empty bid response if server response body is empty', function () {
+ it('should get the correct bid response with different currency', function () {
+ let bidRequest = [{
+ method: 'POST',
+ url: ENDPOINT_URL,
+ data: {
+ placementId: 'testPlacementId',
+ device: 'desktop',
+ currency: 'USD',
+ sizes: ['300x250'],
+ bidId: 'bidId12345',
+ referer: 'www.example.com'
+ }
+ }];
+
let serverResponse = {
- body: {}
+ body: {
+ requestId: 'bidId12345',
+ cpm: 3.9,
+ currency: 'USD',
+ netRevenue: true,
+ width: 300,
+ height: 250,
+ creativeId: 'creativeId12345',
+ ttl: 90,
+ ad: 'I am an ad
'
+ }
};
+ let expectedResponse = [{
+ requestId: 'bidId12345',
+ cpm: 3.9,
+ currency: 'USD',
+ netRevenue: true,
+ width: 300,
+ height: 250,
+ creativeId: 'creativeId12345',
+ ttl: 90,
+ ad: 'I am an ad
'
+ }];
+
+ const getConfigStub = sinon.stub(config, 'getConfig').returns('USD');
+
+ let result = spec.interpretResponse(serverResponse, bidRequest[0]);
+ expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse));
+
+ getConfigStub.restore();
+ });
+
+ it('should get empty bid response requested currency is not available', function () {
+ let bidRequest = [{
+ method: 'POST',
+ url: ENDPOINT_URL,
+ data: {
+ placementId: 'testPlacementId',
+ device: 'desktop',
+ currency: 'BTC',
+ sizes: ['300x250'],
+ bidId: 'bidId12345',
+ referer: 'www.example.com'
+ }
+ }];
+
+ let serverResponse = {};
+
let expectedResponse = [];
+ const getConfigStub = sinon.stub(config, 'getConfig').returns('BTC');
+
let result = spec.interpretResponse(serverResponse, bidRequest[0]);
expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse));
+
+ getConfigStub.restore();
});
it('should get empty bid response if no server response', function () {
+ let bidRequest = [{
+ method: 'POST',
+ url: ENDPOINT_URL,
+ data: {
+ placementId: 'testPlacementId',
+ device: 'desktop',
+ currency: 'EUR',
+ sizes: ['300x250'],
+ bidId: 'bidId12345',
+ referer: 'www.example.com'
+ }
+ }];
+
let serverResponse = {};
let expectedResponse = [];
diff --git a/test/spec/modules/colossussspBidAdapter_spec.js b/test/spec/modules/colossussspBidAdapter_spec.js
index df9bdcbd47b..a10a7590677 100644
--- a/test/spec/modules/colossussspBidAdapter_spec.js
+++ b/test/spec/modules/colossussspBidAdapter_spec.js
@@ -108,7 +108,7 @@ describe('ColossussspAdapter', function () {
bid.userId.britepoolid = 'britepoolid123';
bid.userId.idl_env = 'idl_env123';
bid.userId.tdid = 'tdid123';
- bid.userId.id5id = 'id5id123'
+ bid.userId.id5id = { uid: 'id5id123' };
let serverRequest = spec.buildRequests([bid], bidderRequest);
it('Returns valid data if array of bids is valid', function () {
let data = serverRequest.data;
diff --git a/test/spec/modules/connectadBidAdapter_spec.js b/test/spec/modules/connectadBidAdapter_spec.js
index aef4fb562a7..dbac3c0dc7c 100644
--- a/test/spec/modules/connectadBidAdapter_spec.js
+++ b/test/spec/modules/connectadBidAdapter_spec.js
@@ -84,7 +84,6 @@ describe('ConnectAd Adapter', function () {
}
};
const isValid = spec.isBidRequestValid(validBid);
-
expect(isValid).to.equal(true);
});
@@ -162,13 +161,19 @@ describe('ConnectAd Adapter', function () {
bidRequests[0].getFloor = () => floorInfo;
const request = spec.buildRequests(bidRequests, bidderRequest);
const requestparse = JSON.parse(request.data);
- expect(requestparse.placements[0].floor).to.equal(5.20);
+ expect(requestparse.placements[0].bidfloor).to.equal(5.20);
});
- it('should be 0 if no floormodule is available', function() {
+ it('should be bidfloor if no floormodule is available', function() {
const request = spec.buildRequests(bidRequests, bidderRequest);
const requestparse = JSON.parse(request.data);
- expect(requestparse.placements[0].floor).to.equal(0);
+ expect(requestparse.placements[0].bidfloor).to.equal(0.50);
+ });
+
+ it('should have 0 bidfloor value', function() {
+ const request = spec.buildRequests(bidRequestsUserIds, bidderRequest);
+ const requestparse = JSON.parse(request.data);
+ expect(requestparse.placements[0].bidfloor).to.equal(0);
});
it('should contain gdpr info', function () {
diff --git a/test/spec/modules/districtmDmxBidAdapter_spec.js b/test/spec/modules/districtmDmxBidAdapter_spec.js
index 9b65ab855d8..90e6957fc2c 100644
--- a/test/spec/modules/districtmDmxBidAdapter_spec.js
+++ b/test/spec/modules/districtmDmxBidAdapter_spec.js
@@ -103,7 +103,9 @@ const bidRequest = [{
id: {}
}
},
- id5id: {},
+ id5id: {
+ uid: ''
+ },
pubcid: {},
tdid: {},
criteoId: {},
diff --git a/test/spec/modules/eids_spec.js b/test/spec/modules/eids_spec.js
index 8ad44f0b1ad..26dbad2f153 100644
--- a/test/spec/modules/eids_spec.js
+++ b/test/spec/modules/eids_spec.js
@@ -29,15 +29,39 @@ describe('eids array generation for known sub-modules', function() {
});
});
- it('id5Id', function() {
- const userId = {
- id5id: 'some-random-id-value'
- };
- const newEids = createEidsArray(userId);
- expect(newEids.length).to.equal(1);
- expect(newEids[0]).to.deep.equal({
- source: 'id5-sync.com',
- uids: [{id: 'some-random-id-value', atype: 1}]
+ describe('id5Id', function() {
+ it('does not include an ext if not provided', function() {
+ const userId = {
+ id5id: {
+ uid: 'some-random-id-value'
+ }
+ };
+ const newEids = createEidsArray(userId);
+ expect(newEids.length).to.equal(1);
+ expect(newEids[0]).to.deep.equal({
+ source: 'id5-sync.com',
+ uids: [{ id: 'some-random-id-value', atype: 1 }]
+ });
+ });
+
+ it('includes ext if provided', function() {
+ const userId = {
+ id5id: {
+ uid: 'some-random-id-value',
+ ext: {
+ linkType: 0
+ }
+ }
+ };
+ const newEids = createEidsArray(userId);
+ expect(newEids.length).to.equal(1);
+ expect(newEids[0]).to.deep.equal({
+ source: 'id5-sync.com',
+ uids: [{ id: 'some-random-id-value', atype: 1 }],
+ ext: {
+ linkType: 0
+ }
+ });
});
});
@@ -192,8 +216,87 @@ describe('eids array generation for known sub-modules', function() {
}]
});
});
-});
+ it('zeotapIdPlus', function() {
+ const userId = {
+ IDP: 'some-random-id-value'
+ };
+ const newEids = createEidsArray(userId);
+ expect(newEids.length).to.equal(1);
+ expect(newEids[0]).to.deep.equal({
+ source: 'zeotap.com',
+ uids: [{
+ id: 'some-random-id-value',
+ atype: 1
+ }]
+ });
+ });
+
+ it('haloId', function() {
+ const userId = {
+ haloId: 'some-random-id-value'
+ };
+ const newEids = createEidsArray(userId);
+ expect(newEids.length).to.equal(1);
+ expect(newEids[0]).to.deep.equal({
+ source: 'audigent.com',
+ uids: [{
+ id: 'some-random-id-value',
+ atype: 1
+ }]
+ });
+ });
+
+ it('quantcastId', function() {
+ const userId = {
+ quantcastId: 'some-random-id-value'
+ };
+ const newEids = createEidsArray(userId);
+ expect(newEids.length).to.equal(1);
+ expect(newEids[0]).to.deep.equal({
+ source: 'quantcast.com',
+ uids: [{
+ id: 'some-random-id-value',
+ atype: 1
+ }]
+ });
+ });
+ it('pubProvidedId', function() {
+ const userId = {
+ pubProvidedId: [{
+ source: 'example.com',
+ uids: [{
+ id: 'value read from cookie or local storage',
+ ext: {
+ stype: 'ppuid'
+ }
+ }]
+ }, {
+ source: 'id-partner.com',
+ uids: [{
+ id: 'value read from cookie or local storage'
+ }]
+ }]
+ };
+ const newEids = createEidsArray(userId);
+ expect(newEids.length).to.equal(2);
+ expect(newEids[0]).to.deep.equal({
+ source: 'example.com',
+ uids: [{
+ id: 'value read from cookie or local storage',
+ ext: {
+ stype: 'ppuid'
+ }
+ }]
+ });
+ expect(newEids[1]).to.deep.equal({
+ source: 'id-partner.com',
+ uids: [{
+ id: 'value read from cookie or local storage'
+ }]
+ });
+ });
+});
describe('Negative case', function() {
it('eids array generation for UN-known sub-module', function() {
// UnknownCommonId
diff --git a/test/spec/modules/fabrickIdSystem_spec.js b/test/spec/modules/fabrickIdSystem_spec.js
new file mode 100644
index 00000000000..cbd538816ab
--- /dev/null
+++ b/test/spec/modules/fabrickIdSystem_spec.js
@@ -0,0 +1,106 @@
+import * as utils from '../../../src/utils.js';
+import {server} from '../../mocks/xhr.js';
+
+import * as fabrickIdSystem from 'modules/fabrickIdSystem.js';
+
+const defaultConfigParams = {
+ apiKey: '123',
+ e: 'abc',
+ p: ['def', 'hij'],
+ url: 'http://localhost:9999/test/mocks/fabrickId.json?'
+};
+const responseHeader = {'Content-Type': 'application/json'}
+const fabrickIdSubmodule = fabrickIdSystem.fabrickIdSubmodule;
+
+describe('Fabrick ID System', function() {
+ let logErrorStub;
+
+ beforeEach(function () {
+ logErrorStub = sinon.stub(utils, 'logError');
+ });
+
+ afterEach(function () {
+ logErrorStub.restore();
+ fabrickIdSubmodule.getRefererInfoOverride = null;
+ });
+
+ it('should log an error if no configParams were passed into getId', function () {
+ fabrickIdSubmodule.getId();
+ expect(logErrorStub.calledOnce).to.be.true;
+ });
+
+ it('should error on json parsing', function() {
+ let submoduleCallback = fabrickIdSubmodule.getId({
+ name: 'fabrickId',
+ params: defaultConfigParams
+ }).callback;
+ let callBackSpy = sinon.spy();
+ submoduleCallback(callBackSpy);
+ let request = server.requests[0];
+ request.respond(
+ 200,
+ responseHeader,
+ '] this is not json {'
+ );
+ expect(callBackSpy.calledOnce).to.be.true;
+ expect(logErrorStub.calledOnce).to.be.true;
+ });
+
+ it('should truncate the params', function() {
+ let r = '';
+ for (let i = 0; i < 300; i++) {
+ r += 'r';
+ }
+ let configParams = Object.assign({}, defaultConfigParams, {
+ refererInfo: {
+ referer: r,
+ stack: ['s-0'],
+ canonicalUrl: 'cu-0'
+ }
+ });
+ let submoduleCallback = fabrickIdSubmodule.getId({
+ name: 'fabrickId',
+ params: configParams
+ }).callback;
+ let callBackSpy = sinon.spy();
+ submoduleCallback(callBackSpy);
+ let request = server.requests[0];
+ r = '';
+ for (let i = 0; i < 200; i++) {
+ r += 'r';
+ }
+ expect(request.url).to.match(new RegExp(`r=${r}&r=`));
+ request.respond(
+ 200,
+ responseHeader,
+ JSON.stringify({})
+ );
+ expect(callBackSpy.calledOnce).to.be.true;
+ expect(logErrorStub.calledOnce).to.be.false;
+ });
+
+ it('should complete successfully', function() {
+ let configParams = Object.assign({}, defaultConfigParams, {
+ refererInfo: {
+ referer: 'r-0',
+ stack: ['s-0'],
+ canonicalUrl: 'cu-0'
+ }
+ });
+ let submoduleCallback = fabrickIdSubmodule.getId({
+ name: 'fabrickId',
+ params: configParams
+ }).callback;
+ let callBackSpy = sinon.spy();
+ submoduleCallback(callBackSpy);
+ let request = server.requests[0];
+ expect(request.url).to.match(/r=r-0&r=s-0&r=cu-0&r=http/);
+ request.respond(
+ 200,
+ responseHeader,
+ JSON.stringify({})
+ );
+ expect(callBackSpy.calledOnce).to.be.true;
+ expect(logErrorStub.calledOnce).to.be.false;
+ });
+});
diff --git a/test/spec/modules/gamoshiBidAdapter_spec.js b/test/spec/modules/gamoshiBidAdapter_spec.js
index 79f58470cb3..2996b853046 100644
--- a/test/spec/modules/gamoshiBidAdapter_spec.js
+++ b/test/spec/modules/gamoshiBidAdapter_spec.js
@@ -423,7 +423,7 @@ describe('GamoshiAdapter', () => {
it('build request with ID5 Id', () => {
const bidRequestClone = utils.deepClone(bidRequest);
bidRequestClone.userId = {};
- bidRequestClone.userId.id5id = 'id5-user-id';
+ bidRequestClone.userId.id5id = { uid: 'id5-user-id' };
let request = spec.buildRequests([bidRequestClone], bidRequestClone)[0];
expect(request.data.user.ext.eids).to.deep.equal([{
'source': 'id5-sync.com',
diff --git a/test/spec/modules/gjirafaBidAdapter_spec.js b/test/spec/modules/gjirafaBidAdapter_spec.js
index 566b1243f62..db9b82e0a10 100644
--- a/test/spec/modules/gjirafaBidAdapter_spec.js
+++ b/test/spec/modules/gjirafaBidAdapter_spec.js
@@ -31,7 +31,7 @@ describe('gjirafaAdapterTest', () => {
})).to.equal(false);
});
- it('bidRequest without propertyId orplacementId', () => {
+ it('bidRequest without propertyId or placementId', () => {
expect(spec.isBidRequestValid({
bidder: 'gjirafa',
params: {
@@ -80,7 +80,11 @@ describe('gjirafaAdapterTest', () => {
it('bidRequest sizes', () => {
const requests = spec.buildRequests(bidRequests);
- expect(requests[0].data.sizes).to.equal('728x90');
+ requests.forEach(function (requestItem) {
+ expect(requestItem.data.placements).to.exist;
+ expect(requestItem.data.placements.length).to.equal(1);
+ expect(requestItem.data.placements[0].sizes).to.equal('728x90');
+ });
});
});
@@ -128,7 +132,9 @@ describe('gjirafaAdapterTest', () => {
'netRevenue',
'ttl',
'referrer',
- 'ad'
+ 'ad',
+ 'vastUrl',
+ 'mediaType'
];
let resultKeys = Object.keys(result[0]);
diff --git a/test/spec/modules/gridBidAdapter_spec.js b/test/spec/modules/gridBidAdapter_spec.js
index 344f1764c05..1cfca4779ad 100644
--- a/test/spec/modules/gridBidAdapter_spec.js
+++ b/test/spec/modules/gridBidAdapter_spec.js
@@ -536,7 +536,7 @@ describe('TheMediaGrid Adapter', function () {
const bidRequestsWithUserIds = bidRequests.map((bid) => {
return Object.assign({
userId: {
- id5id: 'id5id_1',
+ id5id: { uid: 'id5id_1' },
tdid: 'tdid_1',
digitrustid: {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}},
lipb: {lipbid: 'lipb_1'}
@@ -578,6 +578,34 @@ describe('TheMediaGrid Adapter', function () {
expect(payload.source.ext).to.have.property('schain');
expect(payload.source.ext.schain).to.deep.equal(schain);
});
+
+ it('if content and segment is present in realTimeData.jwTargeting, payload must have right params', function () {
+ const jsContent = {id: 'test_jw_content_id'};
+ const jsSegments = ['test_seg_1', 'test_seg_2'];
+ const bidRequestsWithUserIds = bidRequests.map((bid) => {
+ return Object.assign({
+ realTimeData: {
+ jwTargeting: {
+ segments: jsSegments,
+ content: jsContent
+ }
+ }
+ }, bid);
+ });
+ const [request] = spec.buildRequests(bidRequestsWithUserIds, bidderRequest);
+ expect(request.data).to.be.an('string');
+ const payload = parseRequest(request.data);
+ expect(payload).to.have.property('user');
+ expect(payload.user.data).to.deep.equal([{
+ name: 'iow_labs_pub_data',
+ segment: [
+ {name: 'jwpseg', value: jsSegments[0]},
+ {name: 'jwpseg', value: jsSegments[1]}
+ ]
+ }]);
+ expect(payload).to.have.property('site');
+ expect(payload.site.content).to.deep.equal(jsContent);
+ });
});
describe('interpretResponse', function () {
diff --git a/test/spec/modules/gumgumBidAdapter_spec.js b/test/spec/modules/gumgumBidAdapter_spec.js
index cf672d89e22..701ce9a7e81 100644
--- a/test/spec/modules/gumgumBidAdapter_spec.js
+++ b/test/spec/modules/gumgumBidAdapter_spec.js
@@ -33,7 +33,11 @@ describe('gumgumAdapter', function () {
};
it('should return true when required params found', function () {
+ const zoneBid = { ...bid, params: { 'zone': '123' } };
+ const pubIdBid = { ...bid, params: { 'pubId': '123' } };
expect(spec.isBidRequestValid(bid)).to.equal(true);
+ expect(spec.isBidRequestValid(zoneBid)).to.equal(true);
+ expect(spec.isBidRequestValid(pubIdBid)).to.equal(true);
});
it('should return true when required params found', function () {
@@ -139,20 +143,68 @@ describe('gumgumAdapter', function () {
}
};
+ describe('zone param', function () {
+ const zoneParam = { 'zone': '123a' };
+
+ it('should set t and pi param', function () {
+ const request = { ...bidRequests[0], params: zoneParam };
+ const bidRequest = spec.buildRequests([request])[0];
+ expect(bidRequest.data.t).to.equal(zoneParam.zone);
+ expect(bidRequest.data.pi).to.equal(2);
+ });
+ it('should set the correct pi param if slot param is found', function () {
+ const request = { ...bidRequests[0], params: { ...zoneParam, 'slot': 1 } };
+ const bidRequest = spec.buildRequests([request])[0];
+ expect(bidRequest.data.pi).to.equal(3);
+ });
+ it('should set the correct pi param if native param is found', function () {
+ const request = { ...bidRequests[0], params: { ...zoneParam, 'native': 2 } };
+ const bidRequest = spec.buildRequests([request])[0];
+ expect(bidRequest.data.pi).to.equal(5);
+ });
+ it('should set the correct pi param for video', function () {
+ const request = { ...bidRequests[0], params: zoneParam, mediaTypes: vidMediaTypes };
+ const bidRequest = spec.buildRequests([request])[0];
+ expect(bidRequest.data.pi).to.equal(7);
+ });
+ it('should set the correct pi param for invideo', function () {
+ const invideo = { video: { ...vidMediaTypes.video, linearity: 2 } };
+ const request = { ...bidRequests[0], params: zoneParam, mediaTypes: invideo };
+ const bidRequest = spec.buildRequests([request])[0];
+ expect(bidRequest.data.pi).to.equal(6);
+ });
+ });
+
+ describe('pubId zone', function () {
+ const pubIdParam = { 'pubId': 'abc' };
+
+ it('should set t param', function () {
+ const request = { ...bidRequests[0], params: pubIdParam };
+ const bidRequest = spec.buildRequests([request])[0];
+ expect(bidRequest.data.pubId).to.equal(pubIdParam.pubId);
+ });
+
+ it('should set the correct pi depending on what is found in mediaTypes', function () {
+ const request = { ...bidRequests[0], params: pubIdParam };
+ const bidRequest = spec.buildRequests([request])[0];
+ const vidRequest = { ...bidRequests[0], mediaTypes: vidMediaTypes, params: { 'videoPubID': 123 } };
+ const vidBidRequest = spec.buildRequests([vidRequest])[0];
+
+ expect(bidRequest.data.pi).to.equal(2);
+ expect(vidBidRequest.data.pi).to.equal(7);
+ });
+ });
+
it('should return a defined sizes field for video', function () {
const request = { ...bidRequests[0], mediaTypes: vidMediaTypes, params: { 'videoPubID': 123 } };
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.sizes).to.equal(vidMediaTypes.video.playerSize);
});
it('should handle multiple sizes for inslot', function () {
- const request = Object.assign({}, bidRequests[0]);
- delete request.params;
- request.params = {
- 'inSlot': '123',
- 'sizes': [[0, 1], [0, 2]]
- };
+ const mediaTypes = { banner: { sizes: [[300, 250], [300, 600]] } }
+ const request = { ...bidRequests[0], mediaTypes };
const bidRequest = spec.buildRequests([request])[0];
- expect(bidRequest.data.bf).to.equal('0x1,0x2');
+ expect(bidRequest.data.bf).to.equal('300x250,300x600');
});
describe('floorModule', function () {
const floorTestData = {
@@ -163,9 +215,8 @@ describe('gumgumAdapter', function () {
return floorTestData;
};
it('should return the value from getFloor if present', function () {
- const request = { ...bidRequests[0] };
- const bidRequest = spec.buildRequests([request])[0];
- expect(bidRequest.data.fp).to.equal(floorTestData.floor);
+ const request = spec.buildRequests(bidRequests)[0];
+ expect(request.data.fp).to.equal(floorTestData.floor);
});
it('should return the getFloor.floor value if it is greater than bidfloor', function () {
const bidfloor = 0.80;
@@ -201,6 +252,25 @@ describe('gumgumAdapter', function () {
expect(bidRequest.data).to.include.any.keys('t');
expect(bidRequest.data).to.include.any.keys('fp');
});
+ it('should set iriscat parameter if iriscat param is found and is of type string', function () {
+ const iriscat = 'segment';
+ const request = { ...bidRequests[0] };
+ request.params = { ...request.params, iriscat };
+ const bidRequest = spec.buildRequests([request])[0];
+ expect(bidRequest.data.iriscat).to.equal(iriscat);
+ });
+ it('should not send iriscat parameter if iriscat param is not found', function () {
+ const request = { ...bidRequests[0] };
+ const bidRequest = spec.buildRequests([request])[0];
+ expect(bidRequest.data.iriscat).to.be.undefined;
+ });
+ it('should not send iriscat parameter if iriscat param is not of type string', function () {
+ const iriscat = 123;
+ const request = { ...bidRequests[0] };
+ request.params = { ...request.params, iriscat };
+ const bidRequest = spec.buildRequests([request])[0];
+ expect(bidRequest.data.iriscat).to.be.undefined;
+ });
it('should send pubId if inScreenPubID param is specified', function () {
const request = Object.assign({}, bidRequests[0]);
delete request.params;
diff --git a/test/spec/modules/id5IdSystem_spec.js b/test/spec/modules/id5IdSystem_spec.js
index 05ecec8dc36..ac000c1e6dd 100644
--- a/test/spec/modules/id5IdSystem_spec.js
+++ b/test/spec/modules/id5IdSystem_spec.js
@@ -50,7 +50,9 @@ describe('ID5 ID System', function() {
return {
name: ID5_MODULE_NAME,
value: {
- id5id: value
+ id5id: {
+ uid: value
+ }
}
}
}
@@ -93,10 +95,12 @@ describe('ID5 ID System', function() {
it('should fail if no partner is provided in the config', function() {
expect(id5IdSubmodule.getId()).to.be.eq(undefined);
+ expect(id5IdSubmodule.getId({ })).to.be.eq(undefined);
+ expect(id5IdSubmodule.getId({ params: { } })).to.be.eq(undefined);
});
it('should call the ID5 server with 1puid field for legacy storedObj format', function () {
- let submoduleCallback = id5IdSubmodule.getId(getId5FetchConfig().params, undefined, ID5_LEGACY_STORED_OBJ).callback;
+ let submoduleCallback = id5IdSubmodule.getId(getId5FetchConfig(), undefined, ID5_LEGACY_STORED_OBJ).callback;
submoduleCallback(callbackSpy);
let request = server.requests[0];
@@ -113,7 +117,7 @@ describe('ID5 ID System', function() {
});
it('should call the ID5 server with signature field for new storedObj format', function () {
- let submoduleCallback = id5IdSubmodule.getId(getId5FetchConfig().params, undefined, ID5_STORED_OBJ).callback;
+ let submoduleCallback = id5IdSubmodule.getId(getId5FetchConfig(), undefined, ID5_STORED_OBJ).callback;
submoduleCallback(callbackSpy);
let request = server.requests[0];
@@ -132,8 +136,8 @@ describe('ID5 ID System', function() {
it('should call the ID5 server with pd field when pd config is set', function () {
const pubData = 'b50ca08271795a8e7e4012813f23d505193d75c0f2e2bb99baa63aa822f66ed3';
- let config = getId5FetchConfig().params;
- config.pd = pubData;
+ let config = getId5FetchConfig();
+ config.params.pd = pubData;
let submoduleCallback = id5IdSubmodule.getId(config, undefined, ID5_STORED_OBJ).callback;
submoduleCallback(callbackSpy);
@@ -152,8 +156,8 @@ describe('ID5 ID System', function() {
});
it('should call the ID5 server with empty pd field when pd config is not set', function () {
- let config = getId5FetchConfig().params;
- config.pd = undefined;
+ let config = getId5FetchConfig();
+ config.params.pd = undefined;
let submoduleCallback = id5IdSubmodule.getId(config, undefined, ID5_STORED_OBJ).callback;
submoduleCallback(callbackSpy);
@@ -172,7 +176,7 @@ describe('ID5 ID System', function() {
it('should call the ID5 server with nb=1 when no stored value exists', function () {
coreStorage.setCookie(ID5_NB_COOKIE_NAME, '', ID5_EXPIRED_COOKIE_DATE);
- let submoduleCallback = id5IdSubmodule.getId(getId5FetchConfig().params, undefined, ID5_STORED_OBJ).callback;
+ let submoduleCallback = id5IdSubmodule.getId(getId5FetchConfig(), undefined, ID5_STORED_OBJ).callback;
submoduleCallback(callbackSpy);
let request = server.requests[0];
@@ -192,7 +196,7 @@ describe('ID5 ID System', function() {
let expStr = (new Date(Date.now() + 25000).toUTCString());
coreStorage.setCookie(ID5_NB_COOKIE_NAME, '1', expStr);
- let submoduleCallback = id5IdSubmodule.getId(getId5FetchConfig().params, undefined, ID5_STORED_OBJ).callback;
+ let submoduleCallback = id5IdSubmodule.getId(getId5FetchConfig(), undefined, ID5_STORED_OBJ).callback;
submoduleCallback(callbackSpy);
let request = server.requests[0];
@@ -238,10 +242,13 @@ describe('ID5 ID System', function() {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property(`userId.${ID5_EIDS_NAME}`);
- expect(bid.userId.id5id).to.equal(ID5_STORED_ID);
+ expect(bid.userId.id5id.uid).to.equal(ID5_STORED_ID);
expect(bid.userIdAsEids[0]).to.deep.equal({
source: ID5_SOURCE,
- uids: [{ id: ID5_STORED_ID, atype: 1 }]
+ uids: [{ id: ID5_STORED_ID, atype: 1 }],
+ ext: {
+ linkType: 0
+ }
});
});
});
@@ -258,7 +265,7 @@ describe('ID5 ID System', function() {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property(`userId.${ID5_EIDS_NAME}`);
- expect(bid.userId.id5id).to.equal(ID5_STORED_ID);
+ expect(bid.userId.id5id.uid).to.equal(ID5_STORED_ID);
expect(bid.userIdAsEids[0]).to.deep.equal({
source: ID5_SOURCE,
uids: [{ id: ID5_STORED_ID, atype: 1 }]
@@ -368,13 +375,13 @@ describe('ID5 ID System', function() {
});
describe('Decode stored object', function() {
- const decodedObject = { 'id5id': ID5_STORED_ID };
+ const expectedDecodedObject = { id5id: { uid: ID5_STORED_ID, ext: { linkType: 0 } } };
it('should properly decode from a stored object', function() {
- expect(id5IdSubmodule.decode(ID5_STORED_OBJ)).to.deep.equal(decodedObject);
+ expect(id5IdSubmodule.decode(ID5_STORED_OBJ)).to.deep.equal(expectedDecodedObject);
});
it('should properly decode from a legacy stored object', function() {
- expect(id5IdSubmodule.decode(ID5_LEGACY_STORED_OBJ)).to.deep.equal(decodedObject);
+ expect(id5IdSubmodule.decode(ID5_LEGACY_STORED_OBJ)).to.deep.equal(expectedDecodedObject);
});
it('should return undefined if passed a string', function() {
expect(id5IdSubmodule.decode('somestring')).to.eq(undefined);
diff --git a/test/spec/modules/identityLinkIdSystem_spec.js b/test/spec/modules/identityLinkIdSystem_spec.js
index 9f36ba92558..c729be4c1d6 100644
--- a/test/spec/modules/identityLinkIdSystem_spec.js
+++ b/test/spec/modules/identityLinkIdSystem_spec.js
@@ -3,7 +3,7 @@ import * as utils from 'src/utils.js';
import {server} from 'test/mocks/xhr.js';
const pid = '14';
-const defaultConfigParams = {pid: pid};
+const defaultConfigParams = { params: {pid: pid} };
const responseHeader = {'Content-Type': 'application/json'}
describe('IdentityLinkId tests', function () {
@@ -18,12 +18,12 @@ describe('IdentityLinkId tests', function () {
});
it('should log an error if no configParams were passed when getId', function () {
- identityLinkSubmodule.getId();
+ identityLinkSubmodule.getId({ params: {} });
expect(logErrorStub.calledOnce).to.be.true;
});
it('should log an error if pid configParam was not passed when getId', function () {
- identityLinkSubmodule.getId({});
+ identityLinkSubmodule.getId({ params: {} });
expect(logErrorStub.calledOnce).to.be.true;
});
diff --git a/test/spec/modules/idxIdSystem_spec.js b/test/spec/modules/idxIdSystem_spec.js
new file mode 100644
index 00000000000..14cd9a88d13
--- /dev/null
+++ b/test/spec/modules/idxIdSystem_spec.js
@@ -0,0 +1,117 @@
+import { expect } from 'chai';
+import find from 'core-js-pure/features/array/find.js';
+import { config } from 'src/config.js';
+import { init, requestBidsHook, setSubmoduleRegistry } from 'modules/userId/index.js';
+import { storage, idxIdSubmodule } from 'modules/idxIdSystem.js';
+
+const IDX_COOKIE_NAME = '_idx';
+const IDX_DUMMY_VALUE = 'idx value for testing';
+const IDX_COOKIE_STORED = '{ "idx": "' + IDX_DUMMY_VALUE + '" }';
+const ID_COOKIE_OBJECT = { id: IDX_DUMMY_VALUE };
+const IDX_COOKIE_OBJECT = { idx: IDX_DUMMY_VALUE };
+
+function getConfigMock() {
+ return {
+ userSync: {
+ syncDelay: 0,
+ userIds: [{
+ name: 'idx'
+ }]
+ }
+ }
+}
+
+function getAdUnitMock(code = 'adUnit-code') {
+ return {
+ code,
+ mediaTypes: {banner: {}, native: {}},
+ sizes: [
+ [300, 200],
+ [300, 600]
+ ],
+ bids: [{
+ bidder: 'sampleBidder',
+ params: { placementId: 'banner-only-bidder' }
+ }]
+ };
+}
+
+describe('IDx ID System', () => {
+ let getDataFromLocalStorageStub, localStorageIsEnabledStub;
+ let getCookieStub, cookiesAreEnabledStub;
+
+ beforeEach(() => {
+ getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage');
+ localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled');
+ getCookieStub = sinon.stub(storage, 'getCookie');
+ cookiesAreEnabledStub = sinon.stub(storage, 'cookiesAreEnabled');
+ });
+
+ afterEach(() => {
+ getDataFromLocalStorageStub.restore();
+ localStorageIsEnabledStub.restore();
+ getCookieStub.restore();
+ cookiesAreEnabledStub.restore();
+ });
+
+ describe('IDx: test "getId" method', () => {
+ it('provides the stored IDx if a cookie exists', () => {
+ getCookieStub.withArgs(IDX_COOKIE_NAME).returns(IDX_COOKIE_STORED);
+ let idx = idxIdSubmodule.getId();
+ expect(idx).to.deep.equal(ID_COOKIE_OBJECT);
+ });
+
+ it('provides the stored IDx if cookie is absent but present in local storage', () => {
+ getDataFromLocalStorageStub.withArgs(IDX_COOKIE_NAME).returns(IDX_COOKIE_STORED);
+ let idx = idxIdSubmodule.getId();
+ expect(idx).to.deep.equal(ID_COOKIE_OBJECT);
+ });
+
+ it('returns undefined if both cookie and local storage are empty', () => {
+ let idx = idxIdSubmodule.getId();
+ expect(idx).to.be.undefined;
+ })
+ });
+
+ describe('IDx: test "decode" method', () => {
+ it('provides the IDx from a stored object', () => {
+ expect(idxIdSubmodule.decode(ID_COOKIE_OBJECT)).to.deep.equal(IDX_COOKIE_OBJECT);
+ });
+
+ it('provides the IDx from a stored string', () => {
+ expect(idxIdSubmodule.decode(IDX_DUMMY_VALUE)).to.deep.equal(IDX_COOKIE_OBJECT);
+ });
+ });
+
+ describe('requestBids hook', () => {
+ let adUnits;
+
+ beforeEach(() => {
+ adUnits = [getAdUnitMock()];
+ setSubmoduleRegistry([idxIdSubmodule]);
+ init(config);
+ config.setConfig(getConfigMock());
+ getCookieStub.withArgs(IDX_COOKIE_NAME).returns(IDX_COOKIE_STORED);
+ });
+
+ it('when a stored IDx exists it is added to bids', (done) => {
+ requestBidsHook(() => {
+ adUnits.forEach(unit => {
+ unit.bids.forEach(bid => {
+ expect(bid).to.have.deep.nested.property('userId.idx');
+ expect(bid.userId.idx).to.equal(IDX_DUMMY_VALUE);
+ const idxIdAsEid = find(bid.userIdAsEids, e => e.source == 'idx.lat');
+ expect(idxIdAsEid).to.deep.equal({
+ source: 'idx.lat',
+ uids: [{
+ id: IDX_DUMMY_VALUE,
+ atype: 1,
+ }]
+ });
+ });
+ });
+ done();
+ }, { adUnits });
+ });
+ });
+});
diff --git a/test/spec/modules/inmarBidAdapter_spec.js b/test/spec/modules/inmarBidAdapter_spec.js
new file mode 100644
index 00000000000..86b7ab3a8af
--- /dev/null
+++ b/test/spec/modules/inmarBidAdapter_spec.js
@@ -0,0 +1,251 @@
+// import or require modules necessary for the test, e.g.:
+import {expect} from 'chai'; // may prefer 'assert' in place of 'expect'
+import {
+ spec
+} from 'modules/inmarBidAdapter.js';
+import {config} from 'src/config.js';
+
+describe('Inmar adapter tests', function () {
+ var DEFAULT_PARAMS_NEW_SIZES = [{
+ adUnitCode: 'test-div',
+ bidId: '2c7c8e9c900244',
+ mediaTypes: {
+ banner: {
+ sizes: [
+ [300, 250], [300, 600], [728, 90], [970, 250]]
+ }
+ },
+ bidder: 'inmar',
+ params: {
+ adnetId: 'ADb1f40rmi',
+ partnerId: 12345
+ },
+ auctionId: '0cb3144c-d084-4686-b0d6-f5dbe917c563',
+ bidRequestsCount: 1,
+ bidderRequestId: '1858b7382993ca',
+ transactionId: '29df2112-348b-4961-8863-1b33684d95e6',
+ user: {}
+ }];
+
+ var DEFAULT_PARAMS_VIDEO = [{
+ adUnitCode: 'test-div',
+ bidId: '2c7c8e9c900244',
+ mediaTypes: {
+ video: {
+ context: 'instream', // or 'outstream'
+ playerSize: [640, 480],
+ mimes: ['video/mp4']
+ }
+ },
+ bidder: 'inmar',
+ params: {
+ adnetId: 'ADb1f40rmi',
+ partnerId: 12345
+ },
+ auctionId: '0cb3144c-d084-4686-b0d6-f5dbe917c563',
+ bidRequestsCount: 1,
+ bidderRequestId: '1858b7382993ca',
+ transactionId: '29df2112-348b-4961-8863-1b33684d95e6',
+ user: {}
+ }];
+
+ var DEFAULT_PARAMS_WO_OPTIONAL = [{
+ adUnitCode: 'test-div',
+ bidId: '2c7c8e9c900244',
+ sizes: [
+ [300, 250],
+ [300, 600],
+ [728, 90],
+ [970, 250]
+ ],
+ bidder: 'inmar',
+ params: {
+ adnetId: 'ADb1f40rmi',
+ partnerId: 12345,
+ },
+ auctionId: '851adee7-d843-48f9-a7e9-9ff00573fcbf',
+ bidRequestsCount: 1,
+ bidderRequestId: '1858b7382993ca',
+ transactionId: '29df2112-348b-4961-8863-1b33684d95e6'
+ }];
+
+ var BID_RESPONSE = {
+ body: {
+ cpm: 1.50,
+ ad: '',
+ meta: {
+ mediaType: 'banner',
+ },
+ width: 300,
+ height: 250,
+ creativeId: '189198063',
+ netRevenue: true,
+ currency: 'USD',
+ ttl: 300,
+ dealId: 'dealId'
+
+ }
+ };
+
+ var BID_RESPONSE_VIDEO = {
+ body: {
+ cpm: 1.50,
+ meta: {
+ mediaType: 'video',
+ },
+ width: 1,
+ height: 1,
+ creativeId: '189198063',
+ netRevenue: true,
+ currency: 'USD',
+ ttl: 300,
+ vastUrl: 'https://vast.com/vast.xml',
+ dealId: 'dealId'
+ }
+ };
+
+ it('Verify build request to prebid 3.0 display test', function() {
+ const request = spec.buildRequests(DEFAULT_PARAMS_NEW_SIZES, {
+ gdprConsent: {
+ consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA',
+ gdprApplies: true
+ },
+ refererInfo: {
+ referer: 'https://domain.com',
+ numIframes: 0
+ }
+ });
+
+ expect(request).to.have.property('method').and.to.equal('POST');
+ const requestContent = JSON.parse(request.data);
+ expect(requestContent.bidRequests[0].params).to.have.property('adnetId').and.to.equal('ADb1f40rmi');
+ expect(requestContent.bidRequests[0].params).to.have.property('partnerId').and.to.equal(12345);
+ expect(requestContent.bidRequests[0]).to.have.property('auctionId').and.to.equal('0cb3144c-d084-4686-b0d6-f5dbe917c563');
+ expect(requestContent.bidRequests[0]).to.have.property('bidId').and.to.equal('2c7c8e9c900244');
+ expect(requestContent.bidRequests[0]).to.have.property('bidRequestsCount').and.to.equal(1);
+ expect(requestContent.bidRequests[0]).to.have.property('bidder').and.to.equal('inmar');
+ expect(requestContent.bidRequests[0]).to.have.property('bidderRequestId').and.to.equal('1858b7382993ca');
+ expect(requestContent.bidRequests[0]).to.have.property('adUnitCode').and.to.equal('test-div');
+ expect(requestContent.refererInfo).to.have.property('referer').and.to.equal('https://domain.com');
+ expect(requestContent.bidRequests[0].mediaTypes.banner).to.have.property('sizes');
+ expect(requestContent.bidRequests[0].mediaTypes.banner.sizes[0]).to.have.ordered.members([300, 250]);
+ expect(requestContent.bidRequests[0].mediaTypes.banner.sizes[1]).to.have.ordered.members([300, 600]);
+ expect(requestContent.bidRequests[0].mediaTypes.banner.sizes[2]).to.have.ordered.members([728, 90]);
+ expect(requestContent.bidRequests[0].mediaTypes.banner.sizes[3]).to.have.ordered.members([970, 250]);
+ expect(requestContent.bidRequests[0]).to.have.property('transactionId').and.to.equal('29df2112-348b-4961-8863-1b33684d95e6');
+ expect(requestContent.refererInfo).to.have.property('numIframes').and.to.equal(0);
+ })
+
+ it('Verify interprete response', function () {
+ const request = spec.buildRequests(DEFAULT_PARAMS_NEW_SIZES, {
+ gdprConsent: {
+ consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA',
+ gdprApplies: true
+ },
+ refererInfo: {
+ referer: 'https://domain.com',
+ numIframes: 0
+ }
+ });
+
+ const bids = spec.interpretResponse(BID_RESPONSE, request);
+ expect(bids).to.have.lengthOf(1);
+ const bid = bids[0];
+ expect(bid.cpm).to.equal(1.50);
+ expect(bid.ad).to.equal('');
+ expect(bid.meta.mediaType).to.equal('banner');
+ expect(bid.width).to.equal(300);
+ expect(bid.height).to.equal(250);
+ expect(bid.creativeId).to.equal('189198063');
+ expect(bid.netRevenue).to.equal(true);
+ expect(bid.currency).to.equal('USD');
+ expect(bid.ttl).to.equal(300);
+ expect(bid.dealId).to.equal('dealId');
+ });
+
+ it('no banner media response', function () {
+ const request = spec.buildRequests(DEFAULT_PARAMS_NEW_SIZES, {
+ gdprConsent: {
+ consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA',
+ gdprApplies: true
+ },
+ refererInfo: {
+ referer: 'https://domain.com',
+ numIframes: 0
+ }
+ });
+
+ const bids = spec.interpretResponse(BID_RESPONSE_VIDEO, request);
+ const bid = bids[0];
+ expect(bid.vastUrl).to.equal('https://vast.com/vast.xml');
+ });
+
+ it('Verifies bidder_code', function () {
+ expect(spec.code).to.equal('inmar');
+ });
+
+ it('Verifies bidder aliases', function () {
+ expect(spec.aliases).to.have.lengthOf(1);
+ expect(spec.aliases[0]).to.equal('inm');
+ });
+
+ it('Verifies if bid request is valid', function () {
+ expect(spec.isBidRequestValid(DEFAULT_PARAMS_NEW_SIZES[0])).to.equal(true);
+ expect(spec.isBidRequestValid(DEFAULT_PARAMS_WO_OPTIONAL[0])).to.equal(true);
+ expect(spec.isBidRequestValid({})).to.equal(false);
+ expect(spec.isBidRequestValid({
+ params: {}
+ })).to.equal(false);
+ expect(spec.isBidRequestValid({
+ params: {
+ adnetId: 'ADb1f40rmi'
+ }
+ })).to.equal(false);
+ expect(spec.isBidRequestValid({
+ params: {
+ partnerId: 12345
+ }
+ })).to.equal(false);
+ expect(spec.isBidRequestValid({
+ params: {
+ adnetId: 'ADb1f40rmi',
+ partnerId: 12345
+ }
+ })).to.equal(true);
+ });
+
+ it('Verifies user syncs image', function () {
+ var syncs = spec.getUserSyncs({
+ iframeEnabled: false,
+ pixelEnabled: true
+ }, [BID_RESPONSE], {
+ consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA',
+ referer: 'http://domain.com',
+ gdprApplies: true
+ })
+ expect(syncs).to.have.lengthOf(1);
+ expect(syncs[0].type).to.equal('image');
+
+ syncs = spec.getUserSyncs({
+ iframeEnabled: false,
+ pixelEnabled: true
+ }, [BID_RESPONSE], {
+ consentString: '',
+ referer: 'http://domain.com',
+ gdprApplies: true
+ })
+ expect(syncs).to.have.lengthOf(1);
+ expect(syncs[0].type).to.equal('image');
+
+ syncs = spec.getUserSyncs({
+ iframeEnabled: false,
+ pixelEnabled: true
+ }, [], {
+ consentString: null,
+ referer: 'http://domain.com',
+ gdprApplies: true
+ })
+ expect(syncs).to.have.lengthOf(1);
+ expect(syncs[0].type).to.equal('image');
+ });
+});
diff --git a/test/spec/modules/instreamTracking_spec.js b/test/spec/modules/instreamTracking_spec.js
new file mode 100644
index 00000000000..8c49da76ab6
--- /dev/null
+++ b/test/spec/modules/instreamTracking_spec.js
@@ -0,0 +1,221 @@
+import { assert } from 'chai';
+import { trackInstreamDeliveredImpressions } from 'modules/instreamTracking.js';
+import { config } from 'src/config.js';
+import * as events from 'src/events.js';
+import * as utils from 'src/utils.js';
+import * as sinon from 'sinon';
+import { INSTREAM, OUTSTREAM } from 'src/video.js';
+
+const BIDDER_CODE = 'sampleBidder';
+const VIDEO_CACHE_KEY = '4cf395af-8fee-4960-af0e-88d44e399f14';
+
+let sandbox;
+
+function enableInstreamTracking(regex) {
+ let configStub = sandbox.stub(config, 'getConfig');
+ configStub.withArgs('instreamTracking').returns(Object.assign(
+ {
+ enabled: true,
+ maxWindow: 10,
+ pollingFreq: 0
+ },
+ regex && {urlPattern: regex},
+ ));
+}
+
+function mockPerformanceApi({adServerCallSent, videoPresent}) {
+ let performanceStub = sandbox.stub(window.performance, 'getEntriesByType');
+ let entries = [{
+ name: 'https://domain.com/img.png',
+ initiatorType: 'img'
+ }, {
+ name: 'https://domain.com/script.js',
+ initiatorType: 'script'
+ }, {
+ name: 'https://domain.com/xhr',
+ initiatorType: 'xmlhttprequest'
+ }, {
+ name: 'https://domain.com/fetch',
+ initiatorType: 'fetch'
+ }];
+
+ if (adServerCallSent || videoPresent) {
+ entries.push({
+ name: 'https://adserver.com/ads?custom_params=hb_uuid%3D' + VIDEO_CACHE_KEY + '%26pos%3D' + VIDEO_CACHE_KEY,
+ initiatorType: 'xmlhttprequest'
+ });
+ }
+
+ if (videoPresent) {
+ entries.push({
+ name: 'https://prebid-vast-cache.com/cache?key=' + VIDEO_CACHE_KEY,
+ initiatorType: 'xmlhttprequest'
+ });
+ }
+
+ performanceStub.withArgs('resource').returns(entries);
+}
+
+function mockBidResponse(adUnit, requestId) {
+ const bid = {
+ 'adUnitCod': adUnit.code,
+ 'bidderCode': adUnit.bids[0].bidder,
+ 'width': adUnit.sizes[0][0],
+ 'height': adUnit.sizes[0][1],
+ 'statusMessage': 'Bid available',
+ 'adId': 'id',
+ 'requestId': requestId,
+ 'source': 'client',
+ 'no_bid': false,
+ 'cpm': '1.1495',
+ 'ttl': 180,
+ 'creativeId': 'id',
+ 'netRevenue': true,
+ 'currency': 'USD',
+ }
+ if (adUnit.mediaTypes.video) {
+ bid.videoCacheKey = VIDEO_CACHE_KEY;
+ }
+ return bid
+}
+
+function mockBidRequest(adUnit, bidResponse) {
+ return {
+ 'bidderCode': bidResponse.bidderCode,
+ 'auctionId': '20882439e3238c',
+ 'bidderRequestId': 'bidderRequestId',
+ 'bids': [
+ {
+ 'adUnitCode': adUnit.code,
+ 'mediaTypes': adUnit.mediaTypes,
+ 'bidder': bidResponse.bidderCode,
+ 'bidId': bidResponse.requestId,
+ 'sizes': adUnit.sizes,
+ 'params': adUnit.bids[0].params,
+ 'bidderRequestId': 'bidderRequestId',
+ 'auctionId': '20882439e3238c',
+ }
+ ],
+ 'auctionStart': 1505250713622,
+ 'timeout': 3000
+ };
+}
+
+function getMockInput(mediaType) {
+ const bannerAdUnit = {
+ code: 'banner',
+ mediaTypes: {banner: {sizes: [[300, 250]]}},
+ sizes: [[300, 250]],
+ bids: [{bidder: BIDDER_CODE, params: {placementId: 'id'}}]
+ };
+ const outStreamAdUnit = {
+ code: 'video-' + OUTSTREAM,
+ mediaTypes: {video: {playerSize: [640, 480], context: OUTSTREAM}},
+ sizes: [[640, 480]],
+ bids: [{bidder: BIDDER_CODE, params: {placementId: 'id'}}]
+ };
+ const inStreamAdUnit = {
+ code: 'video-' + INSTREAM,
+ mediaTypes: {video: {playerSize: [640, 480], context: INSTREAM}},
+ sizes: [[640, 480]],
+ bids: [{bidder: BIDDER_CODE, params: {placementId: 'id'}}]
+ };
+
+ let adUnit;
+ switch (mediaType) {
+ default:
+ case 'banner':
+ adUnit = bannerAdUnit;
+ break;
+ case OUTSTREAM:
+ adUnit = outStreamAdUnit;
+ break;
+ case INSTREAM:
+ adUnit = inStreamAdUnit;
+ break;
+ }
+
+ const bidResponse = mockBidResponse(adUnit, utils.getUniqueIdentifierStr());
+ const bidderRequest = mockBidRequest(adUnit, bidResponse);
+ return {
+ adUnits: [adUnit],
+ bidsReceived: [bidResponse],
+ bidderRequests: [bidderRequest],
+ };
+}
+
+describe('Instream Tracking', function () {
+ beforeEach(function () {
+ sandbox = sinon.sandbox.create();
+ });
+
+ afterEach(function () {
+ sandbox.restore();
+ });
+
+ describe('gaurd checks', function () {
+ it('skip if tracking not enable', function () {
+ sandbox.stub(config, 'getConfig').withArgs('instreamTracking').returns(undefined);
+ assert.isNotOk(trackInstreamDeliveredImpressions({
+ adUnits: [],
+ bidsReceived: [],
+ bidderRequests: []
+ }), 'should not start tracking when tracking is disabled');
+ });
+
+ it('run only if instream bids are present', function () {
+ enableInstreamTracking();
+ assert.isNotOk(trackInstreamDeliveredImpressions({adUnits: [], bidsReceived: [], bidderRequests: []}));
+ });
+
+ it('checks for instream bids', function (done) {
+ enableInstreamTracking();
+ assert.isNotOk(trackInstreamDeliveredImpressions(getMockInput('banner')), 'should not start tracking when banner bids are present')
+ assert.isNotOk(trackInstreamDeliveredImpressions(getMockInput(OUTSTREAM)), 'should not start tracking when outstream bids are present')
+ mockPerformanceApi({});
+ assert.isOk(trackInstreamDeliveredImpressions(getMockInput(INSTREAM)), 'should start tracking when instream bids are present')
+ setTimeout(done, 10);
+ });
+ });
+
+ describe('instream bids check', function () {
+ let spyEventsOn;
+
+ beforeEach(function () {
+ spyEventsOn = sandbox.spy(events, 'emit');
+ });
+
+ it('BID WON event is not emitted when no video cache key entries are present', function (done) {
+ enableInstreamTracking();
+ trackInstreamDeliveredImpressions(getMockInput(INSTREAM));
+ mockPerformanceApi({});
+ setTimeout(function () {
+ assert.isNotOk(spyEventsOn.calledWith('bidWon'))
+ done()
+ }, 10);
+ });
+
+ it('BID WON event is not emitted when ad server call is sent', function (done) {
+ enableInstreamTracking();
+ mockPerformanceApi({adServerCallSent: true});
+ setTimeout(function () {
+ assert.isNotOk(spyEventsOn.calledWith('bidWon'))
+ done()
+ }, 10);
+ });
+
+ it('BID WON event is emitted when video cache key is present', function (done) {
+ enableInstreamTracking(/cache/);
+ const bidWonSpy = sandbox.spy();
+ events.on('bidWon', bidWonSpy);
+ mockPerformanceApi({adServerCallSent: true, videoPresent: true});
+
+ trackInstreamDeliveredImpressions(getMockInput(INSTREAM));
+ setTimeout(function () {
+ assert.isOk(spyEventsOn.calledWith('bidWon'))
+ assert(bidWonSpy.args[0][0].videoCacheKey, VIDEO_CACHE_KEY, 'Video cache key in bid won should be equal to video cache call');
+ done()
+ }, 10);
+ });
+ });
+});
diff --git a/test/spec/modules/intentIqIdSystem_spec.js b/test/spec/modules/intentIqIdSystem_spec.js
new file mode 100644
index 00000000000..4b45342cb6f
--- /dev/null
+++ b/test/spec/modules/intentIqIdSystem_spec.js
@@ -0,0 +1,151 @@
+import { expect } from 'chai';
+import {intentIqIdSubmodule} from 'modules/intentIqIdSystem.js';
+import * as utils from 'src/utils.js';
+import {server} from 'test/mocks/xhr.js';
+
+const partner = 10;
+const pai = '11';
+const pcid = '12';
+const defaultConfigParams = { params: {partner: partner} };
+const paiConfigParams = { params: {partner: partner, pai: pai} };
+const pcidConfigParams = { params: {partner: partner, pcid: pcid} };
+const allConfigParams = { params: {partner: partner, pai: pai, pcid: pcid} };
+const responseHeader = {'Content-Type': 'application/json'}
+
+describe('IntentIQ tests', function () {
+ let logErrorStub;
+
+ beforeEach(function () {
+ logErrorStub = sinon.stub(utils, 'logError');
+ });
+
+ afterEach(function () {
+ logErrorStub.restore();
+ });
+
+ it('should log an error if no configParams were passed when getId', function () {
+ let submodule = intentIqIdSubmodule.getId({ params: {} });
+ expect(logErrorStub.calledOnce).to.be.true;
+ expect(submodule).to.be.undefined;
+ });
+
+ it('should log an error if partner configParam was not passed when getId', function () {
+ let submodule = intentIqIdSubmodule.getId({ params: {} });
+ expect(logErrorStub.calledOnce).to.be.true;
+ expect(submodule).to.be.undefined;
+ });
+
+ it('should log an error if partner configParam was not a numeric value', function () {
+ let submodule = intentIqIdSubmodule.getId({ params: {partner: '10'} });
+ expect(logErrorStub.calledOnce).to.be.true;
+ expect(submodule).to.be.undefined;
+ });
+
+ it('should call the IntentIQ endpoint with only partner', function () {
+ let callBackSpy = sinon.spy();
+ let submoduleCallback = intentIqIdSubmodule.getId(defaultConfigParams).callback;
+ submoduleCallback(callBackSpy);
+ let request = server.requests[0];
+ expect(request.url).to.be.eq('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1');
+ request.respond(
+ 200,
+ responseHeader,
+ JSON.stringify({})
+ );
+ expect(callBackSpy.calledOnce).to.be.true;
+ });
+
+ it('should ignore NA and invalid responses', function () {
+ let resp = JSON.stringify({'RESULT': 'NA'});
+ expect(intentIqIdSubmodule.decode(resp)).to.equal(undefined);
+ expect(intentIqIdSubmodule.decode('NA')).to.equal(undefined);
+ expect(intentIqIdSubmodule.decode('')).to.equal(undefined);
+ expect(intentIqIdSubmodule.decode(undefined)).to.equal(undefined);
+ });
+
+ it('should call the IntentIQ endpoint with only partner, pai', function () {
+ let callBackSpy = sinon.spy();
+ let submoduleCallback = intentIqIdSubmodule.getId(paiConfigParams).callback;
+ submoduleCallback(callBackSpy);
+ let request = server.requests[0];
+ expect(request.url).to.be.eq('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&pai=11');
+ request.respond(
+ 200,
+ responseHeader,
+ JSON.stringify({})
+ );
+ expect(callBackSpy.calledOnce).to.be.true;
+ });
+
+ it('should call the IntentIQ endpoint with only partner, pcid', function () {
+ let callBackSpy = sinon.spy();
+ let submoduleCallback = intentIqIdSubmodule.getId(pcidConfigParams).callback;
+ submoduleCallback(callBackSpy);
+ let request = server.requests[0];
+ expect(request.url).to.be.eq('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&pcid=12');
+ request.respond(
+ 200,
+ responseHeader,
+ JSON.stringify({})
+ );
+ expect(callBackSpy.calledOnce).to.be.true;
+ });
+
+ it('should call the IntentIQ endpoint with partner, pcid, pai', function () {
+ let callBackSpy = sinon.spy();
+ let submoduleCallback = intentIqIdSubmodule.getId(allConfigParams).callback;
+ submoduleCallback(callBackSpy);
+ let request = server.requests[0];
+ expect(request.url).to.be.eq('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&pcid=12&pai=11');
+ request.respond(
+ 200,
+ responseHeader,
+ JSON.stringify({})
+ );
+ expect(callBackSpy.calledOnce).to.be.true;
+ });
+
+ it('should not throw Uncaught TypeError when IntentIQ endpoint returns empty response', function () {
+ let callBackSpy = sinon.spy();
+ let submoduleCallback = intentIqIdSubmodule.getId(defaultConfigParams).callback;
+ submoduleCallback(callBackSpy);
+ let request = server.requests[0];
+ expect(request.url).to.be.eq('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1');
+ request.respond(
+ 204,
+ responseHeader,
+ ''
+ );
+ expect(callBackSpy.calledOnce).to.be.true;
+ expect(request.response).to.equal('');
+ expect(logErrorStub.calledOnce).to.not.be.true;
+ });
+
+ it('should log an error and continue to callback if ajax request errors', function () {
+ let callBackSpy = sinon.spy();
+ let submoduleCallback = intentIqIdSubmodule.getId(defaultConfigParams).callback;
+ submoduleCallback(callBackSpy);
+ let request = server.requests[0];
+ expect(request.url).to.be.eq('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1');
+ request.respond(
+ 503,
+ responseHeader,
+ 'Unavailable'
+ );
+ expect(callBackSpy.calledOnce).to.be.true;
+ });
+
+ it('should log an error and continue to callback if ajax request errors', function () {
+ let callBackSpy = sinon.spy();
+ let submoduleCallback = intentIqIdSubmodule.getId(defaultConfigParams).callback;
+ submoduleCallback(callBackSpy);
+ let request = server.requests[0];
+ expect(request.url).to.be.eq('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1');
+ request.respond(
+ 503,
+ responseHeader,
+ 'Unavailable'
+ );
+ expect(callBackSpy.calledOnce).to.be.true;
+ });
+});
diff --git a/test/spec/modules/ironsourceBidAdapter_spec.js b/test/spec/modules/ironsourceBidAdapter_spec.js
index cfdc51e0235..0c59dfef14b 100644
--- a/test/spec/modules/ironsourceBidAdapter_spec.js
+++ b/test/spec/modules/ironsourceBidAdapter_spec.js
@@ -5,6 +5,7 @@ import { config } from 'src/config.js';
import { VIDEO } from '../../../src/mediaTypes.js';
const ENDPOINT = 'https://hb.yellowblue.io/hb';
+const TEST_ENDPOINT = 'https://hb.yellowblue.io/hb-test';
const TTL = 360;
describe('ironsourceAdapter', function () {
@@ -55,6 +56,21 @@ describe('ironsourceAdapter', function () {
}
];
+ const testModeBidRequests = [
+ {
+ 'bidder': spec.code,
+ 'adUnitCode': 'adunit-code',
+ 'sizes': [[640, 480]],
+ 'params': {
+ 'isOrg': 'jdye8weeyirk00000001',
+ 'testMode': true
+ },
+ 'bidId': '299ffc8cca0b87',
+ 'bidderRequestId': '1144f487e563f9',
+ 'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d',
+ }
+ ];
+
const bidderRequest = {
bidderCode: 'ironsource',
}
@@ -67,6 +83,14 @@ describe('ironsourceAdapter', function () {
}
});
+ it('sends bid request to test ENDPOINT via GET', function () {
+ const requests = spec.buildRequests(testModeBidRequests, bidderRequest);
+ for (const request of requests) {
+ expect(request.url).to.equal(TEST_ENDPOINT);
+ expect(request.method).to.equal('GET');
+ }
+ });
+
it('should send the correct bid Id', function () {
const requests = spec.buildRequests(bidRequests, bidderRequest);
for (const request of requests) {
diff --git a/test/spec/modules/jixieBidAdapter_spec.js b/test/spec/modules/jixieBidAdapter_spec.js
new file mode 100644
index 00000000000..842f9e0ed30
--- /dev/null
+++ b/test/spec/modules/jixieBidAdapter_spec.js
@@ -0,0 +1,597 @@
+import { expect } from 'chai';
+import { spec, internal as jixieaux, storage } from 'modules/jixieBidAdapter.js';
+import { newBidder } from 'src/adapters/bidderFactory.js';
+import { config } from 'src/config.js';
+
+describe('jixie Adapter', function () {
+ const pageurl_ = 'https://testdomain.com/testpage.html';
+ const domain_ = 'https://testdomain.com';
+ const device_ = 'desktop';
+ const timeout_ = 1000;
+ const currency_ = 'USD';
+
+ /**
+ * Basic
+ */
+ const adapter = newBidder(spec);
+ describe('inherited functions', function () {
+ it('exists and is a function', function () {
+ expect(adapter.callBids).to.exist.and.to.be.a('function');
+ });
+ });
+
+ /**
+ * isBidRequestValid
+ */
+ describe('isBidRequestValid', function () {
+ let bid = {
+ 'bidder': 'jixie',
+ 'params': {
+ 'unit': 'prebidsampleunit'
+ },
+ 'adUnitCode': 'adunit-code',
+ 'sizes': [[300, 250], [300, 600]],
+ 'bidId': '30b31c1838de1e',
+ 'bidderRequestId': '22edbae2733bf6',
+ 'auctionId': '1d1a030790a475',
+ };
+
+ it('should return true when required params found', function () {
+ expect(spec.isBidRequestValid(bid)).to.equal(true);
+ });
+
+ it('should return false when required params obj does not exist', function () {
+ let bid0 = Object.assign({}, bid);
+ delete bid0.params;
+ expect(spec.isBidRequestValid(bid0)).to.equal(false);
+ });
+
+ it('should return false when params obj does not contain unit property', function () {
+ let bid1 = Object.assign({}, bid);
+ bid1.params = { rubbish: '' };
+ expect(spec.isBidRequestValid(bid1)).to.equal(false);
+ });
+ });// describe
+
+ /**
+ * buildRequests
+ */
+ describe('buildRequests', function () {
+ const adUnitCode0_ = 'adunit-code-0';
+ const adUnitCode1_ = 'adunit-code-1';
+ const adUnitCode2_ = 'adunit-code-2';
+
+ const bidId0_ = '22a9eb5004cf082';
+ const bidId1_ = '230fceb12fd754f';
+ const bidId2_ = '24dbe5c4fb80ed8';
+
+ const bidderRequestId_ = '2131ce076eeaa1b';
+ const auctionId_ = '26d68819-d6ce-4a2c-a4d3-f1a97b159d66';
+
+ const clientIdTest1_ = '1aba6a40-f711-11e9-868c-53a2ae972xxx';
+ const sessionIdTest1_ = '1594782644-1aba6a40-f711-11e9-868c-53a2ae972xxx';
+
+ // to serve as the object that prebid will call jixie buildRequest with: (param2)
+ const bidderRequest_ = {
+ refererInfo: {referer: pageurl_},
+ auctionId: auctionId_,
+ timeout: timeout_
+ };
+ // to serve as the object that prebid will call jixie buildRequest with: (param1)
+ let bidRequests_ = [
+ {
+ 'bidder': 'jixie',
+ 'params': {
+ 'unit': 'prebidsampleunit'
+ },
+ 'sizes': [[300, 250], [300, 600]],
+ 'adUnitCode': adUnitCode0_,
+ 'bidId': bidId0_,
+ 'bidderRequestId': bidderRequestId_,
+ 'auctionId': auctionId_
+ },
+ {
+ 'bidder': 'jixie',
+ 'params': {
+ 'unit': 'prebidsampleunit'
+ },
+ 'sizes': [[300, 250]],
+ 'mediaTypes': {
+ 'video': {
+ 'playerSize': [640, 360]
+ },
+ 'banner': {
+ 'sizes': [[300, 250]]
+ }
+ },
+ 'adUnitCode': adUnitCode1_,
+ 'bidId': bidId1_,
+ 'bidderRequestId': bidderRequestId_,
+ 'auctionId': auctionId_
+ },
+ {
+ 'bidder': 'jixie',
+ 'params': {
+ 'unit': 'prebidsampleunit'
+ },
+ 'sizes': [[300, 250], [300, 600]],
+ 'mediaTypes': {
+ 'video': {
+ 'playerSize': [640, 360]
+ },
+ 'banner': {
+ 'sizes': [[300, 250], [300, 600]]
+ }
+ },
+ 'adUnitCode': adUnitCode2_,
+ 'bidId': bidId2_,
+ 'bidderRequestId': bidderRequestId_,
+ 'auctionId': auctionId_
+ }
+ ];
+
+ // To serve as a reference to check against the bids array portion of the blob that the call to
+ // buildRequest returns
+ const refBids_ = [
+ {
+ 'bidId': bidId0_,
+ 'adUnitCode': adUnitCode0_,
+ 'sizes': [[300, 250], [300, 600]],
+ 'params': {
+ 'unit': 'prebidsampleunit'
+ }
+ },
+ {
+ 'bidId': bidId1_,
+ 'adUnitCode': adUnitCode1_,
+ 'mediaTypes': {
+ 'video': {
+ 'playerSize': [640, 360]
+ },
+ 'banner': {
+ 'sizes': [[300, 250]]
+ }
+ },
+ 'sizes': [[300, 250]],
+ 'params': {
+ 'unit': 'prebidsampleunit'
+ }
+ },
+ {
+ 'bidId': bidId2_,
+ 'adUnitCode': adUnitCode2_,
+ 'mediaTypes': {
+ 'video': {
+ 'playerSize': [640, 360]
+ },
+ 'banner': {
+ 'sizes': [[300, 250], [300, 600]]
+ }
+ },
+ 'sizes': [[300, 250], [300, 600]],
+ 'params': {
+ 'unit': 'prebidsampleunit'
+ }
+ }
+ ];
+
+ 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)
+ // The next next below we check
+ const request = spec.buildRequests(bidRequests_, bidderRequest_);
+ it('sends bid request to ENDPOINT via POST', function () {
+ expect(request.method).to.equal('POST')
+ })
+ 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_);
+ });// it
+
+ it('should attach valid params to the adserver endpoint (2)', function () {
+ // similar to above test case but here we force some clientid sessionid values
+ // and domain, pageurl
+ // get the interceptors ready:
+ let getCookieStub = sinon.stub(storage, 'getCookie');
+ let getLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage');
+ getCookieStub
+ .withArgs('_jx')
+ .returns(clientIdTest1_);
+ getCookieStub
+ .withArgs('_jxs')
+ .returns(sessionIdTest1_);
+ getLocalStorageStub
+ .withArgs('_jx')
+ .returns(clientIdTest1_);
+ getLocalStorageStub
+ .withArgs('_jxs')
+ .returns(sessionIdTest1_
+ );
+ let miscDimsStub = sinon.stub(jixieaux, 'getMiscDims');
+ miscDimsStub
+ .returns({ device: device_, pageurl: pageurl_, domain: domain_ });
+
+ // actual api call:
+ const request = spec.buildRequests(bidRequests_, bidderRequest_);
+ it('sends bid request to ENDPOINT via POST', function () {
+ expect(request.method).to.equal('POST')
+ })
+ 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_);
+ expect(payload).to.have.property('session_id_ls', sessionIdTest1_);
+ expect(payload).to.have.property('device', device_);
+ expect(payload).to.have.property('domain', domain_);
+ expect(payload).to.have.property('pageurl', pageurl_);
+ expect(payload).to.have.property('timeout', timeout_);
+ expect(payload).to.have.property('currency', currency_);
+ expect(payload).to.have.property('bids').that.deep.equals(refBids_);
+
+ // unwire interceptors
+ getCookieStub.restore();
+ getLocalStorageStub.restore();
+ miscDimsStub.restore();
+ });// it
+ });// describe
+
+ /**
+ * interpretResponse:
+ */
+ const JX_OTHER_OUTSTREAM_RENDERER_URL = 'https://scripts.jixie.io/dummyscript.js';
+ const JX_OUTSTREAM_RENDERER_URL = 'https://scripts.jixie.io/jxhboutstream.js';
+
+ const mockVastXml_ = `JXADSERVERAlway%20Live%20Prebid%20CreativeHybrid in-stream00:00:10`;
+ const responseBody_ = {
+ 'bids': [
+ // video (vast tag url) returned here
+ {
+ 'trackingUrlBase': 'https://tr.jixie.io/sync/ad?',
+ 'jxBidId': '62847e4c696edcb-028d5dee-2c83-44e3-bed1-b75002475cdf',
+ 'requestId': '62847e4c696edcb',
+ 'cpm': 2.19,
+ 'width': 640,
+ 'height': 360,
+ 'ttl': 300,
+ 'adUnitCode': 'demoslot3-div',
+ 'netRevenue': true,
+ 'currency': 'USD',
+ 'creativeId': 'jixie522',
+ 'meta': {
+ 'networkId': 123,
+ 'networkName': 'network123',
+ 'agencyId': 123,
+ 'agencyName': 'agency123',
+ 'advertiserId': 123,
+ 'advertiserName': 'advertiser123',
+ 'brandId': 123,
+ 'brandName': 'brand123',
+ 'primaryCatId': 1,
+ 'secondaryCatIds': [
+ 2,
+ 3,
+ 4
+ ],
+ 'mediaType': 'VIDEO'
+ },
+ 'vastUrl': 'https://ad.jixie.io/v1/video?creativeid=522'
+ },
+ // display ad returned here:
+ {
+ 'trackingUrlBase': 'https://tr.jixie.io/sync/ad?',
+ 'jxBidId': '600c9ae6fda1acb-028d5dee-2c83-44e3-bed1-b75002475cdf',
+ 'requestId': '600c9ae6fda1acb',
+ 'cpm': 1.999,
+ 'width': 300,
+ 'height': 250,
+ 'ttl': 300,
+ 'adUnitCode': 'demoslot1-div',
+ 'netRevenue': true,
+ 'currency': 'USD',
+ 'creativeId': 'jixie520',
+ 'meta': {
+ 'networkId': 123,
+ 'networkName': 'network123',
+ 'agencyId': 123,
+ 'agencyName': 'agency123',
+ 'advertiserId': 123,
+ 'advertiserName': 'advertiser123',
+ 'advertiserDomains': [
+ 'advdom1',
+ 'advdom2',
+ 'advdom3'
+ ],
+ 'brandId': 123,
+ 'brandName': 'brand123',
+ 'primaryCatId': 1,
+ 'secondaryCatIds': [
+ 2,
+ 3,
+ 4
+ ],
+ 'mediaType': 'BANNER'
+ },
+ 'ad': '
'
+ },
+ // outstream, jx non-default renderer specified:
+ {
+ 'trackingUrlBase': 'https://tr.jixie.io/sync/ad?',
+ 'jxBidId': '99bc539c81b00ce-028d5dee-2c83-44e3-bed1-b75002475cdf',
+ 'requestId': '99bc539c81b00ce',
+ 'cpm': 2.99,
+ 'width': 640,
+ 'height': 360,
+ 'ttl': 300,
+ 'netRevenue': true,
+ 'currency': 'USD',
+ 'creativeId': 'jixie521',
+ 'adUnitCode': 'demoslot4-div',
+ 'osplayer': 'jixie',
+ 'osparams': {
+ 'script': JX_OTHER_OUTSTREAM_RENDERER_URL
+ },
+ 'vastXml': mockVastXml_
+ },
+ // outstream, jx default renderer:
+ {
+ 'trackingUrlBase': 'https://tr.jixie.io/sync/ad?',
+ 'jxBidId': '61bc539c81b00ce-028d5dee-2c83-44e3-bed1-b75002475cdf',
+ 'requestId': '61bc539c81b00ce',
+ 'cpm': 1.99,
+ 'width': 640,
+ 'height': 360,
+ 'ttl': 300,
+ 'netRevenue': true,
+ 'currency': 'USD',
+ 'creativeId': 'jixie521',
+ 'meta': {
+ 'networkId': 123,
+ 'networkName': 'network123',
+ 'agencyId': 123,
+ 'agencyName': 'agency123',
+ 'advertiserId': 123,
+ 'advertiserName': 'advertiser123',
+ 'brandId': 123,
+ 'brandName': 'brand123',
+ 'primaryCatId': 1,
+ 'secondaryCatIds': [
+ 2,
+ 3,
+ 4
+ ],
+ 'mediaType': 'VIDEO'
+ },
+ 'adUnitCode': 'demoslot2-div',
+ 'osplayer': 'jixie',
+ 'osparams': {},
+ 'vastXml': mockVastXml_
+ }
+ ],
+ 'setids': {
+ 'client_id': '43aacc10-f643-11ea-8a10-c5fe2d394e7e',
+ 'session_id': '1600057934-43aacc10-f643-11ea-8a10-c5fe2d394e7e'
+ },
+ };
+ const requestObj_ =
+ {
+ 'method': 'POST',
+ 'url': 'http://localhost:8080/v2/hbpost',
+ 'data': '{"auctionid":"028d5dee-2c83-44e3-bed1-b75002475cdf","timeout":1000,"currency":"USD","timestamp":1600057934665,"device":"desktop","domain":"mock.com","pageurl":"https://mock.com/tests/jxprebidtest_pbjs.html","bids":[{"bidId":"600c9ae6fda1acb","adUnitCode":"demoslot1-div","mediaTypes":{"banner":{"sizes":[[300,250],[300,600],[728,90]]}},"params":{"unit":"prebidsampleunit"}},{"bidId":"61bc539c81b00ce","adUnitCode":"demoslot2-div","mediaTypes":{"video":{"playerSize":[[640,360]],"context":"outstream"}},"params":{"unit":"prebidsampleunit"}},{"bidId":"99bc539c81b00ce","adUnitCode":"demoslot4-div","mediaTypes":{"video":{"playerSize":[[640,360]],"context":"outstream"}},"params":{"unit":"prebidsampleunit"}},{"bidId":"62847e4c696edcb","adUnitCode":"demoslot3-div","mediaTypes":{"video":{"playerSize":[[640,360]],"context":"instream"}},"params":{"unit":"prebidsampleunit"}},{"bidId":"6360235ab01d2cd","adUnitCode":"woo-div","mediaTypes":{"video":{"context":"outstream","playerSize":[[640,360]]}},"params":{"unit":"80b76fc951e161d7c019d21b6639e408"}},{"bidId":"64d9724c7a5e512","adUnitCode":"test-div","mediaTypes":{"video":{"context":"outstream","playerSize":[[300,250]]}},"params":{"unit":"80b76fc951e161d7c019d21b6639e408"}},{"bidId":"65bea7e80fed44b","adUnitCode":"test-div","mediaTypes":{"banner":{"sizes":[[300,250],[300,600],[728,90]]}},"params":{"unit":"7854f723e932b951b6c51fc80b23a410"}},{"bidId":"6642054c4ba1b7f","adUnitCode":"div-banner-native-1","mediaTypes":{"banner":{"sizes":[[640,360]]},"video":{"context":"outstream","sizes":[[640,361]],"playerSize":[[640,360]]},"native":{"type":"image"}},"params":{"unit":"632e7695f0910ce0fa74c19859060a04"}},{"bidId":"675ecf4b44db228","adUnitCode":"div-banner-native-2","mediaTypes":{"banner":{"sizes":[[300,250]]},"native":{"title":{"required":true},"image":{"required":true},"sponsoredBy":{"required":true}}},"params":{"unit":"1000008-b1Q2UMQfZx"}},{"bidId":"68f2dbf5dc23f94","adUnitCode":"div-Top-MediumRectangle","mediaTypes":{"banner":{"sizes":[[300,250],[300,100],[320,50]]}},"params":{"unit":"1000008-b1Q2UMQfZx"}},{"bidId":"6991cf107bb7f1a","adUnitCode":"div-Middle-MediumRectangle","mediaTypes":{"banner":{"sizes":[[300,250],[300,100],[320,50]]}},"params":{"unit":"1000008-b1Q2UMQfZx"}},{"bidId":"706be1b011eac83","adUnitCode":"div-Inside-MediumRectangle","mediaTypes":{"banner":{"sizes":[[300,600],[300,250],[300,100],[320,480]]}},"params":{"unit":"1000008-b1Q2UMQfZx"}}],"client_id_c":"ebd0dea0-f5c8-11ea-a2c7-a5b37aa7fe95","client_id_ls":"ebd0dea0-f5c8-11ea-a2c7-a5b37aa7fe95","session_id_c":"","session_id_ls":"1600005388-ebd0dea0-f5c8-11ea-a2c7-a5b37aa7fe95"}',
+ 'currency': 'USD'
+ };
+
+ describe('interpretResponse', function () {
+ it('handles nobid responses', function () {
+ expect(spec.interpretResponse({body: {}}, {validBidRequests: []}).length).to.equal(0)
+ expect(spec.interpretResponse({body: []}, {validBidRequests: []}).length).to.equal(0)
+ });
+
+ it('should get correct bid response', function () {
+ let setCookieSpy = sinon.spy(storage, 'setCookie');
+ let setLocalStorageSpy = sinon.spy(storage, 'setDataInLocalStorage');
+ const result = spec.interpretResponse({body: responseBody_}, requestObj_)
+ expect(setLocalStorageSpy.calledWith('_jx', '43aacc10-f643-11ea-8a10-c5fe2d394e7e')).to.equal(true);
+ expect(setLocalStorageSpy.calledWith('_jxs', '1600057934-43aacc10-f643-11ea-8a10-c5fe2d394e7e')).to.equal(true);
+ expect(setCookieSpy.calledWith('_jxs', '1600057934-43aacc10-f643-11ea-8a10-c5fe2d394e7e')).to.equal(true);
+ expect(setCookieSpy.calledWith('_jx', '43aacc10-f643-11ea-8a10-c5fe2d394e7e')).to.equal(true);
+
+ // video ad with vastUrl returned by adserver
+ expect(result[0].requestId).to.equal('62847e4c696edcb')
+ expect(result[0].cpm).to.equal(2.19)
+ expect(result[0].width).to.equal(640)
+ expect(result[0].height).to.equal(360)
+ expect(result[0].creativeId).to.equal('jixie522')
+ expect(result[0].currency).to.equal('USD')
+ 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')
+
+ // display ad
+ expect(result[1].requestId).to.equal('600c9ae6fda1acb')
+ expect(result[1].cpm).to.equal(1.999)
+ expect(result[1].width).to.equal(300)
+ expect(result[1].height).to.equal(250)
+ expect(result[1].creativeId).to.equal('jixie520')
+ expect(result[1].currency).to.equal('USD')
+ expect(result[1].netRevenue).to.equal(true)
+ expect(result[1].ttl).to.equal(300)
+ expect(result[1].ad).to.include('jxoutstream')
+ expect(result[1].trackingUrlBase).to.include('sync')
+
+ // should pick up about using alternative outstream renderer
+ expect(result[2].requestId).to.equal('99bc539c81b00ce')
+ expect(result[2].cpm).to.equal(2.99)
+ expect(result[2].width).to.equal(640)
+ expect(result[2].height).to.equal(360)
+ expect(result[2].creativeId).to.equal('jixie521')
+ expect(result[2].currency).to.equal('USD')
+ 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].renderer.url).to.equal(JX_OTHER_OUTSTREAM_RENDERER_URL);
+
+ // should know to use default outstream renderer
+ expect(result[3].requestId).to.equal('61bc539c81b00ce')
+ expect(result[3].cpm).to.equal(1.99)
+ expect(result[3].width).to.equal(640)
+ expect(result[3].height).to.equal(360)
+ expect(result[3].creativeId).to.equal('jixie521')
+ expect(result[3].currency).to.equal('USD')
+ 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].renderer.url).to.equal(JX_OUTSTREAM_RENDERER_URL)
+
+ setLocalStorageSpy.restore();
+ setCookieSpy.restore();
+ });// it
+ });// describe
+
+ /**
+ * onBidWon
+ */
+ describe('onBidWon', function() {
+ let ajaxStub;
+ let miscDimsStub;
+ beforeEach(function() {
+ miscDimsStub = sinon.stub(jixieaux, 'getMiscDims');
+ ajaxStub = sinon.stub(jixieaux, 'ajax');
+
+ miscDimsStub
+ .returns({ device: device_, pageurl: pageurl_, domain: domain_ });
+ })
+
+ afterEach(function() {
+ miscDimsStub.restore();
+ ajaxStub.restore();
+ })
+
+ let TRACKINGURL_ = 'https://abc.com/sync?action=bidwon';
+
+ it('Should fire if the adserver trackingUrl flag says so', 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_ });
+ })
+
+ 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/justpremiumBidAdapter_spec.js b/test/spec/modules/justpremiumBidAdapter_spec.js
index c162b785aed..7cc154254ff 100644
--- a/test/spec/modules/justpremiumBidAdapter_spec.js
+++ b/test/spec/modules/justpremiumBidAdapter_spec.js
@@ -21,7 +21,9 @@ describe('justpremium adapter', function () {
},
userId: {
tdid: '1111111',
- id5id: '2222222',
+ id5id: {
+ uid: '2222222'
+ },
digitrustid: {
data: {
id: '3333333'
@@ -84,7 +86,7 @@ describe('justpremium adapter', function () {
expect(jpxRequest.version.jp_adapter).to.equal('1.7')
expect(jpxRequest.pubcid).to.equal('0000000')
expect(jpxRequest.uids.tdid).to.equal('1111111')
- expect(jpxRequest.uids.id5id).to.equal('2222222')
+ expect(jpxRequest.uids.id5id.uid).to.equal('2222222')
expect(jpxRequest.uids.digitrustid.data.id).to.equal('3333333')
expect(jpxRequest.us_privacy).to.equal('1YYN')
})
diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js
index b19d38d5859..80f776168c4 100644
--- a/test/spec/modules/liveIntentIdSystem_spec.js
+++ b/test/spec/modules/liveIntentIdSystem_spec.js
@@ -4,7 +4,7 @@ import {uspDataHandler} from '../../../src/adapterManager.js';
import {server} from 'test/mocks/xhr.js';
const PUBLISHER_ID = '89899';
-const defaultConfigParams = {publisherId: PUBLISHER_ID};
+const defaultConfigParams = { params: {publisherId: PUBLISHER_ID} };
const responseHeader = {'Content-Type': 'application/json'}
describe('LiveIntentId', function () {
@@ -55,8 +55,8 @@ describe('LiveIntentId', function () {
});
it('should initialize LiveConnect with the config params when decode and emit an event', function () {
- liveIntentIdSubmodule.decode({}, {
- ...defaultConfigParams,
+ liveIntentIdSubmodule.decode({}, { params: {
+ ...defaultConfigParams.params,
...{
url: 'https://dummy.liveintent.com',
liCollectConfig: {
@@ -64,7 +64,7 @@ describe('LiveIntentId', function () {
collectorUrl: 'https://collector.liveintent.com'
}
}
- });
+ } });
expect(pixel.src).to.match(/https:\/\/collector.liveintent.com\/p\?aid=a-0001&wpn=prebid.*/)
});
@@ -95,7 +95,7 @@ describe('LiveIntentId', function () {
it('should call the Custom URL of the LiveIntent Identity Exchange endpoint', function () {
getCookieStub.returns(null);
let callBackSpy = sinon.spy();
- let submoduleCallback = liveIntentIdSubmodule.getId({...defaultConfigParams, ...{'url': 'https://dummy.liveintent.com/idex'}}).callback;
+ let submoduleCallback = liveIntentIdSubmodule.getId({ params: {...defaultConfigParams.params, ...{'url': 'https://dummy.liveintent.com/idex'}} }).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899');
@@ -110,13 +110,13 @@ describe('LiveIntentId', function () {
it('should call the default url of the LiveIntent Identity Exchange endpoint, with a partner', function () {
getCookieStub.returns(null);
let callBackSpy = sinon.spy();
- let submoduleCallback = liveIntentIdSubmodule.getId({
- ...defaultConfigParams,
+ let submoduleCallback = liveIntentIdSubmodule.getId({ params: {
+ ...defaultConfigParams.params,
...{
'url': 'https://dummy.liveintent.com/idex',
'partner': 'rubicon'
}
- }).callback;
+ } }).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/rubicon/89899');
@@ -179,12 +179,12 @@ describe('LiveIntentId', function () {
const oldCookie = 'a-xxxx--123e4567-e89b-12d3-a456-426655440000'
getDataFromLocalStorageStub.withArgs('_li_duid').returns(oldCookie);
getDataFromLocalStorageStub.withArgs('_thirdPC').returns('third-pc');
- const configParams = {
- ...defaultConfigParams,
+ const configParams = { params: {
+ ...defaultConfigParams.params,
...{
'identifiersToResolve': ['_thirdPC']
}
- };
+ }};
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback;
submoduleCallback(callBackSpy);
@@ -201,12 +201,12 @@ describe('LiveIntentId', function () {
it('should include an additional identifier value to resolve even if it is an object', function () {
getCookieStub.returns(null);
getDataFromLocalStorageStub.withArgs('_thirdPC').returns({'key': 'value'});
- const configParams = {
- ...defaultConfigParams,
+ const configParams = { params: {
+ ...defaultConfigParams.params,
...{
'identifiersToResolve': ['_thirdPC']
}
- };
+ }};
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback;
submoduleCallback(callBackSpy);
diff --git a/test/spec/modules/livewrappedBidAdapter_spec.js b/test/spec/modules/livewrappedBidAdapter_spec.js
index fb676f75343..2d5ba3f48df 100644
--- a/test/spec/modules/livewrappedBidAdapter_spec.js
+++ b/test/spec/modules/livewrappedBidAdapter_spec.js
@@ -2,7 +2,7 @@ import {expect} from 'chai';
import {spec, storage} from 'modules/livewrappedBidAdapter.js';
import {config} from 'src/config.js';
import * as utils from 'src/utils.js';
-import { BANNER, NATIVE } from 'src/mediaTypes.js';
+import { BANNER, NATIVE, VIDEO } from 'src/mediaTypes.js';
describe('Livewrapped adapter tests', function () {
let sandbox,
@@ -102,7 +102,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
@@ -139,7 +139,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
@@ -177,7 +177,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
@@ -208,7 +208,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
@@ -238,7 +238,7 @@ describe('Livewrapped adapter tests', function () {
let expectedQuery = {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
url: 'https://www.domain.com',
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
@@ -270,7 +270,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
deviceId: 'deviceid',
@@ -303,7 +303,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
tid: 'tracking id',
@@ -335,7 +335,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
@@ -366,7 +366,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
@@ -397,7 +397,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
@@ -428,7 +428,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
@@ -445,6 +445,37 @@ describe('Livewrapped adapter tests', function () {
expect(data).to.deep.equal(expectedQuery);
});
+ it('should make a well-formed single request object with video only parameters', function() {
+ sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false);
+ sandbox.stub(storage, 'cookiesAreEnabled').callsFake(() => true);
+ let testbidRequest = clone(bidderRequest);
+ delete testbidRequest.bids[0].params.userId;
+ delete testbidRequest.bids[0].params.seats;
+ delete testbidRequest.bids[0].params.adUnitId;
+ testbidRequest.bids[0].mediaTypes = {'video': {'videodata': 'content parsed serverside only'}};
+ let result = spec.buildRequests(testbidRequest.bids, testbidRequest);
+ let data = JSON.parse(result.data);
+
+ let expectedQuery = {
+ auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
+ publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
+ url: 'https://www.domain.com',
+ version: '1.4',
+ width: 100,
+ height: 100,
+ cookieSupport: true,
+ adRequests: [{
+ callerAdUnitId: 'panorama_d_1',
+ bidId: '2ffb201a808da7',
+ transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D',
+ formats: [{width: 980, height: 240}, {width: 980, height: 120}],
+ video: {'videodata': 'content parsed serverside only'}
+ }]
+ };
+
+ expect(data).to.deep.equal(expectedQuery);
+ });
+
it('should use app objects', function() {
sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false);
sandbox.stub(storage, 'cookiesAreEnabled').callsFake(() => true);
@@ -474,7 +505,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://appdomain.com',
seats: {'dsp': ['seat 1']},
- version: '1.3',
+ version: '1.4',
width: 300,
height: 200,
ifa: 'ifa',
@@ -507,7 +538,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
@@ -541,7 +572,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
@@ -577,7 +608,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
@@ -608,7 +639,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: false,
@@ -638,7 +669,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: false,
@@ -701,7 +732,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'pubcid 123',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
@@ -733,7 +764,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
- version: '1.3',
+ version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
@@ -756,7 +787,7 @@ describe('Livewrapped adapter tests', function () {
let testbidRequest = clone(bidderRequest);
delete testbidRequest.bids[0].params.userId;
testbidRequest.bids[0].userId = {};
- testbidRequest.bids[0].userId.id5id = 'id5-user-id';
+ testbidRequest.bids[0].userId.id5id = { uid: 'id5-user-id' };
let result = spec.buildRequests(testbidRequest.bids, testbidRequest);
let data = JSON.parse(result.data);
@@ -895,6 +926,48 @@ describe('Livewrapped adapter tests', function () {
expect(bids).to.deep.equal(expectedResponse);
})
+ it('should handle single video success response', function() {
+ let lwResponse = {
+ ads: [
+ {
+ id: '28e5ddf4-3c01-11e8-86a7-0a44794250d4',
+ callerId: 'site_outsider_0',
+ tag: 'VAST XML',
+ video: {},
+ width: 300,
+ height: 250,
+ cpmBid: 2.565917,
+ bidId: '32e50fad901ae89',
+ auctionId: '13e674db-d4d8-4e19-9d28-ff38177db8bf',
+ creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077',
+ ttl: 120,
+ meta: undefined
+ }
+ ],
+ currency: 'USD'
+ };
+
+ let expectedResponse = [{
+ requestId: '32e50fad901ae89',
+ bidderCode: 'livewrapped',
+ cpm: 2.565917,
+ width: 300,
+ height: 250,
+ ad: 'VAST XML',
+ ttl: 120,
+ creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077',
+ netRevenue: true,
+ currency: 'USD',
+ meta: undefined,
+ vastXml: 'VAST XML',
+ mediaType: VIDEO
+ }];
+
+ let bids = spec.interpretResponse({body: lwResponse});
+
+ expect(bids).to.deep.equal(expectedResponse);
+ })
+
it('should handle multiple success response', function() {
let lwResponse = {
ads: [
diff --git a/test/spec/modules/logicadBidAdapter_spec.js b/test/spec/modules/logicadBidAdapter_spec.js
index eddcaecac7b..c4c06630a2b 100644
--- a/test/spec/modules/logicadBidAdapter_spec.js
+++ b/test/spec/modules/logicadBidAdapter_spec.js
@@ -21,6 +21,32 @@ describe('LogicadAdapter', function () {
}
}
}];
+ const nativeBidRequests = [{
+ bidder: 'logicad',
+ bidId: '51ef8751f9aead',
+ params: {
+ tid: 'bgjD1',
+ page: 'https://www.logicad.com/'
+ },
+ adUnitCode: 'div-gpt-ad-1460505748561-1',
+ transactionId: 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec',
+ sizes: [[1, 1]],
+ bidderRequestId: '418b37f85e772c',
+ auctionId: '18fd8b8b0bd757',
+ mediaTypes: {
+ native: {
+ title: {
+ required: true
+ },
+ image: {
+ required: true
+ },
+ sponsoredBy: {
+ required: true
+ }
+ }
+ }
+ }];
const bidderRequest = {
refererInfo: {
referer: 'fakeReferer',
@@ -52,6 +78,40 @@ describe('LogicadAdapter', function () {
}
}
};
+ const nativeServerResponse = {
+ body: {
+ seatbid:
+ [{
+ bid: {
+ requestId: '51ef8751f9aead',
+ cpm: 101.0234,
+ width: 1,
+ height: 1,
+ creativeId: '2019',
+ currency: 'JPY',
+ netRevenue: true,
+ ttl: 60,
+ native: {
+ clickUrl: 'https://www.logicad.com',
+ image: {
+ url: 'https://cd.ladsp.com/img.png',
+ width: '1200',
+ height: '628'
+ },
+ impressionTrackers: [
+ 'https://example.com'
+ ],
+ sponsoredBy: 'Logicad',
+ title: 'Native Creative',
+ }
+ }
+ }],
+ userSync: {
+ type: 'image',
+ url: 'https://cr-p31.ladsp.jp/cookiesender/31'
+ }
+ }
+ };
describe('isBidRequestValid', function () {
it('should return true if the tid parameter is present', function () {
@@ -69,6 +129,10 @@ describe('LogicadAdapter', function () {
delete bidRequest[0].params;
expect(spec.isBidRequestValid(bidRequest)).to.be.false;
});
+
+ it('should return true if the tid parameter is present for native request', function () {
+ expect(spec.isBidRequestValid(nativeBidRequests[0])).to.be.true;
+ });
});
describe('buildRequests', function () {
@@ -101,6 +165,27 @@ describe('LogicadAdapter', function () {
expect(interpretedResponse[0].netRevenue).to.equal(serverResponse.body.seatbid[0].bid.netRevenue);
expect(interpretedResponse[0].ad).to.equal(serverResponse.body.seatbid[0].bid.ad);
expect(interpretedResponse[0].ttl).to.equal(serverResponse.body.seatbid[0].bid.ttl);
+
+ // native
+ const nativeRequest = spec.buildRequests(nativeBidRequests, bidderRequest)[0];
+ const interpretedResponseForNative = spec.interpretResponse(nativeServerResponse, nativeRequest);
+
+ expect(interpretedResponseForNative).to.have.lengthOf(1);
+
+ expect(interpretedResponseForNative[0].requestId).to.equal(nativeServerResponse.body.seatbid[0].bid.requestId);
+ expect(interpretedResponseForNative[0].cpm).to.equal(nativeServerResponse.body.seatbid[0].bid.cpm);
+ expect(interpretedResponseForNative[0].width).to.equal(nativeServerResponse.body.seatbid[0].bid.width);
+ expect(interpretedResponseForNative[0].height).to.equal(nativeServerResponse.body.seatbid[0].bid.height);
+ expect(interpretedResponseForNative[0].creativeId).to.equal(nativeServerResponse.body.seatbid[0].bid.creativeId);
+ expect(interpretedResponseForNative[0].currency).to.equal(nativeServerResponse.body.seatbid[0].bid.currency);
+ expect(interpretedResponseForNative[0].netRevenue).to.equal(nativeServerResponse.body.seatbid[0].bid.netRevenue);
+ expect(interpretedResponseForNative[0].ttl).to.equal(nativeServerResponse.body.seatbid[0].bid.ttl);
+ expect(interpretedResponseForNative[0].native.clickUrl).to.equal(nativeServerResponse.body.seatbid[0].bid.native.clickUrl);
+ expect(interpretedResponseForNative[0].native.image.url).to.equal(nativeServerResponse.body.seatbid[0].bid.native.image.url);
+ expect(interpretedResponseForNative[0].native.image.width).to.equal(nativeServerResponse.body.seatbid[0].bid.native.image.width);
+ expect(interpretedResponseForNative[0].native.impressionTrackers).to.equal(nativeServerResponse.body.seatbid[0].bid.native.impressionTrackers);
+ expect(interpretedResponseForNative[0].native.sponsoredBy).to.equal(nativeServerResponse.body.seatbid[0].bid.native.sponsoredBy);
+ expect(interpretedResponseForNative[0].native.title).to.equal(nativeServerResponse.body.seatbid[0].bid.native.title);
});
});
diff --git a/test/spec/modules/luponmediaBidAdapter_spec.js b/test/spec/modules/luponmediaBidAdapter_spec.js
index 39c915e38b8..8aeecc87c98 100644
--- a/test/spec/modules/luponmediaBidAdapter_spec.js
+++ b/test/spec/modules/luponmediaBidAdapter_spec.js
@@ -364,4 +364,49 @@ describe('luponmediaBidAdapter', function () {
expect(checkSchain).to.equal(false);
});
});
+
+ describe('onBidWon', function () {
+ const bidWonEvent = {
+ 'bidderCode': 'luponmedia',
+ 'width': 300,
+ 'height': 250,
+ 'statusMessage': 'Bid available',
+ 'adId': '105bbf8c54453ff',
+ 'requestId': '934b8752185955',
+ 'mediaType': 'banner',
+ 'source': 'client',
+ 'cpm': 0.364,
+ 'creativeId': '443801010',
+ 'currency': 'USD',
+ 'netRevenue': false,
+ 'ttl': 300,
+ 'referrer': '',
+ 'ad': '',
+ 'auctionId': '926a8ea3-3dd4-4bf2-95ab-c85c2ce7e99b',
+ 'responseTimestamp': 1598527728026,
+ 'requestTimestamp': 1598527727629,
+ 'bidder': 'luponmedia',
+ 'adUnitCode': 'div-gpt-ad-1533155193780-5',
+ 'timeToRespond': 397,
+ 'size': '300x250',
+ 'status': 'rendered'
+ };
+
+ let ajaxStub;
+
+ beforeEach(() => {
+ ajaxStub = sinon.stub(spec, 'sendWinningsToServer')
+ })
+
+ afterEach(() => {
+ ajaxStub.restore()
+ })
+
+ it('calls luponmedia\'s callback endpoint', () => {
+ const result = spec.onBidWon(bidWonEvent);
+ expect(result).to.equal(undefined);
+ expect(ajaxStub.calledOnce).to.equal(true);
+ expect(ajaxStub.firstCall.args[0]).to.deep.equal(JSON.stringify(bidWonEvent));
+ });
+ });
});
diff --git a/test/spec/modules/malltvBidAdapter_spec.js b/test/spec/modules/malltvBidAdapter_spec.js
index 10161b319c5..e1e9ad867e7 100644
--- a/test/spec/modules/malltvBidAdapter_spec.js
+++ b/test/spec/modules/malltvBidAdapter_spec.js
@@ -80,7 +80,11 @@ describe('malltvAdapterTest', () => {
it('bidRequest sizes', () => {
const requests = spec.buildRequests(bidRequests);
- expect(requests[0].data.sizes).to.equal('300x250');
+ requests.forEach(function (requestItem) {
+ expect(requestItem.data.placements).to.exist;
+ expect(requestItem.data.placements.length).to.equal(1);
+ expect(requestItem.data.placements[0].sizes).to.equal('300x250');
+ });
});
});
@@ -128,7 +132,9 @@ describe('malltvAdapterTest', () => {
'netRevenue',
'ttl',
'referrer',
- 'ad'
+ 'ad',
+ 'vastUrl',
+ 'mediaType'
];
let resultKeys = Object.keys(result[0]);
diff --git a/test/spec/modules/medianetAnalyticsAdapter_spec.js b/test/spec/modules/medianetAnalyticsAdapter_spec.js
index 97b45cef00c..41a6338225e 100644
--- a/test/spec/modules/medianetAnalyticsAdapter_spec.js
+++ b/test/spec/modules/medianetAnalyticsAdapter_spec.js
@@ -9,20 +9,23 @@ const {
} = CONSTANTS;
const MOCK = {
- AUCTION_INIT: {'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'timestamp': 1584563605739},
- AUCTION_INIT_WITH_FLOOR: {'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'timestamp': 1584563605739, 'bidderRequests': [{'bids': [{ 'floorData': {'enforcements': {'enforceJS': true}} }]}]},
+ Ad_Units: [{'code': 'div-gpt-ad-1460505748561-0', 'mediaTypes': {'banner': {'sizes': [[300, 250]]}}, 'bids': [], 'ext': {'prop1': 'value1'}}],
+ MULTI_FORMAT_TWIN_AD_UNITS: [{'code': 'div-gpt-ad-1460505748561-0', 'mediaTypes': {'banner': {'sizes': [[300, 250]]}, 'native': {'image': {'required': true, 'sizes': [150, 50]}}}, 'bids': [], 'ext': {'prop1': 'value1'}}, {'code': 'div-gpt-ad-1460505748561-0', 'mediaTypes': {'video': {'playerSize': [640, 480], 'context': 'instream'}}, 'bids': [], 'ext': {'prop1': 'value1'}}],
+ AUCTION_INIT: {'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'timestamp': 1584563605739, 'timeout': 6000},
+ AUCTION_INIT_WITH_FLOOR: {'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'timestamp': 1584563605739, 'timeout': 6000, 'bidderRequests': [{'bids': [{ 'floorData': {'enforcements': {'enforceJS': true}} }]}]},
BID_REQUESTED: {'bidderCode': 'medianet', 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'bids': [{'bidder': 'medianet', 'params': {'cid': 'TEST_CID', 'crid': '451466393'}, 'mediaTypes': {'banner': {'sizes': [[300, 250]], 'ext': ['asdads']}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'sizes': [[300, 250]], 'bidId': '28248b0e6aece2', 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'src': 'client'}], 'auctionStart': 1584563605739, 'timeout': 6000, 'uspConsent': '1YY', 'start': 1584563605743},
- MULTI_FORMAT_BID_REQUESTED: {'bidderCode': 'medianet', 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'bids': [{'bidder': 'medianet', 'params': {'cid': 'TEST_CID', 'crid': '451466393'}, 'mediaTypes': {'banner': {'sizes': [[300, 250]]}, 'video': {'playerSize': [640, 480], 'context': 'instream'}, 'native': {'image': {'required': true, 'sizes': [150, 50]}, 'title': {'required': true, 'len': 80}}, 'ext': ['asdads']}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'sizes': [[300, 250]], 'bidId': '28248b0e6aece2', 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'src': 'client'}], 'auctionStart': 1584563605739, 'timeout': 6000, 'uspConsent': '1YY', 'start': 1584563605743},
+ MULTI_FORMAT_BID_REQUESTED: {'bidderCode': 'medianet', 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'bids': [{'bidder': 'medianet', 'params': {'cid': 'TEST_CID', 'crid': '451466393'}, 'mediaTypes': {'banner': {'sizes': [[300, 250]]}, 'video': {'playerSize': [640, 480], 'context': 'instream'}, 'native': {'image': {'required': true, 'sizes': [150, 50]}, 'title': {'required': true, 'len': 80}}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'sizes': [[300, 250]], 'bidId': '28248b0e6aece2', 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'src': 'client'}], 'auctionStart': 1584563605739, 'timeout': 6000, 'uspConsent': '1YY', 'start': 1584563605743},
BID_RESPONSE: {'bidderCode': 'medianet', 'width': 300, 'height': 250, 'adId': '3e6e4bce5c8fb3', 'requestId': '28248b0e6aece2', 'mediaType': 'banner', 'source': 'client', 'ext': {'pvid': 123, 'crid': '321'}, 'no_bid': false, 'cpm': 2.299, 'ad': 'AD_CODE', 'ttl': 180, 'creativeId': 'Test1', 'netRevenue': true, 'currency': 'USD', 'dfp_id': 'div-gpt-ad-1460505748561-0', 'originalCpm': 1.1495, 'originalCurrency': 'USD', 'floorData': {'floorValue': 1.10, 'floorRule': 'banner'}, 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'responseTimestamp': 1584563606009, 'requestTimestamp': 1584563605743, 'bidder': 'medianet', 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'timeToRespond': 266, 'pbLg': '2.00', 'pbMg': '2.20', 'pbHg': '2.29', 'pbAg': '2.25', 'pbDg': '2.29', 'pbCg': '2.00', 'size': '300x250', 'adserverTargeting': {'hb_bidder': 'medianet', 'hb_adid': '3e6e4bce5c8fb3', 'hb_pb': '2.00', 'hb_size': '300x250', 'hb_source': 'client', 'hb_format': 'banner', 'prebid_test': 1}, 'status': 'rendered', 'params': [{'cid': 'test123', 'crid': '451466393'}]},
AUCTION_END: {'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'auctionEnd': 1584563605739},
SET_TARGETING: {'div-gpt-ad-1460505748561-0': {'prebid_test': '1', 'hb_format': 'banner', 'hb_source': 'client', 'hb_size': '300x250', 'hb_pb': '2.00', 'hb_adid': '3e6e4bce5c8fb3', 'hb_bidder': 'medianet', 'hb_format_medianet': 'banner', 'hb_source_medianet': 'client', 'hb_size_medianet': '300x250', 'hb_pb_medianet': '2.00', 'hb_adid_medianet': '3e6e4bce5c8fb3', 'hb_bidder_medianet': 'medianet'}},
+ NO_BID_SET_TARGETING: {'div-gpt-ad-1460505748561-0': {}},
BID_WON: {'bidderCode': 'medianet', 'width': 300, 'height': 250, 'statusMessage': 'Bid available', 'adId': '3e6e4bce5c8fb3', 'requestId': '28248b0e6aece2', 'mediaType': 'banner', 'source': 'client', 'no_bid': false, 'cpm': 2.299, 'ad': 'AD_CODE', 'ttl': 180, 'creativeId': 'Test1', 'netRevenue': true, 'currency': 'USD', 'dfp_id': 'div-gpt-ad-1460505748561-0', 'originalCpm': 1.1495, 'originalCurrency': 'USD', 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'responseTimestamp': 1584563606009, 'requestTimestamp': 1584563605743, 'bidder': 'medianet', 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'timeToRespond': 266, 'pbLg': '2.00', 'pbMg': '2.20', 'pbHg': '2.29', 'pbAg': '2.25', 'pbDg': '2.29', 'pbCg': '2.00', 'size': '300x250', 'adserverTargeting': {'hb_bidder': 'medianet', 'hb_adid': '3e6e4bce5c8fb3', 'hb_pb': '2.00', 'hb_size': '300x250', 'hb_source': 'client', 'hb_format': 'banner', 'prebid_test': 1}, 'status': 'rendered', 'params': [{'cid': 'test123', 'crid': '451466393'}]},
NO_BID: {'bidder': 'medianet', 'params': {'cid': 'test123', 'crid': '451466393', 'site': {}}, 'mediaTypes': {'banner': {'sizes': [[300, 250]], 'ext': ['asdads']}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': '303fa0c6-682f-4aea-8e4a-dc68f0d5c7d5', 'sizes': [[300, 250], [300, 600]], 'bidId': '28248b0e6aece2', 'bidderRequestId': '13fccf3809fe43', 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'src': 'client'},
BID_TIMEOUT: [{'bidId': '28248b0e6aece2', 'bidder': 'medianet', 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'auctionId': '8e0d5245-deb3-406c-96ca-9b609e077ff7', 'params': [{'cid': 'test123', 'crid': '451466393', 'site': {}}, {'cid': '8CUX0H51P', 'crid': '451466393', 'site': {}}], 'timeout': 6}]
}
function performAuctionWithFloorConfig() {
- events.emit(AUCTION_INIT, MOCK.AUCTION_INIT_WITH_FLOOR);
+ events.emit(AUCTION_INIT, {...MOCK.AUCTION_INIT_WITH_FLOOR, adUnits: MOCK.Ad_Units});
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);
events.emit(BID_RESPONSE, MOCK.BID_RESPONSE);
events.emit(AUCTION_END, MOCK.AUCTION_END);
@@ -31,7 +34,7 @@ function performAuctionWithFloorConfig() {
}
function performStandardAuctionWithWinner() {
- events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
+ events.emit(AUCTION_INIT, {...MOCK.AUCTION_INIT, adUnits: MOCK.Ad_Units});
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);
events.emit(BID_RESPONSE, MOCK.BID_RESPONSE);
events.emit(AUCTION_END, MOCK.AUCTION_END);
@@ -40,27 +43,27 @@ function performStandardAuctionWithWinner() {
}
function performMultiFormatAuctionWithNoBid() {
- events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
+ events.emit(AUCTION_INIT, {...MOCK.AUCTION_INIT, adUnits: MOCK.MULTI_FORMAT_TWIN_AD_UNITS});
events.emit(BID_REQUESTED, MOCK.MULTI_FORMAT_BID_REQUESTED);
- events.emit(BID_RESPONSE, MOCK.BID_RESPONSE);
+ events.emit(NO_BID, MOCK.NO_BID);
events.emit(AUCTION_END, MOCK.AUCTION_END);
- events.emit(SET_TARGETING, MOCK.SET_TARGETING);
+ events.emit(SET_TARGETING, MOCK.NO_BID_SET_TARGETING);
}
function performStandardAuctionWithNoBid() {
- events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
+ events.emit(AUCTION_INIT, {...MOCK.AUCTION_INIT, adUnits: MOCK.Ad_Units});
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);
events.emit(NO_BID, MOCK.NO_BID);
events.emit(AUCTION_END, MOCK.AUCTION_END);
- events.emit(SET_TARGETING, MOCK.SET_TARGETING);
+ events.emit(SET_TARGETING, MOCK.NO_BID_SET_TARGETING);
}
function performStandardAuctionWithTimeout() {
- events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
+ events.emit(AUCTION_INIT, {...MOCK.AUCTION_INIT, adUnits: MOCK.Ad_Units});
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);
events.emit(BID_TIMEOUT, MOCK.BID_TIMEOUT);
events.emit(AUCTION_END, MOCK.AUCTION_END);
- events.emit(SET_TARGETING, MOCK.SET_TARGETING);
+ events.emit(SET_TARGETING, MOCK.NO_BID_SET_TARGETING);
}
function getQueryData(url) {
@@ -123,8 +126,10 @@ describe('Media.net Analytics Adapter', function() {
cid: 'test123'
}
});
+ medianetAnalytics.clearlogsQueue();
});
afterEach(function () {
+ medianetAnalytics.clearlogsQueue();
medianetAnalytics.disableAnalytics();
});
@@ -139,10 +144,9 @@ describe('Media.net Analytics Adapter', function() {
performMultiFormatAuctionWithNoBid();
const noBidLog = medianetAnalytics.getlogsQueue().map((log) => getQueryData(log))[0];
medianetAnalytics.clearlogsQueue();
-
- expect(noBidLog.szs).to.equal(encodeURIComponent('300x250|1x1|640x480'));
+ expect(noBidLog.mtype).to.have.ordered.members([encodeURIComponent('banner|native|video'), encodeURIComponent('banner|video|native')]);
+ expect(noBidLog.szs).to.have.ordered.members([encodeURIComponent('300x250|1x1|640x480'), encodeURIComponent('300x250|1x1|640x480')]);
expect(noBidLog.vplcmtt).to.equal('instream');
- expect(noBidLog.sz2).to.equal(encodeURIComponent('300x250'));
});
it('should have winner log in standard auction', function() {
@@ -167,6 +171,7 @@ describe('Media.net Analytics Adapter', function() {
src: 'client',
size: '300x250',
mtype: 'banner',
+ gdpr: '0',
cid: 'test123',
lper: '1',
ogbdp: '1.1495',
@@ -205,7 +210,7 @@ describe('Media.net Analytics Adapter', function() {
expect(noBidLog.status).to.have.ordered.members(['1', '2']);
expect(noBidLog.src).to.have.ordered.members(['client', 'client']);
expect(noBidLog.curr).to.have.ordered.members(['', '']);
- expect(noBidLog.mtype).to.have.ordered.members(['', '']);
+ expect(noBidLog.mtype).to.have.ordered.members(['banner', 'banner']);
expect(noBidLog.ogbdp).to.have.ordered.members(['', '']);
expect(noBidLog.mpvid).to.have.ordered.members(['', '']);
expect(noBidLog.crid).to.have.ordered.members(['', '451466393']);
@@ -223,7 +228,7 @@ describe('Media.net Analytics Adapter', function() {
expect(timeoutLog.status).to.have.ordered.members(['1', '3']);
expect(timeoutLog.src).to.have.ordered.members(['client', 'client']);
expect(timeoutLog.curr).to.have.ordered.members(['', '']);
- expect(timeoutLog.mtype).to.have.ordered.members(['', '']);
+ expect(timeoutLog.mtype).to.have.ordered.members(['banner', 'banner']);
expect(timeoutLog.ogbdp).to.have.ordered.members(['', '']);
expect(timeoutLog.mpvid).to.have.ordered.members(['', '']);
expect(timeoutLog.crid).to.have.ordered.members(['', '451466393']);
diff --git a/test/spec/modules/medianetBidAdapter_spec.js b/test/spec/modules/medianetBidAdapter_spec.js
index 649929056fa..1b2207de842 100644
--- a/test/spec/modules/medianetBidAdapter_spec.js
+++ b/test/spec/modules/medianetBidAdapter_spec.js
@@ -1,7 +1,9 @@
import {expect} from 'chai';
import {spec} from 'modules/medianetBidAdapter.js';
+import { makeSlot } from '../integration/faker/googletag.js';
import { config } from 'src/config.js';
+$$PREBID_GLOBAL$$.version = $$PREBID_GLOBAL$$.version || 'version';
let VALID_BID_REQUEST = [{
'bidder': 'medianet',
'params': {
@@ -1306,6 +1308,30 @@ describe('Media.net bid adapter', function () {
expect(data.imp[1].ext).to.not.have.ownPropertyDescriptor('viewability');
expect(data.imp[1].ext.visibility).to.equal(0);
});
+ it('slot visibility should be calculable even in case of adUnitPath', function () {
+ const code = '/19968336/header-bid-tag-0';
+ const divId = 'div-gpt-ad-1460505748561-0';
+ window.googletag.pubads().setSlots([makeSlot({ code, divId })]);
+
+ let boundingRect = {
+ top: 1010,
+ left: 1010,
+ bottom: 1050,
+ right: 1050
+ };
+ documentStub.withArgs(divId).returns({
+ getBoundingClientRect: () => boundingRect
+ });
+ documentStub.withArgs('div-gpt-ad-1460505748561-123').returns({
+ getBoundingClientRect: () => boundingRect
+ });
+
+ const bidRequest = [{...VALID_BID_REQUEST[0], adUnitCode: code}]
+ const bidReq = spec.buildRequests(bidRequest, VALID_AUCTIONDATA);
+ const data = JSON.parse(bidReq.data);
+ expect(data.imp[0].ext.visibility).to.equal(2);
+ expect(data.imp[0].ext.viewability).to.equal(0);
+ });
});
describe('getUserSyncs', function () {
diff --git a/test/spec/modules/mediasquareBidAdapter_spec.js b/test/spec/modules/mediasquareBidAdapter_spec.js
index 351fbb40228..5d930f2b6ac 100644
--- a/test/spec/modules/mediasquareBidAdapter_spec.js
+++ b/test/spec/modules/mediasquareBidAdapter_spec.js
@@ -53,7 +53,7 @@ describe('MediaSquare bid adapter tests', function () {
canonicalUrl: 'https://www.prebid.org/the/link/to/the/page'
},
uspConsent: '111222333',
- userId: {'id5id': '1111'},
+ userId: { 'id5id': { uid: '1111' } },
schain: {
'ver': '1.0',
'complete': 1,
diff --git a/test/spec/modules/nobidBidAdapter_spec.js b/test/spec/modules/nobidBidAdapter_spec.js
index 3b8fd32160b..346356e7d5b 100644
--- a/test/spec/modules/nobidBidAdapter_spec.js
+++ b/test/spec/modules/nobidBidAdapter_spec.js
@@ -118,7 +118,7 @@ describe('Nobid Adapter', function () {
expect(payload.a).to.exist;
expect(payload.t).to.exist;
expect(payload.tz).to.exist;
- expect(payload.r).to.exist;
+ expect(payload.r).to.exist.and.to.equal('100x100');
expect(payload.lang).to.exist;
expect(payload.ref).to.exist;
expect(payload.a[0].d).to.exist.and.to.equal('adunit-code');
@@ -264,6 +264,38 @@ describe('Nobid Adapter', function () {
expect(payload.gdpr).to.exist;
});
+ it('sends bid request to ad size', function () {
+ const request = spec.buildRequests(bidRequests);
+ const payload = JSON.parse(request.data);
+ expect(payload.a).to.exist;
+ expect(payload.a.length).to.exist.and.to.equal(1);
+ expect(payload.a[0].z[0][0]).to.equal(300);
+ expect(payload.a[0].z[0][1]).to.equal(250);
+ });
+
+ it('sends bid request to div id', function () {
+ const request = spec.buildRequests(bidRequests);
+ const payload = JSON.parse(request.data);
+ expect(payload.a).to.exist;
+ expect(payload.a[0].d).to.equal('adunit-code');
+ });
+
+ 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);
+ });
+
+ it('sends bid request to ad type', function () {
+ const request = spec.buildRequests(bidRequests);
+ const payload = JSON.parse(request.data);
+ expect(payload.a).to.exist;
+ expect(payload.a[0].at).to.equal('banner');
+ });
+
it('sends bid request to ENDPOINT via POST', function () {
const request = spec.buildRequests(bidRequests);
expect(request.url).to.contain('ads.servenobid.com/adreq');
@@ -291,6 +323,43 @@ describe('Nobid Adapter', function () {
expect(payload.gdpr.consentString).to.exist.and.to.equal(consentString);
expect(payload.gdpr.consentRequired).to.exist.and.to.be.true;
});
+
+ it('should add gdpr consent information to the request', function () {
+ let bidderRequest = {
+ 'bidderCode': 'nobid',
+ 'auctionId': '1d1a030790a475',
+ 'bidderRequestId': '22edbae2733bf6',
+ 'timeout': 3000,
+ 'gdprConsent': {
+ gdprApplies: false
+ }
+ };
+ bidderRequest.bids = bidRequests;
+
+ const request = spec.buildRequests(bidRequests, bidderRequest);
+ const payload = JSON.parse(request.data);
+
+ expect(payload.gdpr).to.exist;
+ expect(payload.gdpr.consentString).to.not.exist;
+ expect(payload.gdpr.consentRequired).to.exist.and.to.be.false;
+ });
+
+ it('should add usp consent information to the request', function () {
+ let bidderRequest = {
+ 'bidderCode': 'nobid',
+ 'auctionId': '1d1a030790a475',
+ 'bidderRequestId': '22edbae2733bf6',
+ 'timeout': 3000,
+ 'uspConsent': '1Y-N'
+ };
+ bidderRequest.bids = bidRequests;
+
+ const request = spec.buildRequests(bidRequests, bidderRequest);
+ const payload = JSON.parse(request.data);
+
+ expect(payload.usp).to.exist;
+ expect(payload.usp).to.exist.and.to.equal('1Y-N');
+ });
});
describe('buildRequestsRefreshCount', function () {
diff --git a/test/spec/modules/openxAnalyticsAdapter_spec.js b/test/spec/modules/openxAnalyticsAdapter_spec.js
index be7ae6fcdc4..b946efe922d 100644
--- a/test/spec/modules/openxAnalyticsAdapter_spec.js
+++ b/test/spec/modules/openxAnalyticsAdapter_spec.js
@@ -78,6 +78,7 @@ describe('openx analytics adapter', function() {
const bidRequestedOpenX = {
auctionId: 'test-auction-id',
auctionStart: CURRENT_TIME,
+ timeout: 2000,
bids: [
{
adUnitCode: AD_UNIT_CODE,
@@ -100,6 +101,7 @@ describe('openx analytics adapter', function() {
const bidRequestedCloseX = {
auctionId: 'test-auction-id',
auctionStart: CURRENT_TIME,
+ timeout: 1000,
bids: [
{
adUnitCode: AD_UNIT_CODE,
@@ -334,7 +336,7 @@ describe('openx analytics adapter', function() {
it('should track values from query params when they exist', function () {
sinon.stub(utils, 'getWindowLocation').returns({search: '?' +
- 'utm_campaign=test-campaign-name&' +
+ 'utm_campaign=test%20campaign-name&' +
'utm_source=test-source&' +
'utm_medium=test-medium&'
});
@@ -348,7 +350,8 @@ describe('openx analytics adapter', function() {
clock.tick(SLOT_LOAD_WAIT_TIME);
auction = JSON.parse(server.requests[0].requestBody)[0];
- expect(auction.campaign.name).to.equal('test-campaign-name');
+ // ensure that value are URI decoded
+ expect(auction.campaign.name).to.equal('test campaign-name');
expect(auction.campaign.source).to.equal('test-source');
expect(auction.campaign.medium).to.equal('test-medium');
expect(auction.campaign.content).to.be.undefined;
@@ -466,6 +469,11 @@ describe('openx analytics adapter', function() {
expect(openxBidRequest.timedOut).to.equal(true);
expect(closexBidRequest.timedOut).to.equal(true);
});
+
+ it('should track the timeout value ie timeLimit', function () {
+ expect(openxBidRequest.timeLimit).to.equal(2000);
+ expect(closexBidRequest.timeLimit).to.equal(1000);
+ });
});
describe('when there are bid responses', function () {
diff --git a/test/spec/modules/openxBidAdapter_spec.js b/test/spec/modules/openxBidAdapter_spec.js
index 0808d78c0aa..121f8e76a07 100644
--- a/test/spec/modules/openxBidAdapter_spec.js
+++ b/test/spec/modules/openxBidAdapter_spec.js
@@ -1043,7 +1043,7 @@ describe('OpenxAdapter', function () {
britepoolid: '1111-britepoolid',
criteoId: '1111-criteoId',
digitrustid: {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}},
- id5id: '1111-id5id',
+ id5id: {uid: '1111-id5id'},
idl_env: '1111-idl_env',
lipb: {lipbid: '1111-lipb'},
netId: 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg',
@@ -1096,6 +1096,9 @@ describe('OpenxAdapter', function () {
case 'parrableId':
userIdValue = EXAMPLE_DATA_BY_ATTR.parrableId.eid;
break;
+ case 'id5id':
+ userIdValue = EXAMPLE_DATA_BY_ATTR.id5id.uid;
+ break;
default:
userIdValue = EXAMPLE_DATA_BY_ATTR[userIdProviderKey];
}
diff --git a/test/spec/modules/ozoneBidAdapter_spec.js b/test/spec/modules/ozoneBidAdapter_spec.js
index f20e75dfedd..c1022608b4a 100644
--- a/test/spec/modules/ozoneBidAdapter_spec.js
+++ b/test/spec/modules/ozoneBidAdapter_spec.js
@@ -66,7 +66,7 @@ var validBidRequestsWithUserIdData = [
params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], lotameData: {'Profile': {'tpid': 'c8ef27a0d4ba771a81159f0d2e792db4', 'Audiences': {'Audience': [{'id': '99999', 'abbr': 'sports'}, {'id': '88888', 'abbr': 'movie'}, {'id': '77777', 'abbr': 'blogger'}]}}}, placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] },
sizes: [[300, 250], [300, 600]],
transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87',
- userId: {'pubcid': '12345678', 'id5id': 'ID5-someId', 'criteortus': {'ozone': {'userid': 'critId123'}}, 'idl_env': 'liverampId', 'lipb': {'lipbid': 'lipbidId123'}, 'parrableId': {eid: 'parrableid123'}}
+ userId: {'pubcid': '12345678', 'id5id': { 'uid': 'ID5-someId' }, 'criteortus': {'ozone': {'userid': 'critId123'}}, 'idl_env': 'liverampId', 'lipb': {'lipbid': 'lipbidId123'}, 'parrableId': {eid: 'parrableid123'}}
}
];
var validBidRequestsMinimal = [
@@ -297,7 +297,7 @@ var validBidderRequest1OutstreamVideo2020 = {
}
},
'userId': {
- 'id5id': 'ID5-ZHMOpSv9CkZNiNd1oR4zc62AzCgSS73fPjmQ6Od7OA',
+ 'id5id': { uid: 'ID5-ZHMOpSv9CkZNiNd1oR4zc62AzCgSS73fPjmQ6Od7OA' },
'pubcid': '2ada6ae6-aeca-4e07-8922-a99b3aaf8a56'
},
'userIdAsEids': [
@@ -2118,7 +2118,7 @@ describe('ozone Adapter', function () {
bidRequests[0]['userId'] = {
'criteortus': '1111',
'digitrustid': {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}},
- 'id5id': '2222',
+ 'id5id': {'uid': '2222'},
'idl_env': '3333',
'lipb': {'lipbid': '4444'},
'parrableId': {eid: 'eidVersion.encryptionKeyReference.encryptedValue'},
@@ -2138,7 +2138,7 @@ describe('ozone Adapter', function () {
bidRequests[0]['userId'] = {
'criteortus': '1111',
'digitrustid': {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}},
- 'id5id': '2222',
+ 'id5id': {'uid': '2222'},
'idl_env': '3333',
'lipb': {'lipbid': '4444'},
'parrableId': {eid: 'eidVersion.encryptionKeyReference.encryptedValue'},
diff --git a/test/spec/modules/parrableIdSystem_spec.js b/test/spec/modules/parrableIdSystem_spec.js
index 1cc89240bc3..5e62af9b2fa 100644
--- a/test/spec/modules/parrableIdSystem_spec.js
+++ b/test/spec/modules/parrableIdSystem_spec.js
@@ -92,7 +92,7 @@ describe('Parrable ID System', function() {
})
it('creates xhr to Parrable that synchronizes the ID', function() {
- let getIdResult = parrableIdSubmodule.getId(P_CONFIG_MOCK.params);
+ let getIdResult = parrableIdSubmodule.getId(P_CONFIG_MOCK);
getIdResult.callback(callbackSpy);
@@ -128,7 +128,7 @@ describe('Parrable ID System', function() {
let uspString = '1YNN';
uspDataHandler.setConsentData(uspString);
parrableIdSubmodule.getId(
- P_CONFIG_MOCK.params,
+ P_CONFIG_MOCK,
null,
null
).callback(callbackSpy);
@@ -138,7 +138,7 @@ describe('Parrable ID System', function() {
it('should log an error and continue to callback if ajax request errors', function () {
let callBackSpy = sinon.spy();
- let submoduleCallback = parrableIdSubmodule.getId({partner: 'prebid'}).callback;
+ let submoduleCallback = parrableIdSubmodule.getId({ params: {partner: 'prebid'} }).callback;
submoduleCallback(callBackSpy);
let request = server.requests[0];
expect(request.url).to.contain('h.parrable.com');
@@ -155,7 +155,7 @@ describe('Parrable ID System', function() {
describe('response id', function() {
it('provides the stored Parrable values if a cookie exists', function() {
writeParrableCookie({ eid: P_COOKIE_EID });
- let getIdResult = parrableIdSubmodule.getId(P_CONFIG_MOCK.params);
+ let getIdResult = parrableIdSubmodule.getId(P_CONFIG_MOCK);
removeParrableCookie();
expect(getIdResult.id).to.deep.equal({
@@ -171,7 +171,7 @@ describe('Parrable ID System', function() {
storage.setCookie(oldEidCookieName, oldEid);
storage.setCookie(oldOptoutCookieName, 'true');
- let getIdResult = parrableIdSubmodule.getId(P_CONFIG_MOCK.params);
+ let getIdResult = parrableIdSubmodule.getId(P_CONFIG_MOCK);
expect(getIdResult.id).to.deep.equal({
eid: oldEid,
ibaOptout: true
@@ -212,9 +212,9 @@ describe('Parrable ID System', function() {
});
it('permits an impression when no timezoneFilter is configured', function() {
- expect(parrableIdSubmodule.getId({
+ expect(parrableIdSubmodule.getId({ params: {
partner: 'prebid-test',
- })).to.have.property('callback');
+ } })).to.have.property('callback');
});
it('permits an impression from a blocked timezone when a cookie exists', function() {
@@ -224,12 +224,12 @@ describe('Parrable ID System', function() {
writeParrableCookie({ eid: P_COOKIE_EID });
- expect(parrableIdSubmodule.getId({
+ expect(parrableIdSubmodule.getId({ params: {
partner: 'prebid-test',
timezoneFilter: {
blockedZones: [ blockedZone ]
}
- })).to.have.property('callback');
+ } })).to.have.property('callback');
expect(resolvedOptions.called).to.equal(false);
removeParrableCookie();
@@ -240,12 +240,12 @@ describe('Parrable ID System', function() {
const resolvedOptions = sinon.stub().returns({ timeZone: allowedZone });
Intl.DateTimeFormat.returns({ resolvedOptions });
- expect(parrableIdSubmodule.getId({
+ expect(parrableIdSubmodule.getId({ params: {
partner: 'prebid-test',
timezoneFilter: {
allowedZones: [ allowedZone ]
}
- })).to.have.property('callback');
+ } })).to.have.property('callback');
expect(resolvedOptions.called).to.equal(true);
});
@@ -254,12 +254,12 @@ describe('Parrable ID System', function() {
const resolvedOptions = sinon.stub().returns({ timeZone: 'Iceland' });
Intl.DateTimeFormat.returns({ resolvedOptions });
- expect(parrableIdSubmodule.getId({
+ expect(parrableIdSubmodule.getId({ params: {
partner: 'prebid-test',
timezoneFilter: {
blockedZones: [ blockedZone ]
}
- })).to.have.property('callback');
+ } })).to.have.property('callback');
expect(resolvedOptions.called).to.equal(true);
});
@@ -268,12 +268,12 @@ describe('Parrable ID System', function() {
const resolvedOptions = sinon.stub().returns({ timeZone: blockedZone });
Intl.DateTimeFormat.returns({ resolvedOptions });
- expect(parrableIdSubmodule.getId({
+ expect(parrableIdSubmodule.getId({ params: {
partner: 'prebid-test',
timezoneFilter: {
blockedZones: [ blockedZone ]
}
- })).to.equal(null);
+ } })).to.equal(null);
expect(resolvedOptions.called).to.equal(true);
});
@@ -282,13 +282,13 @@ describe('Parrable ID System', function() {
const resolvedOptions = sinon.stub().returns({ timeZone: timezone });
Intl.DateTimeFormat.returns({ resolvedOptions });
- expect(parrableIdSubmodule.getId({
+ expect(parrableIdSubmodule.getId({ params: {
partner: 'prebid-test',
timezoneFilter: {
allowedZones: [ timezone ],
blockedZones: [ timezone ]
}
- })).to.equal(null);
+ } })).to.equal(null);
expect(resolvedOptions.called).to.equal(true);
});
});
@@ -312,12 +312,12 @@ describe('Parrable ID System', function() {
writeParrableCookie({ eid: P_COOKIE_EID });
- expect(parrableIdSubmodule.getId({
+ expect(parrableIdSubmodule.getId({ params: {
partner: 'prebid-test',
timezoneFilter: {
blockedOffsets: [ blockedOffset ]
}
- })).to.have.property('callback');
+ } })).to.have.property('callback');
removeParrableCookie();
});
@@ -326,12 +326,12 @@ describe('Parrable ID System', function() {
const allowedOffset = -5;
Date.prototype.getTimezoneOffset.returns(allowedOffset * 60);
- expect(parrableIdSubmodule.getId({
+ expect(parrableIdSubmodule.getId({ params: {
partner: 'prebid-test',
timezoneFilter: {
allowedOffsets: [ allowedOffset ]
}
- })).to.have.property('callback');
+ } })).to.have.property('callback');
expect(Date.prototype.getTimezoneOffset.called).to.equal(true);
});
@@ -340,12 +340,12 @@ describe('Parrable ID System', function() {
const blockedOffset = 5;
Date.prototype.getTimezoneOffset.returns(allowedOffset * 60);
- expect(parrableIdSubmodule.getId({
+ expect(parrableIdSubmodule.getId({ params: {
partner: 'prebid-test',
timezoneFilter: {
blockedOffsets: [ blockedOffset ]
}
- })).to.have.property('callback');
+ }})).to.have.property('callback');
expect(Date.prototype.getTimezoneOffset.called).to.equal(true);
});
@@ -353,12 +353,12 @@ describe('Parrable ID System', function() {
const blockedOffset = -5;
Date.prototype.getTimezoneOffset.returns(blockedOffset * 60);
- expect(parrableIdSubmodule.getId({
+ expect(parrableIdSubmodule.getId({ params: {
partner: 'prebid-test',
timezoneFilter: {
blockedOffsets: [ blockedOffset ]
}
- })).to.equal(null);
+ } })).to.equal(null);
expect(Date.prototype.getTimezoneOffset.called).to.equal(true);
});
@@ -366,13 +366,13 @@ describe('Parrable ID System', function() {
const offset = -5;
Date.prototype.getTimezoneOffset.returns(offset * 60);
- expect(parrableIdSubmodule.getId({
+ expect(parrableIdSubmodule.getId({ params: {
partner: 'prebid-test',
timezoneFilter: {
allowedOffset: [ offset ],
blockedOffsets: [ offset ]
}
- })).to.equal(null);
+ } })).to.equal(null);
expect(Date.prototype.getTimezoneOffset.called).to.equal(true);
});
});
diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js
index d6f755914e5..d069bb74944 100644
--- a/test/spec/modules/prebidServerBidAdapter_spec.js
+++ b/test/spec/modules/prebidServerBidAdapter_spec.js
@@ -1178,7 +1178,13 @@ describe('S2S Adapter', function () {
lipbid: 'li-xyz',
segments: ['segA', 'segB']
},
- idl_env: '0000-1111-2222-3333'
+ idl_env: '0000-1111-2222-3333',
+ id5id: {
+ uid: '11111',
+ ext: {
+ linkType: 'some-link-type'
+ }
+ }
};
userIdBidRequest[0].bids[0].userIdAsEids = createEidsArray(userIdBidRequest[0].bids[0].userId);
@@ -1199,6 +1205,9 @@ describe('S2S Adapter', function () {
expect(requestBid.user.ext.eids.filter(eid => eid.source === 'liveintent.com')[0].ext.segments.length).is.equal(2);
expect(requestBid.user.ext.eids.filter(eid => eid.source === 'liveintent.com')[0].ext.segments[0]).is.equal('segA');
expect(requestBid.user.ext.eids.filter(eid => eid.source === 'liveintent.com')[0].ext.segments[1]).is.equal('segB');
+ expect(requestBid.user.ext.eids.filter(eid => eid.source === 'id5-sync.com')).is.not.empty;
+ expect(requestBid.user.ext.eids.filter(eid => eid.source === 'id5-sync.com')[0].uids[0].id).is.equal('11111');
+ expect(requestBid.user.ext.eids.filter(eid => eid.source === 'id5-sync.com')[0].ext.linkType).is.equal('some-link-type');
// LiveRamp should exist
expect(requestBid.user.ext.eids.filter(eid => eid.source === 'liveramp.com')[0].uids[0].id).is.equal('0000-1111-2222-3333');
});
diff --git a/test/spec/modules/pubmaticAnalyticsAdapter_spec.js b/test/spec/modules/pubmaticAnalyticsAdapter_spec.js
index 537ba4483cf..d38037f40a1 100755
--- a/test/spec/modules/pubmaticAnalyticsAdapter_spec.js
+++ b/test/spec/modules/pubmaticAnalyticsAdapter_spec.js
@@ -316,7 +316,7 @@ describe('pubmatic analytics adapter', function () {
clock.tick(2000 + 1000);
expect(requests.length).to.equal(3); // 1 logger and 2 win-tracker
let request = requests[2]; // logger is executed late, trackers execute first
- expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999&gdEn=1');
+ expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999');
let data = getLoggerJsonFromRequest(request.requestBody);
expect(data.pubid).to.equal('9999');
expect(data.pid).to.equal('1111');
@@ -326,8 +326,6 @@ describe('pubmatic analytics adapter', function () {
expect(data.purl).to.equal('http://www.test.com/page.html');
expect(data.orig).to.equal('www.test.com');
expect(data.tst).to.equal(1519767016);
- expect(data.cns).to.equal('here-goes-gdpr-consent-string');
- expect(data.gdpr).to.equal(1);
expect(data.tgid).to.equal(15);
expect(data.s).to.be.an('array');
expect(data.s.length).to.equal(2);
@@ -423,7 +421,7 @@ describe('pubmatic analytics adapter', function () {
clock.tick(2000 + 1000);
expect(requests.length).to.equal(3); // 1 logger and 2 win-tracker
let request = requests[2]; // logger is executed late, trackers execute first
- expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999&gdEn=1');
+ expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999');
let data = getLoggerJsonFromRequest(request.requestBody);
expect(data.pubid).to.equal('9999');
expect(data.pid).to.equal('1111');
@@ -490,7 +488,7 @@ describe('pubmatic analytics adapter', function () {
clock.tick(2000 + 1000);
expect(requests.length).to.equal(3); // 1 logger and 2 win-tracker
let request = requests[2]; // logger is executed late, trackers execute first
- expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999&gdEn=1');
+ expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999');
let data = getLoggerJsonFromRequest(request.requestBody);
expect(data.pubid).to.equal('9999');
expect(data.pid).to.equal('1111');
@@ -672,7 +670,7 @@ describe('pubmatic analytics adapter', function () {
clock.tick(2000 + 1000);
expect(requests.length).to.equal(3); // 1 logger and 2 win-tracker
let request = requests[2]; // logger is executed late, trackers execute first
- expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999&gdEn=1');
+ expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999');
let data = getLoggerJsonFromRequest(request.requestBody);
expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1');
expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']);
diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js
index 0f51a8df61c..37deb0bca9c 100644
--- a/test/spec/modules/pubmaticBidAdapter_spec.js
+++ b/test/spec/modules/pubmaticBidAdapter_spec.js
@@ -796,18 +796,24 @@ describe('PubMatic adapter', function () {
describe('Request formation', function () {
it('buildRequests function should not modify original bidRequests object', function () {
let originalBidRequests = utils.deepClone(bidRequests);
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
expect(bidRequests).to.deep.equal(originalBidRequests);
});
it('buildRequests function should not modify original nativebidRequests object', function () {
let originalBidRequests = utils.deepClone(nativeBidRequests);
- let request = spec.buildRequests(nativeBidRequests);
+ let request = spec.buildRequests(nativeBidRequests, {
+ auctionId: 'new-auction-id'
+ });
expect(nativeBidRequests).to.deep.equal(originalBidRequests);
});
it('Endpoint checking', function () {
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
expect(request.url).to.equal('https://hbopenbid.pubmatic.com/translator?source=prebid-client');
expect(request.method).to.equal('POST');
});
@@ -823,7 +829,9 @@ describe('PubMatic adapter', function () {
});
it('test flag not sent when pubmaticTest=true is absent in page url', function() {
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.test).to.equal(undefined);
});
@@ -833,13 +841,17 @@ describe('PubMatic adapter', function () {
xit('test flag set to 1 when pubmaticTest=true is present in page url', function() {
window.location.href += '#pubmaticTest=true';
// now all the test cases below will have window.location.href with #pubmaticTest=true
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.test).to.equal(1);
});
it('Request params check', function () {
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.at).to.equal(1); // auction type
expect(data.cur[0]).to.equal('USD'); // currency
@@ -882,7 +894,9 @@ describe('PubMatic adapter', function () {
};
return config[key];
});
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.site.content).to.deep.equal(content);
sandbox.restore();
@@ -898,7 +912,9 @@ describe('PubMatic adapter', function () {
};
return config[key];
});
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.device.js).to.equal(1);
expect(data.device.dnt).to.equal((navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0);
@@ -920,7 +936,9 @@ describe('PubMatic adapter', function () {
};
return config[key];
});
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.device.js).to.equal(1);
expect(data.device.dnt).to.equal((navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0);
@@ -942,7 +960,9 @@ describe('PubMatic adapter', function () {
};
return config[key];
});
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.app.bundle).to.equal('org.prebid.mobile.demoapp');
expect(data.app.domain).to.equal('prebid.org');
@@ -967,7 +987,9 @@ describe('PubMatic adapter', function () {
};
return config[key];
});
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.app.bundle).to.equal('org.prebid.mobile.demoapp');
expect(data.app.domain).to.equal('prebid.org');
@@ -997,7 +1019,9 @@ describe('PubMatic adapter', function () {
};
return config[key];
});
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.app.bundle).to.equal('org.prebid.mobile.demoapp');
expect(data.app.domain).to.equal('prebid.org');
@@ -1010,7 +1034,9 @@ describe('PubMatic adapter', function () {
it('Request params check: without adSlot', function () {
delete bidRequests[0].params.adSlot;
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.at).to.equal(1); // auction type
expect(data.cur[0]).to.equal('USD'); // currency
@@ -1068,7 +1094,9 @@ describe('PubMatic adapter', function () {
}
];
/* case 1 - size passed in adslot */
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.imp[0].banner.w).to.equal(300); // width
@@ -1081,7 +1109,9 @@ describe('PubMatic adapter', function () {
sizes: [[300, 600], [300, 250]]
}
};
- request = spec.buildRequests(bidRequests);
+ request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
data = JSON.parse(request.data);
expect(data.imp[0].banner.w).to.equal(300); // width
@@ -1095,7 +1125,9 @@ describe('PubMatic adapter', function () {
sizes: [[300, 250], [300, 600]]
}
};
- request = spec.buildRequests(bidRequests);
+ request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
data = JSON.parse(request.data);
expect(data.imp[0].banner.w).to.equal(300); // width
@@ -1163,7 +1195,9 @@ describe('PubMatic adapter', function () {
output: imp[0] and imp[1] both use currency specified in bidRequests[0].params.currency
*/
- let request = spec.buildRequests(multipleBidRequests);
+ let request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency);
@@ -1175,7 +1209,9 @@ describe('PubMatic adapter', function () {
*/
delete multipleBidRequests[1].params.currency;
- request = spec.buildRequests(multipleBidRequests);
+ request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
data = JSON.parse(request.data);
expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency);
expect(data.imp[1].bidfloorcur).to.equal(bidRequests[0].params.currency);
@@ -1186,7 +1222,9 @@ describe('PubMatic adapter', function () {
*/
delete multipleBidRequests[0].params.currency;
- request = spec.buildRequests(multipleBidRequests);
+ request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
data = JSON.parse(request.data);
expect(data.imp[0].bidfloorcur).to.equal('USD');
expect(data.imp[1].bidfloorcur).to.equal('USD');
@@ -1197,12 +1235,46 @@ describe('PubMatic adapter', function () {
*/
multipleBidRequests[1].params.currency = 'AUD';
- request = spec.buildRequests(multipleBidRequests);
+ request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
data = JSON.parse(request.data);
expect(data.imp[0].bidfloorcur).to.equal('USD');
expect(data.imp[1].bidfloorcur).to.equal('USD');
});
+ it('Pass auctiondId as wiid if wiid is not passed in params', function () {
+ let bidRequest = {
+ auctionId: 'new-auction-id'
+ };
+ delete bidRequests[0].params.wiid;
+ let request = spec.buildRequests(bidRequests, bidRequest);
+ let data = JSON.parse(request.data);
+ expect(data.at).to.equal(1); // auction type
+ expect(data.cur[0]).to.equal('USD'); // currency
+ expect(data.site.domain).to.be.a('string'); // domain should be set
+ expect(data.site.page).to.equal(bidRequests[0].params.kadpageurl); // forced pageURL
+ expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id
+ expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB
+ expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender
+ expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
+ expect(data.device.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
+ expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude
+ expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude
+ expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version
+ expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId
+ expect(data.ext.wrapper.wiid).to.equal('new-auction-id'); // OpenWrap: Wrapper Impression ID
+ expect(data.ext.wrapper.profile).to.equal(parseInt(bidRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID
+ expect(data.ext.wrapper.version).to.equal(parseInt(bidRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID
+
+ 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].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
+ });
+
it('Request params check with GDPR Consent', function () {
let bidRequest = {
gdprConsent: {
@@ -1311,7 +1383,9 @@ describe('PubMatic adapter', function () {
it('bidfloor should be undefined if calculation is <= 0', function() {
floorModuleTestData.banner.floor = 0; // lowest of them all
newRequest[0].params.kadfloor = undefined;
- let request = spec.buildRequests(newRequest);
+ let request = spec.buildRequests(newRequest, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data = data.imp[0];
expect(data.bidfloor).to.equal(undefined);
@@ -1320,7 +1394,9 @@ describe('PubMatic adapter', function () {
it('ignore floormodule o/p if floor is not number', function() {
floorModuleTestData.banner.floor = 'INR';
newRequest[0].params.kadfloor = undefined;
- let request = spec.buildRequests(newRequest);
+ let request = spec.buildRequests(newRequest, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data = data.imp[0];
expect(data.bidfloor).to.equal(2.5); // video will be lowest now
@@ -1329,7 +1405,9 @@ describe('PubMatic adapter', function () {
it('ignore floormodule o/p if currency is not matched', function() {
floorModuleTestData.banner.currency = 'INR';
newRequest[0].params.kadfloor = undefined;
- let request = spec.buildRequests(newRequest);
+ let request = spec.buildRequests(newRequest, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data = data.imp[0];
expect(data.bidfloor).to.equal(2.5); // video will be lowest now
@@ -1337,7 +1415,9 @@ describe('PubMatic adapter', function () {
it('kadfloor is not passed, use minimum from floorModule', function() {
newRequest[0].params.kadfloor = undefined;
- let request = spec.buildRequests(newRequest);
+ let request = spec.buildRequests(newRequest, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data = data.imp[0];
expect(data.bidfloor).to.equal(1.5);
@@ -1345,7 +1425,9 @@ describe('PubMatic adapter', function () {
it('kadfloor is passed as 3, use kadfloor as it is highest', function() {
newRequest[0].params.kadfloor = '3.0';// yes, we want it as a string
- let request = spec.buildRequests(newRequest);
+ let request = spec.buildRequests(newRequest, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data = data.imp[0];
expect(data.bidfloor).to.equal(3);
@@ -1353,7 +1435,9 @@ describe('PubMatic adapter', function () {
it('kadfloor is passed as 1, use min of fllorModule as it is highest', function() {
newRequest[0].params.kadfloor = '1.0';// yes, we want it as a string
- let request = spec.buildRequests(newRequest);
+ let request = spec.buildRequests(newRequest, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data = data.imp[0];
expect(data.bidfloor).to.equal(1.5);
@@ -1521,7 +1605,7 @@ describe('PubMatic adapter', function () {
describe('ID5 Id', function() {
it('send the id5 id if it is present', function() {
bidRequests[0].userId = {};
- bidRequests[0].userId.id5id = 'id5-user-id';
+ bidRequests[0].userId.id5id = { uid: 'id5-user-id' };
bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId);
let request = spec.buildRequests(bidRequests, {});
let data = JSON.parse(request.data);
@@ -1536,22 +1620,22 @@ describe('PubMatic adapter', function () {
it('do not pass if not string', function() {
bidRequests[0].userId = {};
- bidRequests[0].userId.id5id = 1;
+ bidRequests[0].userId.id5id = { uid: 1 };
bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId);
let request = spec.buildRequests(bidRequests, {});
let data = JSON.parse(request.data);
expect(data.user.eids).to.equal(undefined);
- bidRequests[0].userId.id5id = [];
+ bidRequests[0].userId.id5id = { uid: [] };
bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId);
request = spec.buildRequests(bidRequests, {});
data = JSON.parse(request.data);
expect(data.user.eids).to.equal(undefined);
- bidRequests[0].userId.id5id = null;
+ bidRequests[0].userId.id5id = { uid: null };
bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId);
request = spec.buildRequests(bidRequests, {});
data = JSON.parse(request.data);
expect(data.user.eids).to.equal(undefined);
- bidRequests[0].userId.id5id = {};
+ bidRequests[0].userId.id5id = { uid: {} };
bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId);
request = spec.buildRequests(bidRequests, {});
data = JSON.parse(request.data);
@@ -1807,7 +1891,9 @@ describe('PubMatic adapter', function () {
});
it('Request params check for video ad', function () {
- let request = spec.buildRequests(videoBidRequests);
+ let request = spec.buildRequests(videoBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.imp[0].video).to.exist;
expect(data.imp[0].tagid).to.equal('Div1');
@@ -1845,7 +1931,9 @@ describe('PubMatic adapter', function () {
});
it('Request params check for 1 banner and 1 video ad', function () {
- let request = spec.buildRequests(multipleMediaRequests);
+ let request = spec.buildRequests(multipleMediaRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.imp).to.be.an('array')
@@ -1913,7 +2001,9 @@ describe('PubMatic adapter', function () {
});
it('Request params should have valid native bid request for all valid params', function () {
- let request = spec.buildRequests(nativeBidRequests);
+ let request = spec.buildRequests(nativeBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.imp[0].native).to.exist;
expect(data.imp[0].native['request']).to.exist;
@@ -1923,13 +2013,17 @@ describe('PubMatic adapter', function () {
});
it('Request params should not have valid native bid request for non native request', function () {
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.imp[0].native).to.not.exist;
});
it('Request params should have valid native bid request with valid required param values for all valid params', function () {
- let request = spec.buildRequests(nativeBidRequestsWithRequiredParam);
+ let request = spec.buildRequests(nativeBidRequestsWithRequiredParam, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.imp[0].native).to.exist;
expect(data.imp[0].native['request']).to.exist;
@@ -1939,12 +2033,16 @@ describe('PubMatic adapter', function () {
});
it('should not have valid native request if assets are not defined with minimum required params and only native is the slot', function () {
- let request = spec.buildRequests(nativeBidRequestsWithoutAsset);
+ let request = spec.buildRequests(nativeBidRequestsWithoutAsset, {
+ auctionId: 'new-auction-id'
+ });
expect(request).to.deep.equal(undefined);
});
it('Request params should have valid native bid request for all native params', function () {
- let request = spec.buildRequests(nativeBidRequestsWithAllParams);
+ let request = spec.buildRequests(nativeBidRequestsWithAllParams, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.imp[0].native).to.exist;
expect(data.imp[0].native['request']).to.exist;
@@ -1954,7 +2052,9 @@ describe('PubMatic adapter', function () {
});
it('Request params - should handle banner and video format in single adunit', function() {
- let request = spec.buildRequests(bannerAndVideoBidRequests);
+ let request = spec.buildRequests(bannerAndVideoBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data = data.imp[0];
expect(data.banner).to.exist;
@@ -1965,7 +2065,9 @@ describe('PubMatic adapter', function () {
// Case: when size is not present in adslo
bannerAndVideoBidRequests[0].params.adSlot = '/15671365/DMDemo';
- request = spec.buildRequests(bannerAndVideoBidRequests);
+ request = spec.buildRequests(bannerAndVideoBidRequests, {
+ auctionId: 'new-auction-id'
+ });
data = JSON.parse(request.data);
data = data.imp[0];
expect(data.banner).to.exist;
@@ -1987,7 +2089,9 @@ describe('PubMatic adapter', function () {
*/
bannerAndVideoBidRequests[0].mediaTypes.banner.sizes = [['fluid'], [160, 600]];
- let request = spec.buildRequests(bannerAndVideoBidRequests);
+ let request = spec.buildRequests(bannerAndVideoBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data = data.imp[0];
@@ -2006,7 +2110,9 @@ describe('PubMatic adapter', function () {
bannerAndVideoBidRequests[0].mediaTypes.banner.sizes = [['fluid'], [160, 600]];
bannerAndVideoBidRequests[0].params.adSlot = '/15671365/DMDemo';
- request = spec.buildRequests(bannerAndVideoBidRequests);
+ request = spec.buildRequests(bannerAndVideoBidRequests, {
+ auctionId: 'new-auction-id'
+ });
data = JSON.parse(request.data);
data = data.imp[0];
@@ -2024,7 +2130,9 @@ describe('PubMatic adapter', function () {
*/
bannerAndVideoBidRequests[0].mediaTypes.banner.sizes = [[728, 90], ['fluid'], [300, 250]];
- request = spec.buildRequests(bannerAndVideoBidRequests);
+ request = spec.buildRequests(bannerAndVideoBidRequests, {
+ auctionId: 'new-auction-id'
+ });
data = JSON.parse(request.data);
data = data.imp[0];
@@ -2042,7 +2150,9 @@ describe('PubMatic adapter', function () {
*/
bannerAndVideoBidRequests[0].mediaTypes.banner.sizes = [['fluid']];
- request = spec.buildRequests(bannerAndVideoBidRequests);
+ request = spec.buildRequests(bannerAndVideoBidRequests, {
+ auctionId: 'new-auction-id'
+ });
data = JSON.parse(request.data);
data = data.imp[0];
@@ -2054,14 +2164,18 @@ describe('PubMatic adapter', function () {
delete bannerAndVideoBidRequests[0].mediaTypes.banner;
bannerAndVideoBidRequests[0].params.sizes = [300, 250];
- let request = spec.buildRequests(bannerAndVideoBidRequests);
+ let request = spec.buildRequests(bannerAndVideoBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data = data.imp[0];
expect(data.banner).to.not.exist;
});
it('Request params - should handle banner and native format in single adunit', function() {
- let request = spec.buildRequests(bannerAndNativeBidRequests);
+ let request = spec.buildRequests(bannerAndNativeBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data = data.imp[0];
@@ -2076,7 +2190,9 @@ describe('PubMatic adapter', function () {
});
it('Request params - should handle video and native format in single adunit', function() {
- let request = spec.buildRequests(videoAndNativeBidRequests);
+ let request = spec.buildRequests(videoAndNativeBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data = data.imp[0];
@@ -2089,7 +2205,9 @@ describe('PubMatic adapter', function () {
});
it('Request params - should handle banner, video and native format in single adunit', function() {
- let request = spec.buildRequests(bannerVideoAndNativeBidRequests);
+ let request = spec.buildRequests(bannerVideoAndNativeBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data = data.imp[0];
@@ -2111,7 +2229,9 @@ describe('PubMatic adapter', function () {
delete bannerAndNativeBidRequests[0].mediaTypes.banner;
bannerAndNativeBidRequests[0].sizes = [729, 90];
- let request = spec.buildRequests(bannerAndNativeBidRequests);
+ let request = spec.buildRequests(bannerAndNativeBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data = data.imp[0];
@@ -2134,7 +2254,9 @@ describe('PubMatic adapter', function () {
sponsoredBy: { required: true },
clickUrl: { required: true }
}
- let request = spec.buildRequests(bannerAndNativeBidRequests);
+ let request = spec.buildRequests(bannerAndNativeBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data = data.imp[0];
@@ -2155,7 +2277,9 @@ describe('PubMatic adapter', function () {
sponsoredBy: { required: true },
clickUrl: { required: true }
}
- let request = spec.buildRequests(videoAndNativeBidRequests);
+ let request = spec.buildRequests(videoAndNativeBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data = data.imp[0];
@@ -2218,7 +2342,9 @@ describe('PubMatic adapter', function () {
}
];
- let request = spec.buildRequests(multipleBidRequests);
+ let request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
/* case 1 -
@@ -2232,7 +2358,9 @@ describe('PubMatic adapter', function () {
dctr not present in adunit[0]
*/
delete multipleBidRequests[0].params.dctr;
- request = spec.buildRequests(multipleBidRequests);
+ request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
data = JSON.parse(request.data);
expect(data.site.ext).to.not.exist;
@@ -2241,7 +2369,9 @@ describe('PubMatic adapter', function () {
dctr is present in adunit[0], but is not a string value
*/
multipleBidRequests[0].params.dctr = 123;
- request = spec.buildRequests(multipleBidRequests);
+ request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
data = JSON.parse(request.data);
expect(data.site.ext).to.not.exist;
@@ -2301,7 +2431,9 @@ describe('PubMatic adapter', function () {
}
];
- let request = spec.buildRequests(multipleBidRequests);
+ let request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
// case 1 - deals are passed as expected, ['', ''] , in both adUnits
expect(data.imp[0].pmp).to.deep.equal({
@@ -2329,19 +2461,25 @@ describe('PubMatic adapter', function () {
// case 2 - deals not present in adunit[0]
delete multipleBidRequests[0].params.deals;
- request = spec.buildRequests(multipleBidRequests);
+ request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
data = JSON.parse(request.data);
expect(data.imp[0].pmp).to.not.exist;
// case 3 - deals is present in adunit[0], but is not an array
multipleBidRequests[0].params.deals = 123;
- request = spec.buildRequests(multipleBidRequests);
+ request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
data = JSON.parse(request.data);
expect(data.imp[0].pmp).to.not.exist;
// case 4 - deals is present in adunit[0] as an array but one of the value is not a string
multipleBidRequests[0].params.deals = [123, 'deal-id-1'];
- request = spec.buildRequests(multipleBidRequests);
+ request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
data = JSON.parse(request.data);
expect(data.imp[0].pmp).to.deep.equal({
'private_auction': 0,
@@ -2409,21 +2547,27 @@ describe('PubMatic adapter', function () {
it('bcat: pass only strings', function() {
multipleBidRequests[0].params.bcat = [1, 2, 3, 'IAB1', 'IAB2'];
- let request = spec.buildRequests(multipleBidRequests);
+ let request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.bcat).to.exist.and.to.deep.equal(['IAB1', 'IAB2']);
});
it('bcat: pass strings with length greater than 3', function() {
multipleBidRequests[0].params.bcat = ['AB', 'CD', 'IAB1', 'IAB2'];
- let request = spec.buildRequests(multipleBidRequests);
+ let request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.bcat).to.exist.and.to.deep.equal(['IAB1', 'IAB2']);
});
it('bcat: trim the strings', function() {
multipleBidRequests[0].params.bcat = [' IAB1 ', ' IAB2 '];
- let request = spec.buildRequests(multipleBidRequests);
+ let request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.bcat).to.exist.and.to.deep.equal(['IAB1', 'IAB2']);
});
@@ -2432,7 +2576,9 @@ describe('PubMatic adapter', function () {
// multi slot
multipleBidRequests[0].params.bcat = ['IAB1', 'IAB2', 'IAB1', 'IAB2', 'IAB1', 'IAB2'];
multipleBidRequests[1].params.bcat = ['IAB1', 'IAB2', 'IAB1', 'IAB2', 'IAB1', 'IAB3'];
- let request = spec.buildRequests(multipleBidRequests);
+ let request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.bcat).to.exist.and.to.deep.equal(['IAB1', 'IAB2', 'IAB3']);
});
@@ -2441,7 +2587,9 @@ describe('PubMatic adapter', function () {
// multi slot
multipleBidRequests[0].params.bcat = ['', 'IAB', 'IAB'];
multipleBidRequests[1].params.bcat = [' ', 22, 99999, 'IA'];
- let request = spec.buildRequests(multipleBidRequests);
+ let request = spec.buildRequests(multipleBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
expect(data.bcat).to.deep.equal(undefined);
});
@@ -2449,7 +2597,9 @@ describe('PubMatic adapter', function () {
describe('Response checking', function () {
it('should check for valid response values', function () {
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
let response = spec.interpretResponse(bidResponses, request);
expect(response).to.be.an('array').with.length.above(0);
@@ -2503,7 +2653,9 @@ describe('PubMatic adapter', function () {
});
it('should check for dealChannel value selection', function () {
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let response = spec.interpretResponse(bidResponses, request);
expect(response).to.be.an('array').with.length.above(0);
expect(response[0].dealChannel).to.equal('PMPG');
@@ -2511,7 +2663,9 @@ describe('PubMatic adapter', function () {
});
it('should check for unexpected dealChannel value selection', function () {
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let updateBiResponse = bidResponses;
updateBiResponse.body.seatbid[0].bid[0].ext.deal_channel = 11;
@@ -2522,7 +2676,9 @@ describe('PubMatic adapter', function () {
});
it('should have a valid native bid response', function() {
- let request = spec.buildRequests(nativeBidRequests);
+ let request = spec.buildRequests(nativeBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let data = JSON.parse(request.data);
data.imp[0].id = '2a5571261281d4';
request.data = JSON.stringify(data);
@@ -2540,20 +2696,26 @@ describe('PubMatic adapter', function () {
});
it('should check for valid banner mediaType in case of multiformat request', function() {
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let response = spec.interpretResponse(bannerBidResponse, request);
expect(response[0].mediaType).to.equal('banner');
});
it('should check for valid video mediaType in case of multiformat request', function() {
- let request = spec.buildRequests(videoBidRequests);
+ let request = spec.buildRequests(videoBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let response = spec.interpretResponse(videoBidResponse, request);
expect(response[0].mediaType).to.equal('video');
});
it('should check for valid native mediaType in case of multiformat request', function() {
- let request = spec.buildRequests(nativeBidRequests);
+ let request = spec.buildRequests(nativeBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let response = spec.interpretResponse(nativeBidResponse, request);
expect(response[0].mediaType).to.equal('native');
@@ -2566,25 +2728,33 @@ describe('PubMatic adapter', function () {
});
it('should not assign renderer if bidderRequest is not present', function() {
- let request = spec.buildRequests(outstreamBidRequest);
+ let request = spec.buildRequests(outstreamBidRequest, {
+ auctionId: 'new-auction-id'
+ });
let response = spec.interpretResponse(outstreamVideoBidResponse, request);
expect(response[0].renderer).to.not.exist;
});
it('should not assign renderer if bid is video and request is for instream', function() {
- let request = spec.buildRequests(videoBidRequests);
+ let request = spec.buildRequests(videoBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let response = spec.interpretResponse(videoBidResponse, request);
expect(response[0].renderer).to.not.exist;
});
it('should not assign renderer if bid is native', function() {
- let request = spec.buildRequests(nativeBidRequests);
+ let request = spec.buildRequests(nativeBidRequests, {
+ auctionId: 'new-auction-id'
+ });
let response = spec.interpretResponse(nativeBidResponse, request);
expect(response[0].renderer).to.not.exist;
});
it('should not assign renderer if bid is of banner', function() {
- let request = spec.buildRequests(bidRequests);
+ let request = spec.buildRequests(bidRequests, {
+ auctionId: 'new-auction-id'
+ });
let response = spec.interpretResponse(bidResponses, request);
expect(response[0].renderer).to.not.exist;
});
diff --git a/test/spec/modules/pulsepointBidAdapter_spec.js b/test/spec/modules/pulsepointBidAdapter_spec.js
index d71bd018ab3..a6f5ff2a0dc 100644
--- a/test/spec/modules/pulsepointBidAdapter_spec.js
+++ b/test/spec/modules/pulsepointBidAdapter_spec.js
@@ -630,7 +630,7 @@ describe('PulsePoint Adapter Tests', function () {
britepoolid: 'britepool_id123',
criteoId: 'criteo_id234',
idl_env: 'idl_id123',
- id5id: 'id5id_234',
+ id5id: { uid: 'id5id_234' },
parrableId: { eid: 'parrable_id234' },
lipb: {
lipbid: 'liveintent_id123'
diff --git a/test/spec/modules/quantcastIdSystem_spec.js b/test/spec/modules/quantcastIdSystem_spec.js
new file mode 100644
index 00000000000..12c8689fd3f
--- /dev/null
+++ b/test/spec/modules/quantcastIdSystem_spec.js
@@ -0,0 +1,19 @@
+import { quantcastIdSubmodule, storage } from 'modules/quantcastIdSystem.js';
+
+describe('QuantcastId module', function () {
+ beforeEach(function() {
+ storage.setCookie('__qca', '', 'Thu, 01 Jan 1970 00:00:00 GMT');
+ });
+
+ it('getId() should return a quantcast id when the Quantcast first party cookie exists', function () {
+ storage.setCookie('__qca', 'P0-TestFPA');
+
+ const id = quantcastIdSubmodule.getId();
+ expect(id).to.be.deep.equal({id: {quantcastId: 'P0-TestFPA'}});
+ });
+
+ it('getId() should return an empty id when the Quantcast first party cookie is missing', function () {
+ const id = quantcastIdSubmodule.getId();
+ expect(id).to.be.deep.equal({id: undefined});
+ });
+});
diff --git a/test/spec/modules/quantumdexBidAdapter_spec.js b/test/spec/modules/quantumdexBidAdapter_spec.js
index 82429cbedae..d1817493b36 100644
--- a/test/spec/modules/quantumdexBidAdapter_spec.js
+++ b/test/spec/modules/quantumdexBidAdapter_spec.js
@@ -244,7 +244,7 @@ describe('QuantumdexBidAdapter', function () {
const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/quantumdex')
expect(bidRequests.method).to.equal('POST')
- expect(bidRequests.data.gdpr.gdprApplies).to.equal('true')
+ expect(bidRequests.data.gdpr.gdprApplies).to.equal(true)
expect(bidRequests.data.gdpr.consentString).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==')
})
@@ -253,7 +253,7 @@ describe('QuantumdexBidAdapter', function () {
const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/quantumdex')
expect(bidRequests.method).to.equal('POST')
- expect(bidRequests.data.gdpr.gdprApplies).to.equal('false')
+ expect(bidRequests.data.gdpr.gdprApplies).to.equal(false)
expect(bidRequests.data.gdpr.consentString).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==')
})
it('should return a properly formatted request with GDPR applies set to false with no consent_string param', function () {
@@ -273,7 +273,7 @@ describe('QuantumdexBidAdapter', function () {
const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/quantumdex')
expect(bidRequests.method).to.equal('POST')
- expect(bidRequests.data.gdpr.gdprApplies).to.equal('false')
+ expect(bidRequests.data.gdpr.gdprApplies).to.equal(false)
expect(bidRequests.data.gdpr).to.not.include.keys('consentString')
})
it('should return a properly formatted request with GDPR applies set to true with no consentString param', function () {
@@ -293,12 +293,12 @@ describe('QuantumdexBidAdapter', function () {
const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/quantumdex')
expect(bidRequests.method).to.equal('POST')
- expect(bidRequests.data.gdpr.gdprApplies).to.equal('true')
+ expect(bidRequests.data.gdpr.gdprApplies).to.equal(true)
expect(bidRequests.data.gdpr).to.not.include.keys('consentString')
})
it('should return a properly formatted request with schain defined', function () {
const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
- expect(JSON.parse(bidRequests.data.schain)).to.deep.equal(bidRequest[0].schain)
+ expect(bidRequests.data.schain).to.deep.equal(bidRequest[0].schain)
});
it('should return a properly formatted request with us_privacy included', function () {
const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js
index f18e67a3ac5..1c710c46ea2 100644
--- a/test/spec/modules/richaudienceBidAdapter_spec.js
+++ b/test/spec/modules/richaudienceBidAdapter_spec.js
@@ -357,7 +357,7 @@ describe('Richaudience adapter tests', function () {
});
it('Verify build id5', function () {
DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {};
- DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = 'id5-user-id';
+ DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = { uid: 'id5-user-id' };
var request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR);
var requestContent = JSON.parse(request[0].data);
@@ -369,13 +369,23 @@ describe('Richaudience adapter tests', function () {
var request;
DEFAULT_PARAMS_WO_OPTIONAL[0].userId = {};
- DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = 1;
+ DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = { uid: 1 };
request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR);
var requestContent = JSON.parse(request[0].data);
expect(requestContent.user.eids).to.equal(undefined);
- DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = [];
+ DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = { uid: [] };
+ request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR);
+ requestContent = JSON.parse(request[0].data);
+ expect(requestContent.user.eids).to.equal(undefined);
+
+ DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = { uid: null };
+ request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR);
+ requestContent = JSON.parse(request[0].data);
+ expect(requestContent.user.eids).to.equal(undefined);
+
+ DEFAULT_PARAMS_WO_OPTIONAL[0].userId.id5id = { uid: {} };
request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, DEFAULT_PARAMS_GDPR);
requestContent = JSON.parse(request[0].data);
expect(requestContent.user.eids).to.equal(undefined);
diff --git a/test/spec/modules/rubiconAnalyticsAdapter_spec.js b/test/spec/modules/rubiconAnalyticsAdapter_spec.js
index 0c2c83a4b37..2bbab506b34 100644
--- a/test/spec/modules/rubiconAnalyticsAdapter_spec.js
+++ b/test/spec/modules/rubiconAnalyticsAdapter_spec.js
@@ -2,16 +2,17 @@ import rubiconAnalyticsAdapter, {
SEND_TIMEOUT,
parseBidResponse,
getHostNameFromReferer,
+ storage,
+ rubiConf,
} from 'modules/rubiconAnalyticsAdapter.js';
import CONSTANTS from 'src/constants.json';
import { config } from 'src/config.js';
import { server } from 'test/mocks/xhr.js';
-
+import * as mockGpt from '../integration/faker/googletag.js';
import {
setConfig,
addBidResponseHook,
} from 'modules/currency.js';
-
let Ajv = require('ajv');
let schema = require('./rubiconAnalyticsSchema.json');
let ajv = new Ajv({
@@ -272,11 +273,19 @@ const MOCK = {
]
};
+const STUBBED_UUID = '12345678-1234-1234-1234-123456789abc';
+
const ANALYTICS_MESSAGE = {
+ 'channel': 'web',
'eventTimeMillis': 1519767013781,
'integration': 'pbjs',
'version': '$prebid.version$',
'referrerUri': 'http://www.test.com/page.html',
+ 'session': {
+ 'expires': 1519788613781,
+ 'id': STUBBED_UUID,
+ 'start': 1519767013781
+ },
'referrerHostname': 'www.test.com',
'auctions': [
{
@@ -466,13 +475,18 @@ const ANALYTICS_MESSAGE = {
'wrapperName': '10000_fakewrapper_test'
};
-function performStandardAuction() {
+function performStandardAuction(gptEvents) {
events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);
events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]);
events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]);
events.emit(BIDDER_DONE, MOCK.BIDDER_DONE);
events.emit(AUCTION_END, MOCK.AUCTION_END);
+
+ if (gptEvents && gptEvents.length) {
+ gptEvents.forEach(gptEvent => mockGpt.emitEvent(gptEvent.eventName, gptEvent.params));
+ }
+
events.emit(SET_TARGETING, MOCK.SET_TARGETING);
events.emit(BID_WON, MOCK.BID_WON[0]);
events.emit(BID_WON, MOCK.BID_WON[1]);
@@ -481,12 +495,20 @@ function performStandardAuction() {
describe('rubicon analytics adapter', function () {
let sandbox;
let clock;
-
+ let getDataFromLocalStorageStub, setDataInLocalStorageStub, localStorageIsEnabledStub;
beforeEach(function () {
+ getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage');
+ setDataInLocalStorageStub = sinon.stub(storage, 'setDataInLocalStorage');
+ localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled');
+ mockGpt.disable();
sandbox = sinon.sandbox.create();
+ localStorageIsEnabledStub.returns(true);
+
sandbox.stub(events, 'getEvents').returns([]);
+ sandbox.stub(utils, 'generateUUID').returns(STUBBED_UUID);
+
clock = sandbox.useFakeTimers(1519767013781);
rubiconAnalyticsAdapter.referrerHostname = '';
@@ -505,6 +527,10 @@ describe('rubicon analytics adapter', function () {
afterEach(function () {
sandbox.restore();
config.resetConfig();
+ mockGpt.enable();
+ getDataFromLocalStorageStub.restore();
+ setDataInLocalStorageStub.restore();
+ localStorageIsEnabledStub.restore();
});
it('should require accountId', function () {
@@ -531,6 +557,73 @@ describe('rubicon analytics adapter', function () {
expect(utils.logError.called).to.equal(true);
});
+ describe('config subscribe', function() {
+ it('should update the pvid if user asks', function () {
+ expect(utils.generateUUID.called).to.equal(false);
+ config.setConfig({rubicon: {updatePageView: true}});
+ expect(utils.generateUUID.called).to.equal(true);
+ });
+ it('should merge in and preserve older set configs', function () {
+ config.setConfig({
+ rubicon: {
+ wrapperName: '1001_general',
+ int_type: 'dmpbjs',
+ fpkvs: {
+ source: 'fb'
+ }
+ }
+ });
+ expect(rubiConf).to.deep.equal({
+ pvid: '12345678',
+ wrapperName: '1001_general',
+ int_type: 'dmpbjs',
+ fpkvs: {
+ source: 'fb'
+ },
+ updatePageView: true
+ });
+
+ // update it with stuff
+ config.setConfig({
+ rubicon: {
+ fpkvs: {
+ link: 'email'
+ }
+ }
+ });
+ expect(rubiConf).to.deep.equal({
+ pvid: '12345678',
+ wrapperName: '1001_general',
+ int_type: 'dmpbjs',
+ fpkvs: {
+ source: 'fb',
+ link: 'email'
+ },
+ updatePageView: true
+ });
+
+ // overwriting specific edge keys should update them
+ config.setConfig({
+ rubicon: {
+ fpkvs: {
+ link: 'iMessage',
+ source: 'twitter'
+ }
+ }
+ });
+ expect(rubiConf).to.deep.equal({
+ pvid: '12345678',
+ wrapperName: '1001_general',
+ int_type: 'dmpbjs',
+ fpkvs: {
+ link: 'iMessage',
+ source: 'twitter'
+ },
+ updatePageView: true
+ });
+ });
+ });
+
describe('sampling', function () {
beforeEach(function () {
sandbox.stub(Math, 'random').returns(0.08);
@@ -659,6 +752,41 @@ describe('rubicon analytics adapter', function () {
expect(message).to.deep.equal(ANALYTICS_MESSAGE);
});
+ it('should handle bidResponse dimensions correctly', function () {
+ events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
+ events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);
+
+ // mock bid response with playerWidth and playerHeight (NO width and height)
+ let bidResponse1 = utils.deepClone(MOCK.BID_RESPONSE[0]);
+ delete bidResponse1.width;
+ delete bidResponse1.height;
+ bidResponse1.playerWidth = 640;
+ bidResponse1.playerHeight = 480;
+
+ // mock bid response with no width height or playerwidth playerheight
+ let bidResponse2 = utils.deepClone(MOCK.BID_RESPONSE[1]);
+ delete bidResponse2.width;
+ delete bidResponse2.height;
+ delete bidResponse2.playerWidth;
+ delete bidResponse2.playerHeight;
+
+ events.emit(BID_RESPONSE, bidResponse1);
+ events.emit(BID_RESPONSE, bidResponse2);
+ events.emit(BIDDER_DONE, MOCK.BIDDER_DONE);
+ events.emit(AUCTION_END, MOCK.AUCTION_END);
+ events.emit(SET_TARGETING, MOCK.SET_TARGETING);
+ events.emit(BID_WON, MOCK.BID_WON[0]);
+ events.emit(BID_WON, MOCK.BID_WON[1]);
+
+ let message = JSON.parse(server.requests[0].requestBody);
+ validate(message);
+ expect(message.auctions[0].adUnits[0].bids[0].bidResponse.dimensions).to.deep.equal({
+ width: 640,
+ height: 480
+ });
+ expect(message.auctions[0].adUnits[1].bids[0].bidResponse.dimensions).to.equal(undefined);
+ });
+
function performFloorAuction(provider) {
let auctionInit = utils.deepClone(MOCK.AUCTION_INIT);
auctionInit.bidderRequests[0].bids[0].floorData = {
@@ -747,17 +875,17 @@ describe('rubicon analytics adapter', function () {
provider: 'rubicon'
});
// first adUnit's adSlot
- expect(message.auctions[0].adUnits[0].adSlot).to.equal('12345/sports');
+ expect(message.auctions[0].adUnits[0].gam.adSlot).to.equal('12345/sports');
// since no other bids, we set adUnit status to no-bid
expect(message.auctions[0].adUnits[0].status).to.equal('no-bid');
// first adUnits bid is rejected
- expect(message.auctions[0].adUnits[0].bids[0].status).to.equal('rejected');
+ expect(message.auctions[0].adUnits[0].bids[0].status).to.equal('rejected-ipf');
expect(message.auctions[0].adUnits[0].bids[0].bidResponse.floorValue).to.equal(4);
// if bid rejected should take cpmAfterAdjustments val
expect(message.auctions[0].adUnits[0].bids[0].bidResponse.bidPriceUSD).to.equal(2.1);
// second adUnit's adSlot
- expect(message.auctions[0].adUnits[1].adSlot).to.equal('12345/news');
+ expect(message.auctions[0].adUnits[1].gam.adSlot).to.equal('12345/news');
// top level adUnit status is success
expect(message.auctions[0].adUnits[1].status).to.equal('success');
// second adUnits bid is success
@@ -767,7 +895,7 @@ describe('rubicon analytics adapter', function () {
});
it('should still send floor info if provider is not rubicon', function () {
- let message = performFloorAuction('randomProvider')
+ let message = performFloorAuction('randomProvider');
// verify our floor stuff is passed
// top level floor info
@@ -782,17 +910,17 @@ describe('rubicon analytics adapter', function () {
provider: 'randomProvider'
});
// first adUnit's adSlot
- expect(message.auctions[0].adUnits[0].adSlot).to.equal('12345/sports');
+ expect(message.auctions[0].adUnits[0].gam.adSlot).to.equal('12345/sports');
// since no other bids, we set adUnit status to no-bid
expect(message.auctions[0].adUnits[0].status).to.equal('no-bid');
// first adUnits bid is rejected
- expect(message.auctions[0].adUnits[0].bids[0].status).to.equal('rejected');
+ expect(message.auctions[0].adUnits[0].bids[0].status).to.equal('rejected-ipf');
expect(message.auctions[0].adUnits[0].bids[0].bidResponse.floorValue).to.equal(4);
// if bid rejected should take cpmAfterAdjustments val
expect(message.auctions[0].adUnits[0].bids[0].bidResponse.bidPriceUSD).to.equal(2.1);
// second adUnit's adSlot
- expect(message.auctions[0].adUnits[1].adSlot).to.equal('12345/news');
+ expect(message.auctions[0].adUnits[1].gam.adSlot).to.equal('12345/news');
// top level adUnit status is success
expect(message.auctions[0].adUnits[1].status).to.equal('success');
// second adUnits bid is success
@@ -801,6 +929,344 @@ describe('rubicon analytics adapter', function () {
expect(message.auctions[0].adUnits[1].bids[0].bidResponse.bidPriceUSD).to.equal(1.52);
});
+ describe('with session handling', function () {
+ const expectedPvid = STUBBED_UUID.slice(0, 8);
+ beforeEach(function () {
+ config.setConfig({rubicon: {updatePageView: true}});
+ });
+
+ it('should not log any session data if local storage is not enabled', function () {
+ localStorageIsEnabledStub.returns(false);
+
+ let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE);
+ delete expectedMessage.session;
+ delete expectedMessage.fpkvs;
+
+ performStandardAuction();
+
+ expect(server.requests.length).to.equal(1);
+ let request = server.requests[0];
+
+ expect(request.url).to.equal('//localhost:9999/event');
+
+ let message = JSON.parse(request.requestBody);
+ validate(message);
+
+ expect(message).to.deep.equal(expectedMessage);
+ });
+
+ it('should should pass along custom rubicon kv and pvid when defined', function () {
+ config.setConfig({rubicon: {
+ fpkvs: {
+ source: 'fb',
+ link: 'email'
+ }
+ }});
+ performStandardAuction();
+ expect(server.requests.length).to.equal(1);
+ let request = server.requests[0];
+ let message = JSON.parse(request.requestBody);
+ validate(message);
+
+ let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE);
+ expectedMessage.session.pvid = STUBBED_UUID.slice(0, 8);
+ expectedMessage.fpkvs = [
+ {key: 'source', value: 'fb'},
+ {key: 'link', value: 'email'}
+ ]
+ expect(message).to.deep.equal(expectedMessage);
+ });
+
+ it('should pick up existing localStorage and use its values', function () {
+ // set some localStorage
+ let inputlocalStorage = {
+ id: '987654',
+ start: 1519766113781, // 15 mins before "now"
+ expires: 1519787713781, // six hours later
+ lastSeen: 1519766113781,
+ fpkvs: { source: 'tw' }
+ };
+ getDataFromLocalStorageStub.withArgs('rpaSession').returns(btoa(JSON.stringify(inputlocalStorage)));
+
+ config.setConfig({rubicon: {
+ fpkvs: {
+ link: 'email' // should merge this with what is in the localStorage!
+ }
+ }});
+ performStandardAuction();
+ expect(server.requests.length).to.equal(1);
+ let request = server.requests[0];
+ let message = JSON.parse(request.requestBody);
+ validate(message);
+
+ let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE);
+ expectedMessage.session = {
+ id: '987654',
+ start: 1519766113781,
+ expires: 1519787713781,
+ pvid: expectedPvid
+ }
+ expectedMessage.fpkvs = [
+ {key: 'source', value: 'tw'},
+ {key: 'link', value: 'email'}
+ ]
+ expect(message).to.deep.equal(expectedMessage);
+
+ let calledWith;
+ try {
+ calledWith = JSON.parse(atob(setDataInLocalStorageStub.getCall(0).args[1]));
+ } catch (e) {
+ calledWith = {};
+ }
+
+ expect(calledWith).to.deep.equal({
+ id: '987654', // should have stayed same
+ start: 1519766113781, // should have stayed same
+ expires: 1519787713781, // should have stayed same
+ lastSeen: 1519767013781, // lastSeen updated to our "now"
+ fpkvs: { source: 'tw', link: 'email' }, // link merged in
+ pvid: expectedPvid // new pvid stored
+ });
+ });
+
+ it('should throw out session if lastSeen > 30 mins ago and create new one', function () {
+ // set some localStorage
+ let inputlocalStorage = {
+ id: '987654',
+ start: 1519764313781, // 45 mins before "now"
+ expires: 1519785913781, // six hours later
+ lastSeen: 1519764313781, // 45 mins before "now"
+ fpkvs: { source: 'tw' }
+ };
+ getDataFromLocalStorageStub.withArgs('rpaSession').returns(btoa(JSON.stringify(inputlocalStorage)));
+
+ config.setConfig({rubicon: {
+ fpkvs: {
+ link: 'email' // should merge this with what is in the localStorage!
+ }
+ }});
+
+ performStandardAuction();
+ expect(server.requests.length).to.equal(1);
+ let request = server.requests[0];
+ let message = JSON.parse(request.requestBody);
+ validate(message);
+
+ let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE);
+ // session should match what is already in ANALYTICS_MESSAGE, just need to add pvid
+ expectedMessage.session.pvid = expectedPvid;
+
+ // the saved fpkvs should have been thrown out since session expired
+ expectedMessage.fpkvs = [
+ {key: 'link', value: 'email'}
+ ]
+ expect(message).to.deep.equal(expectedMessage);
+
+ let calledWith;
+ try {
+ calledWith = JSON.parse(atob(setDataInLocalStorageStub.getCall(0).args[1]));
+ } catch (e) {
+ calledWith = {};
+ }
+
+ expect(calledWith).to.deep.equal({
+ id: STUBBED_UUID, // should have stayed same
+ start: 1519767013781, // should have stayed same
+ expires: 1519788613781, // should have stayed same
+ lastSeen: 1519767013781, // lastSeen updated to our "now"
+ fpkvs: { link: 'email' }, // link merged in
+ pvid: expectedPvid // new pvid stored
+ });
+ });
+
+ it('should throw out session if past expires time and create new one', function () {
+ // set some localStorage
+ let inputlocalStorage = {
+ id: '987654',
+ start: 1519745353781, // 6 hours before "expires"
+ expires: 1519766953781, // little more than six hours ago
+ lastSeen: 1519767008781, // 5 seconds ago
+ fpkvs: { source: 'tw' }
+ };
+ getDataFromLocalStorageStub.withArgs('rpaSession').returns(btoa(JSON.stringify(inputlocalStorage)));
+
+ config.setConfig({rubicon: {
+ fpkvs: {
+ link: 'email' // should merge this with what is in the localStorage!
+ }
+ }});
+
+ performStandardAuction();
+ expect(server.requests.length).to.equal(1);
+ let request = server.requests[0];
+ let message = JSON.parse(request.requestBody);
+ validate(message);
+
+ let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE);
+ // session should match what is already in ANALYTICS_MESSAGE, just need to add pvid
+ expectedMessage.session.pvid = expectedPvid;
+
+ // the saved fpkvs should have been thrown out since session expired
+ expectedMessage.fpkvs = [
+ {key: 'link', value: 'email'}
+ ]
+ expect(message).to.deep.equal(expectedMessage);
+
+ let calledWith;
+ try {
+ calledWith = JSON.parse(atob(setDataInLocalStorageStub.getCall(0).args[1]));
+ } catch (e) {
+ calledWith = {};
+ }
+
+ expect(calledWith).to.deep.equal({
+ id: STUBBED_UUID, // should have stayed same
+ start: 1519767013781, // should have stayed same
+ expires: 1519788613781, // should have stayed same
+ lastSeen: 1519767013781, // lastSeen updated to our "now"
+ fpkvs: { link: 'email' }, // link merged in
+ pvid: expectedPvid // new pvid stored
+ });
+ });
+ });
+ describe('with googletag enabled', function () {
+ let gptSlot0, gptSlot1, gptEvent0, gptEvent1;
+ beforeEach(function () {
+ mockGpt.enable();
+ gptSlot0 = mockGpt.makeSlot({code: '/19968336/header-bid-tag-0'});
+ gptSlot1 = mockGpt.makeSlot({code: '/19968336/header-bid-tag1'});
+ gptEvent0 = {
+ eventName: 'slotRenderEnded',
+ params: {
+ slot: gptSlot0,
+ isEmpty: false,
+ advertiserId: 1111,
+ creativeId: 2222,
+ lineItemId: 3333
+ }
+ };
+ gptEvent1 = {
+ eventName: 'slotRenderEnded',
+ params: {
+ slot: gptSlot1,
+ isEmpty: false,
+ advertiserId: 4444,
+ creativeId: 5555,
+ lineItemId: 6666
+ }
+ };
+ });
+
+ afterEach(function () {
+ mockGpt.disable();
+ });
+
+ it('should add necessary gam information if gpt is enabled and slotRender event emmited', function () {
+ performStandardAuction([gptEvent0, gptEvent1]);
+ expect(server.requests.length).to.equal(1);
+ let request = server.requests[0];
+ let message = JSON.parse(request.requestBody);
+ validate(message);
+
+ let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE);
+ expectedMessage.auctions[0].adUnits[0].gam = {
+ advertiserId: 1111,
+ creativeId: 2222,
+ lineItemId: 3333,
+ adSlot: '/19968336/header-bid-tag-0'
+ };
+ expectedMessage.auctions[0].adUnits[1].gam = {
+ advertiserId: 4444,
+ creativeId: 5555,
+ lineItemId: 6666,
+ adSlot: '/19968336/header-bid-tag1'
+ };
+ expect(message).to.deep.equal(expectedMessage);
+ });
+
+ it('should handle empty gam renders', function () {
+ performStandardAuction([gptEvent0, {
+ eventName: 'slotRenderEnded',
+ params: {
+ slot: gptSlot1,
+ isEmpty: true
+ }
+ }]);
+ expect(server.requests.length).to.equal(1);
+ let request = server.requests[0];
+ let message = JSON.parse(request.requestBody);
+ validate(message);
+
+ let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE);
+ expectedMessage.auctions[0].adUnits[0].gam = {
+ advertiserId: 1111,
+ creativeId: 2222,
+ lineItemId: 3333,
+ adSlot: '/19968336/header-bid-tag-0'
+ };
+ expectedMessage.auctions[0].adUnits[1].gam = {
+ isSlotEmpty: true,
+ adSlot: '/19968336/header-bid-tag1'
+ };
+ expect(message).to.deep.equal(expectedMessage);
+ });
+
+ it('should still add gam ids if falsy', function () {
+ performStandardAuction([gptEvent0, {
+ eventName: 'slotRenderEnded',
+ params: {
+ slot: gptSlot1,
+ isEmpty: false,
+ advertiserId: 0,
+ creativeId: 0,
+ lineItemId: 0
+ }
+ }]);
+ expect(server.requests.length).to.equal(1);
+ let request = server.requests[0];
+ let message = JSON.parse(request.requestBody);
+ validate(message);
+
+ let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE);
+ expectedMessage.auctions[0].adUnits[0].gam = {
+ advertiserId: 1111,
+ creativeId: 2222,
+ lineItemId: 3333,
+ adSlot: '/19968336/header-bid-tag-0'
+ };
+ expectedMessage.auctions[0].adUnits[1].gam = {
+ advertiserId: 0,
+ creativeId: 0,
+ lineItemId: 0,
+ adSlot: '/19968336/header-bid-tag1'
+ };
+ expect(message).to.deep.equal(expectedMessage);
+ });
+
+ it('should handle empty gam renders', function () {
+ performStandardAuction([gptEvent0, gptEvent1]);
+ expect(server.requests.length).to.equal(1);
+ let request = server.requests[0];
+ let message = JSON.parse(request.requestBody);
+ validate(message);
+
+ let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE);
+ expectedMessage.auctions[0].adUnits[0].gam = {
+ advertiserId: 1111,
+ creativeId: 2222,
+ lineItemId: 3333,
+ adSlot: '/19968336/header-bid-tag-0'
+ };
+ expectedMessage.auctions[0].adUnits[1].gam = {
+ advertiserId: 4444,
+ creativeId: 5555,
+ lineItemId: 6666,
+ adSlot: '/19968336/header-bid-tag1'
+ };
+ expect(message).to.deep.equal(expectedMessage);
+ });
+ });
+
it('should correctly overwrite bidId if seatBidId is on the bidResponse', function () {
// Only want one bid request in our mock auction
let bidRequested = utils.deepClone(MOCK.BID_REQUESTED);
@@ -963,12 +1429,9 @@ describe('rubicon analytics adapter', function () {
describe('config with integration type', () => {
it('should use the integration type provided in the config instead of the default', () => {
- sandbox.stub(config, 'getConfig').callsFake(function (key) {
- const config = {
- 'rubicon.int_type': 'testType'
- };
- return config[key];
- });
+ config.setConfig({rubicon: {
+ int_type: 'testType'
+ }})
rubiconAnalyticsAdapter.enableAnalytics({
options: {
diff --git a/test/spec/modules/rubiconAnalyticsSchema.json b/test/spec/modules/rubiconAnalyticsSchema.json
index 16cca629d8c..13d39e46cd0 100644
--- a/test/spec/modules/rubiconAnalyticsSchema.json
+++ b/test/spec/modules/rubiconAnalyticsSchema.json
@@ -34,6 +34,53 @@
"type": "string",
"description": "Version of Prebid.js responsible for the auctions contained within."
},
+ "fpkvs": {
+ "type": "array",
+ "description": "List of any dynamic key value pairs set by publisher.",
+ "minItems": 1,
+ "items": {
+ "type": "object",
+ "required": [
+ "key",
+ "value"
+ ],
+ "properties": {
+ "key": {
+ "type": "string"
+ },
+ "value": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "session": {
+ "type": "object",
+ "description": "The session information for a given event",
+ "required": [
+ "id",
+ "start",
+ "expires"
+ ],
+ "properties": {
+ "id": {
+ "type": "string",
+ "description": "UUID of session."
+ },
+ "start": {
+ "type": "integer",
+ "description": "Unix timestamp of time of creation for this session in milliseconds."
+ },
+ "expires": {
+ "type": "integer",
+ "description": "Unix timestamp of the maximum allowed time in milliseconds of the session."
+ },
+ "pvid": {
+ "type": "string",
+ "description": "id to track page view."
+ }
+ }
+ },
"auctions": {
"type": "array",
"minItems": 1,
@@ -125,6 +172,9 @@
"zoneId": {
"type": "number",
"description": "The Rubicon zoneId associated with this adUnit - Removed if null"
+ },
+ "gam": {
+ "$ref": "#/definitions/gam"
}
}
}
@@ -197,6 +247,31 @@
}
},
"definitions": {
+ "gam": {
+ "type": "object",
+ "description": "The gam information for a given ad unit",
+ "required": [
+ "adSlot"
+ ],
+ "properties": {
+ "adSlot": {
+ "type": "string"
+ },
+ "advertiserId": {
+ "type": "integer"
+ },
+ "creativeId": {
+ "type": "integer"
+ },
+ "LineItemId": {
+ "type": "integer"
+ },
+ "isSlotEmpty": {
+ "type": "boolean",
+ "enum": [true]
+ }
+ }
+ },
"adserverTargeting": {
"type": "object",
"description": "The adserverTargeting key/value pairs",
@@ -293,7 +368,8 @@
"success",
"no-bid",
"error",
- "rejected"
+ "rejected-gdpr",
+ "rejected-ipf"
]
},
"error": {
@@ -333,7 +409,6 @@
"bidResponse": {
"type": "object",
"required": [
- "dimensions",
"mediaType",
"bidPriceUSD"
],
diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js
index c5c0f644643..a38743d634a 100644
--- a/test/spec/modules/rubiconBidAdapter_spec.js
+++ b/test/spec/modules/rubiconBidAdapter_spec.js
@@ -1,10 +1,17 @@
import {expect} from 'chai';
-import {spec, getPriceGranularity, masSizeOrdering, resetUserSync, hasVideoMediaType, FASTLANE_ENDPOINT} from 'modules/rubiconBidAdapter.js';
+import {
+ spec,
+ getPriceGranularity,
+ masSizeOrdering,
+ resetUserSync,
+ hasVideoMediaType,
+ resetRubiConf
+} from 'modules/rubiconBidAdapter.js';
import {parse as parseQuery} from 'querystring';
import {config} from 'src/config.js';
import * as utils from 'src/utils.js';
import find from 'core-js-pure/features/array/find.js';
-import { createEidsArray } from 'modules/userId/eids.js';
+import {createEidsArray} from 'modules/userId/eids.js';
const INTEGRATION = `pbjs_lite_v$prebid.version$`; // $prebid.version$ will be substituted in by gulp in built prebid
const PBS_INTEGRATION = 'pbjs';
@@ -137,7 +144,7 @@ describe('the rubicon adapter', function () {
'targeting': [
{
'key': getProp('targeting_key', `rpfl_${i}`),
- 'values': [ '43_tier_all_test' ]
+ 'values': ['43_tier_all_test']
}
]
};
@@ -220,11 +227,26 @@ describe('the rubicon adapter', function () {
'size_id': 201,
};
bid.userId = {
- lipb: { lipbid: '0000-1111-2222-3333', segments: ['segA', 'segB'] },
+ lipb: {lipbid: '0000-1111-2222-3333', segments: ['segA', 'segB']},
idl_env: '1111-2222-3333-4444',
- sharedid: { id: '1111', third: '2222' },
+ sharedid: {id: '1111', third: '2222'},
tdid: '3000',
- pubcid: '4000'
+ pubcid: '4000',
+ pubProvidedId: [{
+ source: 'example.com',
+ uids: [{
+ id: '333333',
+ ext: {
+ stype: 'ppuid'
+ }
+ }]
+ }, {
+ source: 'id-partner.com',
+ uids: [{
+ id: '4444444'
+ }]
+ }],
+ criteoId: '1111'
};
bid.userIdAsEids = createEidsArray(bid.userId);
bid.storedAuctionResponse = 11111;
@@ -347,6 +369,8 @@ describe('the rubicon adapter', function () {
afterEach(function () {
sandbox.restore();
utils.logError.restore();
+ config.resetConfig();
+ resetRubiConf();
});
describe('MAS mapping / ordering', function () {
@@ -461,35 +485,30 @@ describe('the rubicon adapter', function () {
data = parseQuery(request.data);
expect(data.rp_hard_floor).to.equal('1.23');
});
- it('should not send p_pos to AE if not params.position specified', function() {
- var noposRequest = utils.deepClone(bidderRequest);
- delete noposRequest.bids[0].params.position;
+ it('should not send p_pos to AE if not params.position specified', function () {
+ var noposRequest = utils.deepClone(bidderRequest);
+ delete noposRequest.bids[0].params.position;
- let [request] = spec.buildRequests(noposRequest.bids, noposRequest);
- let data = parseQuery(request.data);
+ let [request] = spec.buildRequests(noposRequest.bids, noposRequest);
+ let data = parseQuery(request.data);
- expect(data['site_id']).to.equal('70608');
- expect(data['p_pos']).to.equal(undefined);
+ expect(data['site_id']).to.equal('70608');
+ expect(data['p_pos']).to.equal(undefined);
});
- it('should not send p_pos to AE if not params.position is invalid', function() {
- var badposRequest = utils.deepClone(bidderRequest);
- badposRequest.bids[0].params.position = 'bad';
+ it('should not send p_pos to AE if not params.position is invalid', function () {
+ var badposRequest = utils.deepClone(bidderRequest);
+ badposRequest.bids[0].params.position = 'bad';
- let [request] = spec.buildRequests(badposRequest.bids, badposRequest);
- let data = parseQuery(request.data);
+ let [request] = spec.buildRequests(badposRequest.bids, badposRequest);
+ let data = parseQuery(request.data);
- expect(data['site_id']).to.equal('70608');
- expect(data['p_pos']).to.equal(undefined);
+ expect(data['site_id']).to.equal('70608');
+ expect(data['p_pos']).to.equal(undefined);
});
it('should correctly send p_pos in sra fashion', function() {
- sandbox.stub(config, 'getConfig').callsFake((key) => {
- const config = {
- 'rubicon.singleRequest': true
- };
- return config[key];
- });
+ config.setConfig({rubicon: {singleRequest: true}});
// first one is atf
var sraPosRequest = utils.deepClone(bidderRequest);
@@ -519,11 +538,11 @@ describe('the rubicon adapter', function () {
expect(data['p_pos']).to.equal('atf;;btf;;');
});
- it('should not send x_source.pchain to AE if params.pchain is not specified', function() {
- var noPchainRequest = utils.deepClone(bidderRequest);
- delete noPchainRequest.bids[0].params.pchain;
+ it('should not send x_source.pchain to AE if params.pchain is not specified', function () {
+ var noPchainRequest = utils.deepClone(bidderRequest);
+ delete noPchainRequest.bids[0].params.pchain;
- let [request] = spec.buildRequests(noPchainRequest.bids, noPchainRequest);
+ let [request] = spec.buildRequests(noPchainRequest.bids, noPchainRequest);
expect(request.data).to.contain('&site_id=70608&');
expect(request.data).to.not.contain('x_source.pchain');
});
@@ -624,7 +643,7 @@ describe('the rubicon adapter', function () {
expect(parseQuery(request.data).rf).to.equal('localhost');
delete bidderRequest.bids[0].params.referrer;
- let refererInfo = { referer: 'https://www.prebid.org' };
+ let refererInfo = {referer: 'https://www.prebid.org'};
bidderRequest = Object.assign({refererInfo}, bidderRequest);
[request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
expect(parseQuery(request.data).rf).to.equal('https://www.prebid.org');
@@ -683,233 +702,6 @@ describe('the rubicon adapter', function () {
expect(data['rp_floor']).to.equal('2');
});
- it('should send digitrust params', function () {
- window.DigiTrust = {
- getUser: function () {
- }
- };
- sandbox.stub(window.DigiTrust, 'getUser').callsFake(() =>
- ({
- success: true,
- identity: {
- privacy: {optout: false},
- id: 'testId',
- keyv: 'testKeyV'
- }
- })
- );
-
- let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
- let data = parseQuery(request.data);
-
- let expectedQuery = {
- 'dt.id': 'testId',
- 'dt.keyv': 'testKeyV',
- 'dt.pref': '0'
- };
-
- // test that all values above are both present and correct
- Object.keys(expectedQuery).forEach(key => {
- let value = expectedQuery[key];
- expect(data[key]).to.equal(value);
- });
-
- delete window.DigiTrust;
- });
-
- it('should not send digitrust params when DigiTrust not loaded', function () {
- let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
- let data = parseQuery(request.data);
-
- let undefinedKeys = ['dt.id', 'dt.keyv'];
-
- // Test that none of the DigiTrust keys are part of the query
- undefinedKeys.forEach(key => {
- expect(typeof data[key]).to.equal('undefined');
- });
- });
-
- it('should not send digitrust params due to optout', function () {
- window.DigiTrust = {
- getUser: function () {
- }
- };
- sandbox.stub(window.DigiTrust, 'getUser').callsFake(() =>
- ({
- success: true,
- identity: {
- privacy: {optout: true},
- id: 'testId',
- keyv: 'testKeyV'
- }
- })
- );
-
- let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
- let data = parseQuery(request.data);
-
- let undefinedKeys = ['dt.id', 'dt.keyv'];
-
- // Test that none of the DigiTrust keys are part of the query
- undefinedKeys.forEach(key => {
- expect(typeof data[key]).to.equal('undefined');
- });
-
- delete window.DigiTrust;
- });
-
- it('should not send digitrust params due to failure', function () {
- window.DigiTrust = {
- getUser: function () {
- }
- };
- sandbox.stub(window.DigiTrust, 'getUser').callsFake(() =>
- ({
- success: false,
- identity: {
- privacy: {optout: false},
- id: 'testId',
- keyv: 'testKeyV'
- }
- })
- );
-
- let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
- let data = parseQuery(request.data);
-
- let undefinedKeys = ['dt.id', 'dt.keyv'];
-
- // Test that none of the DigiTrust keys are part of the query
- undefinedKeys.forEach(key => {
- expect(typeof data[key]).to.equal('undefined');
- });
-
- delete window.DigiTrust;
- });
-
- describe('digiTrustId config', function () {
- beforeEach(function () {
- window.DigiTrust = {
- getUser: sandbox.spy()
- };
- });
-
- afterEach(function () {
- delete window.DigiTrust;
- });
-
- it('should send digiTrustId config params', function () {
- sandbox.stub(config, 'getConfig').callsFake((key) => {
- var config = {
- digiTrustId: {
- success: true,
- identity: {
- privacy: {optout: false},
- id: 'testId',
- keyv: 'testKeyV'
- }
- }
- };
- return config[key];
- });
-
- let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
- let data = parseQuery(request.data);
-
- let expectedQuery = {
- 'dt.id': 'testId',
- 'dt.keyv': 'testKeyV'
- };
-
- // test that all values above are both present and correct
- Object.keys(expectedQuery).forEach(key => {
- let value = expectedQuery[key];
- expect(data[key]).to.equal(value);
- });
-
- // should not have called DigiTrust.getUser()
- expect(window.DigiTrust.getUser.notCalled).to.equal(true);
- });
-
- it('should not send digiTrustId config params due to optout', function () {
- sandbox.stub(config, 'getConfig').callsFake((key) => {
- var config = {
- digiTrustId: {
- success: true,
- identity: {
- privacy: {optout: true},
- id: 'testId',
- keyv: 'testKeyV'
- }
- }
- }
- return config[key];
- });
-
- let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
- let data = parseQuery(request.data);
-
- let undefinedKeys = ['dt.id', 'dt.keyv'];
-
- // Test that none of the DigiTrust keys are part of the query
- undefinedKeys.forEach(key => {
- expect(typeof data[key]).to.equal('undefined');
- });
-
- // should not have called DigiTrust.getUser()
- expect(window.DigiTrust.getUser.notCalled).to.equal(true);
- });
-
- it('should not send digiTrustId config params due to failure', function () {
- sandbox.stub(config, 'getConfig').callsFake((key) => {
- var config = {
- digiTrustId: {
- success: false,
- identity: {
- privacy: {optout: false},
- id: 'testId',
- keyv: 'testKeyV'
- }
- }
- }
- return config[key];
- });
-
- let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
- let data = parseQuery(request.data);
-
- let undefinedKeys = ['dt.id', 'dt.keyv'];
-
- // Test that none of the DigiTrust keys are part of the query
- undefinedKeys.forEach(key => {
- expect(typeof data[key]).to.equal('undefined');
- });
-
- // should not have called DigiTrust.getUser()
- expect(window.DigiTrust.getUser.notCalled).to.equal(true);
- });
-
- it('should not send digiTrustId config params if they do not exist', function () {
- sandbox.stub(config, 'getConfig').callsFake((key) => {
- var config = {};
- return config[key];
- });
-
- let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
- let data = parseQuery(request.data);
-
- let undefinedKeys = ['dt.id', 'dt.keyv'];
-
- // Test that none of the DigiTrust keys are part of the query
- undefinedKeys.forEach(key => {
- expect(typeof data[key]).to.equal('undefined');
- });
-
- // should have called DigiTrust.getUser() once
- expect(window.DigiTrust.getUser.calledOnce).to.equal(true);
- });
- });
-
describe('GDPR consent config', function () {
it('should send "gdpr" and "gdpr_consent", when gdprConsent defines consentString and gdprApplies', function () {
createGdprBidderRequest(true);
@@ -1041,7 +833,7 @@ describe('the rubicon adapter', function () {
keywords: ['d'],
gender: 'M',
yob: '1984',
- geo: { country: 'ca' }
+ geo: {country: 'ca'}
};
sandbox.stub(config, 'getConfig').callsFake(key => {
@@ -1082,12 +874,7 @@ describe('the rubicon adapter', function () {
it('should group all bid requests with the same site id', function () {
sandbox.stub(Math, 'random').callsFake(() => 0.1);
- sandbox.stub(config, 'getConfig').callsFake((key) => {
- const config = {
- 'rubicon.singleRequest': true
- };
- return config[key];
- });
+ config.setConfig({rubicon: {singleRequest: true}});
const expectedQuery = {
'account_id': '14062',
@@ -1195,13 +982,7 @@ describe('the rubicon adapter', function () {
});
it('should not send more than 10 bids in a request (split into separate requests with <= 10 bids each)', function () {
- sandbox.stub(config, 'getConfig').callsFake((key) => {
- const config = {
- 'rubicon.singleRequest': true
- };
- return config[key];
- });
-
+ config.setConfig({rubicon: {singleRequest: true}});
let serverRequests;
let data;
@@ -1243,12 +1024,7 @@ describe('the rubicon adapter', function () {
});
it('should not group bid requests if singleRequest does not equal true', function () {
- sandbox.stub(config, 'getConfig').callsFake((key) => {
- const config = {
- 'rubicon.singleRequest': false
- };
- return config[key];
- });
+ config.setConfig({rubicon: {singleRequest: false}});
const bidCopy = utils.deepClone(bidderRequest.bids[0]);
bidderRequest.bids.push(bidCopy);
@@ -1266,12 +1042,7 @@ describe('the rubicon adapter', function () {
});
it('should not group video bid requests', function () {
- sandbox.stub(config, 'getConfig').callsFake((key) => {
- const config = {
- 'rubicon.singleRequest': true
- };
- return config[key];
- });
+ config.setConfig({rubicon: {singleRequest: true}});
const bidCopy = utils.deepClone(bidderRequest.bids[0]);
bidderRequest.bids.push(bidCopy);
@@ -1315,7 +1086,7 @@ describe('the rubicon adapter', function () {
});
});
- describe('user id config', function() {
+ describe('user id config', function () {
it('should send tpid_tdid when userIdAsEids contains unifiedId', function () {
const clonedBid = utils.deepClone(bidderRequest.bids[0]);
clonedBid.userId = {
@@ -1374,6 +1145,34 @@ describe('the rubicon adapter', function () {
});
});
+ describe('pubcid support', function () {
+ it('should send eid_pubcid.org when userIdAsEids contains pubcid', function () {
+ const clonedBid = utils.deepClone(bidderRequest.bids[0]);
+ clonedBid.userId = {
+ pubcid: '1111'
+ };
+ clonedBid.userIdAsEids = createEidsArray(clonedBid.userId);
+ let [request] = spec.buildRequests([clonedBid], bidderRequest);
+ let data = parseQuery(request.data);
+
+ expect(data['eid_pubcid.org']).to.equal('1111^1');
+ });
+ });
+
+ describe('Criteo support', function () {
+ it('should send eid_criteo.com when userIdAsEids contains criteo', function () {
+ const clonedBid = utils.deepClone(bidderRequest.bids[0]);
+ clonedBid.userId = {
+ criteoId: '1111'
+ };
+ clonedBid.userIdAsEids = createEidsArray(clonedBid.userId);
+ let [request] = spec.buildRequests([clonedBid], bidderRequest);
+ let data = parseQuery(request.data);
+
+ expect(data['eid_criteo.com']).to.equal('1111^1');
+ });
+ });
+
describe('SharedID support', function () {
it('should send sharedid when userIdAsEids contains sharedId', function () {
const clonedBid = utils.deepClone(bidderRequest.bids[0]);
@@ -1391,9 +1190,36 @@ describe('the rubicon adapter', function () {
});
});
+ describe('pubProvidedId support', function () {
+ it('should send pubProvidedId when userIdAsEids contains pubProvidedId ids', function () {
+ const clonedBid = utils.deepClone(bidderRequest.bids[0]);
+ clonedBid.userId = {
+ pubProvidedId: [{
+ source: 'example.com',
+ uids: [{
+ id: '11111',
+ ext: {
+ stype: 'ppuid'
+ }
+ }]
+ }, {
+ source: 'id-partner.com',
+ uids: [{
+ id: '222222'
+ }]
+ }]
+ };
+ clonedBid.userIdAsEids = createEidsArray(clonedBid.userId);
+ let [request] = spec.buildRequests([clonedBid], bidderRequest);
+ let data = parseQuery(request.data);
+
+ expect(data['ppuid']).to.equal('11111');
+ });
+ });
+
describe('Config user.id support', function () {
it('should send ppuid when config defines user.id', function () {
- config.setConfig({ user: { id: '123' } });
+ config.setConfig({user: {id: '123'}});
const clonedBid = utils.deepClone(bidderRequest.bids[0]);
clonedBid.userId = {
sharedid: {
@@ -1569,11 +1395,11 @@ describe('the rubicon adapter', function () {
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
let post = request.data;
- expect(post).to.have.property('imp')
+ expect(post).to.have.property('imp');
// .with.length.of(1);
let imp = post.imp[0];
expect(imp.id).to.equal(bidderRequest.bids[0].adUnitCode);
- expect(imp.exp).to.equal(300);
+ expect(imp.exp).to.equal(undefined); // now undefined
expect(imp.video.w).to.equal(640);
expect(imp.video.h).to.equal(480);
expect(imp.video.pos).to.equal(1);
@@ -1630,6 +1456,16 @@ describe('the rubicon adapter', function () {
expect(post.user.ext.eids[4].source).to.equal('pubcid.org');
expect(post.user.ext.eids[4].uids[0].atype).to.equal(1);
expect(post.user.ext.eids[4].uids[0].id).to.equal('4000');
+ // example should exist
+ expect(post.user.ext.eids[5].source).to.equal('example.com');
+ expect(post.user.ext.eids[5].uids[0].id).to.equal('333333');
+ // id-partner.com
+ expect(post.user.ext.eids[6].source).to.equal('id-partner.com');
+ expect(post.user.ext.eids[6].uids[0].id).to.equal('4444444');
+ // CriteoId should exist
+ expect(post.user.ext.eids[7].source).to.equal('criteo.com');
+ expect(post.user.ext.eids[7].uids[0].id).to.equal('1111');
+ expect(post.user.ext.eids[7].uids[0].atype).to.equal(1);
expect(post.regs.ext.gdpr).to.equal(1);
expect(post.regs.ext.us_privacy).to.equal('1NYN');
@@ -1710,7 +1546,7 @@ describe('the rubicon adapter', function () {
expect(request.data.imp[0].bidfloor).to.be.undefined;
});
- it('should add alias name to PBS Request', function() {
+ it('should add alias name to PBS Request', function () {
createVideoBidderRequest();
bidderRequest.bidderCode = 'superRubicon';
@@ -1726,7 +1562,37 @@ describe('the rubicon adapter', function () {
expect(request.data.imp[0].ext).to.not.haveOwnProperty('rubicon');
});
- it('should send correct bidfloor to PBS', function() {
+ it('should send video exp param correctly when set', function () {
+ createVideoBidderRequest();
+ config.setConfig({s2sConfig: {defaultTtl: 600}});
+ let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
+ let post = request.data;
+
+ // should exp set to the right value according to config
+ let imp = post.imp[0];
+ expect(imp.exp).to.equal(600);
+ });
+
+ it('should not send video exp at all if not set in s2sConfig config', function () {
+ createVideoBidderRequest();
+ let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
+ let post = request.data;
+
+ // should exp set to the right value according to config
+ let imp = post.imp[0];
+ // bidderFactory stringifies request body before sending so removes undefined attributes:
+ expect(imp.exp).to.equal(undefined);
+ });
+
+ it('should send tmax as the bidderRequest timeout value', function () {
+ createVideoBidderRequest();
+ bidderRequest.timeout = 3333;
+ let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
+ let post = request.data;
+ expect(post.tmax).to.equal(3333);
+ });
+
+ it('should send correct bidfloor to PBS', function () {
createVideoBidderRequest();
bidderRequest.bids[0].params.floor = 0.1;
@@ -1916,14 +1782,14 @@ describe('the rubicon adapter', function () {
let requests = spec.buildRequests(bidderRequest.bids, bidderRequest);
expect(requests.length).to.equal(1);
- expect(requests[0].url).to.equal(FASTLANE_ENDPOINT);
+ expect(requests[0].url).to.equal('https://fastlane.rubiconproject.com/a/api/fastlane.json');
bidderRequest.mediaTypes.video.context = 'instream';
requests = spec.buildRequests(bidderRequest.bids, bidderRequest);
expect(requests.length).to.equal(1);
- expect(requests[0].url).to.equal(FASTLANE_ENDPOINT);
+ expect(requests[0].url).to.equal('https://fastlane.rubiconproject.com/a/api/fastlane.json');
});
it('should send request as banner when invalid video bid in multiple mediaType bidRequest', function () {
@@ -1942,7 +1808,7 @@ describe('the rubicon adapter', function () {
let requests = spec.buildRequests(bidRequestCopy.bids, bidRequestCopy);
expect(requests.length).to.equal(1);
- expect(requests[0].url).to.equal(FASTLANE_ENDPOINT);
+ expect(requests[0].url).to.equal('https://fastlane.rubiconproject.com/a/api/fastlane.json');
});
it('should include coppa flag in video bid request', () => {
@@ -1974,7 +1840,7 @@ describe('the rubicon adapter', function () {
keywords: ['d'],
gender: 'M',
yob: '1984',
- geo: { country: 'ca' }
+ geo: {country: 'ca'}
};
sandbox.stub(config, 'getConfig').callsFake(key => {
@@ -1988,7 +1854,7 @@ describe('the rubicon adapter', function () {
});
const expected = [{
- bidders: [ 'rubicon' ],
+ bidders: ['rubicon'],
config: {
fpd: {
site: Object.assign({}, bidderRequest.bids[0].params.inventory, context),
@@ -2055,18 +1921,13 @@ describe('the rubicon adapter', function () {
it('should use the integration type provided in the config instead of the default', () => {
createVideoBidderRequest();
- sandbox.stub(config, 'getConfig').callsFake(function (key) {
- const config = {
- 'rubicon.int_type': 'testType'
- };
- return config[key];
- });
+ config.setConfig({rubicon: {int_type: 'testType'}});
const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
expect(request.data.ext.prebid.bidders.rubicon.integration).to.equal('testType');
});
it('should pass the user.id provided in the config', function () {
- config.setConfig({ user: { id: '123' } });
+ config.setConfig({user: {id: '123'}});
createVideoBidderRequest();
sandbox.stub(Date, 'now').callsFake(() =>
@@ -2080,7 +1941,7 @@ describe('the rubicon adapter', function () {
// .with.length.of(1);
let imp = post.imp[0];
expect(imp.id).to.equal(bidderRequest.bids[0].adUnitCode);
- expect(imp.exp).to.equal(300);
+ expect(imp.exp).to.equal(undefined);
expect(imp.video.w).to.equal(640);
expect(imp.video.h).to.equal(480);
expect(imp.video.pos).to.equal(1);
@@ -2120,7 +1981,11 @@ describe('the rubicon adapter', function () {
it('should combine an array of slot url params', function () {
expect(spec.combineSlotUrlParams([])).to.deep.equal({});
- expect(spec.combineSlotUrlParams([{p1: 'foo', p2: 'test', p3: ''}])).to.deep.equal({p1: 'foo', p2: 'test', p3: ''});
+ expect(spec.combineSlotUrlParams([{p1: 'foo', p2: 'test', p3: ''}])).to.deep.equal({
+ p1: 'foo',
+ p2: 'test',
+ p3: ''
+ });
expect(spec.combineSlotUrlParams([{}, {p1: 'foo', p2: 'test'}])).to.deep.equal({p1: ';foo', p2: ';test'});
@@ -2676,7 +2541,7 @@ describe('the rubicon adapter', function () {
}]
};
- let bids = spec.interpretResponse({ body: response }, {
+ let bids = spec.interpretResponse({body: response}, {
bidRequest: [utils.deepClone(bidderRequest.bids[0])]
});
@@ -2687,7 +2552,7 @@ describe('the rubicon adapter', function () {
describe('singleRequest enabled', function () {
it('handles bidRequest of type Array and returns associated adUnits', function () {
const overrideMap = [];
- overrideMap[0] = { impression_id: '1' };
+ overrideMap[0] = {impression_id: '1'};
const stubAds = [];
for (let i = 0; i < 10; i++) {
@@ -2709,7 +2574,8 @@ describe('the rubicon adapter', function () {
'tracking': '',
'inventory': {},
'ads': stubAds
- }}, { bidRequest: stubBids });
+ }
+ }, {bidRequest: stubBids});
expect(bids).to.be.a('array').with.lengthOf(10);
bids.forEach((bid) => {
@@ -2742,7 +2608,7 @@ describe('the rubicon adapter', function () {
it('handles incorrect adUnits length by returning all bids with matching ads', function () {
const overrideMap = [];
- overrideMap[0] = { impression_id: '1' };
+ overrideMap[0] = {impression_id: '1'};
const stubAds = [];
for (let i = 0; i < 6; i++) {
@@ -2764,7 +2630,8 @@ describe('the rubicon adapter', function () {
'tracking': '',
'inventory': {},
'ads': stubAds
- }}, { bidRequest: stubBids });
+ }
+ }, {bidRequest: stubBids});
// no bids expected because response didn't match requested bid number
expect(bids).to.be.a('array').with.lengthOf(6);
@@ -2775,11 +2642,11 @@ describe('the rubicon adapter', function () {
// Create overrides to break associations between bids and ads
// Each override should cause one less bid to be returned by interpretResponse
const overrideMap = [];
- overrideMap[0] = { impression_id: '1' };
- overrideMap[2] = { status: 'error' };
- overrideMap[4] = { status: 'error' };
- overrideMap[7] = { status: 'error' };
- overrideMap[8] = { status: 'error' };
+ overrideMap[0] = {impression_id: '1'};
+ overrideMap[2] = {status: 'error'};
+ overrideMap[4] = {status: 'error'};
+ overrideMap[7] = {status: 'error'};
+ overrideMap[8] = {status: 'error'};
for (let i = 0; i < 10; i++) {
stubAds.push(createResponseAdByIndex(i, sizeMap[i].sizeId, overrideMap));
@@ -2800,7 +2667,8 @@ describe('the rubicon adapter', function () {
'tracking': '',
'inventory': {},
'ads': stubAds
- }}, { bidRequest: stubBids });
+ }
+ }, {bidRequest: stubBids});
expect(bids).to.be.a('array').with.lengthOf(6);
bids.forEach((bid) => {
@@ -2891,12 +2759,7 @@ describe('the rubicon adapter', function () {
describe('config with integration type', () => {
it('should use the integration type provided in the config instead of the default', () => {
- sandbox.stub(config, 'getConfig').callsFake(function (key) {
- const config = {
- 'rubicon.int_type': 'testType'
- };
- return config[key];
- });
+ config.setConfig({rubicon: {int_type: 'testType'}});
const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
expect(parseQuery(request.data).tk_flint).to.equal('testType_v$prebid.version$');
});
@@ -2931,7 +2794,7 @@ describe('the rubicon adapter', function () {
});
it('should pass gdpr params if consent is true', function () {
- expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {
+ expect(spec.getUserSyncs({iframeEnabled: true}, {}, {
gdprApplies: true, consentString: 'foo'
})).to.deep.equal({
type: 'iframe', url: `${emilyUrl}?gdpr=1&gdpr_consent=foo`
@@ -2939,7 +2802,7 @@ describe('the rubicon adapter', function () {
});
it('should pass gdpr params if consent is false', function () {
- expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {
+ expect(spec.getUserSyncs({iframeEnabled: true}, {}, {
gdprApplies: false, consentString: 'foo'
})).to.deep.equal({
type: 'iframe', url: `${emilyUrl}?gdpr=0&gdpr_consent=foo`
@@ -2947,7 +2810,7 @@ describe('the rubicon adapter', function () {
});
it('should pass gdpr param gdpr_consent only when gdprApplies is undefined', function () {
- expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {
+ expect(spec.getUserSyncs({iframeEnabled: true}, {}, {
consentString: 'foo'
})).to.deep.equal({
type: 'iframe', url: `${emilyUrl}?gdpr_consent=foo`
@@ -2955,13 +2818,13 @@ describe('the rubicon adapter', function () {
});
it('should pass no params if gdpr consentString is not defined', function () {
- expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {})).to.deep.equal({
+ expect(spec.getUserSyncs({iframeEnabled: true}, {}, {})).to.deep.equal({
type: 'iframe', url: `${emilyUrl}`
});
});
it('should pass no params if gdpr consentString is a number', function () {
- expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {
+ expect(spec.getUserSyncs({iframeEnabled: true}, {}, {
consentString: 0
})).to.deep.equal({
type: 'iframe', url: `${emilyUrl}`
@@ -2969,7 +2832,7 @@ describe('the rubicon adapter', function () {
});
it('should pass no params if gdpr consentString is null', function () {
- expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {
+ expect(spec.getUserSyncs({iframeEnabled: true}, {}, {
consentString: null
})).to.deep.equal({
type: 'iframe', url: `${emilyUrl}`
@@ -2977,7 +2840,7 @@ describe('the rubicon adapter', function () {
});
it('should pass no params if gdpr consentString is a object', function () {
- expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {
+ expect(spec.getUserSyncs({iframeEnabled: true}, {}, {
consentString: {}
})).to.deep.equal({
type: 'iframe', url: `${emilyUrl}`
@@ -2985,19 +2848,19 @@ describe('the rubicon adapter', function () {
});
it('should pass no params if gdpr is not defined', function () {
- expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined)).to.deep.equal({
+ expect(spec.getUserSyncs({iframeEnabled: true}, {}, undefined)).to.deep.equal({
type: 'iframe', url: `${emilyUrl}`
});
});
it('should pass us_privacy if uspConsent is defined', function () {
- expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, '1NYN')).to.deep.equal({
+ expect(spec.getUserSyncs({iframeEnabled: true}, {}, undefined, '1NYN')).to.deep.equal({
type: 'iframe', url: `${emilyUrl}?us_privacy=1NYN`
});
});
it('should pass us_privacy after gdpr if both are present', function () {
- expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {
+ expect(spec.getUserSyncs({iframeEnabled: true}, {}, {
consentString: 'foo'
}, '1NYN')).to.deep.equal({
type: 'iframe', url: `${emilyUrl}?gdpr_consent=foo&us_privacy=1NYN`
@@ -3005,8 +2868,8 @@ describe('the rubicon adapter', function () {
});
});
- describe('get price granularity', function() {
- it('should return correct buckets for all price granularity values', function() {
+ describe('get price granularity', function () {
+ it('should return correct buckets for all price granularity values', function () {
const CUSTOM_PRICE_BUCKET_ITEM = {max: 5, increment: 0.5};
const mockConfig = {
@@ -3039,7 +2902,7 @@ describe('the rubicon adapter', function () {
});
});
- describe('Supply Chain Support', function() {
+ describe('Supply Chain Support', function () {
const nodePropsOrder = ['asi', 'sid', 'hp', 'rid', 'name', 'domain'];
let bidRequests;
let schainConfig;
@@ -3132,4 +2995,51 @@ describe('the rubicon adapter', function () {
expect(request[0].data.source.ext.schain).to.deep.equal(schain);
});
});
+
+ describe('configurable settings', function() {
+ afterEach(() => {
+ config.setConfig({
+ rubicon: {
+ bannerHost: 'rubicon',
+ videoHost: 'prebid-server',
+ syncHost: 'eus',
+ returnVast: false
+ }
+ });
+ config.resetConfig();
+ });
+
+ beforeEach(function () {
+ resetUserSync();
+ });
+
+ it('should update fastlane endpoint if', function () {
+ config.setConfig({
+ rubicon: {
+ bannerHost: 'fastlane-qa',
+ videoHost: 'prebid-server-qa',
+ syncHost: 'eus-qa',
+ returnVast: true
+ }
+ });
+
+ // banner
+ let [bannerRequest] = spec.buildRequests(bidderRequest.bids, bidderRequest);
+ expect(bannerRequest.url).to.equal('https://fastlane-qa.rubiconproject.com/a/api/fastlane.json');
+
+ // video and returnVast
+ createVideoBidderRequest();
+ let [videoRequest] = spec.buildRequests(bidderRequest.bids, bidderRequest);
+ let post = videoRequest.data;
+ expect(videoRequest.url).to.equal('https://prebid-server-qa.rubiconproject.com/openrtb2/auction');
+ expect(post.ext.prebid.cache.vastxml).to.have.property('returnCreative').that.is.an('boolean');
+ expect(post.ext.prebid.cache.vastxml.returnCreative).to.equal(true);
+
+ // user sync
+ let syncs = spec.getUserSyncs({
+ iframeEnabled: true
+ });
+ expect(syncs).to.deep.equal({type: 'iframe', url: 'https://eus-qa.rubiconproject.com/usync.html'});
+ });
+ });
});
diff --git a/test/spec/modules/smaatoBidAdapter_spec.js b/test/spec/modules/smaatoBidAdapter_spec.js
index 95eb36d8a0d..13716b51436 100644
--- a/test/spec/modules/smaatoBidAdapter_spec.js
+++ b/test/spec/modules/smaatoBidAdapter_spec.js
@@ -291,6 +291,36 @@ const combinedBannerAndVideoBidRequest = {
bidderWinsCount: 0
};
+const inAppBidRequest = {
+ bidder: 'smaato',
+ params: {
+ publisherId: 'publisherId',
+ adspaceId: 'adspaceId',
+ app: {
+ ifa: 'aDeviceId',
+ geo: {
+ lat: 33.3,
+ lon: -88.8
+ }
+ }
+ },
+ mediaTypes: {
+ banner: {
+ sizes: [[300, 50]]
+ }
+ },
+ adUnitCode: '/19968336/header-bid-tag-0',
+ transactionId: 'transactionId',
+ sizes: [[300, 50]],
+ bidId: 'bidId',
+ bidderRequestId: 'bidderRequestId',
+ auctionId: 'auctionId',
+ src: 'client',
+ bidRequestsCount: 1,
+ bidderRequestsCount: 1,
+ bidderWinsCount: 0
+};
+
describe('smaatoBidAdapterTest', () => {
describe('isBidRequestValid', () => {
it('has valid params', () => {
@@ -462,6 +492,27 @@ describe('smaatoBidAdapterTest', () => {
});
});
+ describe('in-app requests', () => {
+ it('add geo and ifa info to device object', () => {
+ let req = JSON.parse(spec.buildRequests([inAppBidRequest], defaultBidderRequest).data);
+ expect(req.device.geo).to.deep.equal({'lat': 33.3, 'lon': -88.8});
+ expect(req.device.ifa).to.equal('aDeviceId');
+ });
+ it('add only ifa to device object', () => {
+ let inAppBidRequestWithoutGeo = utils.deepClone(inAppBidRequest);
+ delete inAppBidRequestWithoutGeo.params.app.geo
+ let req = JSON.parse(spec.buildRequests([inAppBidRequestWithoutGeo], defaultBidderRequest).data);
+
+ expect(req.device.geo).to.not.exist;
+ expect(req.device.ifa).to.equal('aDeviceId');
+ });
+ it('add no specific device info if param does not exist', () => {
+ let req = JSON.parse(spec.buildRequests([singleBannerBidRequest], defaultBidderRequest).data);
+ expect(req.device.geo).to.not.exist;
+ expect(req.device.ifa).to.not.exist;
+ });
+ });
+
describe('interpretResponse', () => {
it('single image reponse', () => {
const bids = spec.interpretResponse(openRtbBidResponse(ADTYPE_IMG), request);
@@ -501,5 +552,11 @@ describe('smaatoBidAdapterTest', () => {
expect(bids[0].ttl).to.equal(400);
clock.restore();
});
+ it('uses net revenue flag send from server', () => {
+ let resp = openRtbBidResponse(ADTYPE_IMG);
+ resp.body.seatbid[0].bid[0].ext = {net: false};
+ const bids = spec.interpretResponse(resp, request);
+ expect(bids[0].netRevenue).to.equal(false);
+ })
});
});
diff --git a/test/spec/modules/smartadserverBidAdapter_spec.js b/test/spec/modules/smartadserverBidAdapter_spec.js
index 2faad47aca8..e3bca240a47 100644
--- a/test/spec/modules/smartadserverBidAdapter_spec.js
+++ b/test/spec/modules/smartadserverBidAdapter_spec.js
@@ -71,7 +71,7 @@ describe('Smart bid adapter tests', function () {
britepoolid: '1111',
criteoId: '1111',
digitrustid: { data: { id: 'DTID', keyv: 4, privacy: { optout: false }, producer: 'ABC', version: 2 } },
- id5id: '1111',
+ id5id: { uid: '1111' },
idl_env: '1111',
lipbid: '1111',
parrableid: 'eidVersion.encryptionKeyReference.encryptedValue',
@@ -425,6 +425,7 @@ describe('Smart bid adapter tests', function () {
expect(bid.mediaType).to.equal('video');
expect(bid.vastUrl).to.equal('http://awesome.fake-vast.url');
expect(bid.vastXml).to.equal('');
+ expect(bid.content).to.equal('');
expect(bid.width).to.equal(640);
expect(bid.height).to.equal(480);
expect(bid.creativeId).to.equal('zioeufg');
@@ -473,6 +474,109 @@ describe('Smart bid adapter tests', function () {
});
});
+ describe('Outstream video tests', function () {
+ afterEach(function () {
+ config.resetConfig();
+ $$PREBID_GLOBAL$$.requestBids.removeAll();
+ });
+
+ const OUTSTREAM_DEFAULT_PARAMS = [{
+ adUnitCode: 'sas_43',
+ bidId: 'abcd1234',
+ bidder: 'smartadserver',
+ mediaTypes: {
+ video: {
+ context: 'outstream',
+ playerSize: [[800, 600]] // It seems prebid.js transforms the player size array into an array of array...
+ }
+ },
+ params: {
+ siteId: '1234',
+ pageId: '5678',
+ formatId: '91',
+ target: 'test=prebid-outstream',
+ bidfloor: 0.430,
+ buId: '7579',
+ appName: 'Mozilla',
+ ckId: 43,
+ video: {
+ protocol: 7
+ }
+ },
+ requestId: 'efgh5679',
+ transactionId: 'zsfgzzga'
+ }];
+
+ var OUTSTREAM_BID_RESPONSE = {
+ body: {
+ cpm: 14,
+ width: 800,
+ height: 600,
+ creativeId: 'zioeufga',
+ currency: 'USD',
+ isNetCpm: true,
+ ttl: 300,
+ adUrl: 'http://awesome.fake-vast2.url',
+ ad: '',
+ cSyncUrl: 'http://awesome.fake2.csync.url'
+ }
+ };
+
+ it('Verify outstream video build request', function () {
+ config.setConfig({
+ 'currency': {
+ 'adServerCurrency': 'EUR'
+ }
+ });
+ const request = spec.buildRequests(OUTSTREAM_DEFAULT_PARAMS);
+ expect(request[0]).to.have.property('url').and.to.equal('https://prg.smartadserver.com/prebid/v1');
+ expect(request[0]).to.have.property('method').and.to.equal('POST');
+ const requestContent = JSON.parse(request[0].data);
+ expect(requestContent).to.have.property('siteid').and.to.equal('1234');
+ expect(requestContent).to.have.property('pageid').and.to.equal('5678');
+ expect(requestContent).to.have.property('formatid').and.to.equal('91');
+ expect(requestContent).to.have.property('currencyCode').and.to.equal('EUR');
+ expect(requestContent).to.have.property('bidfloor').and.to.equal(0.43);
+ expect(requestContent).to.have.property('targeting').and.to.equal('test=prebid-outstream');
+ expect(requestContent).to.have.property('tagId').and.to.equal('sas_43');
+ expect(requestContent).to.not.have.property('pageDomain');
+ expect(requestContent).to.have.property('transactionId').and.to.not.equal(null).and.to.not.be.undefined;
+ expect(requestContent).to.have.property('buid').and.to.equal('7579');
+ expect(requestContent).to.have.property('appname').and.to.equal('Mozilla');
+ expect(requestContent).to.have.property('ckid').and.to.equal(43);
+ expect(requestContent).to.have.property('isVideo').and.to.equal(false);
+ expect(requestContent).to.have.property('videoData');
+ expect(requestContent.videoData).to.have.property('videoProtocol').and.to.equal(7);
+ expect(requestContent.videoData).to.have.property('playerWidth').and.to.equal(800);
+ expect(requestContent.videoData).to.have.property('playerHeight').and.to.equal(600);
+ });
+
+ it('Verify outstream parse response', function () {
+ const request = spec.buildRequests(OUTSTREAM_DEFAULT_PARAMS);
+ const bids = spec.interpretResponse(OUTSTREAM_BID_RESPONSE, request[0]);
+ expect(bids).to.have.lengthOf(1);
+ const bid = bids[0];
+ expect(bid.cpm).to.equal(14);
+ expect(bid.mediaType).to.equal('video');
+ expect(bid.vastUrl).to.equal('http://awesome.fake-vast2.url');
+ expect(bid.vastXml).to.equal('');
+ expect(bid.content).to.equal('');
+ expect(bid.width).to.equal(800);
+ expect(bid.height).to.equal(600);
+ expect(bid.creativeId).to.equal('zioeufga');
+ expect(bid.currency).to.equal('USD');
+ expect(bid.netRevenue).to.equal(true);
+ expect(bid.ttl).to.equal(300);
+ expect(bid.requestId).to.equal(OUTSTREAM_DEFAULT_PARAMS[0].bidId);
+
+ expect(function () {
+ spec.interpretResponse(OUTSTREAM_BID_RESPONSE, {
+ data: 'invalid Json'
+ })
+ }).to.not.throw();
+ });
+ });
+
describe('External ids tests', function () {
it('Verify external ids in request and ids found', function () {
config.setConfig({
diff --git a/test/spec/modules/spotxBidAdapter_spec.js b/test/spec/modules/spotxBidAdapter_spec.js
index baece710ee1..798fb3eec10 100644
--- a/test/spec/modules/spotxBidAdapter_spec.js
+++ b/test/spec/modules/spotxBidAdapter_spec.js
@@ -1,4 +1,5 @@
import {expect} from 'chai';
+import {config} from 'src/config.js';
import {spec, GOOGLE_CONSENT} from 'modules/spotxBidAdapter.js';
describe('the spotx adapter', function () {
@@ -89,6 +90,7 @@ describe('the spotx adapter', function () {
expect(spec.isBidRequestValid(bid)).to.equal(false);
});
});
+
describe('buildRequests', function() {
var bid, bidRequestObj;
@@ -125,6 +127,7 @@ describe('the spotx adapter', function () {
page: 'prebid.js'
});
});
+
it('should change request parameters based on options sent', function() {
var request = spec.buildRequests([bid], bidRequestObj)[0];
expect(request.data.imp.video.ext).to.deep.equal({
@@ -152,7 +155,7 @@ describe('the spotx adapter', function () {
};
bid.userId = {
- id5id: 'id5id_1',
+ id5id: { uid: 'id5id_1' },
tdid: 'tdid_1'
};
@@ -202,7 +205,8 @@ describe('the spotx adapter', function () {
source: 'id5-sync.com',
uids: [{
id: 'id5id_1'
- }]
+ }],
+ ext: {}
},
{
source: 'adserver.org',
@@ -331,6 +335,50 @@ describe('the spotx adapter', function () {
expect(request.data.imp.video.ext.placement).to.equal(2);
expect(request.data.imp.video.ext.pos).to.equal(5);
});
+
+ it('should pass page param and override refererInfo.referer', function() {
+ var request;
+
+ bid.params.page = 'https://example.com';
+
+ var origGetConfig = config.getConfig;
+ sinon.stub(config, 'getConfig').callsFake(function (key) {
+ if (key === 'pageUrl') {
+ return 'https://www.spotx.tv';
+ }
+ return origGetConfig.apply(config, arguments);
+ });
+
+ request = spec.buildRequests([bid], bidRequestObj)[0];
+
+ expect(request.data.site.page).to.equal('https://example.com');
+ config.getConfig.restore();
+ });
+
+ it('should use pageUrl from config if page param is not passed', function() {
+ var request;
+
+ var origGetConfig = config.getConfig;
+ sinon.stub(config, 'getConfig').callsFake(function (key) {
+ if (key === 'pageUrl') {
+ return 'https://www.spotx.tv';
+ }
+ return origGetConfig.apply(config, arguments);
+ });
+
+ request = spec.buildRequests([bid], bidRequestObj)[0];
+
+ expect(request.data.site.page).to.equal('https://www.spotx.tv');
+ config.getConfig.restore();
+ });
+
+ it('should use refererInfo.referer if no page or pageUrl are passed', function() {
+ var request;
+
+ request = spec.buildRequests([bid], bidRequestObj)[0];
+
+ expect(request.data.site.page).to.equal('prebid.js');
+ });
});
describe('interpretResponse', function() {
diff --git a/test/spec/modules/stroeerCoreBidAdapter_spec.js b/test/spec/modules/stroeerCoreBidAdapter_spec.js
new file mode 100644
index 00000000000..dd02ebb7c8e
--- /dev/null
+++ b/test/spec/modules/stroeerCoreBidAdapter_spec.js
@@ -0,0 +1,532 @@
+import {assert} from 'chai';
+import {spec} from 'modules/stroeerCoreBidAdapter.js';
+import * as utils from 'src/utils.js';
+import {BANNER, VIDEO} from '../../../src/mediaTypes.js';
+
+describe('stroeerCore bid adapter', function () {
+ let sandbox;
+ let fakeServer;
+ let bidderRequest;
+ let clock;
+
+ beforeEach(() => {
+ bidderRequest = buildBidderRequest();
+ sandbox = sinon.sandbox.create();
+ fakeServer = sandbox.useFakeServer();
+ clock = sandbox.useFakeTimers();
+ });
+
+ afterEach(() => {
+ sandbox.restore();
+ });
+
+ function assertStandardFieldsOnBid(bidObject, bidId, ad, width, height, cpm) {
+ assert.propertyVal(bidObject, 'requestId', bidId);
+ assert.propertyVal(bidObject, 'ad', ad);
+ assert.propertyVal(bidObject, 'width', width);
+ assert.propertyVal(bidObject, 'height', height);
+ assert.propertyVal(bidObject, 'cpm', cpm);
+ assert.propertyVal(bidObject, 'currency', 'EUR');
+ assert.propertyVal(bidObject, 'netRevenue', true);
+ assert.propertyVal(bidObject, 'creativeId', '');
+ }
+
+ const AUCTION_ID = utils.getUniqueIdentifierStr();
+
+ // Vendor user ids and associated data
+ const userIds = Object.freeze({
+ criteoId: 'criteo-user-id',
+ digitrustid: {
+ data: {
+ id: 'encrypted-user-id==',
+ keyv: 4,
+ privacy: {optout: false},
+ producer: 'ABC',
+ version: 2
+ }
+ },
+ lipb: {
+ lipbid: 'T7JiRRvsRAmh88',
+ segments: ['999']
+ }
+ });
+
+ const buildBidderRequest = () => ({
+ auctionId: AUCTION_ID,
+ bidderRequestId: 'bidder-request-id-123',
+ bidderCode: 'stroeerCore',
+ timeout: 5000,
+ auctionStart: 10000,
+ bids: [{
+ bidId: 'bid1',
+ bidder: 'stroeerCore',
+ adUnitCode: 'div-1',
+ mediaTypes: {
+ banner: {
+ sizes: [[300, 600], [160, 60]]
+ }
+ },
+ params: {
+ sid: 'NDA='
+ },
+ userId: userIds
+ }, {
+ bidId: 'bid2',
+ bidder: 'stroeerCore',
+ adUnitCode: 'div-2',
+ mediaTypes: {
+ banner: {
+ sizes: [[728, 90]],
+ }
+ },
+ params: {
+ sid: 'ODA='
+ },
+ userId: userIds
+ }],
+ });
+
+ const buildBidderRequestPreVersion3 = () => {
+ const request = buildBidderRequest();
+ request.bids.forEach((bid) => {
+ bid.sizes = bid.mediaTypes.banner.sizes;
+ delete bid.mediaTypes;
+ bid.mediaType = 'banner';
+ });
+ return request;
+ };
+
+ const buildBidderResponse = () => ({
+ 'bids': [{
+ 'bidId': 'bid1', 'cpm': 4.0, 'width': 300, 'height': 600, 'ad': 'tag1
', 'tracking': {'brandId': 123}
+ }, {
+ 'bidId': 'bid2', 'cpm': 7.3, 'width': 728, 'height': 90, 'ad': 'tag2
'
+ }]
+ });
+
+ const createWindow = (href, params = {}) => {
+ let {parent, referrer, top, frameElement, placementElements = []} = params;
+
+ const protocol = (href.indexOf('https') === 0) ? 'https:' : 'http:';
+ const win = {
+ frameElement,
+ parent,
+ top,
+ location: {
+ protocol, href
+ },
+ document: {
+ createElement: function () {
+ return {
+ setAttribute: function () {
+ }
+ }
+ },
+ referrer,
+ getElementById: id => placementElements.find(el => el.id === id)
+ }
+ };
+
+ win.self = win;
+
+ if (!parent) {
+ win.parent = win;
+ }
+
+ if (!top) {
+ win.top = win;
+ }
+
+ return win;
+ };
+
+ function createElement(id, offsetTop = 0) {
+ return {
+ id,
+ getBoundingClientRect: function () {
+ return {
+ top: offsetTop, height: 1
+ }
+ }
+ }
+ }
+
+ function setupSingleWindow(sandBox, placementElements = [createElement('div-1', 17), createElement('div-2', 54)]) {
+ const win = createWindow('http://www.xyz.com/', {
+ parent: win, top: win, frameElement: createElement(undefined, 304), placementElements: placementElements
+ });
+
+ win.innerHeight = 200;
+
+ sandBox.stub(utils, 'getWindowSelf').returns(win);
+ sandBox.stub(utils, 'getWindowTop').returns(win);
+
+ return win;
+ }
+
+ function setupNestedWindows(sandBox, placementElements = [createElement('div-1', 17), createElement('div-2', 54)]) {
+ const topWin = createWindow('http://www.abc.org/', {referrer: 'http://www.google.com/?query=monkey'});
+ topWin.innerHeight = 800;
+
+ const midWin = createWindow('http://www.abc.org/', {parent: topWin, top: topWin, frameElement: createElement()});
+ midWin.innerHeight = 400;
+
+ const win = createWindow('http://www.xyz.com/', {
+ parent: midWin, top: topWin, frameElement: createElement(undefined, 304), placementElements
+ });
+
+ win.innerHeight = 200;
+
+ sandBox.stub(utils, 'getWindowSelf').returns(win);
+ sandBox.stub(utils, 'getWindowTop').returns(topWin);
+
+ return {topWin, midWin, win};
+ }
+
+ it('should only support BANNER mediaType', function () {
+ assert.deepEqual(spec.supportedMediaTypes, [BANNER]);
+ });
+
+ describe('bid validation entry point', () => {
+ let bidRequest;
+
+ beforeEach(() => {
+ bidRequest = buildBidderRequest().bids[0];
+ });
+
+ it('should have \"isBidRequestValid\" function', () => {
+ assert.isFunction(spec.isBidRequestValid);
+ });
+
+ it('should pass a valid bid', () => {
+ assert.isTrue(spec.isBidRequestValid(bidRequest));
+ });
+
+ it('should exclude bids without slot id param', () => {
+ bidRequest.params.sid = undefined;
+ assert.isFalse(spec.isBidRequestValid(bidRequest));
+ });
+
+ it('should exclude non-banner bids', () => {
+ delete bidRequest.mediaTypes.banner;
+ bidRequest.mediaTypes.video = {
+ playerSize: [640, 480]
+ };
+
+ assert.isFalse(spec.isBidRequestValid(bidRequest));
+ });
+
+ it('should exclude non-banner, pre-version 3 bids', () => {
+ delete bidRequest.mediaTypes;
+ bidRequest.mediaType = VIDEO;
+ assert.isFalse(spec.isBidRequestValid(bidRequest));
+ });
+ });
+
+ describe('build request entry point', () => {
+ it('should have \"buildRequests\" function', () => {
+ assert.isFunction(spec.buildRequests);
+ });
+
+ describe('url on server request info object', () => {
+ let win;
+ beforeEach(() => {
+ win = setupSingleWindow(sandbox);
+ });
+
+ afterEach(() => {
+ sandbox.restore();
+ });
+
+ it('should use hardcoded url as default endpoint', () => {
+ const bidReq = buildBidderRequest();
+ let serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq);
+
+ assert.equal(serverRequestInfo.method, 'POST');
+ assert.isObject(serverRequestInfo.data);
+ assert.equal(serverRequestInfo.url, 'https://hb.adscale.de/dsh');
+ });
+
+ describe('should use custom url if provided', () => {
+ const samples = [{
+ protocol: 'http:', params: {sid: 'ODA=', host: 'other.com', port: '234', path: '/xyz'}, expected: 'https://other.com:234/xyz'
+ }, {
+ protocol: 'https:', params: {sid: 'ODA=', host: 'other.com', port: '234', path: '/xyz'}, expected: 'https://other.com:234/xyz'
+ }, {
+ protocol: 'https:',
+ params: {sid: 'ODA=', host: 'other.com', port: '234', securePort: '871', path: '/xyz'},
+ expected: 'https://other.com:871/xyz'
+ }, {
+ protocol: 'http:', params: {sid: 'ODA=', port: '234', path: '/xyz'}, expected: 'https://hb.adscale.de:234/xyz'
+ }, ];
+
+ samples.forEach(sample => {
+ it(`should use ${sample.expected} as endpoint when given params ${JSON.stringify(sample.params)} and protocol ${sample.protocol}`,
+ function () {
+ win.location.protocol = sample.protocol;
+
+ const bidReq = buildBidderRequest();
+ bidReq.bids[0].params = sample.params;
+ bidReq.bids.length = 1;
+
+ let serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq);
+
+ assert.equal(serverRequestInfo.method, 'POST');
+ assert.isObject(serverRequestInfo.data);
+ assert.equal(serverRequestInfo.url, sample.expected);
+ });
+ });
+ });
+ });
+
+ describe('payload on server request info object', () => {
+ let topWin;
+ let win;
+
+ let placementElements;
+ beforeEach(() => {
+ placementElements = [createElement('div-1', 17), createElement('div-2', 54)];
+ ({ topWin, win } = setupNestedWindows(sandbox, placementElements));
+ });
+
+ afterEach(() => {
+ sandbox.restore();
+ });
+
+ it('should have expected JSON structure', () => {
+ clock.tick(13500);
+ const bidReq = buildBidderRequest();
+
+ const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq);
+
+ const expectedTimeout = bidderRequest.timeout - (13500 - bidderRequest.auctionStart);
+
+ assert.equal(expectedTimeout, 1500);
+
+ const expectedJsonPayload = {
+ 'id': AUCTION_ID,
+ 'timeout': expectedTimeout,
+ 'ref': topWin.document.referrer,
+ 'mpa': true,
+ 'ssl': false,
+ 'bids': [{
+ 'sid': 'NDA=', 'bid': 'bid1', 'siz': [[300, 600], [160, 60]], 'viz': true
+ }, {
+ 'sid': 'ODA=', 'bid': 'bid2', 'siz': [[728, 90]], 'viz': true
+ }],
+ 'user': {
+ 'euids': userIds
+ }
+ };
+
+ // trim away fields with undefined
+ const actualJsonPayload = JSON.parse(JSON.stringify(serverRequestInfo.data));
+
+ assert.deepEqual(actualJsonPayload, expectedJsonPayload);
+ });
+
+ it('should handle banner sizes for pre version 3', () => {
+ // Version 3 changes the way how banner sizes are accessed.
+ // We can support backwards compatibility with version 2.x
+ const bidReq = buildBidderRequestPreVersion3();
+ const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq);
+ assert.deepEqual(serverRequestInfo.data.bids[0].siz, [[300, 600], [160, 60]]);
+ assert.deepEqual(serverRequestInfo.data.bids[1].siz, [[728, 90]]);
+ });
+
+ describe('optional fields', () => {
+ it('should skip viz field when unable to determine visibility of placement', () => {
+ placementElements.length = 0;
+ const bidReq = buildBidderRequest();
+
+ const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq);
+ assert.lengthOf(serverRequestInfo.data.bids, 2);
+
+ for (let bid of serverRequestInfo.data.bids) {
+ assert.isUndefined(bid.viz);
+ }
+ });
+
+ it('should skip ref field when unable to determine document referrer', () => {
+ // i.e., empty if user came from bookmark, or web page using 'rel="noreferrer" on link, etc
+ buildBidderRequest();
+
+ const serverRequestInfo = spec.buildRequests(bidderRequest.bids, bidderRequest);
+ assert.lengthOf(serverRequestInfo.data.bids, 2);
+
+ for (let bid of serverRequestInfo.data.bids) {
+ assert.isUndefined(bid.ref);
+ }
+ });
+
+ const gdprSamples = [{consentString: 'RG9ua2V5IEtvbmc=', gdprApplies: true}, {consentString: 'UGluZyBQb25n', gdprApplies: false}];
+ gdprSamples.forEach((sample) => {
+ it(`should add GDPR info ${JSON.stringify(sample)} when provided`, () => {
+ const bidReq = buildBidderRequest();
+ bidReq.gdprConsent = sample;
+
+ const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq);
+
+ const actualGdpr = serverRequestInfo.data.gdpr;
+ assert.propertyVal(actualGdpr, 'applies', sample.gdprApplies);
+ assert.propertyVal(actualGdpr, 'consent', sample.consentString);
+ });
+ });
+
+ const skippableGdprSamples = [{consentString: null, gdprApplies: true}, //
+ {consentString: 'UGluZyBQb25n', gdprApplies: null}, //
+ {consentString: null, gdprApplies: null}, //
+ {consentString: undefined, gdprApplies: true}, //
+ {consentString: 'UGluZyBQb25n', gdprApplies: undefined}, //
+ {consentString: undefined, gdprApplies: undefined}];
+ skippableGdprSamples.forEach((sample) => {
+ it(`should not add GDPR info ${JSON.stringify(sample)} when one or more values are missing`, () => {
+ const bidReq = buildBidderRequest();
+ bidReq.gdprConsent = sample;
+
+ const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq);
+
+ const actualGdpr = serverRequestInfo.data.gdpr;
+ assert.isUndefined(actualGdpr);
+ });
+ });
+
+ it('should be able to build without third party user id data', () => {
+ const bidReq = buildBidderRequest();
+ bidReq.bids.forEach(bid => delete bid.userId);
+ const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq);
+ assert.lengthOf(serverRequestInfo.data.bids, 2);
+ assert.notProperty(serverRequestInfo, 'uids');
+ });
+ });
+ });
+ });
+
+ describe('interpret response entry point', () => {
+ it('should have \"interpretResponse\" function', () => {
+ assert.isFunction(spec.interpretResponse);
+ });
+
+ const invalidResponses = ['', ' ', ' ', undefined, null];
+ invalidResponses.forEach(sample => {
+ it('should ignore invalid responses (\"' + sample + '\") response', () => {
+ const result = spec.interpretResponse({body: sample});
+ assert.isArray(result);
+ assert.lengthOf(result, 0);
+ });
+ });
+
+ it('should interpret a standard response', () => {
+ const bidderResponse = buildBidderResponse();
+
+ const result = spec.interpretResponse({body: bidderResponse});
+ assertStandardFieldsOnBid(result[0], 'bid1', 'tag1
', 300, 600, 4);
+ assertStandardFieldsOnBid(result[1], 'bid2', 'tag2
', 728, 90, 7.3);
+ });
+
+ it('should return empty array, when response contains no bids', () => {
+ const result = spec.interpretResponse({body: {bids: []}});
+ assert.deepStrictEqual(result, []);
+ });
+ });
+
+ describe('get user syncs entry point', () => {
+ let win;
+ beforeEach(() => {
+ win = setupSingleWindow(sandbox);
+
+ // fake
+ win.document.createElement = function () {
+ const attrs = {};
+ return {
+ setAttribute: (name, value) => {
+ attrs[name] = value
+ },
+ getAttribute: (name) => attrs[name],
+ hasAttribute: (name) => attrs[name] !== undefined,
+ tagName: 'SCRIPT',
+ }
+ }
+ });
+
+ it('should have \"getUserSyncs\" function', () => {
+ assert.isFunction(spec.getUserSyncs);
+ });
+
+ describe('when iframe option is enabled', () => {
+ it('should perform user connect when there was a response', () => {
+ const expectedUrl = 'https://js.adscale.de/pbsync.html';
+ const userSyncResponse = spec.getUserSyncs({iframeEnabled: true}, ['']);
+
+ assert.deepStrictEqual(userSyncResponse, [{type: 'iframe', url: expectedUrl}]);
+ });
+
+ it('should not perform user connect when there was no response', () => {
+ const userSyncResponse = spec.getUserSyncs({iframeEnabled: true}, []);
+
+ assert.deepStrictEqual(userSyncResponse, []);
+ });
+
+ describe('and gdpr consent is defined', () => {
+ describe('and gdpr applies', () => {
+ it('should place gdpr query param to the user sync url with value of 1', () => {
+ const expectedUrl = 'https://js.adscale.de/pbsync.html?gdpr=1&gdpr_consent=';
+ const userSyncResponse = spec.getUserSyncs({iframeEnabled: true}, [''], {gdprApplies: true});
+
+ assert.deepStrictEqual(userSyncResponse, [{type: 'iframe', url: expectedUrl}]);
+ });
+ });
+
+ describe('and gdpr does not apply', () => {
+ it('should place gdpr query param to the user sync url with zero value', () => {
+ const expectedUrl = 'https://js.adscale.de/pbsync.html?gdpr=0&gdpr_consent=';
+ const userSyncResponse = spec.getUserSyncs({iframeEnabled: true}, [''], {gdprApplies: false});
+
+ assert.deepStrictEqual(userSyncResponse, [{type: 'iframe', url: expectedUrl}]);
+ });
+
+ describe('because consent does not specify it', () => {
+ it('should place gdpr query param to the user sync url with zero value', () => {
+ const expectedUrl = 'https://js.adscale.de/pbsync.html?gdpr=0&gdpr_consent=';
+ const userSyncResponse = spec.getUserSyncs({iframeEnabled: true}, [''], {});
+
+ assert.deepStrictEqual(userSyncResponse, [{type: 'iframe', url: expectedUrl}]);
+ });
+ });
+ });
+
+ describe('and consent string is defined', () => {
+ it('should pass consent string to gdpr consent query param', () => {
+ const consentString = 'consent_string';
+ const expectedUrl = `https://js.adscale.de/pbsync.html?gdpr=1&gdpr_consent=${consentString}`;
+ const userSyncResponse = spec.getUserSyncs({iframeEnabled: true}, [''], {gdprApplies: true, consentString});
+
+ assert.deepStrictEqual(userSyncResponse, [{type: 'iframe', url: expectedUrl}]);
+ });
+
+ it('should correctly escape invalid characters', () => {
+ const consentString = 'consent ?stri&ng';
+ const expectedUrl = `https://js.adscale.de/pbsync.html?gdpr=1&gdpr_consent=consent%20%3Fstri%26ng`;
+ const userSyncResponse = spec.getUserSyncs({iframeEnabled: true}, [''], {gdprApplies: true, consentString});
+
+ assert.deepStrictEqual(userSyncResponse, [{type: 'iframe', url: expectedUrl}]);
+ });
+ });
+ });
+ });
+
+ describe('when iframe option is disabled', () => {
+ it('should not perform user connect even when there was a response', () => {
+ const userSyncResponse = spec.getUserSyncs({iframeEnabled: false}, ['']);
+
+ assert.deepStrictEqual(userSyncResponse, []);
+ });
+
+ it('should not perform user connect when there was no response', () => {
+ const userSyncResponse = spec.getUserSyncs({iframeEnabled: false}, []);
+
+ assert.deepStrictEqual(userSyncResponse, []);
+ });
+ });
+ });
+});
diff --git a/test/spec/modules/sublimeBidAdapter_spec.js b/test/spec/modules/sublimeBidAdapter_spec.js
index ae9e293a757..008f24730bc 100644
--- a/test/spec/modules/sublimeBidAdapter_spec.js
+++ b/test/spec/modules/sublimeBidAdapter_spec.js
@@ -149,7 +149,7 @@ describe('Sublime Adapter', function() {
currency: 'USD',
netRevenue: true,
ttl: 600,
- pbav: '0.5.2',
+ pbav: '0.6.0',
ad: '',
},
];
@@ -191,7 +191,7 @@ describe('Sublime Adapter', function() {
netRevenue: true,
ttl: 600,
ad: '',
- pbav: '0.5.2',
+ pbav: '0.6.0',
};
expect(result[0]).to.deep.equal(expectedResponse);
@@ -241,7 +241,7 @@ describe('Sublime Adapter', function() {
netRevenue: true,
ttl: 600,
ad: '',
- pbav: '0.5.2',
+ pbav: '0.6.0',
};
expect(result[0]).to.deep.equal(expectedResponse);
diff --git a/test/spec/modules/teadsBidAdapter_spec.js b/test/spec/modules/teadsBidAdapter_spec.js
index 17841b271d4..a6ae17ec8ff 100644
--- a/test/spec/modules/teadsBidAdapter_spec.js
+++ b/test/spec/modules/teadsBidAdapter_spec.js
@@ -200,8 +200,8 @@ describe('teadsBidAdapter', () => {
performance.getEntriesByType('navigation')[0] &&
performance.getEntriesByType('navigation')[0].responseStart &&
performance.getEntriesByType('navigation')[0].requestStart &&
- performance.getEntriesByType('navigation')[0].responseStart >= 0 &&
- performance.getEntriesByType('navigation')[0].requestStart >= 0 &&
+ performance.getEntriesByType('navigation')[0].responseStart > 0 &&
+ performance.getEntriesByType('navigation')[0].requestStart > 0 &&
Math.round(
performance.getEntriesByType('navigation')[0].responseStart - performance.getEntriesByType('navigation')[0].requestStart
);
@@ -211,9 +211,15 @@ describe('teadsBidAdapter', () => {
if (ttfbExpectedV2) {
expect(payload.timeToFirstByte).to.deep.equal(ttfbExpectedV2.toString());
} else {
- const ttfbExpectedV1 = performance.timing.responseStart - performance.timing.requestStart;
-
- expect(payload.timeToFirstByte).to.deep.equal(ttfbExpectedV1.toString());
+ const ttfbWithTimingV1 = performance &&
+ performance.timing.responseStart &&
+ performance.timing.requestStart &&
+ performance.timing.responseStart > 0 &&
+ performance.timing.requestStart > 0 &&
+ performance.timing.responseStart - performance.timing.requestStart;
+ const ttfbExpectedV1 = ttfbWithTimingV1 ? ttfbWithTimingV1.toString() : '';
+
+ expect(payload.timeToFirstByte).to.deep.equal(ttfbExpectedV1);
}
});
diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js
index c6c3b622755..797b3fab0c1 100644
--- a/test/spec/modules/tripleliftBidAdapter_spec.js
+++ b/test/spec/modules/tripleliftBidAdapter_spec.js
@@ -4,6 +4,7 @@ import { newBidder } from 'src/adapters/bidderFactory.js';
import { deepClone } from 'src/utils.js';
import { config } from 'src/config.js';
import prebid from '../../../package.json';
+import * as utils from 'src/utils.js';
const ENDPOINT = 'https://tlx.3lift.com/header/auction?';
const GDPR_CONSENT_STR = 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY';
@@ -11,6 +12,7 @@ const GDPR_CONSENT_STR = 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7V
describe('triplelift adapter', function () {
const adapter = newBidder(tripleliftAdapterSpec);
let bid, instreamBid;
+ let sandbox;
this.beforeEach(() => {
bid = {
@@ -194,6 +196,10 @@ describe('triplelift adapter', function () {
gdprApplies: true
},
};
+ sandbox = sinon.sandbox.create();
+ });
+ afterEach(() => {
+ sandbox.restore();
});
it('exists and is an object', function () {
@@ -397,6 +403,31 @@ describe('triplelift adapter', function () {
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
expect(request.data.imp[0].floor).to.equal(1.99);
});
+ it('should send fpd on root level ext if kvps are available', function() {
+ const sens = null;
+ const category = ['news', 'weather', 'hurricane'];
+ const pmp_elig = 'true';
+ const fpd = {
+ context: {
+ pmp_elig,
+ category,
+ },
+ user: {
+ sens,
+ }
+ }
+ sandbox.stub(config, 'getConfig').callsFake(key => {
+ const config = {
+ fpd
+ };
+ return utils.deepAccess(config, key);
+ });
+ const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
+ const { data: payload } = request;
+ expect(payload.ext.fpd).to.not.haveOwnProperty('sens');
+ expect(payload.ext.fpd).to.haveOwnProperty('category');
+ expect(payload.ext.fpd).to.haveOwnProperty('pmp_elig');
+ });
});
describe('interpretResponse', function () {
@@ -413,6 +444,7 @@ describe('triplelift adapter', function () {
ad: 'ad-markup',
iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg',
tl_source: 'tlx',
+ advertiser_name: 'fake advertiser name'
},
{
imp_id: 1,
@@ -486,6 +518,7 @@ describe('triplelift adapter', function () {
currency: 'USD',
ttl: 33,
tl_source: 'tlx',
+ meta: {}
},
{
requestId: '30b31c1838de1e',
@@ -501,6 +534,7 @@ describe('triplelift adapter', function () {
tl_source: 'hdx',
mediaType: 'video',
vastXml: 'The Trade Desk',
+ meta: {}
}
];
let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest});
@@ -513,6 +547,12 @@ describe('triplelift adapter', function () {
let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest});
expect(result).to.have.length(2);
});
+
+ it('should include the advertiser name in the meta field if available', function () {
+ let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest});
+ expect(result[0].meta.advertiserName).to.equal('fake advertiser name')
+ expect(result[1].meta).to.not.have.key('advertiserName');
+ });
});
describe('getUserSyncs', function() {
diff --git a/test/spec/modules/undertoneBidAdapter_spec.js b/test/spec/modules/undertoneBidAdapter_spec.js
index 72321ce415b..e8729965c50 100644
--- a/test/spec/modules/undertoneBidAdapter_spec.js
+++ b/test/spec/modules/undertoneBidAdapter_spec.js
@@ -94,7 +94,8 @@ const bidReqUserIds = [{
userId: {
idl_env: '1111',
tdid: '123456',
- digitrustid: {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}}
+ digitrustid: {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}},
+ id5id: { uid: '1111' }
}
},
{
@@ -316,6 +317,7 @@ describe('Undertone Adapter', () => {
expect(bidCommons.uids.tdid).to.equal('123456');
expect(bidCommons.uids.idl_env).to.equal('1111');
expect(bidCommons.uids.digitrustid.data.id).to.equal('DTID');
+ expect(bidCommons.uids.id5id.uid).to.equal('1111');
});
it('should send page sizes sizes correctly', function () {
const request = spec.buildRequests(bidReqUserIds, bidderReq);
diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js
index 5ac68de345d..5dac5db7b54 100644
--- a/test/spec/modules/userId_spec.js
+++ b/test/spec/modules/userId_spec.js
@@ -1,13 +1,13 @@
import {
attachIdSystem,
auctionDelay,
+ coreStorage,
init,
requestBidsHook,
- setSubmoduleRegistry,
- syncDelay,
- coreStorage,
+ setStoredConsentData,
setStoredValue,
- setStoredConsentData
+ setSubmoduleRegistry,
+ syncDelay
} from 'modules/userId/index.js';
import {createEidsArray} from 'modules/userId/eids.js';
import {config} from 'src/config.js';
@@ -15,8 +15,11 @@ import * as utils from 'src/utils.js';
import events from 'src/events.js';
import CONSTANTS from 'src/constants.json';
import {getGlobal} from 'src/prebidGlobal.js';
-import {setConsentConfig, requestBidsHook as consentManagementRequestBidsHook, resetConsentData} from 'modules/consentManagement.js';
-import {gdprDataHandler} from 'src/adapterManager.js';
+import {
+ requestBidsHook as consentManagementRequestBidsHook,
+ resetConsentData,
+ setConsentConfig
+} from 'modules/consentManagement.js';
import {unifiedIdSubmodule} from 'modules/unifiedIdSystem.js';
import {pubCommonIdSubmodule} from 'modules/pubCommonIdSystem.js';
import {britepoolIdSubmodule} from 'modules/britepoolIdSystem.js';
@@ -26,16 +29,19 @@ import {liveIntentIdSubmodule} from 'modules/liveIntentIdSystem.js';
import {merkleIdSubmodule} from 'modules/merkleIdSystem.js';
import {netIdSubmodule} from 'modules/netIdSystem.js';
import {intentIqIdSubmodule} from 'modules/intentIqIdSystem.js';
+import {zeotapIdPlusSubmodule} from 'modules/zeotapIdPlusIdSystem.js';
import {sharedIdSubmodule} from 'modules/sharedIdSystem.js';
+import {haloIdSubmodule} from 'modules/haloIdSystem.js';
import {server} from 'test/mocks/xhr.js';
+import {pubProvidedIdSubmodule} from 'modules/pubProvidedSystem.js';
let assert = require('chai').assert;
let expect = require('chai').expect;
const EXPIRED_COOKIE_DATE = 'Thu, 01 Jan 1970 00:00:01 GMT';
const CONSENT_LOCAL_STORAGE_NAME = '_pbjs_userid_consent_data';
-describe('User ID', function() {
- function getConfigMock(configArr1, configArr2, configArr3, configArr4, configArr5, configArr6, configArr7, configArr8, configArr9) {
+describe('User ID', function () {
+ function getConfigMock(configArr1, configArr2, configArr3, configArr4, configArr5, configArr6, configArr7, configArr8, configArr9, configArr10) {
return {
userSync: {
syncDelay: 0,
@@ -48,7 +54,8 @@ describe('User ID', function() {
(configArr6 && configArr6.length >= 3) ? getStorageMock.apply(null, configArr6) : null,
(configArr7 && configArr7.length >= 3) ? getStorageMock.apply(null, configArr7) : null,
(configArr8 && configArr8.length >= 3) ? getStorageMock.apply(null, configArr8) : null,
- (configArr9 && configArr9.length >= 3) ? getStorageMock.apply(null, configArr9) : null
+ (configArr9 && configArr9.length >= 3) ? getStorageMock.apply(null, configArr9) : null,
+ (configArr10 && configArr10.length >= 3) ? getStorageMock.apply(null, configArr10) : null
].filter(i => i)
}
}
@@ -87,35 +94,35 @@ describe('User ID', function() {
return cfg;
}
- before(function() {
+ before(function () {
coreStorage.setCookie('_pubcid_optout', '', EXPIRED_COOKIE_DATE);
localStorage.removeItem('_pbjs_id_optout');
localStorage.removeItem('_pubcid_optout');
});
- beforeEach(function() {
+ beforeEach(function () {
coreStorage.setCookie(CONSENT_LOCAL_STORAGE_NAME, '', EXPIRED_COOKIE_DATE);
});
- describe('Decorate Ad Units', function() {
- beforeEach(function() {
+ describe('Decorate Ad Units', function () {
+ beforeEach(function () {
coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('pubcid_alt', 'altpubcid200000', (new Date(Date.now() + 5000).toUTCString()));
sinon.spy(coreStorage, 'setCookie');
});
- afterEach(function() {
+ afterEach(function () {
$$PREBID_GLOBAL$$.requestBids.removeAll();
config.resetConfig();
coreStorage.setCookie.restore();
});
- after(function() {
+ after(function () {
coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('pubcid_alt', '', EXPIRED_COOKIE_DATE);
});
- it('Check same cookie behavior', function() {
+ it('Check same cookie behavior', function () {
let adUnits1 = [getAdUnitMock()];
let adUnits2 = [getAdUnitMock()];
let innerAdUnits1;
@@ -150,7 +157,7 @@ describe('User ID', function() {
assert.deepEqual(innerAdUnits1, innerAdUnits2);
});
- it('Check different cookies', function() {
+ it('Check different cookies', function () {
let adUnits1 = [getAdUnitMock()];
let adUnits2 = [getAdUnitMock()];
let innerAdUnits1;
@@ -201,7 +208,7 @@ describe('User ID', function() {
expect(pubcid1).to.not.equal(pubcid2);
});
- it('Use existing cookie', function() {
+ it('Use existing cookie', function () {
let adUnits = [getAdUnitMock()];
let innerAdUnits;
@@ -226,7 +233,7 @@ describe('User ID', function() {
expect(coreStorage.setCookie.callCount).to.equal(1);
});
- it('Extend cookie', function() {
+ it('Extend cookie', function () {
let adUnits = [getAdUnitMock()];
let innerAdUnits;
let customConfig = getConfigMock(['pubCommonId', 'pubcid_alt', 'cookie']);
@@ -253,7 +260,7 @@ describe('User ID', function() {
expect(coreStorage.setCookie.callCount).to.equal(2);
});
- it('Disable auto create', function() {
+ it('Disable auto create', function () {
let adUnits = [getAdUnitMock()];
let innerAdUnits;
let customConfig = getConfigMock(['pubCommonId', 'pubcid', 'cookie']);
@@ -275,7 +282,7 @@ describe('User ID', function() {
expect(coreStorage.setCookie.callCount).to.equal(1);
});
- it('pbjs.getUserIds', function() {
+ it('pbjs.getUserIds', function () {
setSubmoduleRegistry([pubCommonIdSubmodule]);
init(config);
config.setConfig({
@@ -290,7 +297,7 @@ describe('User ID', function() {
expect((getGlobal()).getUserIds()).to.deep.equal({pubcid: '11111'});
});
- it('pbjs.getUserIdsAsEids', function() {
+ it('pbjs.getUserIdsAsEids', function () {
setSubmoduleRegistry([pubCommonIdSubmodule]);
init(config);
config.setConfig({
@@ -306,16 +313,16 @@ describe('User ID', function() {
});
});
- describe('Opt out', function() {
- before(function() {
+ describe('Opt out', function () {
+ before(function () {
coreStorage.setCookie('_pbjs_id_optout', '1', (new Date(Date.now() + 5000).toUTCString()));
});
- beforeEach(function() {
+ beforeEach(function () {
sinon.stub(utils, 'logInfo');
});
- afterEach(function() {
+ afterEach(function () {
// removed cookie
coreStorage.setCookie('_pbjs_id_optout', '', EXPIRED_COOKIE_DATE);
$$PREBID_GLOBAL$$.requestBids.removeAll();
@@ -323,18 +330,18 @@ describe('User ID', function() {
config.resetConfig();
});
- after(function() {
+ after(function () {
coreStorage.setCookie('_pbjs_id_optout', '', EXPIRED_COOKIE_DATE);
});
- it('fails initialization if opt out cookie exists', function() {
+ it('fails initialization if opt out cookie exists', function () {
setSubmoduleRegistry([pubCommonIdSubmodule]);
init(config);
config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie']));
expect(utils.logInfo.args[0][0]).to.exist.and.to.equal('User ID - opt-out cookie found, exit module');
});
- it('initializes if no opt out cookie exists', function() {
+ it('initializes if no opt out cookie exists', function () {
setSubmoduleRegistry([pubCommonIdSubmodule]);
init(config);
config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie']));
@@ -342,19 +349,19 @@ describe('User ID', function() {
});
});
- describe('Handle variations of config values', function() {
- beforeEach(function() {
+ describe('Handle variations of config values', function () {
+ beforeEach(function () {
sinon.stub(utils, 'logInfo');
});
- afterEach(function() {
+ afterEach(function () {
$$PREBID_GLOBAL$$.requestBids.removeAll();
utils.logInfo.restore();
config.resetConfig();
});
- it('handles config with no usersync object', function() {
- setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]);
+ it('handles config with no usersync object', function () {
+ setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule]);
init(config);
config.setConfig({});
// usersync is undefined, and no logInfo message for 'User ID - usersync config updated'
@@ -362,14 +369,14 @@ describe('User ID', function() {
});
it('handles config with empty usersync object', function () {
- setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]);
+ setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule]);
init(config);
config.setConfig({userSync: {}});
expect(typeof utils.logInfo.args[0]).to.equal('undefined');
});
it('handles config with usersync and userIds that are empty objs', function () {
- setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]);
+ setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule]);
init(config);
config.setConfig({
userSync: {
@@ -380,7 +387,7 @@ describe('User ID', function() {
});
it('handles config with usersync and userIds with empty names or that dont match a submodule.name', function () {
- setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]);
+ setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule]);
init(config);
config.setConfig({
userSync: {
@@ -397,20 +404,22 @@ describe('User ID', function() {
});
it('config with 1 configurations should create 1 submodules', function () {
- setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]);
+ setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule]);
init(config);
config.setConfig(getConfigMock(['unifiedId', 'unifiedid', 'cookie']));
expect(utils.logInfo.args[0][0]).to.exist.and.to.equal('User ID - usersync config updated for 1 submodules');
});
- it('config with 9 configurations should result in 9 submodules add', function () {
- setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, liveIntentIdSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]);
+ it('config with 11 configurations should result in 12 submodules add', function () {
+ setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, liveIntentIdSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule]);
init(config);
config.setConfig({
userSync: {
syncDelay: 0,
userIds: [{
+ name: 'pubProvidedId'
+ }, {
name: 'pubCommonId', value: {'pubcid': '11111'}
}, {
name: 'unifiedId',
@@ -435,15 +444,20 @@ describe('User ID', function() {
storage: {name: 'sharedid', type: 'cookie'}
}, {
name: 'intentIqId',
- storage: { name: 'intentIqId', type: 'cookie' }
+ storage: {name: 'intentIqId', type: 'cookie'}
+ }, {
+ name: 'haloId',
+ storage: {name: 'haloId', type: 'cookie'}
+ }, {
+ name: 'zeotapIdPlus'
}]
}
});
- expect(utils.logInfo.args[0][0]).to.exist.and.to.equal('User ID - usersync config updated for 9 submodules');
+ expect(utils.logInfo.args[0][0]).to.exist.and.to.equal('User ID - usersync config updated for 12 submodules');
});
it('config syncDelay updates module correctly', function () {
- setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]);
+ setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule]);
init(config);
config.setConfig({
userSync: {
@@ -458,7 +472,7 @@ describe('User ID', function() {
});
it('config auctionDelay updates module correctly', function () {
- setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]);
+ setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule]);
init(config);
config.setConfig({
userSync: {
@@ -473,7 +487,7 @@ describe('User ID', function() {
});
it('config auctionDelay defaults to 0 if not a number', function () {
- setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]);
+ setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule]);
init(config);
config.setConfig({
userSync: {
@@ -488,13 +502,13 @@ describe('User ID', function() {
});
});
- describe('auction and user sync delays', function() {
+ describe('auction and user sync delays', function () {
let sandbox;
let adUnits;
let mockIdCallback;
let auctionSpy;
- beforeEach(function() {
+ beforeEach(function () {
sandbox = sinon.createSandbox();
sandbox.stub(global, 'setTimeout').returns(2);
sandbox.stub(events, 'on');
@@ -509,12 +523,12 @@ describe('User ID', function() {
mockIdCallback = sandbox.stub();
const mockIdSystem = {
name: 'mockId',
- decode: function(value) {
+ decode: function (value) {
return {
'mid': value['MOCKID']
};
},
- getId: function() {
+ getId: function () {
const storedId = coreStorage.getCookie('MOCKID');
if (storedId) {
return {id: {'MOCKID': storedId}};
@@ -528,13 +542,13 @@ describe('User ID', function() {
attachIdSystem(mockIdSystem, true);
});
- afterEach(function() {
+ afterEach(function () {
$$PREBID_GLOBAL$$.requestBids.removeAll();
config.resetConfig();
sandbox.restore();
});
- it('delays auction if auctionDelay is set, timing out at auction delay', function() {
+ it('delays auction if auctionDelay is set, timing out at auction delay', function () {
config.setConfig({
userSync: {
auctionDelay: 33,
@@ -567,7 +581,7 @@ describe('User ID', function() {
events.on.called.should.equal(false);
});
- it('delays auction if auctionDelay is set, continuing auction if ids are fetched before timing out', function(done) {
+ it('delays auction if auctionDelay is set, continuing auction if ids are fetched before timing out', function (done) {
config.setConfig({
userSync: {
auctionDelay: 33,
@@ -606,7 +620,7 @@ describe('User ID', function() {
events.on.called.should.equal(false);
});
- it('does not delay auction if not set, delays id fetch after auction ends with syncDelay', function() {
+ it('does not delay auction if not set, delays id fetch after auction ends with syncDelay', function () {
config.setConfig({
userSync: {
syncDelay: 77,
@@ -642,7 +656,7 @@ describe('User ID', function() {
mockIdCallback.calledOnce.should.equal(true);
});
- it('does not delay user id sync after auction ends if set to 0', function() {
+ it('does not delay user id sync after auction ends if set to 0', function () {
config.setConfig({
userSync: {
syncDelay: 0,
@@ -671,7 +685,7 @@ describe('User ID', function() {
mockIdCallback.calledOnce.should.equal(true);
});
- it('does not delay auction if there are no ids to fetch', function() {
+ it('does not delay auction if there are no ids to fetch', function () {
coreStorage.getCookie.withArgs('MOCKID').returns('123456778');
config.setConfig({
userSync: {
@@ -694,21 +708,21 @@ describe('User ID', function() {
});
});
- describe('Request bids hook appends userId to bid objs in adapters', function() {
+ describe('Request bids hook appends userId to bid objs in adapters', function () {
let adUnits;
- beforeEach(function() {
+ beforeEach(function () {
adUnits = [getAdUnitMock()];
});
- it('test hook from pubcommonid cookie', function(done) {
+ it('test hook from pubcommonid cookie', function (done) {
coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 100000).toUTCString()));
setSubmoduleRegistry([pubCommonIdSubmodule]);
init(config);
config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.pubcid');
@@ -724,12 +738,12 @@ describe('User ID', function() {
}, {adUnits});
});
- it('test hook from pubcommonid config value object', function(done) {
+ it('test hook from pubcommonid config value object', function (done) {
setSubmoduleRegistry([pubCommonIdSubmodule]);
init(config);
config.setConfig(getConfigValueMock('pubCommonId', {'pubcidvalue': 'testpubcidvalue'}));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.pubcidvalue');
@@ -741,7 +755,7 @@ describe('User ID', function() {
}, {adUnits});
});
- it('test hook from pubcommonid html5', function(done) {
+ it('test hook from pubcommonid html5', function (done) {
// simulate existing browser local storage values
localStorage.setItem('unifiedid_alt', JSON.stringify({'TDID': 'testunifiedid_alt'}));
localStorage.setItem('unifiedid_alt_exp', '');
@@ -750,7 +764,7 @@ describe('User ID', function() {
init(config);
config.setConfig(getConfigMock(['unifiedId', 'unifiedid_alt', 'html5']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.tdid');
@@ -767,7 +781,7 @@ describe('User ID', function() {
}, {adUnits});
});
- it('test hook from identityLink html5', function(done) {
+ it('test hook from identityLink html5', function (done) {
// simulate existing browser local storage values
localStorage.setItem('idl_env', 'AiGNC8Z5ONyZKSpIPf');
localStorage.setItem('idl_env_exp', '');
@@ -775,7 +789,7 @@ describe('User ID', function() {
setSubmoduleRegistry([identityLinkSubmodule]);
init(config);
config.setConfig(getConfigMock(['identityLink', 'idl_env', 'html5']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.idl_env');
@@ -792,14 +806,14 @@ describe('User ID', function() {
}, {adUnits});
});
- it('test hook from identityLink cookie', function(done) {
+ it('test hook from identityLink cookie', function (done) {
coreStorage.setCookie('idl_env', 'AiGNC8Z5ONyZKSpIPf', (new Date(Date.now() + 100000).toUTCString()));
setSubmoduleRegistry([identityLinkSubmodule]);
init(config);
config.setConfig(getConfigMock(['identityLink', 'idl_env', 'cookie']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.idl_env');
@@ -815,7 +829,7 @@ describe('User ID', function() {
}, {adUnits});
});
- it('test hook from liveIntentId html5', function(done) {
+ it('test hook from liveIntentId html5', function (done) {
// simulate existing browser local storage values
localStorage.setItem('_li_pbid', JSON.stringify({'unifiedId': 'random-ls-identifier'}));
localStorage.setItem('_li_pbid_exp', '');
@@ -823,7 +837,7 @@ describe('User ID', function() {
setSubmoduleRegistry([liveIntentIdSubmodule]);
init(config);
config.setConfig(getConfigMock(['liveIntentId', '_li_pbid', 'html5']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.lipb');
@@ -840,14 +854,14 @@ describe('User ID', function() {
}, {adUnits});
});
- it('test hook from liveIntentId cookie', function(done) {
+ it('test hook from liveIntentId cookie', function (done) {
coreStorage.setCookie('_li_pbid', JSON.stringify({'unifiedId': 'random-cookie-identifier'}), (new Date(Date.now() + 100000).toUTCString()));
setSubmoduleRegistry([liveIntentIdSubmodule]);
init(config);
config.setConfig(getConfigMock(['liveIntentId', '_li_pbid', 'cookie']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.lipb');
@@ -863,7 +877,7 @@ describe('User ID', function() {
}, {adUnits});
});
- it('test hook from sharedId html5', function(done) {
+ it('test hook from sharedId html5', function (done) {
// simulate existing browser local storage values
localStorage.setItem('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611}));
localStorage.setItem('sharedid_exp', '');
@@ -871,7 +885,7 @@ describe('User ID', function() {
setSubmoduleRegistry([sharedIdSubmodule]);
init(config);
config.setConfig(getConfigMock(['sharedId', 'sharedid', 'html5']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.sharedid');
@@ -899,7 +913,7 @@ describe('User ID', function() {
}, {adUnits});
});
- it('test hook from sharedId html5 (id not synced)', function(done) {
+ it('test hook from sharedId html5 (id not synced)', function (done) {
// simulate existing browser local storage values
localStorage.setItem('sharedid', JSON.stringify({'id': 'test_sharedId', 'ns': true, 'ts': 1590525289611}));
localStorage.setItem('sharedid_exp', '');
@@ -907,7 +921,7 @@ describe('User ID', function() {
setSubmoduleRegistry([sharedIdSubmodule]);
init(config);
config.setConfig(getConfigMock(['sharedId', 'sharedid', 'html5']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.sharedid');
@@ -929,14 +943,17 @@ describe('User ID', function() {
done();
}, {adUnits});
});
- it('test hook from sharedId cookie', function(done) {
- coreStorage.setCookie('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611}), (new Date(Date.now() + 100000).toUTCString()));
+ it('test hook from sharedId cookie', function (done) {
+ coreStorage.setCookie('sharedid', JSON.stringify({
+ 'id': 'test_sharedId',
+ 'ts': 1590525289611
+ }), (new Date(Date.now() + 100000).toUTCString()));
setSubmoduleRegistry([sharedIdSubmodule]);
init(config);
config.setConfig(getConfigMock(['sharedId', 'sharedid', 'cookie']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.sharedid');
@@ -962,14 +979,18 @@ describe('User ID', function() {
done();
}, {adUnits});
});
- it('test hook from sharedId cookie (id not synced) ', function(done) {
- coreStorage.setCookie('sharedid', JSON.stringify({'id': 'test_sharedId', 'ns': true, 'ts': 1590525289611}), (new Date(Date.now() + 100000).toUTCString()));
+ it('test hook from sharedId cookie (id not synced) ', function (done) {
+ coreStorage.setCookie('sharedid', JSON.stringify({
+ 'id': 'test_sharedId',
+ 'ns': true,
+ 'ts': 1590525289611
+ }), (new Date(Date.now() + 100000).toUTCString()));
setSubmoduleRegistry([sharedIdSubmodule]);
init(config);
config.setConfig(getConfigMock(['sharedId', 'sharedid', 'cookie']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.sharedid');
@@ -991,7 +1012,104 @@ describe('User ID', function() {
}, {adUnits});
});
- it('test hook from liveIntentId html5', function(done) {
+ it('test hook from pubProvidedId config params', function (done) {
+ setSubmoduleRegistry([pubProvidedIdSubmodule]);
+ init(config);
+ config.setConfig({
+ userSync: {
+ syncDelay: 0,
+ userIds: [{
+ name: 'pubProvidedId',
+ params: {
+ eids: [{
+ source: 'example.com',
+ uids: [{
+ id: 'value read from cookie or local storage',
+ ext: {
+ stype: 'ppuid'
+ }
+ }]
+ }, {
+ source: 'id-partner.com',
+ uids: [{
+ id: 'value read from cookie or local storage',
+ ext: {
+ stype: 'dmp'
+ }
+ }]
+ }],
+ eidsFunction: function () {
+ return [{
+ source: 'provider.com',
+ uids: [{
+ id: 'value read from cookie or local storage',
+ ext: {
+ stype: 'sha256email'
+ }
+ }]
+ }]
+ }
+ }
+ }
+ ]
+ }
+ });
+
+ requestBidsHook(function () {
+ adUnits.forEach(unit => {
+ unit.bids.forEach(bid => {
+ expect(bid).to.have.deep.nested.property('userId.pubProvidedId');
+ expect(bid.userId.pubProvidedId).to.deep.equal([{
+ source: 'example.com',
+ uids: [{
+ id: 'value read from cookie or local storage',
+ ext: {
+ stype: 'ppuid'
+ }
+ }]
+ }, {
+ source: 'id-partner.com',
+ uids: [{
+ id: 'value read from cookie or local storage',
+ ext: {
+ stype: 'dmp'
+ }
+ }]
+ }, {
+ source: 'provider.com',
+ uids: [{
+ id: 'value read from cookie or local storage',
+ ext: {
+ stype: 'sha256email'
+ }
+ }]
+ }]);
+
+ expect(bid.userIdAsEids[0]).to.deep.equal({
+ source: 'example.com',
+ uids: [{
+ id: 'value read from cookie or local storage',
+ ext: {
+ stype: 'ppuid'
+ }
+ }]
+ });
+ expect(bid.userIdAsEids[2]).to.deep.equal({
+ source: 'provider.com',
+ uids: [{
+ id: 'value read from cookie or local storage',
+ ext: {
+ stype: 'sha256email'
+ }
+ }]
+ });
+ });
+ });
+ done();
+ }, {adUnits});
+ });
+
+ it('test hook from liveIntentId html5', function (done) {
// simulate existing browser local storage values
localStorage.setItem('_li_pbid', JSON.stringify({'unifiedId': 'random-ls-identifier', 'segments': ['123']}));
localStorage.setItem('_li_pbid_exp', '');
@@ -999,7 +1117,7 @@ describe('User ID', function() {
setSubmoduleRegistry([liveIntentIdSubmodule]);
init(config);
config.setConfig(getConfigMock(['liveIntentId', '_li_pbid', 'html5']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.lipb');
@@ -1018,7 +1136,7 @@ describe('User ID', function() {
}, {adUnits});
});
- it('test hook from liveIntentId cookie', function(done) {
+ it('test hook from liveIntentId cookie', function (done) {
coreStorage.setCookie('_li_pbid', JSON.stringify({
'unifiedId': 'random-cookie-identifier',
'segments': ['123']
@@ -1028,7 +1146,7 @@ describe('User ID', function() {
init(config);
config.setConfig(getConfigMock(['liveIntentId', '_li_pbid', 'cookie']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.lipb');
@@ -1046,7 +1164,7 @@ describe('User ID', function() {
}, {adUnits});
});
- it('test hook from britepoolid cookies', function(done) {
+ it('test hook from britepoolid cookies', function (done) {
// simulate existing browser local storage values
coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': '279c0161-5152-487f-809e-05d7f7e653fd'}), (new Date(Date.now() + 5000).toUTCString()));
@@ -1054,7 +1172,7 @@ describe('User ID', function() {
init(config);
config.setConfig(getConfigMock(['britepoolId', 'britepoolid', 'cookie']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.britepoolid');
@@ -1070,7 +1188,7 @@ describe('User ID', function() {
}, {adUnits});
});
- it('test hook from netId cookies', function(done) {
+ it('test hook from netId cookies', function (done) {
// simulate existing browser local storage values
coreStorage.setCookie('netId', JSON.stringify({'netId': 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg'}), (new Date(Date.now() + 5000).toUTCString()));
@@ -1078,7 +1196,7 @@ describe('User ID', function() {
init(config);
config.setConfig(getConfigMock(['netId', 'netId', 'cookie']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.netId');
@@ -1094,15 +1212,15 @@ describe('User ID', function() {
}, {adUnits});
});
- it('test hook from intentIqId cookies', function(done) {
+ it('test hook from intentIqId cookies', function (done) {
// simulate existing browser local storage values
- coreStorage.setCookie('intentIqId', JSON.stringify({'ctrid': 'abcdefghijk'}), (new Date(Date.now() + 5000).toUTCString()));
+ coreStorage.setCookie('intentIqId', 'abcdefghijk', (new Date(Date.now() + 5000).toUTCString()));
setSubmoduleRegistry([intentIqIdSubmodule]);
init(config);
config.setConfig(getConfigMock(['intentIqId', 'intentIqId', 'cookie']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.intentIqId');
@@ -1118,7 +1236,33 @@ describe('User ID', function() {
}, {adUnits});
});
- it('test hook from merkleId cookies', function(done) {
+ it('test hook from haloId html5', function (done) {
+ // simulate existing browser local storage values
+ localStorage.setItem('haloId', JSON.stringify({'haloId': 'random-ls-identifier'}));
+ localStorage.setItem('haloId_exp', '');
+
+ setSubmoduleRegistry([haloIdSubmodule]);
+ init(config);
+ config.setConfig(getConfigMock(['haloId', 'haloId', 'html5']));
+
+ requestBidsHook(function () {
+ adUnits.forEach(unit => {
+ unit.bids.forEach(bid => {
+ expect(bid).to.have.deep.nested.property('userId.haloId');
+ expect(bid.userId.haloId).to.equal('random-ls-identifier');
+ expect(bid.userIdAsEids[0]).to.deep.equal({
+ source: 'audigent.com',
+ uids: [{id: 'random-ls-identifier', atype: 1}]
+ });
+ });
+ });
+ localStorage.removeItem('haloId');
+ localStorage.removeItem('haloId_exp', '');
+ done();
+ }, {adUnits});
+ });
+
+ it('test hook from merkleId cookies', function (done) {
// simulate existing browser local storage values
coreStorage.setCookie('merkleId', JSON.stringify({'ppid': {'id': 'testmerkleId'}}), (new Date(Date.now() + 5000).toUTCString()));
@@ -1126,7 +1270,7 @@ describe('User ID', function() {
init(config);
config.setConfig(getConfigMock(['merkleId', 'merkleId', 'cookie']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid).to.have.deep.nested.property('userId.merkleId');
@@ -1142,17 +1286,46 @@ describe('User ID', function() {
}, {adUnits});
});
- it('test hook when pubCommonId, unifiedId, id5Id, identityLink, britepoolId, intentIqId, sharedId and netId have data to pass', function(done) {
+ it('test hook from zeotapIdPlus cookies', function (done) {
+ // simulate existing browser local storage values
+ coreStorage.setCookie('IDP', btoa(JSON.stringify('abcdefghijk')), (new Date(Date.now() + 5000).toUTCString()));
+
+ setSubmoduleRegistry([zeotapIdPlusSubmodule]);
+ init(config);
+ config.setConfig(getConfigMock(['zeotapIdPlus', 'IDP', 'cookie']));
+
+ requestBidsHook(function () {
+ adUnits.forEach(unit => {
+ unit.bids.forEach(bid => {
+ expect(bid).to.have.deep.nested.property('userId.IDP');
+ expect(bid.userId.IDP).to.equal('abcdefghijk');
+ expect(bid.userIdAsEids[0]).to.deep.equal({
+ source: 'zeotap.com',
+ uids: [{id: 'abcdefghijk', atype: 1}]
+ });
+ });
+ });
+ coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE);
+ done();
+ }, {adUnits});
+ });
+
+ it('test hook when pubCommonId, unifiedId, id5Id, identityLink, britepoolId, intentIqId, zeotapIdPlus, sharedId, netId and haloId have data to pass', function (done) {
coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'testunifiedid'}), (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('id5id', JSON.stringify({'universal_uid': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('idl_env', 'AiGNC8Z5ONyZKSpIPf', (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), (new Date(Date.now() + 5000).toUTCString()));
- coreStorage.setCookie('intentIqId', JSON.stringify({'ctrid': 'testintentIqId'}), (new Date(Date.now() + 5000).toUTCString()));
- coreStorage.setCookie('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611}), (new Date(Date.now() + 5000).toUTCString()));
-
- setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]);
+ coreStorage.setCookie('intentIqId', 'testintentIqId', (new Date(Date.now() + 5000).toUTCString()));
+ coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString()));
+ coreStorage.setCookie('sharedid', JSON.stringify({
+ 'id': 'test_sharedId',
+ 'ts': 1590525289611
+ }), (new Date(Date.now() + 5000).toUTCString()));
+ coreStorage.setCookie('haloId', JSON.stringify({'haloId': 'testHaloId'}), (new Date(Date.now() + 5000).toUTCString()));
+
+ setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule]);
init(config);
config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'],
['unifiedId', 'unifiedid', 'cookie'],
@@ -1161,9 +1334,11 @@ describe('User ID', function() {
['britepoolId', 'britepoolid', 'cookie'],
['netId', 'netId', 'cookie'],
['sharedId', 'sharedid', 'cookie'],
- ['intentIqId', 'intentIqId', 'cookie']));
+ ['intentIqId', 'intentIqId', 'cookie'],
+ ['zeotapIdPlus', 'IDP', 'cookie'],
+ ['haloId', 'haloId', 'cookie']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
// verify that the PubCommonId id data was copied to bid
@@ -1173,8 +1348,8 @@ describe('User ID', function() {
expect(bid).to.have.deep.nested.property('userId.tdid');
expect(bid.userId.tdid).to.equal('testunifiedid');
// also check that Id5Id id data was copied to bid
- expect(bid).to.have.deep.nested.property('userId.id5id');
- expect(bid.userId.id5id).to.equal('testid5id');
+ expect(bid).to.have.deep.nested.property('userId.id5id.uid');
+ expect(bid.userId.id5id.uid).to.equal('testid5id');
// check that identityLink id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.idl_env');
expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf');
@@ -1192,7 +1367,13 @@ describe('User ID', function() {
// also check that intentIqId id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.intentIqId');
expect(bid.userId.intentIqId).to.equal('testintentIqId');
- expect(bid.userIdAsEids.length).to.equal(8);
+ // also check that zeotapIdPlus id data was copied to bid
+ expect(bid).to.have.deep.nested.property('userId.IDP');
+ expect(bid.userId.IDP).to.equal('zeotapId');
+ // also check that haloId id was copied to bid
+ expect(bid).to.have.deep.nested.property('userId.haloId');
+ expect(bid.userId.haloId).to.equal('testHaloId');
+ expect(bid.userIdAsEids.length).to.equal(10);
});
});
coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE);
@@ -1203,19 +1384,26 @@ describe('User ID', function() {
coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE);
+ coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE);
+ coreStorage.setCookie('haloId', '', EXPIRED_COOKIE_DATE);
done();
}, {adUnits});
});
- it('test hook when pubCommonId, unifiedId, id5Id, britepoolId, intentIqId, sharedId and netId have their modules added before and after init', function(done) {
+ it('test hook when pubCommonId, unifiedId, id5Id, britepoolId, intentIqId, zeotapIdPlus, sharedId, netId and haloId have their modules added before and after init', function (done) {
coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'cookie-value-add-module-variations'}), new Date(Date.now() + 5000).toUTCString());
coreStorage.setCookie('id5id', JSON.stringify({'universal_uid': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('idl_env', 'AiGNC8Z5ONyZKSpIPf', new Date(Date.now() + 5000).toUTCString());
coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), (new Date(Date.now() + 5000).toUTCString()));
- coreStorage.setCookie('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611}), (new Date(Date.now() + 5000).toUTCString()));
- coreStorage.setCookie('intentIqId', JSON.stringify({'ctrid': 'testintentIqId'}), (new Date(Date.now() + 5000).toUTCString()));
+ coreStorage.setCookie('sharedid', JSON.stringify({
+ 'id': 'test_sharedId',
+ 'ts': 1590525289611
+ }), (new Date(Date.now() + 5000).toUTCString()));
+ coreStorage.setCookie('intentIqId', 'testintentIqId', (new Date(Date.now() + 5000).toUTCString()));
+ coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString()));
+ coreStorage.setCookie('haloId', JSON.stringify({'haloId': 'testHaloId'}), (new Date(Date.now() + 5000).toUTCString()));
setSubmoduleRegistry([]);
@@ -1232,6 +1420,8 @@ describe('User ID', function() {
attachIdSystem(netIdSubmodule);
attachIdSystem(sharedIdSubmodule);
attachIdSystem(intentIqIdSubmodule);
+ attachIdSystem(zeotapIdPlusSubmodule);
+ attachIdSystem(haloIdSubmodule);
config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'],
['unifiedId', 'unifiedid', 'cookie'],
@@ -1240,9 +1430,11 @@ describe('User ID', function() {
['britepoolId', 'britepoolid', 'cookie'],
['netId', 'netId', 'cookie'],
['sharedId', 'sharedid', 'cookie'],
- ['intentIqId', 'intentIqId', 'cookie']));
+ ['intentIqId', 'intentIqId', 'cookie'],
+ ['zeotapIdPlus', 'IDP', 'cookie'],
+ ['haloId', 'haloId', 'cookie']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
// verify that the PubCommonId id data was copied to bid
@@ -1252,8 +1444,8 @@ describe('User ID', function() {
expect(bid).to.have.deep.nested.property('userId.tdid');
expect(bid.userId.tdid).to.equal('cookie-value-add-module-variations');
// also check that Id5Id id data was copied to bid
- expect(bid).to.have.deep.nested.property('userId.id5id');
- expect(bid.userId.id5id).to.equal('testid5id');
+ expect(bid).to.have.deep.nested.property('userId.id5id.uid');
+ expect(bid.userId.id5id.uid).to.equal('testid5id');
// also check that identityLink id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.idl_env');
expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf');
@@ -1271,7 +1463,14 @@ describe('User ID', function() {
// also check that intentIqId id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.intentIqId');
expect(bid.userId.intentIqId).to.equal('testintentIqId');
- expect(bid.userIdAsEids.length).to.equal(8);
+
+ // also check that zeotapIdPlus id data was copied to bid
+ expect(bid).to.have.deep.nested.property('userId.IDP');
+ expect(bid.userId.IDP).to.equal('zeotapId');
+ // also check that haloId id data was copied to bid
+ expect(bid).to.have.deep.nested.property('userId.haloId');
+ expect(bid.userId.haloId).to.equal('testHaloId');
+ expect(bid.userIdAsEids.length).to.equal(10);
});
});
coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE);
@@ -1282,12 +1481,17 @@ describe('User ID', function() {
coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE);
+ coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE);
+ coreStorage.setCookie('haloId', '', EXPIRED_COOKIE_DATE);
done();
}, {adUnits});
});
- it('test hook when sharedId(opted out) have their modules added before and after init', function(done) {
- coreStorage.setCookie('sharedid', JSON.stringify({'id': '00000000000000000000000000', 'ts': 1590525289611}), (new Date(Date.now() + 5000).toUTCString()));
+ it('test hook when sharedId(opted out) have their modules added before and after init', function (done) {
+ coreStorage.setCookie('sharedid', JSON.stringify({
+ 'id': '00000000000000000000000000',
+ 'ts': 1590525289611
+ }), (new Date(Date.now() + 5000).toUTCString()));
setSubmoduleRegistry([]);
init(config);
@@ -1296,7 +1500,7 @@ describe('User ID', function() {
config.setConfig(getConfigMock(['sharedId', 'sharedid', 'cookie']));
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
expect(bid.userIdAsEids).to.be.undefined;
@@ -1307,18 +1511,23 @@ describe('User ID', function() {
}, {adUnits});
});
- it('should add new id system ', function(done) {
+ it('should add new id system ', function (done) {
coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'cookie-value-add-module-variations'}), new Date(Date.now() + 5000).toUTCString());
coreStorage.setCookie('id5id', JSON.stringify({'universal_uid': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('idl_env', 'AiGNC8Z5ONyZKSpIPf', new Date(Date.now() + 5000).toUTCString());
coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), new Date(Date.now() + 5000).toUTCString());
- coreStorage.setCookie('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611}), new Date(Date.now() + 5000).toUTCString());
- coreStorage.setCookie('intentIqId', JSON.stringify({'ctrid': 'testintentIqId'}), (new Date(Date.now() + 5000).toUTCString()));
+ coreStorage.setCookie('sharedid', JSON.stringify({
+ 'id': 'test_sharedId',
+ 'ts': 1590525289611
+ }), new Date(Date.now() + 5000).toUTCString());
+ coreStorage.setCookie('intentIqId', 'testintentIqId', (new Date(Date.now() + 5000).toUTCString()));
+ coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString()));
+ coreStorage.setCookie('haloId', JSON.stringify({'haloId': 'testHaloId'}), (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('MOCKID', JSON.stringify({'MOCKID': '123456778'}), new Date(Date.now() + 5000).toUTCString());
- setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]);
+ setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule]);
init(config);
config.setConfig({
@@ -1339,7 +1548,11 @@ describe('User ID', function() {
}, {
name: 'sharedId', storage: {name: 'sharedid', type: 'cookie'}
}, {
- name: 'intentIqId', storage: { name: 'intentIqId', type: 'cookie' }
+ name: 'intentIqId', storage: {name: 'intentIqId', type: 'cookie'}
+ }, {
+ name: 'zeotapIdPlus'
+ }, {
+ name: 'haloId', storage: {name: 'haloId', type: 'cookie'}
}, {
name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'}
}]
@@ -1349,18 +1562,18 @@ describe('User ID', function() {
// Add new submodule named 'mockId'
attachIdSystem({
name: 'mockId',
- decode: function(value) {
+ decode: function (value) {
return {
'mid': value['MOCKID']
};
},
- getId: function(params, storedId) {
+ getId: function (config, storedId) {
if (storedId) return {};
return {id: {'MOCKID': '1234'}};
}
});
- requestBidsHook(function() {
+ requestBidsHook(function () {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
// check PubCommonId id data was copied to bid
@@ -1370,8 +1583,8 @@ describe('User ID', function() {
expect(bid).to.have.deep.nested.property('userId.tdid');
expect(bid.userId.tdid).to.equal('cookie-value-add-module-variations');
// also check that Id5Id id data was copied to bid
- expect(bid).to.have.deep.nested.property('userId.id5id');
- expect(bid.userId.id5id).to.equal('testid5id');
+ expect(bid).to.have.deep.nested.property('userId.id5id.uid');
+ expect(bid.userId.id5id.uid).to.equal('testid5id');
// also check that identityLink id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.idl_env');
expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf');
@@ -1393,7 +1606,13 @@ describe('User ID', function() {
// also check that intentIqId id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.intentIqId');
expect(bid.userId.intentIqId).to.equal('testintentIqId');
- expect(bid.userIdAsEids.length).to.equal(8);
+ // also check that zeotapIdPlus id data was copied to bid
+ expect(bid).to.have.deep.nested.property('userId.IDP');
+ expect(bid.userId.IDP).to.equal('zeotapId');
+ // also check that haloId id data was copied to bid
+ expect(bid).to.have.deep.nested.property('userId.haloId');
+ expect(bid.userId.haloId).to.equal('testHaloId');
+ expect(bid.userIdAsEids.length).to.equal(10);
});
});
coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE);
@@ -1404,14 +1623,16 @@ describe('User ID', function() {
coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE);
+ coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE);
+ coreStorage.setCookie('haloId', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('MOCKID', '', EXPIRED_COOKIE_DATE);
done();
}, {adUnits});
});
});
- describe('callbacks at the end of auction', function() {
- beforeEach(function() {
+ describe('callbacks at the end of auction', function () {
+ beforeEach(function () {
sinon.stub(events, 'getEvents').returns([]);
sinon.stub(utils, 'triggerPixel');
coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE);
@@ -1419,7 +1640,7 @@ describe('User ID', function() {
coreStorage.setCookie('_parrable_eid', '', EXPIRED_COOKIE_DATE);
});
- afterEach(function() {
+ afterEach(function () {
events.getEvents.restore();
utils.triggerPixel.restore();
coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE);
@@ -1427,7 +1648,7 @@ describe('User ID', function() {
coreStorage.setCookie('_parrable_eid', '', EXPIRED_COOKIE_DATE);
});
- it('pubcid callback with url', function() {
+ it('pubcid callback with url', function () {
let adUnits = [getAdUnitMock()];
let innerAdUnits;
let customCfg = getConfigMock(['pubCommonId', 'pubcid_alt', 'cookie']);
@@ -1445,7 +1666,7 @@ describe('User ID', function() {
expect(utils.triggerPixel.getCall(0).args[0]).to.include('/any/pubcid/url');
});
- it('unifiedid callback with url', function() {
+ it('unifiedid callback with url', function () {
let adUnits = [getAdUnitMock()];
let innerAdUnits;
let customCfg = getConfigMock(['unifiedId', 'unifiedid', 'cookie']);
@@ -1463,7 +1684,7 @@ describe('User ID', function() {
expect(server.requests[0].url).to.equal('/any/unifiedid/url');
});
- it('unifiedid callback with partner', function() {
+ it('unifiedid callback with partner', function () {
let adUnits = [getAdUnitMock()];
let innerAdUnits;
let customCfg = getConfigMock(['unifiedId', 'unifiedid', 'cookie']);
@@ -1482,7 +1703,7 @@ describe('User ID', function() {
});
});
- describe('Set cookie behavior', function() {
+ describe('Set cookie behavior', function () {
let coreStorageSpy;
beforeEach(function () {
coreStorageSpy = sinon.spy(coreStorage, 'setCookie');
@@ -1521,7 +1742,7 @@ describe('User ID', function() {
});
});
- describe('Consent changes determine getId refreshes', function() {
+ describe('Consent changes determine getId refreshes', function () {
let expStr;
let adUnits;
@@ -1557,7 +1778,7 @@ describe('User ID', function() {
allowAuctionWithoutConsent: false
};
- const sharedBeforeFunction = function() {
+ const sharedBeforeFunction = function () {
// clear cookies
expStr = (new Date(Date.now() + 25000).toUTCString());
coreStorage.setCookie(mockIdCookieName, '', EXPIRED_COOKIE_DATE);
@@ -1583,7 +1804,7 @@ describe('User ID', function() {
delete window.__tcfapi;
};
- describe('TCF v1', function() {
+ describe('TCF v1', function () {
testConsentData = {
gdprApplies: true,
consentData: 'xyz',
@@ -1594,7 +1815,8 @@ describe('User ID', function() {
sharedBeforeFunction();
// init v1 consent management
- window.__cmp = function () { };
+ window.__cmp = function () {
+ };
delete window.__tcfapi;
cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => {
args[2](testConsentData);
@@ -1602,17 +1824,20 @@ describe('User ID', function() {
setConsentConfig(consentConfig);
});
- afterEach(function() {
+ afterEach(function () {
sharedAfterFunction();
});
it('does not call getId if no stored consent data and refresh is not needed', function () {
- coreStorage.setCookie(mockIdCookieName, JSON.stringify({ id: '1234' }), expStr);
+ coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr);
coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr);
let innerAdUnits;
- consentManagementRequestBidsHook(() => { }, {});
- requestBidsHook((config) => { innerAdUnits = config.adUnits }, { adUnits });
+ consentManagementRequestBidsHook(() => {
+ }, {});
+ requestBidsHook((config) => {
+ innerAdUnits = config.adUnits
+ }, {adUnits});
sinon.assert.notCalled(mockGetId);
sinon.assert.calledOnce(mockDecode);
@@ -1620,12 +1845,15 @@ describe('User ID', function() {
});
it('calls getId if no stored consent data but refresh is needed', function () {
- coreStorage.setCookie(mockIdCookieName, JSON.stringify({ id: '1234' }), expStr);
+ coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr);
coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 60 * 1000).toUTCString()), expStr);
let innerAdUnits;
- consentManagementRequestBidsHook(() => { }, {});
- requestBidsHook((config) => { innerAdUnits = config.adUnits }, { adUnits });
+ consentManagementRequestBidsHook(() => {
+ }, {});
+ requestBidsHook((config) => {
+ innerAdUnits = config.adUnits
+ }, {adUnits});
sinon.assert.calledOnce(mockGetId);
sinon.assert.calledOnce(mockDecode);
@@ -1633,14 +1861,17 @@ describe('User ID', function() {
});
it('calls getId if empty stored consent and refresh not needed', function () {
- coreStorage.setCookie(mockIdCookieName, JSON.stringify({ id: '1234' }), expStr);
+ coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr);
coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr);
setStoredConsentData();
let innerAdUnits;
- consentManagementRequestBidsHook(() => { }, {});
- requestBidsHook((config) => { innerAdUnits = config.adUnits }, { adUnits });
+ consentManagementRequestBidsHook(() => {
+ }, {});
+ requestBidsHook((config) => {
+ innerAdUnits = config.adUnits
+ }, {adUnits});
sinon.assert.calledOnce(mockGetId);
sinon.assert.calledOnce(mockDecode);
@@ -1648,7 +1879,7 @@ describe('User ID', function() {
});
it('calls getId if stored consent does not match current consent and refresh not needed', function () {
- coreStorage.setCookie(mockIdCookieName, JSON.stringify({ id: '1234' }), expStr);
+ coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr);
coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr);
setStoredConsentData({
@@ -1658,8 +1889,11 @@ describe('User ID', function() {
});
let innerAdUnits;
- consentManagementRequestBidsHook(() => { }, {});
- requestBidsHook((config) => { innerAdUnits = config.adUnits }, { adUnits });
+ consentManagementRequestBidsHook(() => {
+ }, {});
+ requestBidsHook((config) => {
+ innerAdUnits = config.adUnits
+ }, {adUnits});
sinon.assert.calledOnce(mockGetId);
sinon.assert.calledOnce(mockDecode);
@@ -1667,7 +1901,7 @@ describe('User ID', function() {
});
it('does not call getId if stored consent matches current consent and refresh not needed', function () {
- coreStorage.setCookie(mockIdCookieName, JSON.stringify({ id: '1234' }), expStr);
+ coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr);
coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr);
setStoredConsentData({
@@ -1677,8 +1911,11 @@ describe('User ID', function() {
});
let innerAdUnits;
- consentManagementRequestBidsHook(() => { }, {});
- requestBidsHook((config) => { innerAdUnits = config.adUnits }, { adUnits });
+ consentManagementRequestBidsHook(() => {
+ }, {});
+ requestBidsHook((config) => {
+ innerAdUnits = config.adUnits
+ }, {adUnits});
sinon.assert.notCalled(mockGetId);
sinon.assert.calledOnce(mockDecode);
diff --git a/test/spec/modules/vidazooBidAdapter_spec.js b/test/spec/modules/vidazooBidAdapter_spec.js
index 1a503e46b5c..d7f20c434ca 100644
--- a/test/spec/modules/vidazooBidAdapter_spec.js
+++ b/test/spec/modules/vidazooBidAdapter_spec.js
@@ -244,6 +244,7 @@ describe('VidazooBidAdapter', function () {
case 'digitrustid': return { data: { id: id } };
case 'lipb': return { lipbid: id };
case 'parrableId': return { eid: id };
+ case 'id5id': return { uid: id };
default: return id;
}
})();
diff --git a/test/spec/modules/visxBidAdapter_spec.js b/test/spec/modules/visxBidAdapter_spec.js
index 2a4f8e4c7b5..a06f530e145 100755
--- a/test/spec/modules/visxBidAdapter_spec.js
+++ b/test/spec/modules/visxBidAdapter_spec.js
@@ -231,7 +231,7 @@ describe('VisxAdapter', function () {
const schainBidRequests = [
Object.assign({userId: {
tdid: '111',
- id5id: '222',
+ id5id: { uid: '222' },
digitrustid: {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}}
}}, bidRequests[0]),
bidRequests[1],
diff --git a/test/spec/modules/vuukleBidAdapter_spec.js b/test/spec/modules/vuukleBidAdapter_spec.js
new file mode 100644
index 00000000000..fdca4085c8e
--- /dev/null
+++ b/test/spec/modules/vuukleBidAdapter_spec.js
@@ -0,0 +1,59 @@
+import { expect } from 'chai';
+import { spec } from 'modules/vuukleBidAdapter.js';
+
+describe('vuukleBidAdapterTests', function() {
+ let bidRequestData = {
+ bids: [
+ {
+ bidId: 'testbid',
+ bidder: 'vuukle',
+ params: {
+ test: 1
+ },
+ sizes: [[300, 250]]
+ }
+ ]
+ };
+ let request = [];
+
+ it('validate_pub_params', function() {
+ expect(
+ spec.isBidRequestValid({
+ bidder: 'vuukle',
+ params: {
+ test: 1
+ }
+ })
+ ).to.equal(true);
+ });
+
+ it('validate_generated_params', function() {
+ request = spec.buildRequests(bidRequestData.bids);
+ let req_data = request[0].data;
+
+ expect(req_data.bidId).to.equal('testbid');
+ });
+
+ it('validate_response_params', function() {
+ let serverResponse = {
+ body: {
+ 'cpm': 0.01,
+ 'width': 300,
+ 'height': 250,
+ 'creative_id': '12345',
+ 'ad': 'test ad'
+ }
+ };
+
+ request = spec.buildRequests(bidRequestData.bids);
+ 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(0.01);
+ expect(bid.width).to.equal(300);
+ expect(bid.height).to.equal(250);
+ expect(bid.creativeId).to.equal('12345');
+ });
+});
diff --git a/test/spec/modules/welectBidAdapter_spec.js b/test/spec/modules/welectBidAdapter_spec.js
index 2b929be5586..5f047904c76 100644
--- a/test/spec/modules/welectBidAdapter_spec.js
+++ b/test/spec/modules/welectBidAdapter_spec.js
@@ -95,8 +95,8 @@ describe('WelectAdapter', function () {
width: 640,
height: 360,
gdpr_consent: {
- gdpr_applies: 1,
- gdpr_consent: 'some_string'
+ gdprApplies: 1,
+ tcString: 'some_string'
}
}
@@ -166,8 +166,8 @@ describe('WelectAdapter', function () {
width: 640,
height: 320,
gdpr_consent: {
- gdpr_applies: 1,
- gdpr_consent: 'some_string'
+ gdprApplies: 1,
+ tcString: 'some_string'
}
},
method: 'POST',
diff --git a/test/spec/modules/yieldlabBidAdapter_spec.js b/test/spec/modules/yieldlabBidAdapter_spec.js
index e7a9285cb48..90fa26fa823 100644
--- a/test/spec/modules/yieldlabBidAdapter_spec.js
+++ b/test/spec/modules/yieldlabBidAdapter_spec.js
@@ -30,7 +30,24 @@ const REQUEST = {
'id': 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg',
'atype': 1
}]
- }]
+ }],
+ 'schain': {
+ 'ver': '1.0',
+ 'complete': 1,
+ 'nodes': [
+ {
+ 'asi': 'indirectseller.com',
+ 'sid': '1',
+ 'hp': 1
+ },
+ {
+ 'asi': 'indirectseller2.com',
+ 'name': 'indirectseller2 name with comma , and bang !',
+ 'sid': '2',
+ 'hp': 1
+ }
+ ]
+ }
}
const RESPONSE = {
@@ -107,6 +124,10 @@ describe('yieldlabBidAdapter', function () {
expect(request.url).to.include('extraParam=true&foo=bar')
})
+ it('passes unencoded schain string to bid request', function () {
+ expect(request.url).to.include('schain=1.0,1!indirectseller.com,1,1,,,,!indirectseller2.com,2,1,,indirectseller2%20name%20with%20comma%20%2C%20and%20bang%20%21,,')
+ })
+
const refererRequest = spec.buildRequests(bidRequests, {
refererInfo: {
canonicalUrl: undefined,
diff --git a/test/spec/modules/yuktamediaAnalyticsAdapter_spec.js b/test/spec/modules/yuktamediaAnalyticsAdapter_spec.js
index c8643c547e0..e8eb4ab73be 100644
--- a/test/spec/modules/yuktamediaAnalyticsAdapter_spec.js
+++ b/test/spec/modules/yuktamediaAnalyticsAdapter_spec.js
@@ -30,7 +30,7 @@ let prebidAuction = {
}
},
'userId': {
- 'id5id': 'ID5-ZHMOxXeRXPe3inZKGD-Lj0g7y8UWdDbsYXQ_n6aWMQ',
+ 'id5id': { uid: 'ID5-ZHMOxXeRXPe3inZKGD-Lj0g7y8UWdDbsYXQ_n6aWMQ' },
'parrableid': '01.1595590997.46d951017bdc272ca50b88dbcfb0545cfc636bec3e3d8c02091fb1b413328fb2fd3baf65cb4114b3f782895fd09f82f02c9042b85b42c4654d08ba06dc77f0ded936c8ea3fc4085b4a99',
'pubcid': '100a8bc9-f588-4c22-873e-a721cb68bc34'
},
diff --git a/test/spec/modules/zeotapIdPlusIdSystem_spec.js b/test/spec/modules/zeotapIdPlusIdSystem_spec.js
new file mode 100644
index 00000000000..54082618120
--- /dev/null
+++ b/test/spec/modules/zeotapIdPlusIdSystem_spec.js
@@ -0,0 +1,128 @@
+import { expect } from 'chai';
+import find from 'core-js-pure/features/array/find.js';
+import { config } from 'src/config.js';
+import { init, requestBidsHook, setSubmoduleRegistry } from 'modules/userId/index.js';
+import { storage, zeotapIdPlusSubmodule } from 'modules/zeotapIdPlusIdSystem.js';
+
+const ZEOTAP_COOKIE_NAME = 'IDP';
+const ZEOTAP_COOKIE = 'THIS-IS-A-DUMMY-COOKIE';
+const ENCODED_ZEOTAP_COOKIE = btoa(JSON.stringify(ZEOTAP_COOKIE));
+
+function getConfigMock() {
+ return {
+ userSync: {
+ syncDelay: 0,
+ userIds: [{
+ name: 'zeotapIdPlus'
+ }]
+ }
+ }
+}
+
+function getAdUnitMock(code = 'adUnit-code') {
+ return {
+ code,
+ mediaTypes: {banner: {}, native: {}},
+ sizes: [
+ [300, 200],
+ [300, 600]
+ ],
+ bids: [{
+ bidder: 'sampleBidder',
+ params: { placementId: 'banner-only-bidder' }
+ }]
+ };
+}
+
+describe('Zeotap ID System', function() {
+ let getDataFromLocalStorageStub, localStorageIsEnabledStub;
+ let getCookieStub, cookiesAreEnabledStub;
+ beforeEach(function () {
+ getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage');
+ localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled');
+ getCookieStub = sinon.stub(storage, 'getCookie');
+ cookiesAreEnabledStub = sinon.stub(storage, 'cookiesAreEnabled');
+ });
+
+ afterEach(function () {
+ getDataFromLocalStorageStub.restore();
+ localStorageIsEnabledStub.restore();
+ getCookieStub.restore();
+ cookiesAreEnabledStub.restore();
+ });
+
+ describe('test method: getId', function() {
+ it('provides the stored Zeotap id if a cookie exists', function() {
+ getCookieStub.withArgs(ZEOTAP_COOKIE_NAME).returns(ENCODED_ZEOTAP_COOKIE);
+ let id = zeotapIdPlusSubmodule.getId();
+ expect(id).to.deep.equal({
+ id: ENCODED_ZEOTAP_COOKIE
+ });
+ });
+
+ it('provides the stored Zeotap id if cookie is absent but present in local storage', function() {
+ getDataFromLocalStorageStub.withArgs(ZEOTAP_COOKIE_NAME).returns(ENCODED_ZEOTAP_COOKIE);
+ let id = zeotapIdPlusSubmodule.getId();
+ expect(id).to.deep.equal({
+ id: ENCODED_ZEOTAP_COOKIE
+ });
+ });
+
+ it('returns undefined if both cookie and local storage are empty', function() {
+ let id = zeotapIdPlusSubmodule.getId();
+ expect(id).to.be.undefined
+ })
+ });
+
+ describe('test method: decode', function() {
+ it('provides the Zeotap ID (IDP) from a stored object', function() {
+ let zeotapId = {
+ id: ENCODED_ZEOTAP_COOKIE,
+ };
+
+ expect(zeotapIdPlusSubmodule.decode(zeotapId)).to.deep.equal({
+ IDP: ZEOTAP_COOKIE
+ });
+ });
+
+ it('provides the Zeotap ID (IDP) from a stored string', function() {
+ let zeotapId = ENCODED_ZEOTAP_COOKIE;
+
+ expect(zeotapIdPlusSubmodule.decode(zeotapId)).to.deep.equal({
+ IDP: ZEOTAP_COOKIE
+ });
+ });
+ });
+
+ describe('requestBids hook', function() {
+ let adUnits;
+
+ beforeEach(function() {
+ adUnits = [getAdUnitMock()];
+ setSubmoduleRegistry([zeotapIdPlusSubmodule]);
+ init(config);
+ config.setConfig(getConfigMock());
+ getCookieStub.withArgs(ZEOTAP_COOKIE_NAME).returns(ENCODED_ZEOTAP_COOKIE);
+ });
+
+ it('when a stored Zeotap ID exists it is added to bids', function(done) {
+ requestBidsHook(function() {
+ adUnits.forEach(unit => {
+ unit.bids.forEach(bid => {
+ expect(bid).to.have.deep.nested.property('userId.IDP');
+ expect(bid.userId.IDP).to.equal(ZEOTAP_COOKIE);
+ const zeotapIdAsEid = find(bid.userIdAsEids, e => e.source == 'zeotap.com');
+ expect(zeotapIdAsEid).to.deep.equal({
+ source: 'zeotap.com',
+ uids: [{
+ id: ZEOTAP_COOKIE,
+ atype: 1,
+ }]
+ });
+ });
+ });
+ done();
+ }, { adUnits });
+ });
+ });
+});
diff --git a/test/spec/refererDetection_spec.js b/test/spec/refererDetection_spec.js
index 90892d915fe..46990ae841f 100644
--- a/test/spec/refererDetection_spec.js
+++ b/test/spec/refererDetection_spec.js
@@ -1,87 +1,357 @@
import { detectReferer } from 'src/refererDetection.js';
import { expect } from 'chai';
-var mocks = {
- createFakeWindow: function (referrer, href) {
- return {
- document: {
- referrer: referrer
- },
- location: {
- href: href,
- // TODO: add ancestorOrigins to increase test coverage
- },
- parent: null,
- top: null
- };
+/**
+ * Build a walkable linked list of window-like objects for testing.
+ *
+ * @param {Array} urls Array of URL strings starting from the top window.
+ * @param {string} [topReferrer]
+ * @param {string} [canonicalUrl]
+ * @param {boolean} [ancestorOrigins]
+ * @returns {Object}
+ */
+function buildWindowTree(urls, topReferrer = '', canonicalUrl = null, ancestorOrigins = false) {
+ /**
+ * Find the origin from a given fully-qualified URL.
+ *
+ * @param {string} url The fully qualified URL
+ * @returns {string|null}
+ */
+ function getOrigin(url) {
+ const originRegex = new RegExp('^(https?://[^/]+/?)');
+
+ const result = originRegex.exec(url);
+
+ if (result && result[0]) {
+ return result[0];
+ }
+
+ return null;
}
-}
-describe('referer detection', () => {
- it('should return referer details in nested friendly iframes', function() {
- // Fake window object to test friendly iframes
- // - Main page http://example.com/page.html
- // - - Iframe1 http://example.com/iframe1.html
- // - - - Iframe2 http://example.com/iframe2.html
- let mockIframe2WinObject = mocks.createFakeWindow('http://example.com/iframe1.html', 'http://example.com/iframe2.html');
- let mockIframe1WinObject = mocks.createFakeWindow('http://example.com/page.html', 'http://example.com/iframe1.html');
- let mainWinObject = mocks.createFakeWindow('http://example.com/page.html', 'http://example.com/page.html');
- mainWinObject.document.querySelector = function() {
- return {
- href: 'http://prebid.org'
+ let previousWindow;
+ const myOrigin = getOrigin(urls[urls.length - 1]);
+
+ const windowList = urls.map((url, index) => {
+ const theirOrigin = getOrigin(url),
+ sameOrigin = (myOrigin === theirOrigin);
+
+ const win = {};
+
+ if (sameOrigin) {
+ win.location = {
+ href: url
+ };
+
+ if (ancestorOrigins) {
+ win.location.ancestorOrigins = urls.slice(0, index).reverse().map(getOrigin);
+ }
+
+ if (index === 0) {
+ win.document = {
+ referrer: topReferrer
+ };
+
+ if (canonicalUrl) {
+ win.document.querySelector = function(selector) {
+ if (selector === "link[rel='canonical']") {
+ return {
+ href: canonicalUrl
+ };
+ }
+
+ return null;
+ };
+ }
+ } else {
+ win.document = {
+ referrer: urls[index - 1]
+ };
}
}
- mockIframe2WinObject.parent = mockIframe1WinObject;
- mockIframe2WinObject.top = mainWinObject;
- mockIframe1WinObject.parent = mainWinObject;
- mockIframe1WinObject.top = mainWinObject;
- mainWinObject.top = mainWinObject;
-
- const getRefererInfo = detectReferer(mockIframe2WinObject);
- let result = getRefererInfo();
- let expectedResult = {
- referer: 'http://example.com/page.html',
- reachedTop: true,
- numIframes: 2,
- stack: [
- 'http://example.com/page.html',
- 'http://example.com/iframe1.html',
- 'http://example.com/iframe2.html'
- ],
- canonicalUrl: 'http://prebid.org'
- };
- expect(result).to.deep.equal(expectedResult);
+
+ previousWindow = win;
+
+ return win;
+ });
+
+ const topWindow = windowList[0];
+
+ previousWindow = null;
+
+ windowList.forEach((win) => {
+ win.top = topWindow;
+ win.parent = previousWindow || topWindow;
+ previousWindow = win;
+ });
+
+ return windowList[windowList.length - 1];
+}
+
+describe('Referer detection', () => {
+ describe('Non cross-origin scenarios', () => {
+ describe('No iframes', () => {
+ it('Should return the current window location and no canonical URL', () => {
+ const testWindow = buildWindowTree(['https://example.com/some/page'], 'https://othersite.com/'),
+ result = detectReferer(testWindow)();
+
+ expect(result).to.deep.equal({
+ referer: 'https://example.com/some/page',
+ reachedTop: true,
+ isAmp: false,
+ numIframes: 0,
+ stack: ['https://example.com/some/page'],
+ canonicalUrl: null
+ });
+ });
+
+ it('Should return the current window location and a canonical URL', () => {
+ const testWindow = buildWindowTree(['https://example.com/some/page'], 'https://othersite.com/', 'https://example.com/canonical/page'),
+ result = detectReferer(testWindow)();
+
+ expect(result).to.deep.equal({
+ referer: 'https://example.com/some/page',
+ reachedTop: true,
+ isAmp: false,
+ numIframes: 0,
+ stack: ['https://example.com/some/page'],
+ canonicalUrl: 'https://example.com/canonical/page'
+ });
+ });
+ });
+
+ describe('Friendly iframes', () => {
+ it('Should return the top window location and no canonical URL', () => {
+ const testWindow = buildWindowTree(['https://example.com/some/page', 'https://example.com/other/page', 'https://example.com/third/page'], 'https://othersite.com/'),
+ result = detectReferer(testWindow)();
+
+ expect(result).to.deep.equal({
+ referer: 'https://example.com/some/page',
+ reachedTop: true,
+ isAmp: false,
+ numIframes: 2,
+ stack: [
+ 'https://example.com/some/page',
+ 'https://example.com/other/page',
+ 'https://example.com/third/page'
+ ],
+ canonicalUrl: null
+ });
+ });
+
+ it('Should return the top window location and a canonical URL', () => {
+ const testWindow = buildWindowTree(['https://example.com/some/page', 'https://example.com/other/page', 'https://example.com/third/page'], 'https://othersite.com/', 'https://example.com/canonical/page'),
+ result = detectReferer(testWindow)();
+
+ expect(result).to.deep.equal({
+ referer: 'https://example.com/some/page',
+ reachedTop: true,
+ isAmp: false,
+ numIframes: 2,
+ stack: [
+ 'https://example.com/some/page',
+ 'https://example.com/other/page',
+ 'https://example.com/third/page'
+ ],
+ canonicalUrl: 'https://example.com/canonical/page'
+ });
+ });
+ });
});
- it('should return referer details in nested cross domain iframes', function() {
- // Fake window object to test cross domain iframes.
- // - Main page http://example.com/page.html
- // - - Iframe1 http://aaa.com/iframe1.html
- // - - - Iframe2 http://bbb.com/iframe2.html
- let mockIframe2WinObject = mocks.createFakeWindow('http://aaa.com/iframe1.html', 'http://bbb.com/iframe2.html');
- // Sinon cannot throw exception when accessing a propery so passing null to create cross domain
- // environment for refererDetection module
- let mockIframe1WinObject = mocks.createFakeWindow(null, null);
- let mainWinObject = mocks.createFakeWindow(null, null);
- mockIframe2WinObject.parent = mockIframe1WinObject;
- mockIframe2WinObject.top = mainWinObject;
- mockIframe1WinObject.parent = mainWinObject;
- mockIframe1WinObject.top = mainWinObject;
- mainWinObject.top = mainWinObject;
-
- const getRefererInfo = detectReferer(mockIframe2WinObject);
- let result = getRefererInfo();
- let expectedResult = {
- referer: 'http://aaa.com/iframe1.html',
- reachedTop: false,
- numIframes: 2,
- stack: [
- null,
- 'http://aaa.com/iframe1.html',
- 'http://bbb.com/iframe2.html'
- ],
- canonicalUrl: undefined
- };
- expect(result).to.deep.equal(expectedResult);
+ describe('Cross-origin scenarios', () => {
+ it('Should return the top URL and no canonical URL with one cross-origin iframe', () => {
+ const testWindow = buildWindowTree(['https://example.com/some/page', 'https://safe.frame/ad'], 'https://othersite.com/', 'https://canonical.example.com/'),
+ result = detectReferer(testWindow)();
+
+ expect(result).to.deep.equal({
+ referer: 'https://example.com/some/page',
+ reachedTop: true,
+ isAmp: false,
+ numIframes: 1,
+ stack: [
+ 'https://example.com/some/page',
+ 'https://safe.frame/ad'
+ ],
+ canonicalUrl: null
+ });
+ });
+
+ it('Should return the top URL and no canonical URL with one cross-origin iframe and one friendly iframe', () => {
+ const testWindow = buildWindowTree(['https://example.com/some/page', 'https://safe.frame/ad', 'https://safe.frame/ad'], 'https://othersite.com/', 'https://canonical.example.com/'),
+ result = detectReferer(testWindow)();
+
+ expect(result).to.deep.equal({
+ referer: 'https://example.com/some/page',
+ reachedTop: true,
+ isAmp: false,
+ numIframes: 2,
+ stack: [
+ 'https://example.com/some/page',
+ 'https://safe.frame/ad',
+ 'https://safe.frame/ad'
+ ],
+ canonicalUrl: null
+ });
+ });
+
+ it('Should return the second iframe location with three cross-origin windows and no ancessorOrigins', () => {
+ const testWindow = buildWindowTree(['https://example.com/some/page', 'https://safe.frame/ad', 'https://otherfr.ame/ad'], 'https://othersite.com/', 'https://canonical.example.com/'),
+ result = detectReferer(testWindow)();
+
+ expect(result).to.deep.equal({
+ referer: 'https://safe.frame/ad',
+ reachedTop: false,
+ isAmp: false,
+ numIframes: 2,
+ stack: [
+ null,
+ 'https://safe.frame/ad',
+ 'https://otherfr.ame/ad'
+ ],
+ canonicalUrl: null
+ });
+ });
+
+ it('Should return the top window origin with three cross-origin windows with ancessorOrigins', () => {
+ const testWindow = buildWindowTree(['https://example.com/some/page', 'https://safe.frame/ad', 'https://otherfr.ame/ad'], 'https://othersite.com/', 'https://canonical.example.com/', true),
+ result = detectReferer(testWindow)();
+
+ expect(result).to.deep.equal({
+ referer: 'https://example.com/',
+ reachedTop: false,
+ isAmp: false,
+ numIframes: 2,
+ stack: [
+ 'https://example.com/',
+ 'https://safe.frame/ad',
+ 'https://otherfr.ame/ad'
+ ],
+ canonicalUrl: null
+ });
+ });
+ });
+
+ describe('Cross-origin AMP page scenarios', () => {
+ it('Should return the AMP page source and canonical URLs in an amp-ad iframe for a non-cached AMP page', () => {
+ const testWindow = buildWindowTree(['https://example.com/some/page/amp/', 'https://ad-iframe.ampproject.org/ad']);
+
+ testWindow.context = {
+ sourceUrl: 'https://example.com/some/page/amp/',
+ canonicalUrl: 'https://example.com/some/page/'
+ };
+
+ const result = detectReferer(testWindow)();
+
+ expect(result).to.deep.equal({
+ referer: 'https://example.com/some/page/amp/',
+ reachedTop: true,
+ isAmp: true,
+ numIframes: 1,
+ stack: [
+ 'https://example.com/some/page/amp/',
+ 'https://ad-iframe.ampproject.org/ad'
+ ],
+ canonicalUrl: 'https://example.com/some/page/'
+ });
+ });
+
+ it('Should return the AMP page source and canonical URLs in an amp-ad iframe for a cached AMP page on top', () => {
+ const testWindow = buildWindowTree(['https://example-com.amp-cache.example.com/some/page/amp/', 'https://ad-iframe.ampproject.org/ad']);
+
+ testWindow.context = {
+ sourceUrl: 'https://example.com/some/page/amp/',
+ canonicalUrl: 'https://example.com/some/page/'
+ };
+
+ const result = detectReferer(testWindow)();
+
+ expect(result).to.deep.equal({
+ referer: 'https://example.com/some/page/amp/',
+ reachedTop: true,
+ isAmp: true,
+ numIframes: 1,
+ stack: [
+ 'https://example.com/some/page/amp/',
+ 'https://ad-iframe.ampproject.org/ad'
+ ],
+ canonicalUrl: 'https://example.com/some/page/'
+ });
+ });
+
+ describe('Cached AMP page in iframed search result', () => {
+ it('Should return the AMP source and canonical URLs but with a null top-level stack location Without ancesorOrigins', () => {
+ const testWindow = buildWindowTree(['https://google.com/amp/example-com/some/page/amp/', 'https://example-com.amp-cache.example.com/some/page/amp/', 'https://ad-iframe.ampproject.org/ad']);
+
+ testWindow.context = {
+ sourceUrl: 'https://example.com/some/page/amp/',
+ canonicalUrl: 'https://example.com/some/page/'
+ };
+
+ const result = detectReferer(testWindow)();
+
+ expect(result).to.deep.equal({
+ referer: 'https://example.com/some/page/amp/',
+ reachedTop: false,
+ isAmp: true,
+ numIframes: 2,
+ stack: [
+ null,
+ 'https://example.com/some/page/amp/',
+ 'https://ad-iframe.ampproject.org/ad'
+ ],
+ canonicalUrl: 'https://example.com/some/page/'
+ });
+ });
+
+ it('Should return the AMP source and canonical URLs and include the top window origin in the stack with ancesorOrigins', () => {
+ const testWindow = buildWindowTree(['https://google.com/amp/example-com/some/page/amp/', 'https://example-com.amp-cache.example.com/some/page/amp/', 'https://ad-iframe.ampproject.org/ad'], null, null, true);
+
+ testWindow.context = {
+ sourceUrl: 'https://example.com/some/page/amp/',
+ canonicalUrl: 'https://example.com/some/page/'
+ };
+
+ const result = detectReferer(testWindow)();
+
+ expect(result).to.deep.equal({
+ referer: 'https://example.com/some/page/amp/',
+ reachedTop: false,
+ isAmp: true,
+ numIframes: 2,
+ stack: [
+ 'https://google.com/',
+ 'https://example.com/some/page/amp/',
+ 'https://ad-iframe.ampproject.org/ad'
+ ],
+ canonicalUrl: 'https://example.com/some/page/'
+ });
+ });
+
+ it('Should return the AMP source and canonical URLs and include the top window origin in the stack with ancesorOrigins and a friendly iframe under the amp-ad iframe', () => {
+ const testWindow = buildWindowTree(['https://google.com/amp/example-com/some/page/amp/', 'https://example-com.amp-cache.example.com/some/page/amp/', 'https://ad-iframe.ampproject.org/ad', 'https://ad-iframe.ampproject.org/ad'], null, null, true);
+
+ testWindow.parent.context = {
+ sourceUrl: 'https://example.com/some/page/amp/',
+ canonicalUrl: 'https://example.com/some/page/'
+ };
+
+ const result = detectReferer(testWindow)();
+
+ expect(result).to.deep.equal({
+ referer: 'https://example.com/some/page/amp/',
+ reachedTop: false,
+ isAmp: true,
+ numIframes: 3,
+ stack: [
+ 'https://google.com/',
+ 'https://example.com/some/page/amp/',
+ 'https://ad-iframe.ampproject.org/ad',
+ 'https://ad-iframe.ampproject.org/ad'
+ ],
+ canonicalUrl: 'https://example.com/some/page/'
+ });
+ });
+ });
});
});
diff --git a/test/spec/unit/core/storageManager_spec.js b/test/spec/unit/core/storageManager_spec.js
index 0b406242f90..de09df5b196 100644
--- a/test/spec/unit/core/storageManager_spec.js
+++ b/test/spec/unit/core/storageManager_spec.js
@@ -42,5 +42,32 @@ describe('storage manager', function() {
storage.setCookie('foo1', 'baz1');
expect(deviceAccessSpy.calledOnce).to.equal(true);
deviceAccessSpy.restore();
+ });
+
+ describe('localstorage forbidden access in 3rd-party context', function() {
+ let errorLogSpy;
+ const originalLocalStorage = { get: () => window.localStorage };
+ const localStorageMock = { get: () => { throw Error } };
+
+ beforeEach(function() {
+ Object.defineProperty(window, 'localStorage', localStorageMock);
+ errorLogSpy = sinon.spy(utils, 'logError');
+ });
+
+ afterEach(function() {
+ Object.defineProperty(window, 'localStorage', originalLocalStorage);
+ errorLogSpy.restore();
+ })
+
+ it('should not throw if the localstorage is not accessible when setting/getting/removing from localstorage', function() {
+ const coreStorage = getStorageManager();
+
+ coreStorage.setDataInLocalStorage('key', 'value');
+ const val = coreStorage.getDataFromLocalStorage('key');
+ coreStorage.removeDataFromLocalStorage('key');
+
+ expect(val).to.be.null;
+ sinon.assert.calledThrice(errorLogSpy);
+ })
})
});
diff --git a/test/spec/unit/core/targeting_spec.js b/test/spec/unit/core/targeting_spec.js
index 3aae6e3c33a..5d43ed48266 100644
--- a/test/spec/unit/core/targeting_spec.js
+++ b/test/spec/unit/core/targeting_spec.js
@@ -416,6 +416,46 @@ describe('targeting tests', function () {
});
});
+ describe('targetingControls.allowTargetingKeys', function () {
+ let bid4;
+
+ beforeEach(function() {
+ bid4 = utils.deepClone(bid1);
+ bid4.adserverTargeting = {
+ hb_deal: '4321',
+ hb_pb: '0.1',
+ hb_adid: '567891011',
+ hb_bidder: 'appnexus',
+ };
+ bid4.bidder = bid4.bidderCode = 'appnexus';
+ bid4.cpm = 0.1; // losing bid so not included if enableSendAllBids === false
+ bid4.dealId = '4321';
+ enableSendAllBids = true;
+ config.setConfig({
+ targetingControls: {
+ allowTargetingKeys: ['BIDDER', 'AD_ID', 'PRICE_BUCKET']
+ }
+ });
+ bidsReceived.push(bid4);
+ });
+
+ it('targeting should include custom keys', function () {
+ const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']);
+ expect(targeting['/123456/header-bid-tag-0']).to.include.all.keys('foobar');
+ });
+
+ it('targeting should include keys prefixed by allowed default targeting keys', function () {
+ const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']);
+ expect(targeting['/123456/header-bid-tag-0']).to.include.all.keys('hb_bidder_rubicon', 'hb_adid_rubicon', 'hb_pb_rubicon');
+ expect(targeting['/123456/header-bid-tag-0']).to.include.all.keys('hb_bidder_appnexus', 'hb_adid_appnexus', 'hb_pb_appnexus');
+ });
+
+ it('targeting should not include keys prefixed by disallowed default targeting keys', function () {
+ const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']);
+ expect(targeting['/123456/header-bid-tag-0']).to.not.have.all.keys(['hb_deal_appnexus', 'hb_deal_rubicon']);
+ });
+ });
+
describe('targetingControls.alwaysIncludeDeals', function () {
let bid4;
diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js
index 960ccf08c92..efb1338ac5d 100644
--- a/test/spec/unit/pbjs_api_spec.js
+++ b/test/spec/unit/pbjs_api_spec.js
@@ -1197,6 +1197,14 @@ 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({