Skip to content

Commit

Permalink
Lifestreet: gdpr and consent string parameters (#2537)
Browse files Browse the repository at this point in the history
* GDPR support for Lifestreet bid adapter

* removed trailing spaces
  • Loading branch information
Lifestreet authored and jsnellbaker committed May 15, 2018
1 parent 735bf76 commit 6bfed30
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
16 changes: 13 additions & 3 deletions modules/lifestreetBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const urlTemplate = template`//ads.lfstmedia.com/gate/${'adapter'}/${'slot'}?adk
*
* @param {BidRequest} bid The bid params to use for formatting a request
*/
function formatBidRequest(bid) {
function formatBidRequest(bid, bidderRequest) {
let url = urlTemplate({
adapter: 'prebid',
slot: bid.params.slot,
Expand All @@ -28,6 +28,16 @@ function formatBidRequest(bid) {
hbver: ADAPTER_VERSION
});

if (bidderRequest && bidderRequest.gdprConsent) {
if (bidderRequest.gdprConsent.gdprApplies !== undefined) {
const gdpr = '&__gdpr=' + (bidderRequest.gdprConsent.gdprApplies ? '1' : '0');
url += gdpr;
}
if (bidderRequest.gdprConsent.consentString !== undefined) {
url += '&__consent=' + bidderRequest.gdprConsent.consentString;
}
}

return {
method: 'GET',
url: url,
Expand Down Expand Up @@ -95,9 +105,9 @@ export const spec = {
* @param {validBidRequests[]} - an array of bids
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function(validBidRequests) {
buildRequests: function(validBidRequests, bidderRequest) {
return validBidRequests.map(bid => {
return formatBidRequest(bid)
return formatBidRequest(bid, bidderRequest)
});
},

Expand Down
41 changes: 41 additions & 0 deletions test/spec/modules/lifestreetBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,51 @@ describe('LifestreetAdapter', () => {
it('should include gzip', () => {
expect(request.url).to.contain('__gz=1');
});
it('should not contain __gdpr parameter', () => {
expect(request.url).to.not.contain('__gdpr');
});
it('should not contain __concent parameter', () => {
expect(request.url).to.not.contain('__consent');
});

it('should contain the right version of adapter', () => {
expect(request.url).to.contain('__hbver=' + ADAPTER_VERSION);
});

it('should contain __gdpr and __consent parameters', () => {
const options = {
gdprConsent: {
gdprApplies: true,
consentString: 'test',
vendorData: {}
}
};
let [request] = spec.buildRequests(bidRequest.bids, options);
expect(request.url).to.contain('__gdpr=1');
expect(request.url).to.contain('__consent=test');
});
it('should contain __gdpr parameters', () => {
const options = {
gdprConsent: {
gdprApplies: true,
vendorData: {}
}
};
let [request] = spec.buildRequests(bidRequest.bids, options);
expect(request.url).to.contain('__gdpr=1');
expect(request.url).to.not.contain('__consent');
});
it('should contain __consent parameters', () => {
const options = {
gdprConsent: {
consentString: 'test',
vendorData: {}
}
};
let [request] = spec.buildRequests(bidRequest.bids, options);
expect(request.url).to.not.contain('__gdpr');
expect(request.url).to.contain('__consent=test');
});
});
describe('interpretResponse()', () => {
it('should return formatted bid response with required properties', () => {
Expand Down

0 comments on commit 6bfed30

Please sign in to comment.