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

Lifestreet: gdpr and consent string parameters #2537

Merged
merged 2 commits into from May 15, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions modules/lifestreetBidAdapter.js
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
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