Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulsepoint adapter: fixing bid rejection due to missing mandatory bid params. #1823

Merged
merged 19 commits into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2fba6a2
ET-1691: Pulsepoint Analytics adapter for Prebid. (#1)
anand-venkatraman Oct 14, 2016
ca17acb
Merge remote-tracking branch 'upstream/master'
anand-venkatraman Oct 25, 2016
5da43c3
Adding bidRequest to bidFactory.createBid method as per https://githu…
anand-venkatraman Oct 25, 2016
cf41114
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Nov 8, 2016
62756a9
ET-1765: Adding support for additional params in PulsePoint adapter (#2)
anand-venkatraman Nov 9, 2016
f8fabb7
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Dec 8, 2016
b9af15c
ET-1850: Fixing https://github.com/prebid/Prebid.js/issues/866
anand-venkatraman Dec 8, 2016
6523c25
Merge pull request #3 from pulsepointinc/ET-1850
anand-venkatraman Dec 8, 2016
b5eeb7f
Minor fix
anand-venkatraman Dec 8, 2016
0f33ef5
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Mar 1, 2017
b5dbd34
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Jun 27, 2017
d6fcd11
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Jul 17, 2017
fce16ad
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Aug 15, 2017
9833867
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Sep 22, 2017
70924c5
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Oct 12, 2017
41f4aca
Merge branch 'master' of https://github.com/prebid/Prebid.js
anand-venkatraman Nov 13, 2017
aae98a7
Adding mandatory parameters to Bid
anand-venkatraman Nov 13, 2017
a5f5297
Fixing review comment
anand-venkatraman Nov 13, 2017
ecd0a82
Applying values from "ext" as applicable
anand-venkatraman Nov 13, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions modules/pulsepointLiteBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const NATIVE_DEFAULTS = {
ICON_MIN: 50,
};

const DEFAULT_BID_TTL = 20;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this value is in seconds - is that right? Just double checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. ttl is in seconds, according to docs here - http://prebid.org/dev-docs/bidder-adapter-1.html.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool. LGTM.

const DEFAULT_CURRENCY = 'USD';
const DEFAULT_NET_REVENUE = true;

/**
* PulsePoint "Lite" Adapter. This adapter implementation is lighter than the
* alternative/original PulsePointAdapter because it has no external
Expand Down Expand Up @@ -89,6 +93,9 @@ function bidResponseAvailable(bidRequest, bidResponse) {
creative_id: id,
creativeId: id,
adId: id,
ttl: DEFAULT_BID_TTL,
netRevenue: DEFAULT_NET_REVENUE,
currency: DEFAULT_CURRENCY
};
if (idToImpMap[id]['native']) {
bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]);
Expand All @@ -98,12 +105,21 @@ function bidResponseAvailable(bidRequest, bidResponse) {
bid.width = idToImpMap[id].banner.w;
bid.height = idToImpMap[id].banner.h;
}
applyExt(bid, idToBidMap[id])
bids.push(bid);
}
});
return bids;
}

function applyExt(bid, ortbBid) {
if (ortbBid && ortbBid.ext) {
bid.ttl = ortbBid.ext.ttl || bid.ttl;
bid.currency = ortbBid.ext.currency || bid.currency;
bid.netRevenue = ortbBid.ext.netRevenue != null ? ortbBid.ext.netRevenue : bid.netRevenue;
}
}

/**
* Produces an OpenRTBImpression from a slot config.
*/
Expand Down
29 changes: 29 additions & 0 deletions test/spec/modules/pulsepointLiteBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,35 @@ 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 use ttl in ext', () => {
const request = spec.buildRequests(slotConfigs);
const ortbRequest = JSON.parse(request.data);
const ortbResponse = {
seatbid: [{
bid: [{
impid: ortbRequest.imp[0].id,
price: 1.25,
adm: 'This is an Ad',
ext: {
ttl: 30,
netRevenue: false,
currency: 'INR'
}
}]
}]
};
const bids = spec.interpretResponse({ body: ortbResponse }, request);
expect(bids).to.have.lengthOf(1);
// verify first bid
const bid = bids[0];
expect(bid.ttl).to.equal(30);
expect(bid.netRevenue).to.equal(false);
expect(bid.currency).to.equal('INR');
});

it('Verify full passback', () => {
Expand Down