Skip to content

Commit 43327a9

Browse files
committed
convert bidders: adkernel
1 parent 0170539 commit 43327a9

File tree

6 files changed

+37
-18
lines changed

6 files changed

+37
-18
lines changed

modules/adheseBidAdapter.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export const spec = {
2626

2727
const adheseConfig = config.getConfig('adhese');
2828
const gdprParams = (gdprConsent && gdprConsent.consentString) ? { xt: [gdprConsent.consentString] } : {};
29-
const refererParams = (refererInfo && refererInfo.referer) ? { xf: [base64urlEncode(refererInfo.referer)] } : {};
29+
// TODO: is 'page' the right value here?
30+
const refererParams = (refererInfo && refererInfo.page) ? { xf: [base64urlEncode(refererInfo.page)] } : {};
3031
const globalCustomParams = (adheseConfig && adheseConfig.globalTargets) ? cleanTargets(adheseConfig.globalTargets) : {};
3132
const commonParams = { ...globalCustomParams, ...gdprParams, ...refererParams };
3233
const vastContentAsUrl = !(adheseConfig && adheseConfig.vastContentAsUrl == false);

modules/adkernelAdnAnalyticsAdapter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ export function ExpiringQueue(callback, ttl) {
381381
}
382382
}
383383

384+
// TODO: this should reuse logic from refererDetection
384385
function getNavigationInfo() {
385386
try {
386387
return getLocationAndReferrer(self.top);

modules/adkernelAdnBidAdapter.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { deepAccess, parseSizesInput, isArray, deepSetValue, parseUrl, isStr, isNumber, logInfo } from '../src/utils.js';
1+
import { deepAccess, parseSizesInput, isArray, deepSetValue, isStr, isNumber, logInfo } from '../src/utils.js';
22
import {registerBidder} from '../src/adapters/bidderFactory.js';
33
import {BANNER, VIDEO} from '../src/mediaTypes.js';
44
import {config} from '../src/config.js';
@@ -10,7 +10,7 @@ const DEFAULT_APIS = [1, 2];
1010
const GVLID = 14;
1111

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

1616
function buildImp(bidRequest) {
@@ -83,13 +83,10 @@ function buildRequestParams(tags, bidderRequest) {
8383
}
8484

8585
function buildSite(refInfo) {
86-
let loc = parseUrl(refInfo.referer);
87-
let result = {
88-
page: `${loc.protocol}://${loc.hostname}${loc.pathname}`,
89-
secure: ~~(loc.protocol === 'https')
90-
};
91-
if (self === top && document.referrer) {
92-
result.ref = document.referrer;
86+
const result = {
87+
page: refInfo.page,
88+
secure: ~~(refInfo.page && refInfo.page.startsWith('https')),
89+
ref: refInfo.ref
9390
}
9491
let keywords = document.getElementsByTagName('meta')['keywords'];
9592
if (keywords && keywords.content) {

src/refererDetection.js

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,36 @@ export function detectReferer(win) {
228228
isAmp: valuesFromAmp,
229229
numIframes: level - 1,
230230
stack,
231-
topmostLocation: bestLocation || null, // location of the topmost accessible frame
232-
location, // location of window.top, if available
233-
canonicalUrl: bestCanonicalUrl || null, // canonical URL as provided with setConfig({pageUrl}) or link[rel="canonical"], in that order of priority
234-
page, // canonicalUrl, falling back to location
235-
domain: parseDomain(page) || null, // the domain portion of `page`
236-
ref: ref || null, // window.top.document.referrer, if available
231+
topmostLocation: bestLocation || null,
232+
location,
233+
canonicalUrl: bestCanonicalUrl || null,
234+
page,
235+
domain: parseDomain(page) || null,
236+
ref: ref || null,
237237
};
238238
}
239239

240240
return refererInfo;
241241
}
242242

243+
// TODO: the meaning of "reachedTop" seems to be intentionally ambiguous - best to leave them out of
244+
// the typedef for now. (for example, unit tests enforce that "reachedTop" should be false in some situations where we
245+
// happily provide a location for the top).
246+
247+
/**
248+
* @typedef {Object} refererInfo
249+
* @property {string|null} location the browser's location, or null if not available (due to cross-origin restrictions)
250+
* @property {string|null} canonicalUrl the site's canonical URL as set by the publisher, through setConfig({pageUrl}) or <link rel="canonical" />
251+
* @property {string|null} page the best candidate for the current page URL: `canonicalUrl`, falling back to `location`
252+
* @property {string|null} domain the domain portion of `page`
253+
* @property {string|null} the referrer (document.referrer) to the current page, or null if not available (due to cross-origin restricitons)
254+
* @property {string} topmostLocation of the top-most frame for which we could guess the location. Outside of cross-origin scenarios, this is
255+
* equivalent to `location`.
256+
* @property {number} numIframes number of steps between window.self and window.top
257+
* @property {Array[string|null]} stack our best guess at the location for each frame, in the direction top -> self.
258+
*/
259+
260+
/**
261+
* @type {function(): refererInfo}
262+
*/
243263
export const getRefererInfo = detectReferer(window);

test/spec/modules/adheseBidAdapter_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe('AdheseAdapter', function () {
6767
consentString: 'CONSENT_STRING'
6868
},
6969
refererInfo: {
70-
referer: 'http://prebid.org/dev-docs/subjects?_d=1'
70+
page: 'http://prebid.org/dev-docs/subjects?_d=1'
7171
}
7272
};
7373

test/spec/modules/adkernelAdnBidAdapter_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ describe('AdkernelAdn adapter', function () {
144144
auctionStart: 1545836987704,
145145
timeout: 3000,
146146
refererInfo: {
147-
referer: 'https://example.com/index.html',
147+
page: 'https://example.com/index.html',
148148
reachedTop: true,
149149
numIframes: 0,
150150
stack: ['https://example.com/index.html']

0 commit comments

Comments
 (0)