Skip to content

Commit

Permalink
convert bidders: axonix
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed May 19, 2022
1 parent 0f5d97b commit 97ea0df
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 46 deletions.
5 changes: 1 addition & 4 deletions modules/appierBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ export const spec = {
const payload = {
'bids': bidRequests,
// TODO: please do not pass internal data structures over to the network
'refererInfo': {
...bidderRequest.refererInfo,
referer: bidderRequest.refererInfo.topmostLocation,
},
'refererInfo': bidderRequest.refererInfo.legacy,
'version': ADAPTER_VERSION
};
return [{
Expand Down
3 changes: 2 additions & 1 deletion modules/asealBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export const spec = {

const data = {
bids: validBidRequests,
refererInfo: bidderRequest.refererInfo,
// TODO: please do not pass internal data structures over to the network
refererInfo: bidderRequest.refererInfo?.legacy,
device: {
webSessionId: getTrekWebSessionId(),
},
Expand Down
28 changes: 7 additions & 21 deletions modules/asoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js';
import {config} from '../src/config.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {Renderer} from '../src/Renderer.js';
import {parseDomain} from '../src/refererDetection.js';

const BIDDER_CODE = 'aso';
const DEFAULT_SERVER_URL = 'https://srv.aso1.net';
Expand Down Expand Up @@ -167,28 +168,13 @@ function createRenderer(bid, url) {
}

function getUrlsInfo(bidderRequest) {
let page = '';
let referrer = '';

const {refererInfo} = bidderRequest;

if (inIframe()) {
page = refererInfo.referer;
} else {
const w = getWindowTop();
page = w.location.href;
referrer = w.document.referrer || '';
}

page = config.getConfig('pageUrl') || page;
const url = parseUrl(page);
const domain = url.hostname;

const {page, domain, ref} = bidderRequest.refererInfo;
return {
domain,
page,
referrer
};
// TODO: do the fallbacks make sense here?
page: page || bidderRequest.refererInfo?.topmostLocation,
referrer: ref || '',
domain: domain || parseDomain(bidderRequest?.refererInfo?.topmostLocation)
}
}

function getSize(paramSizes) {
Expand Down
2 changes: 1 addition & 1 deletion modules/astraoneBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const spec = {
*/
buildRequests(validBidRequests, bidderRequest) {
const payload = {
url: bidderRequest.refererInfo.referer,
url: bidderRequest.refererInfo.page,
cmp: !!bidderRequest.gdprConsent,
bidRequests: buildBidRequests(validBidRequests)
};
Expand Down
15 changes: 6 additions & 9 deletions modules/audiencerunBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@ function getPageReferer() {
* @return {string}
*/
function getPageUrl(bidderRequest) {
return (
config.getConfig('pageUrl') ||
deepAccess(bidderRequest, 'refererInfo.referer') ||
getPageReferer() ||
null
);
return bidderRequest?.refererInfo?.page
}

export const spec = {
Expand Down Expand Up @@ -127,10 +122,12 @@ export const spec = {

const payload = {
libVersion: this.version,
pageUrl: config.getConfig('pageUrl'),
pageUrl: bidderRequest?.refererInfo?.page,
// TODO: does it make sense to find a half-way referer? what should these parameters pick
pageReferer: getPageReferer(),
referer: deepAccess(bidderRequest, 'refererInfo.referer'),
refererInfo: deepAccess(bidderRequest, 'refererInfo'),
referer: deepAccess(bidderRequest, 'refererInfo.topmostLocation'),
// TODO: please do not send internal data structures over the network
refererInfo: deepAccess(bidderRequest, 'refererInfo.legacy'),
currencyCode: config.getConfig('currency.adServerCurrency'),
timeout: config.getConfig('bidderTimeout'),
bids,
Expand Down
6 changes: 3 additions & 3 deletions modules/automatadBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ export const spec = {
imp: impressions,
site: {
id: siteId,
domain: window.location.hostname,
page: window.location.href,
ref: bidderRequest.refererInfo ? bidderRequest.refererInfo.referer || null : null,
domain: bidderRequest.refererInfo?.domain,
page: bidderRequest.refererInfo?.page,
ref: bidderRequest.refererInfo?.ref
},
}

Expand Down
7 changes: 3 additions & 4 deletions modules/axonixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ function getBidFloor(bidRequest) {
}

function getPageUrl(bidRequest, bidderRequest) {
let pageUrl = config.getConfig('pageUrl');

let pageUrl;
if (bidRequest.params.referrer) {
pageUrl = bidRequest.params.referrer;
} else if (!pageUrl) {
pageUrl = bidderRequest.refererInfo.referer;
} else {
pageUrl = bidderRequest.refererInfo.page;
}

return bidRequest.params.secure ? pageUrl.replace(/^http:/i, 'https:') : pageUrl;
Expand Down
10 changes: 10 additions & 0 deletions src/refererDetection.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,16 @@ export function detectReferer(win) {
page,
domain: parseDomain(page) || null,
ref: ref || null,
// TODO: the "legacy" refererInfo object is provided here, for now, to accomodate
// adapters that decided to just sent it verbatim to their backend.
legacy: {
reachedTop,
isAmp: valuesFromAmp,
numIframes: level - 1,
stack,
referer: bestLocation || null,
canonicalUrl: bestCanonicalUrl || null,
}
};
}

Expand Down
3 changes: 2 additions & 1 deletion test/spec/modules/asoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ describe('Adserver.Online bidding adapter', function () {
refererInfo: {
numIframes: 0,
reachedTop: true,
referer: 'https://example.com'
page: 'https://example.com',
domain: 'example.com'
}
};

Expand Down
3 changes: 2 additions & 1 deletion test/spec/modules/audiencerunBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ describe('AudienceRun bid adapter tests', function () {
},
refererInfo: {
canonicalUrl: undefined,
referer: 'https://example.com',
page: 'https://example.com',
topmostLocation: 'https://example.com',
numIframes: 0,
reachedTop: true,
},
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/axonixBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('AxonixBidAdapter', function () {
gdprApplies: true
},
refererInfo: {
referer: 'https://www.prebid.org',
page: 'https://www.prebid.org',
canonicalUrl: 'https://www.prebid.org/the/link/to/the/page'
}
};
Expand Down

0 comments on commit 97ea0df

Please sign in to comment.