Skip to content

Commit

Permalink
convert adapters: adagio
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed May 18, 2022
1 parent e861922 commit f849022
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
12 changes: 5 additions & 7 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ import {
logInfo,
logWarn,
mergeDeep,
parseUrl
} from '../src/utils.js';
import {config} from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {loadExternalScript} from '../src/adloader.js';
import {verify} from 'criteo-direct-rsa-validate/build/verify.js';
import {getStorageManager} from '../src/storageManager.js';
import {getRefererInfo} from '../src/refererDetection.js';
import {getRefererInfo, parseDomain} from '../src/refererDetection.js';
import {createEidsArray} from './userId/eids.js';
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {Renderer} from '../src/Renderer.js';
Expand Down Expand Up @@ -270,12 +269,11 @@ function getDevice() {

function getSite(bidderRequest) {
const { refererInfo } = bidderRequest;
const url = parseUrl(refererInfo.referer);

return {
domain: url.hostname || '',
page: refererInfo.referer || '',
referrer: canAccessTopWindow() ? getWindowTop().document.referrer || '' : getWindowSelf().document.referrer || '',
// TODO: do these fallbacks make sense?
domain: refererInfo.domain || parseDomain(refererInfo.topmostLocation) || '',
page: refererInfo.page || refererInfo.topmostLocation || '',
referrer: refererInfo.ref || getWindowSelf().document.referrer || '',
top: refererInfo.reachedTop
};
};
Expand Down
27 changes: 12 additions & 15 deletions test/spec/modules/adagioBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1381,21 +1381,13 @@ describe('Adagio bid adapter', () => {

describe('site information using refererDetection or window.top', function() {
it('should returns domain, page and window.referrer in a window.top context', function() {
sandbox.stub(utils, 'getWindowTop').returns({
location: {
hostname: 'test.io',
href: 'https://test.io/article/a.html'
},
document: {
referrer: 'https://google.com'
}
});

const bidderRequest = new BidderRequestBuilder({
refererInfo: {
numIframes: 0,
reachedTop: true,
referer: 'https://test.io/article/a.html'
page: 'https://test.io/article/a.html',
domain: 'test.io',
ref: 'https://google.com'
}
}).build();

Expand All @@ -1418,13 +1410,15 @@ describe('Adagio bid adapter', () => {
const info = {
numIframes: 0,
reachedTop: true,
referer: 'http://level.io/',
page: 'http://level.io/',
stack: [
'http://level.io/',
'http://example.com/iframe1.html',
'http://example.com/iframe2.html'
],
canonicalUrl: ''
canonicalUrl: '',
domain: 'level.io',
ref: null,
};

const bidderRequest = new BidderRequestBuilder({
Expand All @@ -1445,13 +1439,16 @@ describe('Adagio bid adapter', () => {
const info = {
numIframes: 2,
reachedTop: false,
referer: 'http://example.com/iframe1.html',
topmostLocation: 'http://example.com/iframe1.html',
stack: [
null,
'http://example.com/iframe1.html',
'http://example.com/iframe2.html'
],
canonicalUrl: ''
canonicalUrl: '',
page: null,
domain: null,
ref: null
};

const bidderRequest = new BidderRequestBuilder({
Expand Down

0 comments on commit f849022

Please sign in to comment.