From ffe093241c2ff117f4e8a65c4422be3d9b473e63 Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Thu, 26 Apr 2018 14:04:05 -0400 Subject: [PATCH 1/3] return null from buildRequests if there is no keymakers --- modules/sonobiBidAdapter.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index a8b5bd13e05..4777f23df05 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -66,6 +66,11 @@ export const spec = { return null; } + // If there is no key_maker data, then dont make the request. + if (utils.isEmpty(data)) { + return null; + } + return { method: 'GET', url: STR_ENDPOINT, From e0d53c1351ab7d119440036baa61953f72d14a3c Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Fri, 27 Apr 2018 14:55:59 -0400 Subject: [PATCH 2/3] fixed issue where isEmpty was being called from old utils var. Changed test port expectations to the original 9876 port --- modules/sonobiBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 4777f23df05..d5c941b6702 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -67,7 +67,7 @@ export const spec = { } // If there is no key_maker data, then dont make the request. - if (utils.isEmpty(data)) { + if (isEmpty(data)) { return null; } From 4d7079a7dddce2dbdf9c9df6989e41514f62995d Mon Sep 17 00:00:00 2001 From: Nick Narbone Date: Thu, 17 May 2018 14:26:10 -0400 Subject: [PATCH 3/3] Add gdpr support --- modules/sonobiBidAdapter.js | 11 ++++----- test/spec/modules/sonobiBidAdapter_spec.js | 26 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index d5c941b6702..e66a1aa2606 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -24,7 +24,7 @@ export const spec = { * @param {BidRequest[]} validBidRequests - an array of bids * @return {object} ServerRequest - Info describing the request to the server. */ - buildRequests: (validBidRequests) => { + buildRequests: (validBidRequests, bidderRequest) => { const bids = validBidRequests.map(bid => { let slotIdentifier = _validateSlot(bid); if (/^[\/]?[\d]+[[\/].+[\/]?]?$/.test(slotIdentifier)) { @@ -61,12 +61,13 @@ export const spec = { payload.ref = validBidRequests[0].params.referrer; } - // If there is no key_maker data, then dont make the request. - if (isEmpty(data)) { - return null; + // Apply GDPR parameters to request. + if (bidderRequest && bidderRequest.gdprConsent) { + payload.gdpr = bidderRequest.gdprConsent.gdprApplies ? 'true' : 'false'; + payload.consent_string = bidderRequest.gdprConsent.consentString; } - // If there is no key_maker data, then dont make the request. + // If there is no key_maker data, then don't make the request. if (isEmpty(data)) { return null; } diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 431bf134349..d92553d6661 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -130,6 +130,14 @@ describe('SonobiBidAdapter', () => { '/7780971/sparks_prebid_LB|30b31c1838de1e': '300x250,300x600', }; + let bidderRequests = { + 'gdprConsent': { + 'consentString': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', + 'vendorData': {}, + 'gdprApplies': true + }, + }; + it('should return a properly formatted request', () => { const bidRequests = spec.buildRequests(bidRequest) const bidRequestsPageViewID = spec.buildRequests(bidRequest) @@ -145,6 +153,23 @@ describe('SonobiBidAdapter', () => { expect(['mobile', 'tablet', 'desktop']).to.contain(bidRequests.data.vp); }) + it('should return a properly formatted request with GDPR applies set to true', () => { + const bidRequests = spec.buildRequests(bidRequest, bidderRequests) + expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json') + expect(bidRequests.method).to.equal('GET') + expect(bidRequests.data.gdpr).to.equal('true') + expect(bidRequests.data.consent_string).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==') + }) + + it('should return a properly formatted request with GDPR applies set to false', () => { + bidderRequests.gdprConsent.gdprApplies = false; + const bidRequests = spec.buildRequests(bidRequest, bidderRequests) + expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json') + expect(bidRequests.method).to.equal('GET') + expect(bidRequests.data.gdpr).to.equal('false') + expect(bidRequests.data.consent_string).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==') + }) + it('should return a properly formatted request with hfa', () => { bidRequest[0].params.hfa = 'hfakey' bidRequest[1].params.hfa = 'hfakey' @@ -155,6 +180,7 @@ describe('SonobiBidAdapter', () => { expect(bidRequests.data.s).not.to.be.empty expect(bidRequests.data.hfa).to.equal('hfakey') }) + it('should return null if there is nothing to bid on', () => { const bidRequests = spec.buildRequests([{params: {}}]) expect(bidRequests).to.equal(null);