Skip to content

Commit

Permalink
convert bidders: adxcg
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed May 18, 2022
1 parent 06b0c9d commit b9a4d56
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
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
16 changes: 5 additions & 11 deletions modules/advangelistsBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {deepAccess, generateUUID, isEmpty, isFn, parseSizesInput, parseUrl} from '../src/utils.js';
import {config} from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {find, includes} from '../src/polyfill.js';
Expand Down Expand Up @@ -200,12 +199,8 @@ function getBannerSizes(bid) {
return parseSizes(deepAccess(bid, 'mediaTypes.banner.sizes') || bid.sizes);
}

function getTopWindowReferrer() {
try {
return window.top.document.referrer;
} catch (e) {
return '';
}
function getTopWindowReferrer(bidderRequest) {
return bidderRequest?.refererInfo?.ref || '';
}

function getVideoTargetingParams(bid) {
Expand All @@ -226,7 +221,7 @@ function getVideoTargetingParams(bid) {

function createVideoRequestData(bid, bidderRequest) {
let topLocation = getTopWindowLocation(bidderRequest);
let topReferrer = getTopWindowReferrer();
let topReferrer = getTopWindowReferrer(bidderRequest);

let sizes = getVideoSizes(bid);
let firstSize = getFirstSize(sizes);
Expand Down Expand Up @@ -309,13 +304,12 @@ function createVideoRequestData(bid, bidderRequest) {
}

function getTopWindowLocation(bidderRequest) {
let url = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer;
return parseUrl(config.getConfig('pageUrl') || url, { decodeSearchAsString: true });
return parseUrl(bidderRequest?.refererInfo?.page, {decodeSearchAsString: true});
}

function createBannerRequestData(bid, bidderRequest) {
let topLocation = getTopWindowLocation(bidderRequest);
let topReferrer = getTopWindowReferrer();
let topReferrer = getTopWindowReferrer(bidderRequest);

let sizes = getBannerSizes(bid);
let bidfloor = (getBannerBidFloor(bid) == null || typeof getBannerBidFloor(bid) == 'undefined') ? 2 : getBannerBidFloor(bid);
Expand Down
4 changes: 2 additions & 2 deletions modules/adxcgBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export const spec = {
}

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

Expand Down
8 changes: 4 additions & 4 deletions test/spec/modules/adxcgBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Adxcg adapter', function () {
adzoneid: '19910113'
}
}];
let request = spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}});
let request = spec.buildRequests(validBidRequests, {refererInfo: {page: 'page', domain: 'localhost'}});

assert.equal(request.method, 'POST');
assert.equal(request.url, 'https://pbc.adxcg.net/rtb/ortb/pbc?adExchangeId=1');
Expand Down Expand Up @@ -180,7 +180,7 @@ describe('Adxcg adapter', function () {
bidId: 'bidId',
params: {adzoneid: '1000'}
}];
let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data);
let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {page: 'page', domain: 'localhost'}}).data);

assert.equal(request.device.ua, navigator.userAgent);
assert.equal(request.device.w, 100);
Expand Down Expand Up @@ -227,13 +227,13 @@ describe('Adxcg adapter', function () {
params: {adzoneid: '1000'},
ortb2
}];
let refererInfo = {referer: 'page'};
let refererInfo = {page: 'page', domain: 'localhost'};
let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo, ortb2}).data);

assert.deepEqual(request.site, {
domain: 'localhost',
id: '123123',
page: refererInfo.referer,
page: refererInfo.page,
publisher: {
domain: 'publisher.domain.com',
id: 4441,
Expand Down

0 comments on commit b9a4d56

Please sign in to comment.