Skip to content

Commit

Permalink
convert bidders: emx
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed May 20, 2022
1 parent 7f5c15a commit 2a93dab
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
7 changes: 4 additions & 3 deletions modules/displayioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ export const spec = {
keywords: params.keywords ? params.keywords.split(',').map(k => k.trim()) : [],
lang_content: document.documentElement.lang,
lang: window.navigator.language,
domain: window.location.hostname,
page: window.location.href,
ref: refererInfo.referer,
// TODO: are these the correct refererInfo values?
domain: refererInfo.domain,
page: refererInfo.page,
ref: refererInfo.ref,
userids: _getUserIDs(),
geo: '',
},
Expand Down
3 changes: 2 additions & 1 deletion modules/distroscaleBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ export const spec = {
},

buildRequests: (validBidRequests, bidderRequest) => {
var pageUrl = (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) || window.location.href;
// TODO: does the fallback to window.location make sense?
var pageUrl = bidderRequest?.refererInfo?.page || window.location.href;

var payload = {
id: '' + (new Date()).getTime(),
Expand Down
1 change: 1 addition & 0 deletions modules/docereeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const spec = {
buildRequests: (validBidRequests) => {
const serverRequests = [];
const { data } = config.getConfig('doceree.user')
// TODO: this should probably look at refererInfo
const { page, domain, token } = config.getConfig('doceree.context')
const encodedUserInfo = window.btoa(encodeURIComponent(JSON.stringify(data)))

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

const placementId = params.placement;
const rnd = Math.floor(Math.random() * 99999999999);
const referrer = bidderRequest.refererInfo.referer;
const referrer = bidderRequest.refererInfo.page;
const bidId = bidRequest.bidId;
const isDev = params.devMode || false;
const pbcode = bidRequest.adUnitCode || false; // div id
Expand Down
3 changes: 2 additions & 1 deletion modules/e_volutionBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,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
16 changes: 5 additions & 11 deletions modules/emx_digitalBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {Renderer} from '../src/Renderer.js';
import {find, includes} from '../src/polyfill.js';
import {parseDomain} from '../src/refererDetection.js';

const BIDDER_CODE = 'emx_digital';
const ENDPOINT = 'hb.emxdgt.com';
Expand Down Expand Up @@ -140,19 +141,12 @@ export const emxAdapter = {
logError('emx_digitalBidAdapter', 'error', err);
}
},
getReferrer: () => {
try {
return window.top.document.referrer;
} catch (err) {
return document.referrer;
}
},
getSite: (refInfo) => {
let url = parseUrl(refInfo.referer);
// TODO: do the fallbacks make sense?
return {
domain: url.hostname,
page: refInfo.referer,
ref: emxAdapter.getReferrer()
domain: refInfo.domain || parseDomain(refInfo.topmostLocation),
page: refInfo.page || refInfo.topmostLocation,
ref: refInfo.ref || window.document.referrer
}
},
getGdpr: (bidRequests, emxData) => {
Expand Down
6 changes: 4 additions & 2 deletions test/spec/modules/emx_digitalBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ describe('emx_digital Adapter', function () {
'refererInfo': {
'numIframes': 0,
'reachedTop': true,
'referer': 'https://example.com/index.html?pbjs_debug=true'
'page': 'https://example.com/index.html?pbjs_debug=true',
'domain': 'example.com',
'ref': 'https://referrer.com'
},
'bids': [{
'bidder': 'emx_digital',
Expand Down Expand Up @@ -304,7 +306,7 @@ describe('emx_digital Adapter', function () {
request = JSON.parse(request.data);
expect(request.site).to.have.property('domain', 'example.com');
expect(request.site).to.have.property('page', 'https://example.com/index.html?pbjs_debug=true');
expect(request.site).to.have.property('ref', window.top.document.referrer);
expect(request.site).to.have.property('ref', 'https://referrer.com');
});

it('builds correctly formatted request banner object', function () {
Expand Down

0 comments on commit 2a93dab

Please sign in to comment.