Skip to content

Commit

Permalink
PulsePoint: remove usage of deprecated utils method / prep for 3.0 (p…
Browse files Browse the repository at this point in the history
…rebid#4257)

* 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

* Adding bidRequest to bidFactory.createBid method as per prebid#509

* ET-1765: Adding support for additional params in PulsePoint adapter (#2)

* ET-1850: Fixing prebid#866

* Minor fix

* Adding mandatory parameters to Bid

* Removing usage of deprecated utils method

* minor refactor
  • Loading branch information
anand-venkatraman authored and robertrmartinez committed Oct 15, 2019
1 parent e4d3ff5 commit 6fb6706
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
12 changes: 6 additions & 6 deletions modules/pulsepointBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
app: app(bidRequests),
device: device(),
bcat: bidRequests[0].params.bcat,
Expand Down Expand Up @@ -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;
});
Expand Down Expand Up @@ -307,16 +307,16 @@ function dataAsset(id, params, type, defaultLen) {
/**
* Produces an OpenRTB site object.
*/
function site(bidderRequest) {
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: utils.getTopWindowLocation().href,
page: bidderRequest && bidderRequest.refererInfo ? bidderRequest.refererInfo.referer : '',
}
}
return null;
Expand Down
42 changes: 24 additions & 18 deletions test/spec/modules/pulsepointBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -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 = [{
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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: [{
Expand Down Expand Up @@ -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: [{
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -448,15 +453,15 @@ 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);
expect(ortbRequest.imp[0].ext).to.equal(null);
});

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']);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 6fb6706

Please sign in to comment.