From 039444b63520494bf40be18eea33f16589d4b1c7 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Wed, 18 May 2022 12:23:16 -0700 Subject: [PATCH] convert bidders: adrino --- modules/adotBidAdapter.js | 17 ++--------------- modules/adpartnerBidAdapter.js | 8 ++------ modules/adplusBidAdapter.js | 1 + modules/adprimeBidAdapter.js | 2 +- modules/adrelevantisBidAdapter.js | 3 ++- modules/adrinoBidAdapter.js | 3 ++- test/spec/modules/adotBidAdapter_spec.js | 12 ++++++------ test/spec/modules/adpartnerBidAdapter_spec.js | 2 +- .../spec/modules/adrelevantisBidAdapter_spec.js | 2 +- test/spec/modules/adrinoBidAdapter_spec.js | 4 ++-- 10 files changed, 20 insertions(+), 34 deletions(-) diff --git a/modules/adotBidAdapter.js b/modules/adotBidAdapter.js index ac49f7ae32d..4141b7e2c6d 100644 --- a/modules/adotBidAdapter.js +++ b/modules/adotBidAdapter.js @@ -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 * @@ -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: { diff --git a/modules/adpartnerBidAdapter.js b/modules/adpartnerBidAdapter.js index e8d8a43aa1b..471a0bba64a 100644 --- a/modules/adpartnerBidAdapter.js +++ b/modules/adpartnerBidAdapter.js @@ -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 = { diff --git a/modules/adplusBidAdapter.js b/modules/adplusBidAdapter.js index 4707ca2ff5a..6fbe1fe1dde 100644 --- a/modules/adplusBidAdapter.js +++ b/modules/adplusBidAdapter.js @@ -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, diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index d64874c393e..77bcee92b12 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -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; diff --git a/modules/adrelevantisBidAdapter.js b/modules/adrelevantisBidAdapter.js index 73077241c3b..bce55a46597 100644 --- a/modules/adrelevantisBidAdapter.js +++ b/modules/adrelevantisBidAdapter.js @@ -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(',') diff --git a/modules/adrinoBidAdapter.js b/modules/adrinoBidAdapter.js index 4520066c3e7..ed898c46cac 100644 --- a/modules/adrinoBidAdapter.js +++ b/modules/adrinoBidAdapter.js @@ -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, } diff --git a/test/spec/modules/adotBidAdapter_spec.js b/test/spec/modules/adotBidAdapter_spec.js index 81b9c5e15e9..8851df37d34 100644 --- a/test/spec/modules/adotBidAdapter_spec.js +++ b/test/spec/modules/adotBidAdapter_spec.js @@ -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 = { @@ -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: { @@ -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 = { @@ -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: { @@ -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 = { @@ -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: { diff --git a/test/spec/modules/adpartnerBidAdapter_spec.js b/test/spec/modules/adpartnerBidAdapter_spec.js index 94b56f7735b..d9f9b0d0074 100644 --- a/test/spec/modules/adpartnerBidAdapter_spec.js +++ b/test/spec/modules/adpartnerBidAdapter_spec.js @@ -86,7 +86,7 @@ describe('AdpartnerAdapter', function () { let bidderRequest = { refererInfo: { - referer: 'https://test.domain' + page: 'https://test.domain' } }; diff --git a/test/spec/modules/adrelevantisBidAdapter_spec.js b/test/spec/modules/adrelevantisBidAdapter_spec.js index 569cb0eba60..2612800aa56 100644 --- a/test/spec/modules/adrelevantisBidAdapter_spec.js +++ b/test/spec/modules/adrelevantisBidAdapter_spec.js @@ -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: [ diff --git a/test/spec/modules/adrinoBidAdapter_spec.js b/test/spec/modules/adrinoBidAdapter_spec.js index 52b2796e6db..a7b7007dcf8 100644 --- a/test/spec/modules/adrinoBidAdapter_spec.js +++ b/test/spec/modules/adrinoBidAdapter_spec.js @@ -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'); @@ -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');