Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zeta Ssp Bid Adapter: provide domain in site object #6928

Merged
merged 11 commits into from
Jun 4, 2021
20 changes: 16 additions & 4 deletions modules/zetaSspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ export const spec = {
sid: params.sid ? params.sid : undefined
}
};

const rInfo = bidderRequest.refererInfo;
payload.device.ua = navigator.userAgent;
payload.site.page = bidderRequest.refererInfo.referer;
payload.site.page = (rInfo && rInfo.referer) ? rInfo.referer.trim() : window.location.href;
payload.site.domain = getDomainFromURL(payload.site.page);
payload.site.mobile = /(ios|ipod|ipad|iphone|android)/i.test(navigator.userAgent) ? 1 : 0;

if (params.test) {
Expand Down Expand Up @@ -116,8 +117,9 @@ export const spec = {
netRevenue: NET_REV,
};
if (zetaBid.adomain && zetaBid.adomain.length) {
bid.meta = {};
bid.meta.advertiserDomains = zetaBid.adomain;
bid.meta = {
advertiserDomains: zetaBid.adomain
};
}
bidResponse.push(bid);
}
Expand Down Expand Up @@ -179,4 +181,14 @@ function provideEids(request, payload) {
}
}

function getDomainFromURL(url) {
let anchor = document.createElement('a');
anchor.href = url;
let hostname = anchor.hostname;
if (hostname.indexOf('www.') === 0) {
return hostname.substring(4);
}
return hostname;
}

registerBidder(spec);
9 changes: 8 additions & 1 deletion test/spec/modules/zetaSspBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Zeta Ssp Bid Adapter', function() {
}
},
refererInfo: {
referer: 'zetaglobal.com'
referer: 'http://www.zetaglobal.com/page?param=value'
},
params: {
placement: 12345,
Expand Down Expand Up @@ -64,6 +64,13 @@ describe('Zeta Ssp Bid Adapter', function() {
expect(payload.user.ext.eids).to.eql(eids);
});

it('Test page and domain in site', function () {
const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
const payload = JSON.parse(request.data);
expect(payload.site.page).to.eql('http://www.zetaglobal.com/page?param=value');
expect(payload.site.domain).to.eql('zetaglobal.com');
});

it('Test the request processing function', function () {
const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
expect(request).to.not.be.empty;
Expand Down