Skip to content

Commit

Permalink
Add support for userid modules in Yieldlab adapter (#5022)
Browse files Browse the repository at this point in the history
* Add support for userid modules in Yieldlab adapter

* Change for-of-loop for IE11 compatibility

* Check if userIdAsEids is an array
  • Loading branch information
mirkorean authored Mar 31, 2020
1 parent a23ce02 commit 25214ab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
16 changes: 16 additions & 0 deletions modules/yieldlabBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export const spec = {
if (bid.params.targeting) {
query.t = createQueryString(bid.params.targeting)
}
if (bid.userIdAsEids && Array.isArray(bid.userIdAsEids)) {
query.ids = createUserIdString(bid.userIdAsEids)
}
})

if (bidderRequest && bidderRequest.gdprConsent) {
Expand Down Expand Up @@ -162,6 +165,19 @@ function parseSize (size) {
return size.split('x').map(Number)
}

/**
* Creates a string out of an array of eids with source and uid
* @param {Array} eids
* @returns {String}
*/
function createUserIdString (eids) {
let str = []
for (let i = 0; i < eids.length; i++) {
str.push(eids[i].source + ':' + eids[i].uids[0].id)
}
return str.join(',')
}

/**
* Creates a querystring out of an object with key-values
* @param {Object} obj
Expand Down
13 changes: 12 additions & 1 deletion test/spec/modules/yieldlabBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ const REQUEST = {
'auctionId': '2e41f65424c87c',
'adUnitCode': 'adunit-code',
'bidId': '2d925f27f5079f',
'sizes': [728, 90]
'sizes': [728, 90],
'userIdAsEids': [{
'source': 'netid.de',
'uids': [{
'id': 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg',
'atype': 1
}]
}]
}

const RESPONSE = {
Expand Down Expand Up @@ -77,6 +84,10 @@ describe('yieldlabBidAdapter', function () {
expect(request.url).to.include('t=key1%3Dvalue1%26key2%3Dvalue2')
})

it('passes userids to bid request', function () {
expect(request.url).to.include('ids=netid.de%3AfH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg')
})

const gdprRequest = spec.buildRequests(bidRequests, {
gdprConsent: {
consentString: 'BN5lERiOMYEdiAKAWXEND1AAAAE6DABACMA',
Expand Down

0 comments on commit 25214ab

Please sign in to comment.