Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prebid 7: refactoring of refererInfo, pageUrl, publisherDomain #8450

Merged
merged 18 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function _buildRequestParams(bidRequests, bidderRequest) {

const uspConsent = bidderRequest && bidderRequest.uspConsent;

const pageUrl = (bidderRequest && bidderRequest.refererInfo) ? (bidderRequest.refererInfo.referer) : (undefined);
const pageUrl = bidderRequest?.refererInfo?.page

adapterState.uniqueSiteIds = bidRequests.map(req => req.params.siteId).filter(uniques);

Expand Down
2 changes: 1 addition & 1 deletion modules/a4gBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const spec = {

let data = {
[IFRAME_PARAM_NAME]: 0,
[LOCATION_PARAM_NAME]: (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) ? bidderRequest.refererInfo.referer : window.location.href,
[LOCATION_PARAM_NAME]: bidderRequest.refererInfo?.page,
[SIZE_PARAM_NAME]: sizeParams.join(ARRAY_PARAM_SEPARATOR),
[ID_PARAM_NAME]: idParams.join(ARRAY_PARAM_SEPARATOR),
[ZONE_ID_PARAM_NAME]: zoneIds.join(ARRAY_PARAM_SEPARATOR)
Expand Down
3 changes: 2 additions & 1 deletion modules/ablidaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export const spec = {
sizes: sizes,
bidId: bidRequest.bidId,
categories: bidRequest.params.categories,
referer: bidderRequest.refererInfo.referer,
// TODO: should referer be 'ref'?
referer: bidderRequest.refererInfo.page,
jaySupported: jaySupported,
device: device,
adapterVersion: 5,
Expand Down
5 changes: 3 additions & 2 deletions modules/adWMGBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ export const spec = {
buildRequests: (validBidRequests, bidderRequest) => {
const timeout = bidderRequest.timeout || 0;
const debug = config.getConfig('debug') || false;
const referrer = bidderRequest.refererInfo.referer;
// TODO: is 'page' the right value here?
const referrer = bidderRequest.refererInfo.page;
const locale = window.navigator.language && window.navigator.language.length > 0 ? window.navigator.language.substr(0, 2) : '';
const domain = config.getConfig('publisherDomain') || (window.location && window.location.host ? window.location.host : '');
const domain = bidderRequest.refererInfo.domain || '';
const ua = window.navigator.userAgent.toLowerCase();
const additional = spec.parseUserAgent(ua);

Expand Down
12 changes: 5 additions & 7 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ import {
logInfo,
logWarn,
mergeDeep,
parseUrl
} from '../src/utils.js';
import {config} from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {loadExternalScript} from '../src/adloader.js';
import {verify} from 'criteo-direct-rsa-validate/build/verify.js';
import {getStorageManager} from '../src/storageManager.js';
import {getRefererInfo} from '../src/refererDetection.js';
import {getRefererInfo, parseDomain} from '../src/refererDetection.js';
import {createEidsArray} from './userId/eids.js';
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {Renderer} from '../src/Renderer.js';
Expand Down Expand Up @@ -270,12 +269,11 @@ function getDevice() {

function getSite(bidderRequest) {
const { refererInfo } = bidderRequest;
const url = parseUrl(refererInfo.referer);

return {
domain: url.hostname || '',
page: refererInfo.referer || '',
referrer: canAccessTopWindow() ? getWindowTop().document.referrer || '' : getWindowSelf().document.referrer || '',
// TODO: do these fallbacks make sense?
domain: refererInfo.domain || parseDomain(refererInfo.topmostLocation) || '',
page: refererInfo.page || refererInfo.topmostLocation || '',
referrer: refererInfo.ref || getWindowSelf().document.referrer || '',
top: refererInfo.reachedTop
};
};
Expand Down
6 changes: 3 additions & 3 deletions modules/adbookpspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ function buildRequest(validBidRequests, bidderRequest) {
id: bidderRequest.bidderRequestId,
tmax: bidderRequest.timeout,
site: {
domain: window.location.hostname,
page: window.location.href,
ref: bidderRequest.refererInfo.referer,
domain: bidderRequest.refererInfo.domain,
page: bidderRequest.refererInfo.page,
ref: bidderRequest.refererInfo.ref,
},
source: buildSource(validBidRequests, bidderRequest),
device: buildDevice(),
Expand Down
3 changes: 2 additions & 1 deletion modules/addefendBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export const spec = {
pageId: false,
gdpr_applies: bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies ? bidderRequest.gdprConsent.gdprApplies : 'true',
gdpr_consent: bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString ? bidderRequest.gdprConsent.consentString : '',
referer: bidderRequest.refererInfo.referer,
// TODO: is 'page' the correct item here?
referer: bidderRequest.refererInfo.page,
bids: [],
};

Expand Down
16 changes: 6 additions & 10 deletions modules/adfBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// jshint esversion: 6, es3: false, node: true
'use strict';

import {
registerBidder
} from '../src/adapters/bidderFactory.js';
import {
NATIVE, BANNER, VIDEO
} from '../src/mediaTypes.js';
import { mergeDeep, _map, deepAccess, parseSizesInput, deepSetValue } from '../src/utils.js';
import { config } from '../src/config.js';
import { Renderer } from '../src/Renderer.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {_map, deepAccess, deepSetValue, mergeDeep, parseSizesInput} from '../src/utils.js';
import {config} from '../src/config.js';
import {Renderer} from '../src/Renderer.js';

const { getConfig } = config;

Expand Down Expand Up @@ -81,7 +77,7 @@ export const spec = {
}

if (!site.page) {
site.page = bidderRequest.refererInfo.referer;
site.page = bidderRequest.refererInfo.page;
}
}

Expand Down
3 changes: 2 additions & 1 deletion modules/adgenerationBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export const spec = {
if (!validReq.mediaTypes || !validReq.mediaTypes.native) {
data = tryAppendQueryString(data, 'imark', '1');
}
data = tryAppendQueryString(data, 'tp', bidderRequest.refererInfo.referer);
// TODO: is 'page' the right value here?
data = tryAppendQueryString(data, 'tp', bidderRequest.refererInfo.page);
if (isIos()) {
const hyperId = getHyperId(validReq);
if (hyperId != null) {
Expand Down
3 changes: 2 additions & 1 deletion modules/adhashBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ export const spec = {
const bidRequests = [];
let referrer = '';
if (bidderRequest && bidderRequest.refererInfo) {
referrer = bidderRequest.refererInfo.referer;
// TODO: is 'page' the right value here?
referrer = bidderRequest.refererInfo.page;
}
for (var i = 0; i < validBidRequests.length; i++) {
var index = Math.floor(Math.random() * validBidRequests[i].sizes.length);
Expand Down
3 changes: 2 additions & 1 deletion modules/adheseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export const spec = {

const adheseConfig = config.getConfig('adhese');
const gdprParams = (gdprConsent && gdprConsent.consentString) ? { xt: [gdprConsent.consentString] } : {};
const refererParams = (refererInfo && refererInfo.referer) ? { xf: [base64urlEncode(refererInfo.referer)] } : {};
// TODO: is 'page' the right value here?
const refererParams = (refererInfo && refererInfo.page) ? { xf: [base64urlEncode(refererInfo.page)] } : {};
const globalCustomParams = (adheseConfig && adheseConfig.globalTargets) ? cleanTargets(adheseConfig.globalTargets) : {};
const commonParams = { ...globalCustomParams, ...gdprParams, ...refererParams };
const vastContentAsUrl = !(adheseConfig && adheseConfig.vastContentAsUrl == false);
Expand Down
1 change: 1 addition & 0 deletions modules/adkernelAdnAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ export function ExpiringQueue(callback, ttl) {
}
}

// TODO: this should reuse logic from refererDetection
function getNavigationInfo() {
try {
return getLocationAndReferrer(self.top);
Expand Down
15 changes: 6 additions & 9 deletions modules/adkernelAdnBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deepAccess, parseSizesInput, isArray, deepSetValue, parseUrl, isStr, isNumber, logInfo } from '../src/utils.js';
import { deepAccess, parseSizesInput, isArray, deepSetValue, isStr, isNumber, logInfo } from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {config} from '../src/config.js';
Expand All @@ -10,7 +10,7 @@ const DEFAULT_APIS = [1, 2];
const GVLID = 14;

function isRtbDebugEnabled(refInfo) {
return refInfo.referer.indexOf('adk_debug=true') !== -1;
return refInfo.topmostLocation?.indexOf('adk_debug=true') !== -1;
}

function buildImp(bidRequest) {
Expand Down Expand Up @@ -83,13 +83,10 @@ function buildRequestParams(tags, bidderRequest) {
}

function buildSite(refInfo) {
let loc = parseUrl(refInfo.referer);
let result = {
page: `${loc.protocol}://${loc.hostname}${loc.pathname}`,
secure: ~~(loc.protocol === 'https')
};
if (self === top && document.referrer) {
result.ref = document.referrer;
const result = {
page: refInfo.page,
secure: ~~(refInfo.page && refInfo.page.startsWith('https')),
ref: refInfo.ref
}
let keywords = document.getElementsByTagName('meta')['keywords'];
if (keywords && keywords.content) {
Expand Down
15 changes: 6 additions & 9 deletions modules/adkernelBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ import {
deepSetValue,
getAdUnitSizes,
getDNT,
inIframe,
isArray,
isArrayOfNums,
isEmpty,
isNumber,
isPlainObject,
isStr,
mergeDeep,
parseGPTSingleSizeArrayToRtbSize,
parseUrl
parseGPTSingleSizeArrayToRtbSize
} from '../src/utils.js';
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
Expand Down Expand Up @@ -226,7 +224,7 @@ registerBidder(spec);
* @param refererInfo {refererInfo}
*/
function groupImpressionsByHostZone(bidRequests, refererInfo) {
let secure = (refererInfo && refererInfo.referer.indexOf('https:') === 0);
let secure = (refererInfo && refererInfo.page?.indexOf('https:') === 0);
return Object.values(
bidRequests.map(bidRequest => buildImp(bidRequest, secure))
.reduce((acc, curr, index) => {
Expand Down Expand Up @@ -535,14 +533,13 @@ function getLanguage() {
* Creates site description object
*/
function createSite(refInfo, fpd) {
let url = parseUrl(refInfo.referer);
let site = {
'domain': url.hostname,
'page': `${url.protocol}://${url.hostname}${url.pathname}`
'domain': refInfo.domain,
'page': refInfo.page
};
mergeDeep(site, fpd.site);
if (!inIframe() && document.referrer) {
site.ref = document.referrer;
if (refInfo.ref != null) {
site.ref = refInfo.ref;
} else {
delete site.ref;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/adlooxAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ MACRO['creatype'] = function(b, c) {
};
MACRO['pageurl'] = function(b, c) {
const refererInfo = getRefererInfo();
return (refererInfo.canonicalUrl || refererInfo.referer || '').substr(0, 300).split(/[?#]/)[0];
return (refererInfo.page || '').substr(0, 300).split(/[?#]/)[0];
};
MACRO['pbadslot'] = function(b, c) {
const adUnit = find(auctionManager.getAdUnits(), a => b.adUnitCode === a.code);
Expand Down
2 changes: 1 addition & 1 deletion modules/adlooxRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ function getBidRequestData(reqBidsConfigObj, callback, config, userConsent) {
[ 'imp', config.params.imps ],
[ 'fc_ip', config.params.freqcap_ip ],
[ 'fc_ipua', config.params.freqcap_ipua ],
[ 'pn', (refererInfo.canonicalUrl || refererInfo.referer || '').substr(0, 300).split(/[?#]/)[0] ]
[ 'pn', (refererInfo.page || '').substr(0, 300).split(/[?#]/)[0] ]
];

if (!adUnits.length) {
Expand Down
3 changes: 2 additions & 1 deletion modules/admanBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ export const spec = {
buildRequests: (validBidRequests = [], bidderRequest) => {
let winTop = window;
let location;
// TODO: this odd try-catch block was copied in several adapters; it doesn't seem to be correct for cross-origin
try {
location = new URL(bidderRequest.refererInfo.referer)
location = new URL(bidderRequest.refererInfo.page)
winTop = window.top;
} catch (e) {
location = winTop.location;
Expand Down
5 changes: 3 additions & 2 deletions modules/admixerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ export const spec = {
if (bidderRequest) {
const {bidderCode} = bidderRequest;
endpointUrl = config.getConfig(`${bidderCode}.endpoint_url`);
if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) {
payload.referrer = encodeURIComponent(bidderRequest.refererInfo.referer);
// TODO: is 'page' the right value here?
if (bidderRequest.refererInfo?.page) {
payload.referrer = encodeURIComponent(bidderRequest.refererInfo.page);
}
if (bidderRequest.gdprConsent) {
payload.gdprConsent = {
Expand Down
2 changes: 1 addition & 1 deletion modules/adnuntiusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const spec = {

networks[network] = networks[network] || {};
networks[network].adUnits = networks[network].adUnits || [];
if (bidderRequest && bidderRequest.refererInfo) networks[network].context = bidderRequest.refererInfo.referer;
if (bidderRequest && bidderRequest.refererInfo) networks[network].context = bidderRequest.refererInfo.page;
if (adnMeta) networks[network].metaData = adnMeta;
networks[network].adUnits.push({ ...targeting, auId: bid.params.auId, targetId: bid.bidId });
}
Expand Down
20 changes: 3 additions & 17 deletions modules/adotBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {isArray, isBoolean, isFn, isPlainObject, isStr, logError, replaceAuctionPrice} from '../src/utils.js';
import {find} from '../src/polyfill.js';
import {config} from '../src/config.js';
import { OUTSTREAM } from '../src/video.js';
import {OUTSTREAM} from '../src/video.js';

const BIDDER_CODE = 'adot';
const ADAPTER_VERSION = 'v2.0.0';
const BID_METHOD = 'POST';
const BIDDER_URL = 'https://dsp.adotmob.com/headerbidding{PUBLISHER_PATH}/bidrequest';
const REQUIRED_VIDEO_PARAMS = ['mimes', 'protocols'];
const DOMAIN_REGEX = new RegExp('//([^/]*)');
const FIRST_PRICE = 1;
const IMP_BUILDER = { banner: buildBanner, video: buildVideo, native: buildNative };
const NATIVE_PLACEMENTS = {
Expand Down Expand Up @@ -43,19 +42,6 @@ function tryParse(data) {
}
}

/**
* Extract domain from given url
*
* @param {string} url
* @returns {string|null} Extracted domain
*/
function extractDomainFromURL(url) {
if (!url || !isStr(url)) return null;
const domain = url.match(DOMAIN_REGEX);
if (isArray(domain) && domain.length === 2) return domain[1];
return null;
}

/**
* Create and return site OpenRtb object from given bidderRequest
*
Expand All @@ -65,13 +51,13 @@ function extractDomainFromURL(url) {
function getOpenRTBSiteObject(bidderRequest) {
if (!bidderRequest || !bidderRequest.refererInfo) return null;

const domain = extractDomainFromURL(bidderRequest.refererInfo.referer);
const domain = bidderRequest.refererInfo.domain;
const publisherId = config.getConfig('adot.publisherId');

if (!domain) return null;

return {
page: bidderRequest.refererInfo.referer,
page: bidderRequest.refererInfo.page,
domain: domain,
name: domain,
publisher: {
Expand Down
8 changes: 2 additions & 6 deletions modules/adpartnerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ export const spec = {
},

buildRequests: function (validBidRequests, bidderRequest) {
let referer = window.location.href;
try {
referer = typeof bidderRequest.refererInfo === 'undefined'
? window.top.location.href
: bidderRequest.refererInfo.referer;
} catch (e) {}
// TODO does it make sense to fall back to window.location.href?
const referer = bidderRequest?.refererInfo?.page || window.location.href;

let bidRequests = [];
let beaconParams = {
Expand Down
1 change: 1 addition & 0 deletions modules/adplusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function createBidRequest(bid) {
screenWidth: screen.width,
screenHeight: screen.height,
language: window.navigator.language || 'en-US',
// TODO: these should probably look at refererInfo
pageUrl: window.location.href,
domain: window.location.hostname,
referrer: window.location.referrer,
Expand Down
3 changes: 2 additions & 1 deletion modules/adprimeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ export const spec = {
buildRequests: (validBidRequests = [], bidderRequest) => {
let winTop = window;
let location;
// TODO: this odd try-catch block was copied in several adapters; it doesn't seem to be correct for cross-origin
try {
location = new URL(bidderRequest.refererInfo.referer)
location = new URL(bidderRequest.refererInfo.page)
winTop = window.top;
} catch (e) {
location = winTop.location;
Expand Down
3 changes: 2 additions & 1 deletion modules/adrelevantisBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export const spec = {

if (bidderRequest && bidderRequest.refererInfo) {
let refererinfo = {
rd_ref: encodeURIComponent(bidderRequest.refererInfo.referer),
// TODO: this sends everything it finds to the backend, except for canonicalUrl
rd_ref: encodeURIComponent(bidderRequest.refererInfo.topmostLocation),
rd_top: bidderRequest.refererInfo.reachedTop,
rd_ifs: bidderRequest.refererInfo.numIframes,
rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',')
Expand Down
3 changes: 2 additions & 1 deletion modules/adrinoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export const spec = {
bidId: validBidRequests[i].bidId,
nativeParams: validBidRequests[i].nativeParams,
placementHash: validBidRequests[i].params.hash,
referer: bidderRequest.refererInfo.referer,
// TODO: is 'page' the right value here?
referer: bidderRequest.refererInfo.page,
userAgent: navigator.userAgent,
}

Expand Down
Loading