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 schain param #4442

Merged
merged 2 commits into from
Nov 21, 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
26 changes: 26 additions & 0 deletions modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,28 @@ function _getDigiTrustQueryParams(userId) {
};
}

/**
* Serializes the supply chain object according to IAB standards
* @see https://github.com/InteractiveAdvertisingBureau/openrtb/blob/master/supplychainobject.md
* @param {Object} schainObj supply chain object
* @returns {string}
*/
function _serializeSupplyChainObj(schainObj) {
let serializedSchain = `${schainObj.ver},${schainObj.complete}`;

// order of properties: asi,sid,hp,rid,name,domain
schainObj.nodes.map(node => {
serializedSchain += `!${encodeURIComponent(node['asi'] || '')},`;
serializedSchain += `${encodeURIComponent(node['sid'] || '')},`;
serializedSchain += `${encodeURIComponent(node['hp'] || '')},`;
serializedSchain += `${encodeURIComponent(node['rid'] || '')},`;
serializedSchain += `${encodeURIComponent(node['name'] || '')},`;
serializedSchain += `${encodeURIComponent(node['domain'] || '')}`;
})

return serializedSchain;
}

/**
* Determines whether or not the given bid request is valid.
*
Expand Down Expand Up @@ -141,6 +163,7 @@ function buildRequests (validBidRequests, bidderRequest) {
const {
bidId,
params = {},
schain,
transactionId,
userId = {}
} = bidRequest;
Expand Down Expand Up @@ -171,6 +194,9 @@ function buildRequests (validBidRequests, bidderRequest) {
if (data.gdprApplies) {
data.gdprConsent = gdprConsent.consentString;
}
if (schain && schain.nodes) {
data.schain = _serializeSupplyChainObj(schain);
}

bids.push({
id: bidId,
Expand Down
30 changes: 29 additions & 1 deletion test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,29 @@ describe('gumgumAdapter', function () {
},
'adUnitCode': 'adunit-code',
'sizes': [[300, 250], [300, 600]],
'bidId': '30b31c1838de1e'
'bidId': '30b31c1838de1e',
'schain': {
'ver': '1.0',
'complete': 1,
'nodes': [
{
'asi': 'exchange1.com',
'sid': '1234',
'hp': 1,
'rid': 'bid-request-1',
'name': 'publisher',
'domain': 'publisher.com'
},
{
'asi': 'exchange2.com',
'sid': 'abcd',
'hp': 1,
'rid': 'bid-request-2',
'name': 'intermediary',
'domain': 'intermediary.com'
}
]
}
}
];

Expand Down Expand Up @@ -140,6 +162,12 @@ describe('gumgumAdapter', function () {
const request = spec.buildRequests(bidRequests)[0];
expect(request.data).to.not.include.any.keys('tdid');
});
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];
expect(request.data).to.include.any.keys('schain');
expect(request.data.schain).to.eq(serializedForm);
});
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;
Expand Down