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

Teads adapter : Support page referrer and network bandwidth #5430

Merged
merged 1 commit into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modules/teadsBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const spec = {
const bids = validBidRequests.map(buildRequestObject);
const payload = {
referrer: getReferrerInfo(bidderRequest),
pageReferrer: document.referrer,
networkBandwidth: getConnectionDownLink(window.navigator),
data: bids,
deviceWidth: screen.width,
hb_version: '$prebid.version$'
Expand Down Expand Up @@ -117,6 +119,10 @@ function getReferrerInfo(bidderRequest) {
return ref;
}

function getConnectionDownLink(nav) {
return nav && nav.connection && nav.connection.downlink >= 0 ? nav.connection.downlink.toString() : '';
}

function findGdprStatus(gdprApplies, gdprData, apiVersion) {
let status = gdprStatus.GDPR_APPLIES_PUBLISHER
if (gdprApplies) {
Expand Down
23 changes: 23 additions & 0 deletions test/spec/modules/teadsBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,29 @@ describe('teadsBidAdapter', () => {
expect(payload.referrer).to.deep.equal('https://example.com/page.html')
});

it('should add networkBandwidth info to payload', function () {
const request = spec.buildRequests(bidRequests, bidderResquestDefault);
const payload = JSON.parse(request.data);

const bandwidth = window.navigator && window.navigator.connection && window.navigator.connection.downlink;

expect(payload.networkBandwidth).to.exist;

if (bandwidth) {
expect(payload.networkBandwidth).to.deep.equal(bandwidth.toString());
} else {
expect(payload.networkBandwidth).to.deep.equal('');
}
});

it('should add pageReferrer info to payload', function () {
const request = spec.buildRequests(bidRequests, bidderResquestDefault);
const payload = JSON.parse(request.data);

expect(payload.pageReferrer).to.exist;
expect(payload.pageReferrer).to.deep.equal(document.referrer);
});

it('should send GDPR to endpoint with 11 status', function() {
let consentString = 'JRJ8RKfDeBNsERRDCSAAZ+A==';
let bidderRequest = {
Expand Down