Skip to content

Commit

Permalink
convert bidders: adrino
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed May 18, 2022
1 parent 70305f4 commit 039444b
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 34 deletions.
17 changes: 2 additions & 15 deletions modules/adotBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,6 @@ function tryParse(data) {
}
}

/**
* Extract domain from given url
*
* @param {string} url
* @returns {string|null} Extracted domain
*/
function extractDomainFromURL(url) {
if (!url || !isStr(url)) return null;
const domain = url.match(DOMAIN_REGEX);
if (isArray(domain) && domain.length === 2) return domain[1];
return null;
}

/**
* Create and return site OpenRtb object from given bidderRequest
*
Expand All @@ -65,13 +52,13 @@ function extractDomainFromURL(url) {
function getOpenRTBSiteObject(bidderRequest) {
if (!bidderRequest || !bidderRequest.refererInfo) return null;

const domain = extractDomainFromURL(bidderRequest.refererInfo.referer);
const domain = bidderRequest.refererInfo.domain;
const publisherId = config.getConfig('adot.publisherId');

if (!domain) return null;

return {
page: bidderRequest.refererInfo.referer,
page: bidderRequest.refererInfo.page,
domain: domain,
name: domain,
publisher: {
Expand Down
8 changes: 2 additions & 6 deletions modules/adpartnerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ export const spec = {
},

buildRequests: function (validBidRequests, bidderRequest) {
let referer = window.location.href;
try {
referer = typeof bidderRequest.refererInfo === 'undefined'
? window.top.location.href
: bidderRequest.refererInfo.referer;
} catch (e) {}
// TODO does it make sense to fall back to window.location.href?
const referer = bidderRequest?.refererInfo?.page || window.location.href;

let bidRequests = [];
let beaconParams = {
Expand Down
1 change: 1 addition & 0 deletions modules/adplusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function createBidRequest(bid) {
screenWidth: screen.width,
screenHeight: screen.height,
language: window.navigator.language || 'en-US',
// TODO: these should probably look at refererInfo
pageUrl: window.location.href,
domain: window.location.hostname,
referrer: window.location.referrer,
Expand Down
2 changes: 1 addition & 1 deletion modules/adprimeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const spec = {
let winTop = window;
let location;
try {
location = new URL(bidderRequest.refererInfo.referer)
location = new URL(bidderRequest.refererInfo.page)
winTop = window.top;
} catch (e) {
location = winTop.location;
Expand Down
3 changes: 2 additions & 1 deletion modules/adrelevantisBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export const spec = {

if (bidderRequest && bidderRequest.refererInfo) {
let refererinfo = {
rd_ref: encodeURIComponent(bidderRequest.refererInfo.referer),
// TODO: this sends everything it finds to the backend, except for canonicalUrl
rd_ref: encodeURIComponent(bidderRequest.refererInfo.topmostLocation),
rd_top: bidderRequest.refererInfo.reachedTop,
rd_ifs: bidderRequest.refererInfo.numIframes,
rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',')
Expand Down
3 changes: 2 additions & 1 deletion modules/adrinoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export const spec = {
bidId: validBidRequests[i].bidId,
nativeParams: validBidRequests[i].nativeParams,
placementHash: validBidRequests[i].params.hash,
referer: bidderRequest.refererInfo.referer,
// TODO: is 'page' the right value here?
referer: bidderRequest.refererInfo.page,
userAgent: navigator.userAgent,
}

Expand Down
12 changes: 6 additions & 6 deletions test/spec/modules/adotBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Adot Adapter', function () {
it('should build request (banner)', function () {
const bidderRequestId = 'bidderRequestId';
const validBidRequests = [{ bidderRequestId, mediaTypes: {} }, { bidderRequestId, bidId: 'bidId', mediaTypes: { banner: { sizes: [[300, 250]] } }, params: { placementId: 'placementId', adUnitCode: 200 } }];
const bidderRequest = { position: 2, refererInfo: { referer: 'http://localhost.com' }, gdprConsent: { consentString: 'consentString', gdprApplies: true } };
const bidderRequest = { position: 2, refererInfo: { page: 'http://localhost.com', domain: 'localhost.com' }, gdprConsent: { consentString: 'consentString', gdprApplies: true } };

const request = spec.buildRequests(validBidRequests, bidderRequest);
const buildBidRequestResponse = {
Expand All @@ -48,7 +48,7 @@ describe('Adot Adapter', function () {
bidfloor: 0
}],
site: {
page: bidderRequest.refererInfo.referer,
page: bidderRequest.refererInfo.page,
domain: 'localhost.com',
name: 'localhost.com',
publisher: {
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('Adot Adapter', function () {
it('should build request (native)', function () {
const bidderRequestId = 'bidderRequestId';
const validBidRequests = [{ bidderRequestId, mediaTypes: {} }, { bidderRequestId, bidId: 'bidId', mediaTypes: { native: { title: { required: true, len: 50, sizes: [[300, 250]] }, wrong: {}, image: {} } }, params: { placementId: 'placementId', adUnitCode: 200 } }];
const bidderRequest = { position: 2, refererInfo: { referer: 'http://localhost.com' }, gdprConsent: { consentString: 'consentString', gdprApplies: true } };
const bidderRequest = { position: 2, refererInfo: { page: 'http://localhost.com', domain: 'localhost.com' }, gdprConsent: { consentString: 'consentString', gdprApplies: true } };

const request = spec.buildRequests(validBidRequests, bidderRequest);
const buildBidRequestResponse = {
Expand All @@ -95,7 +95,7 @@ describe('Adot Adapter', function () {
bidfloor: 0
}],
site: {
page: bidderRequest.refererInfo.referer,
page: bidderRequest.refererInfo.page,
domain: 'localhost.com',
name: 'localhost.com',
publisher: {
Expand Down Expand Up @@ -123,7 +123,7 @@ describe('Adot Adapter', function () {
it('should build request (video)', function () {
const bidderRequestId = 'bidderRequestId';
const validBidRequests = [{ bidderRequestId, mediaTypes: {} }, { bidderRequestId, bidId: 'bidId', mediaTypes: { video: { playerSize: [[300, 250]], minduration: 1, maxduration: 2, api: 'api', linearity: 'linearity', mimes: [], placement: 'placement', playbackmethod: 'playbackmethod', protocols: 'protocol', startdelay: 'startdelay' } }, params: { placementId: 'placementId', adUnitCode: 200 } }];
const bidderRequest = { position: 2, refererInfo: { referer: 'http://localhost.com' }, gdprConsent: { consentString: 'consentString', gdprApplies: true } };
const bidderRequest = { position: 2, refererInfo: { page: 'http://localhost.com', domain: 'localhost.com' }, gdprConsent: { consentString: 'consentString', gdprApplies: true } };

const request = spec.buildRequests(validBidRequests, bidderRequest);
const buildBidRequestResponse = {
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('Adot Adapter', function () {
bidfloor: 0
}],
site: {
page: bidderRequest.refererInfo.referer,
page: bidderRequest.refererInfo.page,
domain: 'localhost.com',
name: 'localhost.com',
publisher: {
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/adpartnerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('AdpartnerAdapter', function () {

let bidderRequest = {
refererInfo: {
referer: 'https://test.domain'
page: 'https://test.domain'
}
};

Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/adrelevantisBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ describe('AdrelevantisAdapter', function () {
const bidRequest = Object.assign({}, bidRequests[0])
const bidderRequest = {
refererInfo: {
referer: 'http://example.com/page.html',
topmostLocation: 'http://example.com/page.html',
reachedTop: true,
numIframes: 2,
stack: [
Expand Down
4 changes: 2 additions & 2 deletions test/spec/modules/adrinoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('adrinoBidAdapter', function () {
it('should build the request correctly with gdpr', function () {
const result = spec.buildRequests(
[ bidRequest ],
{ gdprConsent: { gdprApplies: true, consentString: 'abc123' }, refererInfo: { referer: 'http://example.com/' } }
{ gdprConsent: { gdprApplies: true, consentString: 'abc123' }, refererInfo: { page: 'http://example.com/' } }
);
expect(result.length).to.equal(1);
expect(result[0].method).to.equal('POST');
Expand All @@ -91,7 +91,7 @@ describe('adrinoBidAdapter', function () {
it('should build the request correctly without gdpr', function () {
const result = spec.buildRequests(
[ bidRequest ],
{ refererInfo: { referer: 'http://example.com/' } }
{ refererInfo: { page: 'http://example.com/' } }
);
expect(result.length).to.equal(1);
expect(result[0].method).to.equal('POST');
Expand Down

0 comments on commit 039444b

Please sign in to comment.