Skip to content

Commit

Permalink
convert bidders: microad
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed May 20, 2022
1 parent 8da461f commit d0703d4
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 22 deletions.
10 changes: 5 additions & 5 deletions modules/medianetAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,16 @@ class Configure {

class PageDetail {
constructor () {
const canonicalUrl = this._getUrlFromSelector('link[rel="canonical"]', 'href');
const ogUrl = this._getUrlFromSelector('meta[property="og:url"]', 'content');
const twitterUrl = this._getUrlFromSelector('meta[name="twitter:url"]', 'content');
const refererInfo = getRefererInfo();

this.domain = URL.parseUrl(refererInfo.referer).hostname;
this.page = refererInfo.referer;
// TODO: are these the right refererInfo values?
this.domain = refererInfo.domain;
this.page = refererInfo.page;
this.is_top = refererInfo.reachedTop;
this.referrer = this._getTopWindowReferrer();
this.canonical_url = canonicalUrl;
this.referrer = refererInfo.ref || window.document.referrer;
this.canonical_url = refererInfo.canonicalUrl;
this.og_url = ogUrl;
this.twitter_url = twitterUrl;
this.screen = this._getWindowSize();
Expand Down
6 changes: 4 additions & 2 deletions modules/medianetBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const EVENTS = {
};
const EVENT_PIXEL_URL = 'qsearch-a.akamaihd.net/log';
const OUTSTREAM = 'outstream';

// TODO: this should be picked from bidderRequest
let refererInfo = getRefererInfo();

let mnData = {};
Expand All @@ -27,8 +29,8 @@ window.mnet = window.mnet || {};
window.mnet.queue = window.mnet.queue || [];

mnData.urlData = {
domain: parseUrl(refererInfo.referer).hostname,
page: refererInfo.referer,
domain: refererInfo.domain,
page: refererInfo.page,
isTop: refererInfo.reachedTop
}

Expand Down
11 changes: 5 additions & 6 deletions modules/mediasniperBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,18 @@ export const spec = {

// Assign payload.site from refererinfo
if (bidderRequest.refererInfo) {
// TODO: reachedTop is probably not the right check - it may be false when page is available or vice-versa
if (bidderRequest.refererInfo.reachedTop) {
const sitePage = bidderRequest.refererInfo.referer;
const sitePage = bidderRequest.refererInfo.page;
deepSetValue(payload, 'site.page', sitePage);
deepSetValue(
payload,
'site.domain',
parseUrl(sitePage, {
noDecodeWholeURL: true,
}).hostname
bidderRequest.refererInfo.domain
);

if (canAccessTopWindow()) {
deepSetValue(payload, 'site.ref', getWindowTop().document.referrer);
if (bidderRequest.refererInfo?.ref) {
deepSetValue(payload, 'site.ref', bidderRequest.refererInfo.ref);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion modules/mediasquareBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export const spec = {
});
const payload = {
codes: codes,
referer: encodeURIComponent(bidderRequest.refererInfo.referer),
// TODO: is 'page' the right value here?
referer: encodeURIComponent(bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation),
pbjs: '$prebid.version$'
};
if (bidderRequest) { // modules informations (gdpr, ccpa, schain, userId)
Expand Down
3 changes: 2 additions & 1 deletion modules/mgidBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ export const spec = {
return;
}
const info = pageInfo();
const page = info.location || deepAccess(bidderRequest, 'refererInfo.referer') || deepAccess(bidderRequest, 'refererInfo.canonicalUrl');
// TODO: the fallback seems to never be used here, and probably in the wrong order
const page = info.location || deepAccess(bidderRequest, 'refererInfo.page')
const hostname = parseUrl(page).hostname;
let domain = extractDomainFromHost(hostname) || hostname;
const accountId = setOnAny(validBidRequests, 'params.accountId');
Expand Down
5 changes: 3 additions & 2 deletions modules/microadBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ export const spec = {
const bidParams = bid.params;
const params = {
spot: bidParams.spot,
url: bidderRequest.refererInfo.canonicalUrl || window.location.href,
referrer: bidderRequest.refererInfo.referer,
// TODO: are these the right refererInfo values - does the fallback make sense here?
url: bidderRequest.refererInfo.page || window.location.href,
referrer: bidderRequest.refererInfo.ref,
bid_id: bid.bidId,
transaction_id: bid.transactionId,
media_types: convertMediaTypes(bid),
Expand Down
2 changes: 1 addition & 1 deletion src/refererDetection.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function detectReferer(win) {
* @property {string|null} canonicalUrl the site's canonical URL as set by the publisher, through setConfig({pageUrl}) or <link rel="canonical" />
* @property {string|null} page the best candidate for the current page URL: `canonicalUrl`, falling back to `location`
* @property {string|null} domain the domain portion of `page`
* @property {string|null} the referrer (document.referrer) to the current page, or null if not available (due to cross-origin restrictions)
* @property {string|null} ref the referrer (document.referrer) to the current page, or null if not available (due to cross-origin restrictions)
* @property {string} topmostLocation of the top-most frame for which we could guess the location. Outside of cross-origin scenarios, this is equivalent to `location`.
* @property {number} numIframes number of steps between window.self and window.top
* @property {Array[string|null]} stack our best guess at the location for each frame, in the direction top -> self.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ describe('microadBidAdapter', () => {
describe('buildRequests', () => {
const bidderRequest = {
refererInfo: {
canonicalUrl: 'https://example.com/to',
referer: 'https://example.com/from'
page: 'https://example.com/to',
ref: 'https://example.com/from'
}
};
const expectedResultTemplate = {
Expand Down Expand Up @@ -124,10 +124,10 @@ describe('microadBidAdapter', () => {
]);
});

it('should use window.location.href if there is no canonicalUrl', () => {
it('should use window.location.href if there is no page', () => {
const bidderRequestWithoutCanonicalUrl = {
refererInfo: {
referer: 'https://example.com/from'
ref: 'https://example.com/from'
}
};
const requests = spec.buildRequests([bidRequestTemplate], bidderRequestWithoutCanonicalUrl);
Expand Down

0 comments on commit d0703d4

Please sign in to comment.