Skip to content

Commit

Permalink
GumGum: add DigiTrust module (prebid#4109)
Browse files Browse the repository at this point in the history
* adds digitrust module, mods gdpr from bool to int

* update unit test
  • Loading branch information
susyt authored and sa1omon committed Nov 28, 2019
1 parent e307a6c commit 1693c37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
27 changes: 13 additions & 14 deletions modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,20 @@ function getWrapperCode(wrapper, data) {
return wrapper.replace('AD_JSON', window.btoa(JSON.stringify(data)))
}

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

// TODO: use getConfig()
function _getDigiTrustQueryParams() {
function getDigiTrustId () {
var digiTrustUser = (window.DigiTrust && window.DigiTrust.getUser) ? window.DigiTrust.getUser(DT_CREDENTIALS) : {};
return (digiTrustUser && digiTrustUser.success && digiTrustUser.identity) || '';
};

let digiTrustId = getDigiTrustId();
function _getDigiTrustQueryParams(userId) {
let digiTrustId = userId.digitrustid && userId.digitrustid.data;
if (!digiTrustId) {
const digiTrustUser = (window.DigiTrust && window.DigiTrust.getUser) ? window.DigiTrust.getUser(DT_CREDENTIALS) : {};
digiTrustId = (digiTrustUser && digiTrustUser.success && digiTrustUser.identity) || '';
}
// Verify there is an ID and this user has not opted out
if (!digiTrustId || (digiTrustId.privacy && digiTrustId.privacy.optout)) {
return {};
Expand Down Expand Up @@ -143,7 +141,8 @@ function buildRequests (validBidRequests, bidderRequest) {
const {
bidId,
params = {},
transactionId
transactionId,
userId = {}
} = bidRequest;
const data = {};
const topWindowUrl = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer;
Expand All @@ -165,7 +164,7 @@ function buildRequests (validBidRequests, bidderRequest) {
data.ni = parseInt(params.ICV, 10);
data.pi = 5;
}
data.gdprApplies = gdprConsent.gdprApplies;
data.gdprApplies = gdprConsent.gdprApplies ? 1 : 0;
if (gdprConsent.gdprApplies) {
data.gdprConsent = gdprConsent.consentString;
}
Expand All @@ -179,7 +178,7 @@ function buildRequests (validBidRequests, bidderRequest) {
sizes: bidRequest.sizes || bidRequest.mediatype[banner].sizes,
url: BID_ENDPOINT,
method: 'GET',
data: Object.assign(data, _getBrowserParams(topWindowUrl), _getDigiTrustQueryParams(), _getTradeDeskIDParam(bidRequest))
data: Object.assign(data, _getBrowserParams(topWindowUrl), _getDigiTrustQueryParams(userId), _getTradeDeskIDParam(userId))
})
});
return bids;
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('gumgumAdapter', function () {
const gdprConsent = { consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', gdprApplies: true };
const fakeBidRequest = { gdprConsent: gdprConsent };
const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0];
expect(bidRequest.data.gdprApplies).to.eq(true);
expect(bidRequest.data.gdprApplies).to.eq(1);
expect(bidRequest.data.gdprConsent).to.eq('BOJ/P2HOJ/P2HABABMAAAAAZ+A==');
});
it('should handle gdprConsent is present but values are undefined case', function () {
Expand Down

0 comments on commit 1693c37

Please sign in to comment.