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: ADTS-134 Fetch IDL envelope and pass to ad server if available #7095

Merged
merged 1 commit into from
Jun 29, 2021
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
37 changes: 28 additions & 9 deletions modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ function getWrapperCode(wrapper, data) {
return wrapper.replace('AD_JSON', window.btoa(JSON.stringify(data)))
}

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

function _getDigiTrustQueryParams(userId) {
let digiTrustId = userId.digitrustid && userId.digitrustid.data;
// Verify there is an ID and this user has not opted out
Expand Down Expand Up @@ -230,6 +222,29 @@ function _getFloor (mediaTypes, staticBidFloor, bid) {
return bidFloor;
}

function getEids (userId) {
const idProperties = [
'uid',
'eid',
'lipbid'
];

return Object.keys(userId).reduce(function (eids, provider) {
const eid = userId[provider];
switch (typeof eid) {
case 'string':
eids[provider] = eid;
break;

case 'object':
const idProp = idProperties.filter(prop => eid.hasOwnProperty(prop));
idProp.length && (eids[provider] = eid[idProp[0]]);
break;
}
return eids;
}, {});
}

/**
* Make a server request from the list of BidRequests.
*
Expand All @@ -253,10 +268,14 @@ function buildRequests (validBidRequests, bidderRequest) {
ortb2Imp
} = bidRequest;
const { currency, floor } = _getFloor(mediaTypes, params.bidfloor, bidRequest);
const eids = getEids(userId);
let sizes = [1, 1];
let data = {};
let gpid = '';

// ADTS-134 Retrieve ID envelopes
for (const eid in eids) data[eid] = eids[eid];

// ADJS-1024
if (utils.deepAccess(ortb2Imp, 'ext.data.adserver.name')) {
gpid = ortb2Imp.ext.data.adserver.adslot
Expand Down Expand Up @@ -328,7 +347,7 @@ function buildRequests (validBidRequests, bidderRequest) {
url: BID_ENDPOINT,
method: 'GET',
gpid: gpid,
data: Object.assign(data, _getBrowserParams(topWindowUrl), _getDigiTrustQueryParams(userId), _getTradeDeskIDParam(userId))
data: Object.assign(data, _getBrowserParams(topWindowUrl), _getDigiTrustQueryParams(userId))
})
});
return bids;
Expand Down
14 changes: 14 additions & 0 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,20 @@ describe('gumgumAdapter', function () {
const request = spec.buildRequests(bidRequests)[0];
expect(request.data).to.not.include.any.keys('tdid');
});
it('should send IDL envelope ID if available', function () {
const idl_env = 'abc123';
const request = { ...bidRequests[0], userId: { idl_env } };
const bidRequest = spec.buildRequests([request])[0];

expect(bidRequest.data).to.have.property('idl_env');
expect(bidRequest.data.idl_env).to.equal(idl_env);
});
it('should not send IDL envelope if not available', function () {
const request = { ...bidRequests[0] };
const bidRequest = spec.buildRequests([request])[0];

expect(bidRequest.data).to.not.have.property('idl_env');
});
it('should send schain parameter in serialized form', function () {
const serializedForm = '1.0,1!exchange1.com,1234,1,bid-request-1,publisher,publisher.com!exchange2.com,abcd,1,bid-request-2,intermediary,intermediary.com'
const request = spec.buildRequests(bidRequests)[0];
Expand Down