From 2fba6a29ce0f473e4b174c35afdd9b535d363699 Mon Sep 17 00:00:00 2001 From: anand-venkatraman Date: Fri, 14 Oct 2016 08:31:49 -0400 Subject: [PATCH 1/8] 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 2/8] 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 3/8] 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 4/8] 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 5/8] 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 6/8] 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 ef4053aab952238ffda8c8f076a0a19b3fd17207 Mon Sep 17 00:00:00 2001 From: avenkatraman Date: Wed, 2 Oct 2019 03:15:22 +0530 Subject: [PATCH 7/8] Removing usage of deprecated utils method --- modules/pulsepointBidAdapter.js | 8 ++-- .../spec/modules/pulsepointBidAdapter_spec.js | 42 +++++++++++-------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/modules/pulsepointBidAdapter.js b/modules/pulsepointBidAdapter.js index 9c0d67d9612..17205b2a03b 100644 --- a/modules/pulsepointBidAdapter.js +++ b/modules/pulsepointBidAdapter.js @@ -40,7 +40,7 @@ export const spec = { const request = { id: bidRequests[0].bidderRequestId, imp: bidRequests.map(slot => impression(slot)), - site: site(bidRequests), + site: site(bidRequests, bidderRequest.refererInfo), app: app(bidRequests), device: device(), bcat: bidRequests[0].params.bcat, @@ -100,7 +100,7 @@ function bidResponseAvailable(request, response) { idToBidMap[bid.impid] = bid; })); } - if (request.bidderRequest) { + if (request.bidderRequest && request.bidderRequest.bids) { request.bidderRequest.bids.forEach(bid => { idToSlotConfig[bid.bidId] = bid; }); @@ -307,7 +307,7 @@ function dataAsset(id, params, type, defaultLen) { /** * Produces an OpenRTB site object. */ -function site(bidderRequest) { +function site(bidderRequest, refererInfo) { const pubId = bidderRequest && bidderRequest.length > 0 ? bidderRequest[0].params.cp : '0'; const appParams = bidderRequest[0].params.app; if (!appParams) { @@ -316,7 +316,7 @@ function site(bidderRequest) { id: pubId.toString(), }, ref: referrer(), - page: utils.getTopWindowLocation().href, + page: refererInfo.referer, } } return null; diff --git a/test/spec/modules/pulsepointBidAdapter_spec.js b/test/spec/modules/pulsepointBidAdapter_spec.js index 1d22ca6eadc..9ed6d3631f5 100644 --- a/test/spec/modules/pulsepointBidAdapter_spec.js +++ b/test/spec/modules/pulsepointBidAdapter_spec.js @@ -1,7 +1,7 @@ /* eslint dot-notation:0, quote-props:0 */ import {expect} from 'chai'; import {spec} from 'modules/pulsepointBidAdapter'; -import {deepClone, getTopWindowLocation} from 'src/utils'; +import {deepClone} from 'src/utils'; describe('PulsePoint Adapter Tests', function () { const slotConfigs = [{ @@ -138,9 +138,14 @@ describe('PulsePoint Adapter Tests', function () { } } }]; + const bidderRequest = { + refererInfo: { + referer: 'https://publisher.com/home' + } + }; it('Verify build request', function () { - const request = spec.buildRequests(slotConfigs); + const request = spec.buildRequests(slotConfigs, bidderRequest); expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); expect(request.method).to.equal('POST'); const ortbRequest = request.data; @@ -149,7 +154,7 @@ describe('PulsePoint Adapter Tests', function () { expect(ortbRequest.site.publisher).to.not.equal(null); expect(ortbRequest.site.publisher.id).to.equal('p10000'); expect(ortbRequest.site.ref).to.equal(window.top.document.referrer); - expect(ortbRequest.site.page).to.equal(getTopWindowLocation().href); + expect(ortbRequest.site.page).to.equal('https://publisher.com/home'); expect(ortbRequest.imp).to.have.lengthOf(2); // device object expect(ortbRequest.device).to.not.equal(null); @@ -167,7 +172,7 @@ describe('PulsePoint Adapter Tests', function () { }); it('Verify parse response', function () { - const request = spec.buildRequests(slotConfigs); + const request = spec.buildRequests(slotConfigs, bidderRequest); const ortbRequest = request.data; const ortbResponse = { seatbid: [{ @@ -196,7 +201,7 @@ describe('PulsePoint Adapter Tests', function () { }); it('Verify use ttl in ext', function () { - const request = spec.buildRequests(slotConfigs); + const request = spec.buildRequests(slotConfigs, bidderRequest); const ortbRequest = request.data; const ortbResponse = { seatbid: [{ @@ -222,13 +227,13 @@ describe('PulsePoint Adapter Tests', function () { }); it('Verify full passback', function () { - const request = spec.buildRequests(slotConfigs); + const request = spec.buildRequests(slotConfigs, bidderRequest); const bids = spec.interpretResponse({ body: null }, request) expect(bids).to.have.lengthOf(0); }); it('Verify Native request', function () { - const request = spec.buildRequests(nativeSlotConfig); + const request = spec.buildRequests(nativeSlotConfig, bidderRequest); expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); expect(request.method).to.equal('POST'); const ortbRequest = request.data; @@ -266,7 +271,7 @@ describe('PulsePoint Adapter Tests', function () { }); it('Verify Native response', function () { - const request = spec.buildRequests(nativeSlotConfig); + const request = spec.buildRequests(nativeSlotConfig, bidderRequest); expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); expect(request.method).to.equal('POST'); const ortbRequest = request.data; @@ -355,7 +360,7 @@ describe('PulsePoint Adapter Tests', function () { }); it('Verify app requests', function () { - const request = spec.buildRequests(appSlotConfig); + const request = spec.buildRequests(appSlotConfig, bidderRequest); const ortbRequest = request.data; // site object expect(ortbRequest.site).to.equal(null); @@ -368,13 +373,13 @@ describe('PulsePoint Adapter Tests', function () { }); it('Verify GDPR', function () { - const bidderRequest = { + const bidderRequestGdpr = { gdprConsent: { gdprApplies: true, consentString: 'serialized_gpdr_data' } }; - const request = spec.buildRequests(slotConfigs, bidderRequest); + const request = spec.buildRequests(slotConfigs, Object.assign({}, bidderRequest, bidderRequestGdpr)); expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); expect(request.method).to.equal('POST'); const ortbRequest = request.data; @@ -389,7 +394,7 @@ describe('PulsePoint Adapter Tests', function () { }); it('Verify Video request', function () { - const request = spec.buildRequests(videoSlotConfig); + const request = spec.buildRequests(videoSlotConfig, bidderRequest); expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); expect(request.method).to.equal('POST'); const ortbRequest = request.data; @@ -409,7 +414,7 @@ describe('PulsePoint Adapter Tests', function () { }); it('Verify Video response', function () { - const request = spec.buildRequests(videoSlotConfig); + const request = spec.buildRequests(videoSlotConfig, bidderRequest); expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); expect(request.method).to.equal('POST'); const ortbRequest = request.data; @@ -433,7 +438,7 @@ describe('PulsePoint Adapter Tests', function () { }); it('Verify extra parameters', function () { - let request = spec.buildRequests(additionalParamsConfig); + let request = spec.buildRequests(additionalParamsConfig, bidderRequest); let ortbRequest = request.data; expect(ortbRequest).to.not.equal(null); expect(ortbRequest.imp).to.have.lengthOf(1); @@ -448,7 +453,7 @@ describe('PulsePoint Adapter Tests', function () { expect(ortbRequest.imp[0].ext.prebid.extra_key4).to.eql([1, 2, 3]); expect(Object.keys(ortbRequest.imp[0].ext.prebid)).to.eql(['extra_key1', 'extra_key2', 'extra_key3', 'extra_key4']); // attempting with a configuration with no unknown params. - request = spec.buildRequests(outstreamSlotConfig); + request = spec.buildRequests(outstreamSlotConfig, bidderRequest); ortbRequest = request.data; expect(ortbRequest).to.not.equal(null); expect(ortbRequest.imp).to.have.lengthOf(1); @@ -456,7 +461,7 @@ describe('PulsePoint Adapter Tests', function () { }); it('Verify ortb parameters', function () { - const request = spec.buildRequests(ortbParamsSlotConfig); + const request = spec.buildRequests(ortbParamsSlotConfig, bidderRequest); const ortbRequest = request.data; expect(ortbRequest).to.not.equal(null); expect(ortbRequest.bcat).to.eql(['IAB-1', 'IAB-20']); @@ -472,7 +477,8 @@ describe('PulsePoint Adapter Tests', function () { }); it('Verify outstream renderer', function () { - const request = spec.buildRequests(outstreamSlotConfig, {bids: [outstreamSlotConfig[0]]}); + const bidderRequestOutstream = Object.assign({}, bidderRequest, {bids: [outstreamSlotConfig[0]]}); + const request = spec.buildRequests(outstreamSlotConfig, bidderRequestOutstream); const ortbRequest = request.data; expect(ortbRequest).to.not.be.null; expect(ortbRequest.imp[0]).to.not.be.null; @@ -521,7 +527,7 @@ describe('PulsePoint Adapter Tests', function () { } } }; - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidderRequest); expect(request).to.be.not.null; const ortbRequest = request.data; expect(request.data).to.be.not.null; From fb845227a1f6fb51b2a0842522d0c1e3335ab5c5 Mon Sep 17 00:00:00 2001 From: avenkatraman Date: Wed, 2 Oct 2019 11:12:02 +0530 Subject: [PATCH 8/8] minor refactor --- modules/pulsepointBidAdapter.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/pulsepointBidAdapter.js b/modules/pulsepointBidAdapter.js index 17205b2a03b..fee247ba31f 100644 --- a/modules/pulsepointBidAdapter.js +++ b/modules/pulsepointBidAdapter.js @@ -40,7 +40,7 @@ export const spec = { const request = { id: bidRequests[0].bidderRequestId, imp: bidRequests.map(slot => impression(slot)), - site: site(bidRequests, bidderRequest.refererInfo), + site: site(bidRequests, bidderRequest), app: app(bidRequests), device: device(), bcat: bidRequests[0].params.bcat, @@ -307,16 +307,16 @@ function dataAsset(id, params, type, defaultLen) { /** * Produces an OpenRTB site object. */ -function site(bidderRequest, refererInfo) { - const pubId = bidderRequest && bidderRequest.length > 0 ? bidderRequest[0].params.cp : '0'; - const appParams = bidderRequest[0].params.app; +function site(bidRequests, bidderRequest) { + const pubId = bidRequests && bidRequests.length > 0 ? bidRequests[0].params.cp : '0'; + const appParams = bidRequests[0].params.app; if (!appParams) { return { publisher: { id: pubId.toString(), }, ref: referrer(), - page: refererInfo.referer, + page: bidderRequest && bidderRequest.refererInfo ? bidderRequest.refererInfo.referer : '', } } return null;