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

GumGum: adds tradedesk id param #3896

Merged
merged 5 commits into from
Jun 20, 2019
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
10 changes: 9 additions & 1 deletion modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ function getWrapperCode(wrapper, data) {
return wrapper.replace('AD_JSON', window.btoa(JSON.stringify(data)))
}

function _getTradeDeskIDParam(bidRequest) {
const unifiedIdObj = {};
if (bidRequest.userId && bidRequest.userId.tdid) {
unifiedIdObj.tdid = bidRequest.userId.tdid;
}
return unifiedIdObj;
}

// TODO: use getConfig()
function _getDigiTrustQueryParams() {
function getDigiTrustId () {
Expand Down Expand Up @@ -170,7 +178,7 @@ function buildRequests (validBidRequests, bidderRequest) {
sizes: bidRequest.sizes,
url: BID_ENDPOINT,
method: 'GET',
data: Object.assign(data, _getBrowserParams(), _getDigiTrustQueryParams())
data: Object.assign(data, _getBrowserParams(), _getDigiTrustQueryParams(), _getTradeDeskIDParam(bidRequest))
})
});
return bids;
Expand Down
54 changes: 54 additions & 0 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,35 @@ describe('gumgumAdapter', function () {
expect(request.method).to.equal('GET');
expect(request.id).to.equal('30b31c1838de1e');
});
it('should correctly set the request paramters depending on params field', function () {
const request = Object.assign({}, bidRequests[0]);
delete request.params;
request.params = {
'inScreen': '10433394',
'bidfloor': 0.05
};
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.data.pi).to.equal(2);
expect(bidRequest.data).to.include.any.keys('t');
expect(bidRequest.data).to.include.any.keys('fp');
});
it('should correctly set the request paramters depending on params field', function () {
const request = Object.assign({}, bidRequests[0]);
delete request.params;
request.params = {
'ICV': '10433395'
};
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.data.pi).to.equal(5);
expect(bidRequest.data).to.include.any.keys('ni');
});
it('should not add additional parameters depending on params field', function () {
const request = spec.buildRequests(bidRequests)[0];
expect(request.data).to.not.include.any.keys('ni');
expect(request.data).to.not.include.any.keys('t');
expect(request.data).to.not.include.any.keys('eAdBuyId');
expect(request.data).to.not.include.any.keys('adBuyId');
});
it('should add consent parameters if gdprConsent is present', function () {
const gdprConsent = { consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', gdprApplies: true };
const fakeBidRequest = { gdprConsent: gdprConsent };
Expand All @@ -93,6 +122,31 @@ describe('gumgumAdapter', function () {
const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0];
expect(bidRequest.data).to.not.include.any.keys('gdprConsent')
});
it('should add a tdid parameter if request contains unified id from TradeDesk', function () {
const unifiedId = {
'userId': {
'tdid': 'tradedesk-id'
}
}
const request = Object.assign(unifiedId, bidRequests[0]);
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.data.tdid).to.eq(unifiedId.userId.tdid);
});
it('should not add a tdid parameter if unified id is not found', function () {
const request = spec.buildRequests(bidRequests)[0];
expect(request.data).to.not.include.any.keys('tdid');
});
it('should send ns parameter if browser contains navigator.connection property', function () {
const bidRequest = spec.buildRequests(bidRequests)[0];
const connection = window.navigator && window.navigator.connection;
if (connection) {
const downlink = connection.downlink || connection.bandwidth;
expect(bidRequest.data).to.include.any.keys('ns');
expect(bidRequest.data.ns).to.eq(Math.round(downlink * 1024));
} else {
expect(bidRequest.data).to.not.include.any.keys('ns');
}
});
})

describe('interpretResponse', function () {
Expand Down