From 4f9d0a599f1b4c055cca3c446e1cce17aa2663f2 Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Wed, 25 Apr 2018 15:57:22 -0400 Subject: [PATCH 01/15] added vp param to trinity request --- modules/sonobiBidAdapter.js | 43 ++++++++++++++++++---- test/spec/modules/sonobiBidAdapter_spec.js | 20 ++++++++-- 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 170228dde7a..697c6dd8d17 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -1,7 +1,7 @@ import { registerBidder } from 'src/adapters/bidderFactory'; -import * as utils from 'src/utils'; +import { getTopWindowLocation, parseSizesInput } from 'src/utils'; +import * as utils from '../src/utils'; import { BANNER, VIDEO } from '../src/mediaTypes'; -import find from 'core-js/library/fn/array/find'; const BIDDER_CODE = 'sonobi'; const STR_ENDPOINT = 'https://apex.go.sonobi.com/trinity.json'; @@ -46,9 +46,10 @@ export const spec = { const payload = { 'key_maker': JSON.stringify(data), - 'ref': utils.getTopWindowLocation().host, + 'ref': getTopWindowLocation().host, 's': utils.generateUUID(), 'pv': PAGEVIEW_ID, + 'vp': _getPlatform() }; if (validBidRequests[0].params.hfa) { @@ -80,7 +81,7 @@ export const spec = { Object.keys(bidResponse.slots).forEach(slot => { const bidId = _getBidIdFromTrinityKey(slot); - const bidRequest = find(bidderRequests, bidReqest => bidReqest.bidId === bidId); + const bidRequest = bidderRequests.find(bidReqest => bidReqest.bidId === bidId); const videoMediaType = utils.deepAccess(bidRequest, 'mediaTypes.video'); const mediaType = bidRequest.mediaType || (videoMediaType ? 'video' : null); const createCreative = _creative(mediaType); @@ -138,9 +139,9 @@ export const spec = { function _validateSize (bid) { if (bid.params.sizes) { - return utils.parseSizesInput(bid.params.sizes).join(','); + return parseSizesInput(bid.params.sizes).join(','); } - return utils.parseSizesInput(bid.sizes).join(','); + return parseSizesInput(bid.sizes).join(','); } function _validateSlot (bid) { @@ -161,16 +162,42 @@ const _creative = (mediaType) => (sbi_dc, sbi_aid) => { if (mediaType === 'video') { return _videoCreative(sbi_dc, sbi_aid) } - const src = 'https://' + sbi_dc + 'apex.go.sonobi.com/sbi.js?aid=' + sbi_aid + '&as=null' + '&ref=' + utils.getTopWindowLocation().host; + const src = 'https://' + sbi_dc + 'apex.go.sonobi.com/sbi.js?aid=' + sbi_aid + '&as=null' + '&ref=' + getTopWindowLocation().host; return ''; } function _videoCreative(sbi_dc, sbi_aid) { - return `https://${sbi_dc}apex.go.sonobi.com/vast.xml?vid=${sbi_aid}&ref=${utils.getTopWindowLocation().host}` + return `https://${sbi_dc}apex.go.sonobi.com/vast.xml?vid=${sbi_aid}&ref=${getTopWindowLocation().host}` } function _getBidIdFromTrinityKey (key) { return key.split('|').slice(-1)[0] } +/** + * @param context - the window to determine the innerWidth from. This is purely for test purposes as it should always be the current window + */ +export const _isInbounds = (context = window) => (lowerBound = 0, upperBound = Number.MAX_SAFE_INTEGER) => context.innerWidth >= lowerBound && context.innerWidth < upperBound; + +/** + * @param context - the window to determine the innerWidth from. This is purely for test purposes as it should always be the current window + */ +export function _getPlatform(context = window) { + const isInBounds = _isInbounds(context); + const MOBILE_VIEWPORT = { + lt: 768 + }; + const TABLET_VIEWPORT = { + lt: 992, + ge: 768 + }; + if (isInBounds(0, MOBILE_VIEWPORT.lt)) { + return 'mobile' + } + if (isInBounds(TABLET_VIEWPORT.ge, TABLET_VIEWPORT.lt)) { + return 'tablet' + } + return 'desktop'; +} + registerBidder(spec); diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 4fd5c13e65c..241c12a564f 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai' -import { spec } from 'modules/sonobiBidAdapter' +import { spec, _getPlatform } from 'modules/sonobiBidAdapter' import { newBidder } from 'src/adapters/bidderFactory' describe('SonobiBidAdapter', () => { @@ -139,6 +139,7 @@ describe('SonobiBidAdapter', () => { expect(bidRequests.data.pv).to.equal(bidRequestsPageViewID.data.pv) expect(bidRequests.data.hfa).to.not.exist expect(bidRequests.bidderRequests).to.eql(bidRequest); + expect(bidRequests.data.vp).to.equal('tablet'); }) it('should return a properly formatted request with hfa', () => { @@ -159,7 +160,7 @@ describe('SonobiBidAdapter', () => { 'url': 'https://apex.go.sonobi.com/trinity.json', 'withCredentials': true, 'data': { - 'key_maker': '{"30b31c1838de1f":"1a2b3c4d5e6f1a2b3c4d|300x250,300x600|f=1.25","/7780971/sparks_prebid_LB|30b31c1838de1e":"300x250,300x600"}', 'ref': 'localhost:9876', 's': '2474372d-c0ff-4f46-aef4-a173058403d9', 'pv': 'c9cfc207-cd83-4a01-b591-8bb29389d4b0' + 'key_maker': '{"30b31c1838de1f":"1a2b3c4d5e6f1a2b3c4d|300x250,300x600|f=1.25","/7780971/sparks_prebid_LB|30b31c1838de1e":"300x250,300x600"}', 'ref': 'localhost:9877', 's': '2474372d-c0ff-4f46-aef4-a173058403d9', 'pv': 'c9cfc207-cd83-4a01-b591-8bb29389d4b0' }, 'bidderRequests': [ { @@ -232,7 +233,7 @@ describe('SonobiBidAdapter', () => { 'cpm': 1.07, 'width': 300, 'height': 600, - 'ad': '', + 'ad': '', 'ttl': 500, 'creativeId': '30292e432662bd5f86d90774b944b039', 'netRevenue': true, @@ -243,7 +244,7 @@ describe('SonobiBidAdapter', () => { 'cpm': 1.25, 'width': 300, 'height': 250, - 'ad': 'https://mco-1-apex.go.sonobi.com/vast.xml?vid=30292e432662bd5f86d90774b944b038&ref=localhost:9876', + 'ad': 'https://mco-1-apex.go.sonobi.com/vast.xml?vid=30292e432662bd5f86d90774b944b038&ref=localhost:9877', 'ttl': 500, 'creativeId': '30292e432662bd5f86d90774b944b038', 'netRevenue': true, @@ -287,4 +288,15 @@ describe('SonobiBidAdapter', () => { expect(spec.getUserSyncs({ pixelEnabled: false }, bidResponse)).to.have.length(0); }) }) + describe('_getPlatform', () => { + it('should return mobile', () => { + expect(_getPlatform({innerWidth: 767})).to.equal('mobile') + }) + it('should return tablet', () => { + expect(_getPlatform({innerWidth: 800})).to.equal('tablet') + }) + it('should return desktop', () => { + expect(_getPlatform({innerWidth: 1000})).to.equal('desktop') + }) + }) }) From d23114c59769fc3be73c28cea8d191e553b1d316 Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Thu, 26 Apr 2018 13:20:19 -0400 Subject: [PATCH 02/15] added lib_name and lib_v to trinity --- modules/sonobiBidAdapter.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 170228dde7a..3fc59659072 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -49,6 +49,8 @@ export const spec = { 'ref': utils.getTopWindowLocation().host, 's': utils.generateUUID(), 'pv': PAGEVIEW_ID, + 'lib_name': 'prebid', + 'lib_v': window.pbjs.version }; if (validBidRequests[0].params.hfa) { From ff5fabf22fe941cdce9b0982e207e7be9d59dd84 Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Thu, 26 Apr 2018 14:04:05 -0400 Subject: [PATCH 03/15] 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 170228dde7a..376e2a0776e 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -55,6 +55,11 @@ export const spec = { payload.hfa = validBidRequests[0].params.hfa; } + // 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 ac246fd392f863ad63945f93ddfcc2f36544d3ac Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Thu, 26 Apr 2018 14:08:59 -0400 Subject: [PATCH 04/15] added test case for empty keymaker --- test/spec/modules/sonobiBidAdapter_spec.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 4fd5c13e65c..1d5eebc1719 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -151,6 +151,11 @@ 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); + + }) }) describe('.interpretResponse', () => { From ef36be22317db1c939b32b0f3cfd873001e2f6d4 Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Thu, 26 Apr 2018 16:45:43 -0400 Subject: [PATCH 05/15] only importing functions we need from utils --- modules/sonobiBidAdapter.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 697c6dd8d17..04d28375a96 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -1,11 +1,10 @@ import { registerBidder } from 'src/adapters/bidderFactory'; -import { getTopWindowLocation, parseSizesInput } from 'src/utils'; -import * as utils from '../src/utils'; +import { getTopWindowLocation, parseSizesInput, logError, generateUUID, deepAccess } from '../src/utils'; import { BANNER, VIDEO } from '../src/mediaTypes'; const BIDDER_CODE = 'sonobi'; const STR_ENDPOINT = 'https://apex.go.sonobi.com/trinity.json'; -const PAGEVIEW_ID = utils.generateUUID(); +const PAGEVIEW_ID = generateUUID(); export const spec = { code: BIDDER_CODE, @@ -37,7 +36,7 @@ export const spec = { [bid.bidId]: `${slotIdentifier}|${_validateSize(bid)}${_validateFloor(bid)}` } } else { - utils.logError(`The ad unit code or Sonobi Placement id for slot ${bid.bidId} is invalid`); + logError(`The ad unit code or Sonobi Placement id for slot ${bid.bidId} is invalid`); } }); @@ -47,7 +46,7 @@ export const spec = { const payload = { 'key_maker': JSON.stringify(data), 'ref': getTopWindowLocation().host, - 's': utils.generateUUID(), + 's': generateUUID(), 'pv': PAGEVIEW_ID, 'vp': _getPlatform() }; @@ -82,7 +81,7 @@ export const spec = { Object.keys(bidResponse.slots).forEach(slot => { const bidId = _getBidIdFromTrinityKey(slot); const bidRequest = bidderRequests.find(bidReqest => bidReqest.bidId === bidId); - const videoMediaType = utils.deepAccess(bidRequest, 'mediaTypes.video'); + const videoMediaType = deepAccess(bidRequest, 'mediaTypes.video'); const mediaType = bidRequest.mediaType || (videoMediaType ? 'video' : null); const createCreative = _creative(mediaType); const bid = bidResponse.slots[slot]; From 85c999477ba7d862e0df8a08d4e9ca366e67a02d Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Fri, 27 Apr 2018 10:44:06 -0400 Subject: [PATCH 06/15] changed window.pbjs.version to use the gulp repalced macro .version$ --- modules/sonobiBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 3fc59659072..d1b3f01f15d 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -50,7 +50,7 @@ export const spec = { 's': utils.generateUUID(), 'pv': PAGEVIEW_ID, 'lib_name': 'prebid', - 'lib_v': window.pbjs.version + 'lib_v': '$prebid.version$' }; if (validBidRequests[0].params.hfa) { From 6c3e3a82867f3cc456fd1ed93360aacdfa608f90 Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Fri, 27 Apr 2018 14:55:59 -0400 Subject: [PATCH 07/15] fixed issue where isEmpty was being called from old utils var. Changed test port expectations to the original 9876 port --- modules/sonobiBidAdapter.js | 4 ++-- test/spec/modules/sonobiBidAdapter_spec.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 29122dee5dc..dd684bf8767 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -1,5 +1,5 @@ import { registerBidder } from 'src/adapters/bidderFactory'; -import { getTopWindowLocation, parseSizesInput, logError, generateUUID, deepAccess } from '../src/utils'; +import { getTopWindowLocation, parseSizesInput, logError, generateUUID, deepAccess, isEmpty } from '../src/utils'; import { BANNER, VIDEO } from '../src/mediaTypes'; const BIDDER_CODE = 'sonobi'; @@ -58,7 +58,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; } diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 25e19582424..2069564bf01 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -165,7 +165,7 @@ describe('SonobiBidAdapter', () => { 'url': 'https://apex.go.sonobi.com/trinity.json', 'withCredentials': true, 'data': { - 'key_maker': '{"30b31c1838de1f":"1a2b3c4d5e6f1a2b3c4d|300x250,300x600|f=1.25","/7780971/sparks_prebid_LB|30b31c1838de1e":"300x250,300x600"}', 'ref': 'localhost:9877', 's': '2474372d-c0ff-4f46-aef4-a173058403d9', 'pv': 'c9cfc207-cd83-4a01-b591-8bb29389d4b0' + 'key_maker': '{"30b31c1838de1f":"1a2b3c4d5e6f1a2b3c4d|300x250,300x600|f=1.25","/7780971/sparks_prebid_LB|30b31c1838de1e":"300x250,300x600"}', 'ref': 'localhost:9876', 's': '2474372d-c0ff-4f46-aef4-a173058403d9', 'pv': 'c9cfc207-cd83-4a01-b591-8bb29389d4b0' }, 'bidderRequests': [ { @@ -238,7 +238,7 @@ describe('SonobiBidAdapter', () => { 'cpm': 1.07, 'width': 300, 'height': 600, - 'ad': '', + 'ad': '', 'ttl': 500, 'creativeId': '30292e432662bd5f86d90774b944b039', 'netRevenue': true, @@ -249,7 +249,7 @@ describe('SonobiBidAdapter', () => { 'cpm': 1.25, 'width': 300, 'height': 250, - 'ad': 'https://mco-1-apex.go.sonobi.com/vast.xml?vid=30292e432662bd5f86d90774b944b038&ref=localhost:9877', + 'ad': 'https://mco-1-apex.go.sonobi.com/vast.xml?vid=30292e432662bd5f86d90774b944b038&ref=localhost:9876', 'ttl': 500, 'creativeId': '30292e432662bd5f86d90774b944b038', 'netRevenue': true, From cf45587dae1ab7c3ad640a023f76794fdbd65690 Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Fri, 27 Apr 2018 15:01:58 -0400 Subject: [PATCH 08/15] fixed lint issue --- test/spec/modules/sonobiBidAdapter_spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 2069564bf01..874c92e518e 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -155,7 +155,6 @@ describe('SonobiBidAdapter', () => { it('should return null if there is nothing to bid on', () => { const bidRequests = spec.buildRequests([{params: {}}]) expect(bidRequests).to.equal(null); - }) }) From 8898bf8b413df1b462c244fc992f59c3ed9f86fa Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Thu, 3 May 2018 10:33:18 -0400 Subject: [PATCH 09/15] fixed issue where sonobi getUserSync was throwing an error on timeout --- modules/sonobiBidAdapter.js | 24 +++++++++++++--------- test/spec/modules/sonobiBidAdapter_spec.js | 3 +++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 438ab7f3a74..0b07cdcc720 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -28,7 +28,7 @@ export const spec = { const bids = validBidRequests.map(bid => { let slotIdentifier = _validateSlot(bid); if (/^[\/]?[\d]+[[\/].+[\/]?]?$/.test(slotIdentifier)) { - slotIdentifier = slotIdentifier.charAt(0) === '/' ? slotIdentifier : '/' + slotIdentifier + slotIdentifier = slotIdentifier.charAt(0) === '/' ? slotIdentifier : '/' + slotIdentifier; return { [`${slotIdentifier}|${bid.bidId}`]: `${_validateSize(bid)}${_validateFloor(bid)}` } @@ -41,7 +41,7 @@ export const spec = { } }); - let data = {} + let data = {}; bids.forEach((bid) => { Object.assign(data, bid); }); const payload = { @@ -132,17 +132,21 @@ export const spec = { */ getUserSyncs: (syncOptions, serverResponses) => { const syncs = []; - if (syncOptions.pixelEnabled && serverResponses[0].body.sbi_px) { - serverResponses[0].body.sbi_px.forEach(pixel => { - syncs.push({ - type: pixel.type, - url: pixel.url + try { + if (syncOptions.pixelEnabled) { + serverResponses[0].body.sbi_px.forEach(pixel => { + syncs.push({ + type: pixel.type, + url: pixel.url + }); }); - }); + } + } catch (e) { + logError(e) } return syncs; } -} +}; function _validateSize (bid) { if (bid.params.sizes) { @@ -171,7 +175,7 @@ const _creative = (mediaType) => (sbi_dc, sbi_aid) => { } const src = 'https://' + sbi_dc + 'apex.go.sonobi.com/sbi.js?aid=' + sbi_aid + '&as=null' + '&ref=' + getTopWindowLocation().host; return ''; -} +}; function _videoCreative(sbi_dc, sbi_aid) { return `https://${sbi_dc}apex.go.sonobi.com/vast.xml?vid=${sbi_aid}&ref=${getTopWindowLocation().host}` diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 791d07ba91a..6d8064d7334 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -281,6 +281,9 @@ describe('SonobiBidAdapter', () => { url: 'https://pixel-test' }]); }) + it('should return an empty array when sync is enabled but there are no bidResponses', () => { + expect(spec.getUserSyncs({ pixelEnabled: true }, [])).to.have.length(0); + }) it('should return an empty array when sync is enabled but no sync pixel returned', () => { const pixel = Object.assign({}, bidResponse); From 271e16d263bd164d396f66898663d80edc142b48 Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Fri, 4 May 2018 09:00:22 -0400 Subject: [PATCH 10/15] sonobi support referrer param --- modules/sonobiBidAdapter.js | 3 +++ test/spec/modules/sonobiBidAdapter_spec.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 438ab7f3a74..35dfb2f382c 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -57,6 +57,9 @@ export const spec = { if (validBidRequests[0].params.hfa) { payload.hfa = validBidRequests[0].params.hfa; } + if (validBidRequests[0].params.referrer) { + payload.ref = validBidRequests[0].params.referrer; + } // If there is no key_maker data, then dont make the request. if (isEmpty(data)) { diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 791d07ba91a..a309e98ad56 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -107,6 +107,7 @@ describe('SonobiBidAdapter', () => { 'placement_id': '1a2b3c4d5e6f1a2b3c4d', 'sizes': [[300, 250], [300, 600]], 'floor': '1.25', + 'referrer': 'overrides_top_window_location' }, 'adUnitCode': 'adunit-code-1', 'sizes': [[300, 250], [300, 600]], @@ -117,6 +118,7 @@ describe('SonobiBidAdapter', () => { 'params': { 'ad_unit': '/7780971/sparks_prebid_LB', 'sizes': [[300, 250], [300, 600]], + 'referrer': 'overrides_top_window_location' }, 'adUnitCode': 'adunit-code-2', 'sizes': [[120, 600], [300, 600], [160, 600]], @@ -139,6 +141,7 @@ describe('SonobiBidAdapter', () => { expect(bidRequests.data.pv).to.equal(bidRequestsPageViewID.data.pv) expect(bidRequests.data.hfa).to.not.exist expect(bidRequests.bidderRequests).to.eql(bidRequest); + expect(bidRequests.data.referrer).to.equal('overrides_top_window_location'); expect(['mobile', 'tablet', 'desktop']).to.contain(bidRequests.data.vp); }) From 2f457864735c60cd43021e8ccc450b33418ac72d Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Fri, 4 May 2018 13:45:33 -0400 Subject: [PATCH 11/15] fixed unit test for testing the ref param on bid request --- test/spec/modules/sonobiBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index a2b76498243..431bf134349 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -141,7 +141,7 @@ describe('SonobiBidAdapter', () => { expect(bidRequests.data.pv).to.equal(bidRequestsPageViewID.data.pv) expect(bidRequests.data.hfa).to.not.exist expect(bidRequests.bidderRequests).to.eql(bidRequest); - expect(bidRequests.data.referrer).to.equal('overrides_top_window_location'); + expect(bidRequests.data.ref).to.equal('overrides_top_window_location'); expect(['mobile', 'tablet', 'desktop']).to.contain(bidRequests.data.vp); }) From ffe093241c2ff117f4e8a65c4422be3d9b473e63 Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Thu, 26 Apr 2018 14:04:05 -0400 Subject: [PATCH 12/15] 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 13/15] 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 14/15] 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); From 7549d450391286bcac5bc2c2f33a1748632c777d Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Fri, 25 May 2018 10:48:34 -0400 Subject: [PATCH 15/15] fixed issue where we were no longer exposing the aid in the bidsBackHandler. Added an 'aid' property to each bid. --- modules/sonobiBidAdapter.js | 1 + test/spec/modules/sonobiBidAdapter_spec.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index d1d0949f6a0..ef3353e0271 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -115,6 +115,7 @@ export const spec = { ad: createCreative(bidResponse.sbi_dc, bid.sbi_aid), ttl: 500, creativeId: bid.sbi_crid || bid.sbi_aid, + aid: bid.sbi_aid, netRevenue: true, currency: 'USD' }; diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index d7097f4927d..f2aacb00c0c 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -271,7 +271,8 @@ describe('SonobiBidAdapter', () => { 'ttl': 500, 'creativeId': '1234abcd', 'netRevenue': true, - 'currency': 'USD' + 'currency': 'USD', + 'aid': '30292e432662bd5f86d90774b944b039' }, { 'requestId': '30b31c1838de1e', @@ -283,7 +284,8 @@ describe('SonobiBidAdapter', () => { 'creativeId': '30292e432662bd5f86d90774b944b038', 'netRevenue': true, 'currency': 'USD', - 'dealId': 'dozerkey' + 'dealId': 'dozerkey', + 'aid': '30292e432662bd5f86d90774b944b038' } ];