Skip to content

Commit

Permalink
convert bidders: mediakeys
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed May 20, 2022
1 parent 15ee1b4 commit 8da461f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 17 deletions.
3 changes: 2 additions & 1 deletion modules/malltvBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
7 changes: 6 additions & 1 deletion modules/marsmediaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion modules/mathildeadsBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,15 @@ 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);
} catch (e) {
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;
Expand Down
4 changes: 3 additions & 1 deletion modules/mediaforceBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 5 additions & 8 deletions modules/mediakeysBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/marsmediaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('marsmedia adapter tests', function () {
};
this.defaultBidderRequest = {
'refererInfo': {
'referer': 'Reference Page',
'ref': 'Reference Page',
'stack': [
'aodomain.dvl',
'page.dvl'
Expand Down
8 changes: 4 additions & 4 deletions test/spec/modules/mediaforceBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit 8da461f

Please sign in to comment.