Skip to content

Commit

Permalink
convert bidders: adkernel
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed May 18, 2022
1 parent 0170539 commit 43327a9
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 18 deletions.
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
32 changes: 26 additions & 6 deletions src/refererDetection.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,36 @@ export function detectReferer(win) {
isAmp: valuesFromAmp,
numIframes: level - 1,
stack,
topmostLocation: bestLocation || null, // location of the topmost accessible frame
location, // location of window.top, if available
canonicalUrl: bestCanonicalUrl || null, // canonical URL as provided with setConfig({pageUrl}) or link[rel="canonical"], in that order of priority
page, // canonicalUrl, falling back to location
domain: parseDomain(page) || null, // the domain portion of `page`
ref: ref || null, // window.top.document.referrer, if available
topmostLocation: bestLocation || null,
location,
canonicalUrl: bestCanonicalUrl || null,
page,
domain: parseDomain(page) || null,
ref: ref || null,
};
}

return refererInfo;
}

// TODO: the meaning of "reachedTop" seems to be intentionally ambiguous - best to leave them out of
// the typedef for now. (for example, unit tests enforce that "reachedTop" should be false in some situations where we
// happily provide a location for the top).

/**
* @typedef {Object} refererInfo
* @property {string|null} location the browser's location, or null if not available (due to cross-origin restrictions)
* @property {string|null} canonicalUrl the site's canonical URL as set by the publisher, through setConfig({pageUrl}) or <link rel="canonical" />
* @property {string|null} page the best candidate for the current page URL: `canonicalUrl`, falling back to `location`
* @property {string|null} domain the domain portion of `page`
* @property {string|null} the referrer (document.referrer) to the current page, or null if not available (due to cross-origin restricitons)
* @property {string} topmostLocation of the top-most frame for which we could guess the location. Outside of cross-origin scenarios, this is
* equivalent to `location`.
* @property {number} numIframes number of steps between window.self and window.top
* @property {Array[string|null]} stack our best guess at the location for each frame, in the direction top -> self.
*/

/**
* @type {function(): refererInfo}
*/
export const getRefererInfo = detectReferer(window);
2 changes: 1 addition & 1 deletion test/spec/modules/adheseBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('AdheseAdapter', function () {
consentString: 'CONSENT_STRING'
},
refererInfo: {
referer: 'http://prebid.org/dev-docs/subjects?_d=1'
page: 'http://prebid.org/dev-docs/subjects?_d=1'
}
};

Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/adkernelAdnBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe('AdkernelAdn adapter', function () {
auctionStart: 1545836987704,
timeout: 3000,
refererInfo: {
referer: 'https://example.com/index.html',
page: 'https://example.com/index.html',
reachedTop: true,
numIframes: 0,
stack: ['https://example.com/index.html']
Expand Down

0 comments on commit 43327a9

Please sign in to comment.