From 3144ad92b516eace70771b97af37d92b259d2b01 Mon Sep 17 00:00:00 2001 From: Dmitry Vodianyk Date: Tue, 15 May 2018 15:12:29 +0300 Subject: [PATCH 1/2] GDPR support for Lifestreet bid adapter --- modules/lifestreetBidAdapter.js | 16 ++++++-- .../spec/modules/lifestreetBidAdapter_spec.js | 41 +++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/modules/lifestreetBidAdapter.js b/modules/lifestreetBidAdapter.js index 919e83576d3..17aeeb56f2e 100644 --- a/modules/lifestreetBidAdapter.js +++ b/modules/lifestreetBidAdapter.js @@ -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, @@ -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, @@ -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) }); }, diff --git a/test/spec/modules/lifestreetBidAdapter_spec.js b/test/spec/modules/lifestreetBidAdapter_spec.js index b47c5f949e2..73a9b9abed9 100644 --- a/test/spec/modules/lifestreetBidAdapter_spec.js +++ b/test/spec/modules/lifestreetBidAdapter_spec.js @@ -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', () => { From 7c27ca49ad29582936e899261ae5bf6350b10a39 Mon Sep 17 00:00:00 2001 From: Dmitry Vodianyk Date: Tue, 15 May 2018 15:24:51 +0300 Subject: [PATCH 2/2] removed trailing spaces --- test/spec/modules/lifestreetBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/lifestreetBidAdapter_spec.js b/test/spec/modules/lifestreetBidAdapter_spec.js index 73a9b9abed9..2c48a0f1892 100644 --- a/test/spec/modules/lifestreetBidAdapter_spec.js +++ b/test/spec/modules/lifestreetBidAdapter_spec.js @@ -119,7 +119,7 @@ describe('LifestreetAdapter', () => { 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: {