From 8da461f08fd7775b62467343d21e9ce00ae8b170 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Fri, 20 May 2022 11:47:18 -0700 Subject: [PATCH] convert bidders: mediakeys --- modules/malltvBidAdapter.js | 3 ++- modules/marsmediaBidAdapter.js | 7 ++++++- modules/mathildeadsBidAdapter.js | 3 ++- modules/mediaforceBidAdapter.js | 4 +++- modules/mediakeysBidAdapter.js | 13 +++++-------- test/spec/modules/marsmediaBidAdapter_spec.js | 2 +- test/spec/modules/mediaforceBidAdapter_spec.js | 8 ++++---- 7 files changed, 23 insertions(+), 17 deletions(-) diff --git a/modules/malltvBidAdapter.js b/modules/malltvBidAdapter.js index 53f745d4004..6466aa4feed 100644 --- a/modules/malltvBidAdapter.js +++ b/modules/malltvBidAdapter.js @@ -47,7 +47,8 @@ export const spec = { if (!propertyId) { propertyId = bidRequest.params.propertyId; } if (!pageViewGuid && bidRequest.params) { pageViewGuid = bidRequest.params.pageViewGuid || ''; } if (!bidderRequestId) { bidderRequestId = bidRequest.bidderRequestId; } - if (!url && bidderRequest) { url = bidderRequest.refererInfo.referer; } + // TODO: is 'page' the right value here? + if (!url && bidderRequest) { url = bidderRequest.refererInfo.page; } if (!contents.length && bidRequest.params.contents && bidRequest.params.contents.length) { contents = bidRequest.params.contents; } if (Object.keys(data).length === 0 && bidRequest.params.data && Object.keys(bidRequest.params.data).length !== 0) { data = bidRequest.params.data; } if (bidderRequest && bidRequest.gdprConsent) { gdrpApplies = bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies ? bidderRequest.gdprConsent.gdprApplies : true; } diff --git a/modules/marsmediaBidAdapter.js b/modules/marsmediaBidAdapter.js index 92374b748c7..f144d1df22f 100644 --- a/modules/marsmediaBidAdapter.js +++ b/modules/marsmediaBidAdapter.js @@ -31,6 +31,7 @@ function MarsmediaAdapter() { var isSecure = 0; if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.stack.length) { // clever trick to get the protocol + // TODO: this should probably use parseUrl var el = document.createElement('a'); el.href = bidderRequest.refererInfo.stack[0]; isSecure = (el.protocol == 'https:') ? 1 : 0; @@ -67,13 +68,17 @@ function MarsmediaAdapter() { ref: '' } if (bidderRequest && bidderRequest.refererInfo) { + var ri = bidderRequest.refererInfo; - site.ref = ri.referer; + // TODO: is 'ref' the right value here? + site.ref = ri.ref; if (ri.stack.length) { site.page = ri.stack[ri.stack.length - 1]; // clever trick to get the domain + // TODO: does this logic make sense? why should domain be set to the lowermost frame's? + // TODO: this should probably use parseUrl var el = document.createElement('a'); el.href = ri.stack[0]; site.domain = el.hostname; diff --git a/modules/mathildeadsBidAdapter.js b/modules/mathildeadsBidAdapter.js index 3f5d94f0df2..f80e6e1f749 100644 --- a/modules/mathildeadsBidAdapter.js +++ b/modules/mathildeadsBidAdapter.js @@ -125,7 +125,7 @@ export const spec = { winLocation = window.location; } - const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.referer; + const refferUrl = bidderRequest?.refererInfo?.page; let refferLocation; try { refferLocation = refferUrl && new URL(refferUrl); @@ -133,6 +133,7 @@ export const spec = { logMessage(e); } + // TODO: does the fallback make sense here? let location = refferLocation || winLocation; const language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; const host = location.host; diff --git a/modules/mediaforceBidAdapter.js b/modules/mediaforceBidAdapter.js index c686a2e378d..8f15af72235 100644 --- a/modules/mediaforceBidAdapter.js +++ b/modules/mediaforceBidAdapter.js @@ -113,7 +113,8 @@ export const spec = { return; } - const referer = bidderRequest && bidderRequest.refererInfo ? encodeURIComponent(bidderRequest.refererInfo.referer) : ''; + // TODO: is 'ref' the right value here? + const referer = bidderRequest && bidderRequest.refererInfo ? encodeURIComponent(bidderRequest.refererInfo.ref) : ''; const auctionId = bidderRequest && bidderRequest.auctionId; const timeout = bidderRequest && bidderRequest.timeout; const dnt = getDNT() ? 1 : 0; @@ -156,6 +157,7 @@ export const spec = { request = { id: Math.round(Math.random() * 1e16).toString(16), site: { + // TODO: this should probably look at refererInfo page: window.location.href, ref: referer, id: bid.params.publisher_id, diff --git a/modules/mediakeysBidAdapter.js b/modules/mediakeysBidAdapter.js index a2b5d8b8ecc..4a4e9e54c9a 100644 --- a/modules/mediakeysBidAdapter.js +++ b/modules/mediakeysBidAdapter.js @@ -650,15 +650,12 @@ export const spec = { // Assign payload.site from refererinfo if (bidderRequest.refererInfo) { + // TODO: reachedTop is probably not the right check here - it may be false when page is available or vice-versa if (bidderRequest.refererInfo.reachedTop) { - const sitePage = bidderRequest.refererInfo.referer; - deepSetValue(payload, 'site.page', sitePage); - deepSetValue(payload, 'site.domain', parseUrl(sitePage, { - noDecodeWholeURL: true - }).hostname); - - if (canAccessTopWindow()) { - deepSetValue(payload, 'site.ref', getWindowTop().document.referrer); + deepSetValue(payload, 'site.page', bidderRequest.refererInfo.page); + deepSetValue(payload, 'site.domain', bidderRequest.refererInfo.domain) + if (bidderRequest.refererInfo.ref) { + deepSetValue(payload, 'site.ref', bidderRequest.refererInfo.ref); } } } diff --git a/test/spec/modules/marsmediaBidAdapter_spec.js b/test/spec/modules/marsmediaBidAdapter_spec.js index cf074b0f3d6..055b05700b2 100644 --- a/test/spec/modules/marsmediaBidAdapter_spec.js +++ b/test/spec/modules/marsmediaBidAdapter_spec.js @@ -38,7 +38,7 @@ describe('marsmedia adapter tests', function () { }; this.defaultBidderRequest = { 'refererInfo': { - 'referer': 'Reference Page', + 'ref': 'Reference Page', 'stack': [ 'aodomain.dvl', 'page.dvl' diff --git a/test/spec/modules/mediaforceBidAdapter_spec.js b/test/spec/modules/mediaforceBidAdapter_spec.js index 0b5c4d00f53..22f584306a9 100644 --- a/test/spec/modules/mediaforceBidAdapter_spec.js +++ b/test/spec/modules/mediaforceBidAdapter_spec.js @@ -132,7 +132,7 @@ describe('mediaforce bid adapter', function () { }); const refererInfo = { - referer: 'https://www.prebid.org', + ref: 'https://www.prebid.org', reachedTop: true, stack: [ 'https://www.prebid.org/page.html', @@ -181,7 +181,7 @@ describe('mediaforce bid adapter', function () { site: { id: bid.params.publisher_id, publisher: {id: bid.params.publisher_id}, - ref: encodeURIComponent(refererInfo.referer), + ref: encodeURIComponent(refererInfo.ref), page: pageUrl, }, device: { @@ -265,7 +265,7 @@ describe('mediaforce bid adapter', function () { site: { id: 'pub123', publisher: {id: 'pub123'}, - ref: encodeURIComponent(refererInfo.referer), + ref: encodeURIComponent(refererInfo.ref), page: pageUrl, }, device: { @@ -321,7 +321,7 @@ describe('mediaforce bid adapter', function () { site: { id: 'pub124', publisher: {id: 'pub124'}, - ref: encodeURIComponent(refererInfo.referer), + ref: encodeURIComponent(refererInfo.ref), page: pageUrl, }, device: {