From 2fba6a29ce0f473e4b174c35afdd9b535d363699 Mon Sep 17 00:00:00 2001 From: anand-venkatraman Date: Fri, 14 Oct 2016 08:31:49 -0400 Subject: [PATCH 01/10] ET-1691: Pulsepoint Analytics adapter for Prebid. (#1) * ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter * ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter * ET-1691: cleanup * ET-1691: minor * ET-1691: revert package.json change --- src/adapters/analytics/pulsepoint.js | 12 +++ test/spec/adapters/pulsepoint_spec.js | 143 ++++++++++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 src/adapters/analytics/pulsepoint.js create mode 100644 test/spec/adapters/pulsepoint_spec.js diff --git a/src/adapters/analytics/pulsepoint.js b/src/adapters/analytics/pulsepoint.js new file mode 100644 index 00000000000..28f4e7f1c78 --- /dev/null +++ b/src/adapters/analytics/pulsepoint.js @@ -0,0 +1,12 @@ +/** + * pulsepoint.js - Analytics Adapter for PulsePoint + */ + +import adapter from 'AnalyticsAdapter'; + +export default adapter({ + global: 'PulsePointPrebidAnalytics', + handler: 'on', + analyticsType: 'bundle' + }); + diff --git a/test/spec/adapters/pulsepoint_spec.js b/test/spec/adapters/pulsepoint_spec.js new file mode 100644 index 00000000000..fe5dee461db --- /dev/null +++ b/test/spec/adapters/pulsepoint_spec.js @@ -0,0 +1,143 @@ +import {expect} from 'chai'; +import PulsePointAdapter from '../../../src/adapters/pulsepoint'; +import bidManager from '../../../src/bidmanager'; +import adLoader from '../../../src/adloader'; + +describe("PulsePoint Adapter Tests", () => { + + let pulsepointAdapter = new PulsePointAdapter(); + let slotConfigs; + let requests = []; + let responses = {}; + + function initPulsepointLib() { + /* Mocked PulsePoint library */ + window.pp = { + requestActions: { + BID: 0 + } + }; + /* Ad object*/ + window.pp.Ad = function(config) { + this.display = function() { + requests.push(config); + config.callback(responses[config.ct]); + }; + }; + } + + function resetPulsepointLib() { + window.pp = undefined; + } + + beforeEach(() => { + initPulsepointLib(); + sinon.stub(bidManager, 'addBidResponse'); + sinon.stub(adLoader, 'loadScript'); + + slotConfigs = { + bids: [ + { + placementCode: "/DfpAccount1/slot1", + bidder: "pulsepoint", + params: { + cp: "p10000", + ct: "t10000", + cf: "300x250" + } + },{ + placementCode: "/DfpAccount2/slot2", + bidder: "pulsepoint", + params: { + cp: "p20000", + ct: "t20000", + cf: "728x90" + } + } + ] + }; + }); + + afterEach(() => { + bidManager.addBidResponse.restore(); + adLoader.loadScript.restore(); + requests = []; + responses = {}; + }); + + it('Verify requests sent to PulsePoint library', () => { + pulsepointAdapter.callBids(slotConfigs); + expect(requests).to.have.length(2); + //slot 1 + expect(requests[0].cp).to.equal('p10000'); + expect(requests[0].ct).to.equal('t10000'); + expect(requests[0].cf).to.equal('300x250'); + expect(requests[0].ca).to.equal(0); + expect(requests[0].cn).to.equal(1); + expect(requests[0].cu).to.equal('http://bid.contextweb.com/header/tag'); + expect(requests[0].adUnitId).to.equal('/DfpAccount1/slot1'); + expect(requests[0]).to.have.property('callback'); + // //slot 2 + expect(requests[1].cp).to.equal('p20000'); + expect(requests[1].ct).to.equal('t20000'); + expect(requests[1].cf).to.equal('728x90'); + expect(requests[1].ca).to.equal(0); + expect(requests[1].cn).to.equal(1); + expect(requests[1].cu).to.equal('http://bid.contextweb.com/header/tag'); + expect(requests[1].adUnitId).to.equal('/DfpAccount2/slot2'); + expect(requests[1]).to.have.property('callback'); + }); + + it('Verify bid', () => { + responses['t10000'] = { + html: 'This is an Ad', + bidCpm: 1.25 + }; + pulsepointAdapter.callBids(slotConfigs); + let placement = bidManager.addBidResponse.firstCall.args[0]; + let bid = bidManager.addBidResponse.firstCall.args[1]; + expect(placement).to.equal('/DfpAccount1/slot1'); + expect(bid.bidderCode).to.equal('pulsepoint'); + expect(bid.cpm).to.equal(1.25); + expect(bid.ad).to.equal('This is an Ad'); + expect(bid.width).to.equal('300'); + expect(bid.height).to.equal('250'); + }); + + it('Verify passback', () => { + pulsepointAdapter.callBids(slotConfigs); + let placement = bidManager.addBidResponse.firstCall.args[0]; + let bid = bidManager.addBidResponse.firstCall.args[1]; + expect(placement).to.equal('/DfpAccount1/slot1'); + expect(bid.bidderCode).to.equal('pulsepoint'); + expect(bid).to.not.have.property('ad'); + expect(bid).to.not.have.property('cpm'); + }); + + it('Verify PulsePoint library is downloaded if nessesary', () => { + resetPulsepointLib(); + pulsepointAdapter.callBids(slotConfigs); + let libraryLoadCall = adLoader.loadScript.firstCall.args[0]; + let callback = adLoader.loadScript.firstCall.args[1]; + expect(libraryLoadCall).to.equal('http://tag.contextweb.com/getjs.static.js'); + expect(callback).to.be.a('function'); + }); + + it('Verify Bids get processed after PulsePoint library downloads', () => { + resetPulsepointLib(); + pulsepointAdapter.callBids(slotConfigs); + let callback = adLoader.loadScript.firstCall.args[1]; + let bidCall = bidManager.addBidResponse.firstCall; + expect(callback).to.be.a('function'); + expect(bidCall).to.be.a('null'); + //the library load should initialize pulsepoint lib + initPulsepointLib(); + callback(); + expect(requests.length).to.equal(2); + bidCall = bidManager.addBidResponse.firstCall; + expect(bidCall).to.be.a('object'); + expect(bidCall.args[0]).to.equal('/DfpAccount1/slot1'); + expect(bidCall.args[1]).to.be.a('object'); + }); + +}); From 5da43c32c0d739bb1946601bdf7bf713cd7b1d7c Mon Sep 17 00:00:00 2001 From: avenkatraman Date: Tue, 25 Oct 2016 15:56:41 -0400 Subject: [PATCH 02/10] Adding bidRequest to bidFactory.createBid method as per https://github.com/prebid/Prebid.js/issues/509 --- src/adapters/pulsepoint.js | 4 ++-- test/spec/adapters/pulsepoint_spec.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/adapters/pulsepoint.js b/src/adapters/pulsepoint.js index fa2d2f73748..ef82b05f4e5 100644 --- a/src/adapters/pulsepoint.js +++ b/src/adapters/pulsepoint.js @@ -43,7 +43,7 @@ var PulsePointAdapter = function PulsePointAdapter() { function bidResponseAvailable(bidRequest, bidResponse) { if (bidResponse) { var adSize = bidRequest.params.cf.toUpperCase().split('X'); - var bid = bidfactory.createBid(1); + var bid = bidfactory.createBid(1, bidRequest); bid.bidderCode = bidRequest.bidder; bid.cpm = bidResponse.bidCpm; bid.ad = bidResponse.html; @@ -51,7 +51,7 @@ var PulsePointAdapter = function PulsePointAdapter() { bid.height = adSize[1]; bidmanager.addBidResponse(bidRequest.placementCode, bid); } else { - var passback = bidfactory.createBid(2); + var passback = bidfactory.createBid(2, bidRequest); passback.bidderCode = bidRequest.bidder; bidmanager.addBidResponse(bidRequest.placementCode, passback); } diff --git a/test/spec/adapters/pulsepoint_spec.js b/test/spec/adapters/pulsepoint_spec.js index fe5dee461db..96755a36207 100644 --- a/test/spec/adapters/pulsepoint_spec.js +++ b/test/spec/adapters/pulsepoint_spec.js @@ -40,6 +40,7 @@ describe("PulsePoint Adapter Tests", () => { { placementCode: "/DfpAccount1/slot1", bidder: "pulsepoint", + bidId: 'bid12345', params: { cp: "p10000", ct: "t10000", @@ -48,6 +49,7 @@ describe("PulsePoint Adapter Tests", () => { },{ placementCode: "/DfpAccount2/slot2", bidder: "pulsepoint", + bidId: 'bid23456', params: { cp: "p20000", ct: "t20000", @@ -102,6 +104,7 @@ describe("PulsePoint Adapter Tests", () => { expect(bid.ad).to.equal('This is an Ad'); expect(bid.width).to.equal('300'); expect(bid.height).to.equal('250'); + expect(bid.adId).to.equal('bid12345'); }); it('Verify passback', () => { @@ -112,6 +115,7 @@ describe("PulsePoint Adapter Tests", () => { expect(bid.bidderCode).to.equal('pulsepoint'); expect(bid).to.not.have.property('ad'); expect(bid).to.not.have.property('cpm'); + expect(bid.adId).to.equal('bid12345'); }); it('Verify PulsePoint library is downloaded if nessesary', () => { From 62756a9cf82a835fd2e77f0efc1449c84d748467 Mon Sep 17 00:00:00 2001 From: anand-venkatraman Date: Wed, 9 Nov 2016 10:57:09 -0500 Subject: [PATCH 03/10] ET-1765: Adding support for additional params in PulsePoint adapter (#2) --- src/adapters/pulsepoint.js | 29 +++++++++++++++++---------- test/spec/adapters/pulsepoint_spec.js | 6 +++++- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/adapters/pulsepoint.js b/src/adapters/pulsepoint.js index ef82b05f4e5..42479b895a3 100644 --- a/src/adapters/pulsepoint.js +++ b/src/adapters/pulsepoint.js @@ -19,21 +19,28 @@ var PulsePointAdapter = function PulsePointAdapter() { var bids = params.bids; for (var i = 0; i < bids.length; i++) { var bidRequest = bids[i]; - var callback = bidResponseCallback(bidRequest); - var ppBidRequest = new window.pp.Ad({ - cf: bidRequest.params.cf, - cp: bidRequest.params.cp, - ct: bidRequest.params.ct, - cn: 1, - ca: window.pp.requestActions.BID, - cu: bidUrl, - adUnitId: bidRequest.placementCode, - callback: callback - }); + var ppBidRequest = new window.pp.Ad(bidRequestOptions(bidRequest)); ppBidRequest.display(); } } + function bidRequestOptions(bidRequest) { + var callback = bidResponseCallback(bidRequest); + var options = { + cn: 1, + ca: window.pp.requestActions.BID, + cu: bidUrl, + adUnitId: bidRequest.placementCode, + callback: callback + }; + for(var param in bidRequest.params) { + if(bidRequest.params.hasOwnProperty(param)) { + options[param] = bidRequest.params[param]; + } + } + return options; + } + function bidResponseCallback(bid) { return function (bidResponse) { bidResponseAvailable(bid, bidResponse); diff --git a/test/spec/adapters/pulsepoint_spec.js b/test/spec/adapters/pulsepoint_spec.js index 96755a36207..9c901cd149b 100644 --- a/test/spec/adapters/pulsepoint_spec.js +++ b/test/spec/adapters/pulsepoint_spec.js @@ -44,7 +44,9 @@ describe("PulsePoint Adapter Tests", () => { params: { cp: "p10000", ct: "t10000", - cf: "300x250" + cf: "300x250", + param1: "value1", + param2: 2 } },{ placementCode: "/DfpAccount2/slot2", @@ -79,6 +81,8 @@ describe("PulsePoint Adapter Tests", () => { expect(requests[0].cu).to.equal('http://bid.contextweb.com/header/tag'); expect(requests[0].adUnitId).to.equal('/DfpAccount1/slot1'); expect(requests[0]).to.have.property('callback'); + expect(requests[0].param1).to.equal('value1'); + expect(requests[0].param2).to.equal(2); // //slot 2 expect(requests[1].cp).to.equal('p20000'); expect(requests[1].ct).to.equal('t20000'); From b9af15cac48fc7180ef79c6a7936ae721c6a0fb1 Mon Sep 17 00:00:00 2001 From: avenkatraman Date: Thu, 8 Dec 2016 12:48:40 -0500 Subject: [PATCH 04/10] ET-1850: Fixing https://github.com/prebid/Prebid.js/issues/866 --- src/adapters/pulsepoint.js | 11 +++++++++++ test/spec/adapters/pulsepoint_spec.js | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/adapters/pulsepoint.js b/src/adapters/pulsepoint.js index 42479b895a3..7e882ea8591 100644 --- a/src/adapters/pulsepoint.js +++ b/src/adapters/pulsepoint.js @@ -1,6 +1,7 @@ var bidfactory = require('../bidfactory.js'); var bidmanager = require('../bidmanager.js'); var adloader = require('../adloader.js'); +var utils = require('../utils.js'); var PulsePointAdapter = function PulsePointAdapter() { @@ -19,8 +20,18 @@ var PulsePointAdapter = function PulsePointAdapter() { var bids = params.bids; for (var i = 0; i < bids.length; i++) { var bidRequest = bids[i]; + requestBid(bidRequest); + } + } + + function requestBid(bidRequest) { + try { var ppBidRequest = new window.pp.Ad(bidRequestOptions(bidRequest)); ppBidRequest.display(); + } catch(e) { + //register passback on any exceptions while attempting to fetch response. + utils.logMessage('pulsepoint.requestBid', 'ERROR', e); + bidResponseAvailable(bidRequest); } } diff --git a/test/spec/adapters/pulsepoint_spec.js b/test/spec/adapters/pulsepoint_spec.js index 9c901cd149b..0e9fb97fa4c 100644 --- a/test/spec/adapters/pulsepoint_spec.js +++ b/test/spec/adapters/pulsepoint_spec.js @@ -148,4 +148,18 @@ describe("PulsePoint Adapter Tests", () => { expect(bidCall.args[1]).to.be.a('object'); }); + //related to issue https://github.com/prebid/Prebid.js/issues/866 + it('Verify Passbacks when window.pp is not available', () => { + window.pp = function() {}; + pulsepointAdapter.callBids(slotConfigs); + let placement = bidManager.addBidResponse.firstCall.args[0]; + let bid = bidManager.addBidResponse.firstCall.args[1]; + //verify that we passed back without exceptions, should window.pp be already taken. + expect(placement).to.equal('/DfpAccount1/slot1'); + expect(bid.bidderCode).to.equal('pulsepoint'); + expect(bid).to.not.have.property('ad'); + expect(bid).to.not.have.property('cpm'); + expect(bid.adId).to.equal('bid12345'); + }); + }); From b5eeb7f618fbe62c81c4c3f80a293f7e12a9aaad Mon Sep 17 00:00:00 2001 From: avenkatraman Date: Thu, 8 Dec 2016 17:34:55 -0500 Subject: [PATCH 05/10] Minor fix --- src/adapters/pulsepoint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adapters/pulsepoint.js b/src/adapters/pulsepoint.js index 7e882ea8591..aaad60ee311 100644 --- a/src/adapters/pulsepoint.js +++ b/src/adapters/pulsepoint.js @@ -30,7 +30,7 @@ var PulsePointAdapter = function PulsePointAdapter() { ppBidRequest.display(); } catch(e) { //register passback on any exceptions while attempting to fetch response. - utils.logMessage('pulsepoint.requestBid', 'ERROR', e); + utils.logError('pulsepoint.requestBid', 'ERROR', e); bidResponseAvailable(bidRequest); } } From aae98a716d33043d8855f67dabfdb7195ddec7c6 Mon Sep 17 00:00:00 2001 From: avenkatraman Date: Mon, 13 Nov 2017 16:07:32 -0500 Subject: [PATCH 06/10] Adding mandatory parameters to Bid --- modules/pulsepointLiteBidAdapter.js | 6 ++++++ test/spec/modules/pulsepointLiteBidAdapter_spec.js | 3 +++ 2 files changed, 9 insertions(+) diff --git a/modules/pulsepointLiteBidAdapter.js b/modules/pulsepointLiteBidAdapter.js index 99a83871dd8..f4c8ee1f210 100644 --- a/modules/pulsepointLiteBidAdapter.js +++ b/modules/pulsepointLiteBidAdapter.js @@ -10,6 +10,9 @@ const NATIVE_DEFAULTS = { ICON_MIN: 50, }; +const BID_TTL = 20; +const CURRENCY = 'USD'; + /** * PulsePoint "Lite" Adapter. This adapter implementation is lighter than the * alternative/original PulsePointAdapter because it has no external @@ -89,6 +92,9 @@ function bidResponseAvailable(bidRequest, bidResponse) { creative_id: id, creativeId: id, adId: id, + ttl: BID_TTL, + netRevenue: true, + currency: CURRENCY }; if (idToImpMap[id]['native']) { bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]); diff --git a/test/spec/modules/pulsepointLiteBidAdapter_spec.js b/test/spec/modules/pulsepointLiteBidAdapter_spec.js index 9731164cd50..68d13eb648b 100644 --- a/test/spec/modules/pulsepointLiteBidAdapter_spec.js +++ b/test/spec/modules/pulsepointLiteBidAdapter_spec.js @@ -100,6 +100,9 @@ describe('PulsePoint Lite Adapter Tests', () => { expect(bid.adId).to.equal('bid12345'); expect(bid.creative_id).to.equal('bid12345'); expect(bid.creativeId).to.equal('bid12345'); + expect(bid.netRevenue).to.equal(true); + expect(bid.currency).to.equal('USD'); + expect(bid.ttl).to.equal(20); }); it('Verify full passback', () => { From 0661fc7f6d784f4d57b23e6cbb7506aef87a0483 Mon Sep 17 00:00:00 2001 From: avenkatraman Date: Mon, 30 Apr 2018 19:08:55 +0530 Subject: [PATCH 07/10] Pulsepoint Bid Adapter - GDPR support --- modules/pulsepointBidAdapter.js | 11 +++++++++++ .../spec/modules/pulsepointBidAdapter_spec.js | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/modules/pulsepointBidAdapter.js b/modules/pulsepointBidAdapter.js index fc637cc9fff..6e2e5c5f002 100644 --- a/modules/pulsepointBidAdapter.js +++ b/modules/pulsepointBidAdapter.js @@ -42,6 +42,7 @@ export const spec = { app: app(bidRequests), device: device(), }; + applyGdpr(bidRequests, request); return { method: 'POST', url: '//bid.contextweb.com/header/ortb', @@ -304,6 +305,16 @@ function adSize(slot) { return [1, 1]; } +/** + * Applies GDPR parameters to rqeeust. + */ +function applyGdpr(bidRequest, ortbRequest) { + if (bidRequest && bidRequest.length > 0 && bidRequest[0].gdprConsent) { + ortbRequest.regs = { ext: { gdpr: bidRequest[0].gdprConsent.consentRequired ? 1 : 0 } }; + ortbRequest.user = { ext: { consent: bidRequest[0].gdprConsent.consentString } }; + } +} + /** * Parses the native response from the Bid given. */ diff --git a/test/spec/modules/pulsepointBidAdapter_spec.js b/test/spec/modules/pulsepointBidAdapter_spec.js index b4793256ee0..4cd11bc027d 100644 --- a/test/spec/modules/pulsepointBidAdapter_spec.js +++ b/test/spec/modules/pulsepointBidAdapter_spec.js @@ -273,4 +273,23 @@ describe('PulsePoint Adapter Tests', () => { expect(ortbRequest.app.storeurl).to.equal('http://pulsepoint.com/apps'); expect(ortbRequest.app.domain).to.equal('pulsepoint.com'); }); + + it('Verify GDPR', () => { + slotConfigs[0].gdprConsent = { + consentRequired: true, + consentString: 'serialized_gpdr_data' + }; + const request = spec.buildRequests(slotConfigs); + expect(request.url).to.equal('//bid.contextweb.com/header/ortb'); + expect(request.method).to.equal('POST'); + const ortbRequest = JSON.parse(request.data); + // user object + expect(ortbRequest.user).to.not.equal(null); + expect(ortbRequest.user.ext).to.not.equal(null); + expect(ortbRequest.user.ext.consent).to.equal('serialized_gpdr_data'); + // regs object + expect(ortbRequest.regs).to.not.equal(null); + expect(ortbRequest.regs.ext).to.not.equal(null); + expect(ortbRequest.regs.ext.gdpr).to.equal(1); + }); }); From 861eea38b775a34cf315fba4bc957a43cb6957c7 Mon Sep 17 00:00:00 2001 From: avenkatraman Date: Mon, 30 Apr 2018 19:27:37 +0530 Subject: [PATCH 08/10] minor update --- modules/pulsepointBidAdapter.js | 2 +- test/spec/modules/pulsepointBidAdapter_spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/pulsepointBidAdapter.js b/modules/pulsepointBidAdapter.js index 6e2e5c5f002..5e5817bc9ff 100644 --- a/modules/pulsepointBidAdapter.js +++ b/modules/pulsepointBidAdapter.js @@ -310,7 +310,7 @@ function adSize(slot) { */ function applyGdpr(bidRequest, ortbRequest) { if (bidRequest && bidRequest.length > 0 && bidRequest[0].gdprConsent) { - ortbRequest.regs = { ext: { gdpr: bidRequest[0].gdprConsent.consentRequired ? 1 : 0 } }; + ortbRequest.regs = { ext: { gdpr: bidRequest[0].gdprConsent.gdprApplies ? 1 : 0 } }; ortbRequest.user = { ext: { consent: bidRequest[0].gdprConsent.consentString } }; } } diff --git a/test/spec/modules/pulsepointBidAdapter_spec.js b/test/spec/modules/pulsepointBidAdapter_spec.js index 4cd11bc027d..947f0dd6ff0 100644 --- a/test/spec/modules/pulsepointBidAdapter_spec.js +++ b/test/spec/modules/pulsepointBidAdapter_spec.js @@ -276,7 +276,7 @@ describe('PulsePoint Adapter Tests', () => { it('Verify GDPR', () => { slotConfigs[0].gdprConsent = { - consentRequired: true, + gdprApplies: true, consentString: 'serialized_gpdr_data' }; const request = spec.buildRequests(slotConfigs); From 4588e9d3883f30b2f3915130a0463c66adefee5f Mon Sep 17 00:00:00 2001 From: avenkatraman Date: Mon, 30 Apr 2018 19:29:23 +0530 Subject: [PATCH 09/10] minor update --- modules/pulsepointBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/pulsepointBidAdapter.js b/modules/pulsepointBidAdapter.js index 5e5817bc9ff..7459f4d4761 100644 --- a/modules/pulsepointBidAdapter.js +++ b/modules/pulsepointBidAdapter.js @@ -306,7 +306,7 @@ function adSize(slot) { } /** - * Applies GDPR parameters to rqeeust. + * Applies GDPR parameters to request. */ function applyGdpr(bidRequest, ortbRequest) { if (bidRequest && bidRequest.length > 0 && bidRequest[0].gdprConsent) { From 6435142b2be9a7c5187613c48cada0c3dda6d6d6 Mon Sep 17 00:00:00 2001 From: avenkatraman Date: Tue, 1 May 2018 11:02:02 +0530 Subject: [PATCH 10/10] Fixing review comment --- modules/pulsepointBidAdapter.js | 12 ++++++------ test/spec/modules/pulsepointBidAdapter_spec.js | 10 ++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/pulsepointBidAdapter.js b/modules/pulsepointBidAdapter.js index 7459f4d4761..94733ad7805 100644 --- a/modules/pulsepointBidAdapter.js +++ b/modules/pulsepointBidAdapter.js @@ -34,7 +34,7 @@ export const spec = { !!(bid && bid.params && bid.params.cp && bid.params.ct) ), - buildRequests: bidRequests => { + buildRequests: (bidRequests, bidderRequest) => { const request = { id: bidRequests[0].bidderRequestId, imp: bidRequests.map(slot => impression(slot)), @@ -42,7 +42,7 @@ export const spec = { app: app(bidRequests), device: device(), }; - applyGdpr(bidRequests, request); + applyGdpr(bidderRequest, request); return { method: 'POST', url: '//bid.contextweb.com/header/ortb', @@ -308,10 +308,10 @@ function adSize(slot) { /** * Applies GDPR parameters to request. */ -function applyGdpr(bidRequest, ortbRequest) { - if (bidRequest && bidRequest.length > 0 && bidRequest[0].gdprConsent) { - ortbRequest.regs = { ext: { gdpr: bidRequest[0].gdprConsent.gdprApplies ? 1 : 0 } }; - ortbRequest.user = { ext: { consent: bidRequest[0].gdprConsent.consentString } }; +function applyGdpr(bidderRequest, ortbRequest) { + if (bidderRequest && bidderRequest.gdprConsent) { + ortbRequest.regs = { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0 } }; + ortbRequest.user = { ext: { consent: bidderRequest.gdprConsent.consentString } }; } } diff --git a/test/spec/modules/pulsepointBidAdapter_spec.js b/test/spec/modules/pulsepointBidAdapter_spec.js index 947f0dd6ff0..709dbeb76a2 100644 --- a/test/spec/modules/pulsepointBidAdapter_spec.js +++ b/test/spec/modules/pulsepointBidAdapter_spec.js @@ -275,11 +275,13 @@ describe('PulsePoint Adapter Tests', () => { }); it('Verify GDPR', () => { - slotConfigs[0].gdprConsent = { - gdprApplies: true, - consentString: 'serialized_gpdr_data' + const bidderRequest = { + gdprConsent: { + gdprApplies: true, + consentString: 'serialized_gpdr_data' + } }; - const request = spec.buildRequests(slotConfigs); + const request = spec.buildRequests(slotConfigs, bidderRequest); expect(request.url).to.equal('//bid.contextweb.com/header/ortb'); expect(request.method).to.equal('POST'); const ortbRequest = JSON.parse(request.data);