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

PubMatic bidAdapter and analyticsAdapter #5495

Merged
merged 56 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
33762d1
added support for pubcommon, digitrust, id5id
pm-harshad-mane Sep 12, 2019
0722354
added support for IdentityLink
pm-harshad-mane Sep 13, 2019
f2c32c0
changed the source for id5
pm-harshad-mane Sep 13, 2019
37163d1
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 13, 2019
eaed987
added unit test cases
pm-harshad-mane Sep 13, 2019
602ee7e
changed source param for identityLink
pm-harshad-mane Sep 16, 2019
b6fcd36
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 23, 2019
58381f3
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 26, 2019
c9fb11b
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Oct 10, 2019
8ece7fd
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Oct 16, 2019
28d12a0
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Oct 16, 2019
05a55e1
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Oct 31, 2019
e8b10d5
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Nov 5, 2019
870085f
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Nov 12, 2019
844ce4e
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Nov 12, 2019
704eca3
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Nov 13, 2019
2565cb9
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 4, 2019
1d75bd4
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 4, 2019
6adde1e
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 6, 2019
477c98a
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 9, 2019
cef5422
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 10, 2019
c110a7d
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Jan 9, 2020
e8fb062
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 5, 2020
d77cd71
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 17, 2020
817ce3f
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 24, 2020
cda825e
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 26, 2020
f34a3ec
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 27, 2020
f106dc8
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 4, 2020
1f6937e
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 6, 2020
06ffe84
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 6, 2020
5448ceb
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 6, 2020
e9b90fe
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 11, 2020
a7a1d12
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 11, 2020
30b72df
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 26, 2020
76adbc9
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 30, 2020
50e13bc
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 30, 2020
a1c7ca1
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 30, 2020
96fbadc
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Apr 1, 2020
4b026e2
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Apr 9, 2020
38740bc
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Apr 10, 2020
9daf778
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Apr 20, 2020
eff8828
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Apr 21, 2020
ede95de
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Apr 21, 2020
c98f1a1
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Apr 23, 2020
312da6d
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane May 18, 2020
d92972c
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Jun 1, 2020
fd4fb2e
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Jun 26, 2020
e551136
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Jun 30, 2020
9b62aa4
passing piId in bid object
pm-harshad-mane Jul 1, 2020
9d6193d
piId will be logged in PubMatic analytics too
pm-harshad-mane Jul 1, 2020
bbc7d57
if testGroupId is set in pbjs config then that value will be passed i…
pm-harshad-mane Jul 1, 2020
52a9aa7
bid.piId ==> bid.partnerImpId
pm-harshad-mane Jul 1, 2020
55fe2dd
chnaged key names, added a Todo
pm-harshad-mane Jul 2, 2020
58c8a54
capping testGroupId in 0-15; defaults to 0
pm-harshad-mane Jul 2, 2020
1c612f4
testGroupId should be INT
pm-harshad-mane Jul 2, 2020
fd83bc9
Merge remote-tracking branch 'upstream/master' into pubmatic_piid
pm-harshad-mane Jul 15, 2020
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
12 changes: 11 additions & 1 deletion modules/pubmaticAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function parseBidResponse(bid) {
'mediaType',
'params',
'mi',
'partnerImpId', // partner impression ID
'dimensions', () => utils.pick(bid, [
'width',
'height'
Expand Down Expand Up @@ -188,7 +189,8 @@ function gatherPartnerBidsForAdUnitForLogger(adUnit, adUnitId, highestBid) {
'mi': bid.bidResponse ? (bid.bidResponse.mi || undefined) : undefined,
'af': bid.bidResponse ? (bid.bidResponse.mediaType || undefined) : undefined,
'ocpm': bid.bidResponse ? (bid.bidResponse.originalCpm || 0) : 0,
'ocry': bid.bidResponse ? (bid.bidResponse.originalCurrency || CURRENCY_USD) : CURRENCY_USD
'ocry': bid.bidResponse ? (bid.bidResponse.originalCurrency || CURRENCY_USD) : CURRENCY_USD,
'piid': bid.bidResponse ? (bid.bidResponse.partnerImpId || EMPTY_STRING) : EMPTY_STRING
});
return partnerBids;
}, [])
Expand Down Expand Up @@ -218,6 +220,13 @@ function executeBidsLoggerCall(e, highestCpmBids) {
outputObj['tst'] = Math.round((new window.Date()).getTime() / 1000);
outputObj['pid'] = '' + profileId;
outputObj['pdvid'] = '' + profileVersionId;
outputObj['tgid'] = (function() {
var testGroupId = parseInt(config.getConfig('testGroupId') || 0);
if (testGroupId <= 15 && testGroupId >= 0) {
return testGroupId;
}
return 0;
})();

// GDPR support
if (auctionCache.gdprConsent) {
Expand Down Expand Up @@ -267,6 +276,7 @@ function executeBidWonLoggerCall(auctionId, adUnitId) {
pixelURL += '&en=' + enc(winningBid.bidResponse.bidPriceUSD);
pixelURL += '&eg=' + enc(winningBid.bidResponse.bidGrossCpmUSD);
pixelURL += '&kgpv=' + enc(winningBid.params.kgpv || adUnitId);
pixelURL += '&piid=' + enc(winningBid.bidResponse.partnerImpId || EMPTY_STRING);
ajax(
pixelURL,
null,
Expand Down
3 changes: 2 additions & 1 deletion modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,8 @@ export const spec = {
referrer: parsedReferrer,
ad: bid.adm,
pm_seat: seatbidder.seat || null,
pm_dspid: bid.ext && bid.ext.dspid ? bid.ext.dspid : null
pm_dspid: bid.ext && bid.ext.dspid ? bid.ext.dspid : null,
partnerImpId: bid.id || '' // partner impression Id
};
if (parsedRequest.imp && parsedRequest.imp.length > 0) {
parsedRequest.imp.forEach(req => {
Expand Down
21 changes: 21 additions & 0 deletions test/spec/modules/pubmaticAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const BID = {
'mediaType': 'video',
'statusMessage': 'Bid available',
'bidId': '2ecff0db240757',
'partnerImpId': 'partnerImpressionID-1',
'adId': 'fake_ad_id',
'source': 's2s',
'requestId': '2ecff0db240757',
Expand Down Expand Up @@ -69,6 +70,7 @@ const BID = {
const BID2 = Object.assign({}, BID, {
adUnitCode: '/19968336/header-bid-tag-1',
bidId: '3bd4ebb1c900e2',
partnerImpId: 'partnerImpressionID-2',
adId: 'fake_ad_id_2',
requestId: '3bd4ebb1c900e2',
width: 728,
Expand Down Expand Up @@ -297,6 +299,10 @@ describe('pubmatic analytics adapter', function () {
return [MOCK.BID_RESPONSE[0], MOCK.BID_RESPONSE[1]]
});

config.setConfig({
testGroupId: 15
});

events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);
events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]);
Expand All @@ -322,6 +328,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.tst).to.equal(1519767016);
expect(data.cns).to.equal('here-goes-gdpr-consent-string');
expect(data.gdpr).to.equal(1);
expect(data.tgid).to.equal(15);
expect(data.s).to.be.an('array');
expect(data.s.length).to.equal(2);
// slot 1
Expand All @@ -331,6 +338,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[0].ps.length).to.equal(1);
expect(data.s[0].ps[0].pn).to.equal('pubmatic');
expect(data.s[0].ps[0].bidid).to.equal('2ecff0db240757');
expect(data.s[0].ps[0].piid).to.equal('partnerImpressionID-1');
expect(data.s[0].ps[0].db).to.equal(0);
expect(data.s[0].ps[0].kgpv).to.equal('/19968336/header-bid-tag-0');
expect(data.s[0].ps[0].kgpsv).to.equal('/19968336/header-bid-tag-0');
Expand All @@ -354,6 +362,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.s[1].ps.length).to.equal(1);
expect(data.s[1].ps[0].pn).to.equal('pubmatic');
expect(data.s[1].ps[0].bidid).to.equal('3bd4ebb1c900e2');
expect(data.s[1].ps[0].piid).to.equal('partnerImpressionID-2');
expect(data.s[1].ps[0].db).to.equal(0);
expect(data.s[1].ps[0].kgpv).to.equal('this-is-a-kgpv');
expect(data.s[1].ps[0].kgpsv).to.equal('this-is-a-kgpv');
Expand Down Expand Up @@ -389,6 +398,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.pn).to.equal('pubmatic');
expect(data.eg).to.equal('1.23');
expect(data.en).to.equal('1.23');
expect(data.piid).to.equal('partnerImpressionID-1');
});

it('bidCpmAdjustment: USD: Logger: best case + win tracker', function() {
Expand Down Expand Up @@ -419,6 +429,7 @@ describe('pubmatic analytics adapter', function () {
expect(data.pid).to.equal('1111');
expect(data.s).to.be.an('array');
expect(data.s.length).to.equal(2);
expect(data.tgid).to.equal(0);
// slot 1
expect(data.s[0].sn).to.equal('/19968336/header-bid-tag-0');
expect(data.s[0].sz).to.deep.equal(['640x480']);
Expand Down Expand Up @@ -446,6 +457,10 @@ describe('pubmatic analytics adapter', function () {
});

it('bidCpmAdjustment: JPY: Logger: best case + win tracker', function() {
config.setConfig({
testGroupId: 25
});

setConfig({
adServerCurrency: 'JPY',
rates: {
Expand Down Expand Up @@ -479,6 +494,7 @@ describe('pubmatic analytics adapter', function () {
let data = getLoggerJsonFromRequest(request.requestBody);
expect(data.pubid).to.equal('9999');
expect(data.pid).to.equal('1111');
expect(data.tgid).to.equal(0);// test group id should be between 0-15 else set to 0
expect(data.s).to.be.an('array');
expect(data.s.length).to.equal(2);
// slot 1
Expand Down Expand Up @@ -508,6 +524,10 @@ describe('pubmatic analytics adapter', function () {
});

it('Logger: when bid is not submitted, default bid status 1 check: pubmatic set as s2s', function() {
config.setConfig({
testGroupId: '25'
});

events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);
events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]);
Expand All @@ -520,6 +540,7 @@ describe('pubmatic analytics adapter', function () {
expect(requests.length).to.equal(2); // 1 logger and 1 win-tracker
let request = requests[1]; // logger is executed late, trackers execute first
let data = getLoggerJsonFromRequest(request.requestBody);
expect(data.tgid).to.equal(0);// test group id should be an INT between 0-15 else set to 0
expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1');
expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']);
expect(data.s[1].ps).to.be.an('array');
Expand Down
2 changes: 2 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2306,6 +2306,7 @@ describe('PubMatic adapter', function () {
expect(response[0].ad).to.equal(bidResponses.body.seatbid[0].bid[0].adm);
expect(response[0].pm_seat).to.equal(bidResponses.body.seatbid[0].seat);
expect(response[0].pm_dspid).to.equal(bidResponses.body.seatbid[0].bid[0].ext.dspid);
expect(response[0].partnerImpId).to.equal(bidResponses.body.seatbid[0].bid[0].id);

expect(response[1].requestId).to.equal(bidResponses.body.seatbid[1].bid[0].impid);
expect(response[1].cpm).to.equal((bidResponses.body.seatbid[1].bid[0].price).toFixed(2));
Expand All @@ -2328,6 +2329,7 @@ describe('PubMatic adapter', function () {
expect(response[1].ad).to.equal(bidResponses.body.seatbid[1].bid[0].adm);
expect(response[1].pm_seat).to.equal(bidResponses.body.seatbid[1].seat || null);
expect(response[1].pm_dspid).to.equal(bidResponses.body.seatbid[1].bid[0].ext.dspid);
expect(response[0].partnerImpId).to.equal(bidResponses.body.seatbid[0].bid[0].id);
});

it('should check for dealChannel value selection', function () {
Expand Down