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 Bid Adapter: add support for JW Player #7291

Merged
merged 20 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7a10d02
Merge pull request #1 from prebid/master
pm-manasi-moghe Dec 19, 2018
8082b2e
Merge pull request #2 from prebid/master
pm-manasi-moghe Dec 26, 2018
6e856c0
Merge pull request #3 from prebid/master
pm-manasi-moghe Jan 9, 2019
881c7db
Merge pull request #4 from prebid/master
pm-manasi-moghe Jan 16, 2019
5dc2d30
Merge pull request #6 from prebid/master
pm-manasi-moghe Jan 18, 2019
e3c151a
Merge pull request #8 from prebid/master
pm-manasi-moghe Jan 22, 2019
84c6e64
Merge pull request #9 from prebid/master
pm-manasi-moghe Feb 27, 2019
7cb5041
Merge pull request #11 from prebid/master
pm-manasi-moghe Mar 6, 2019
6c50bd3
Merge pull request #13 from prebid/master
pm-manasi-moghe Mar 20, 2019
04ebe44
Merge pull request #16 from prebid/master
pm-manasi-moghe Mar 27, 2019
999d4aa
Merge branch 'prebid:master' into master
pm-manasi-moghe Jun 1, 2021
90592f4
Merge branch 'prebid:master' into master
pm-manasi-moghe Jun 7, 2021
e1373f1
Merge branch 'prebid:master' into master
pm-manasi-moghe Jun 22, 2021
892b993
Merge branch 'prebid:master' into master
pm-manasi-moghe Aug 4, 2021
7f58807
changes to support jw player in pubmatic adapter
pm-manasi-moghe Aug 4, 2021
a818b31
changed incorrect variable name in function
pm-manasi-moghe Aug 5, 2021
0e135b0
Merge branch 'prebid:master' into master
pm-manasi-moghe Aug 12, 2021
a21d099
Merge remote-tracking branch 'remotes/origin/master' into jwplayer_su…
Aug 12, 2021
fef4ea1
code optimisation changes
pm-manasi-moghe Aug 24, 2021
596b625
unmix quotes for linting
ChrisHuie Aug 24, 2021
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
21 changes: 21 additions & 0 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,26 @@ function _addDealCustomTargetings(imp, bid) {
}
}

function _addJWPlayerSegmentData(imp, bid) {
var jwSegData = (bid.rtd && bid.rtd.jwplayer && bid.rtd.jwplayer.targeting) || undefined;
var jwPlayerData = '';
const jwMark = 'jw-';

if (jwSegData === undefined || jwSegData === '' || !jwSegData.hasOwnProperty('segments')) return;

var maxLength = jwSegData.segments.length;

jwPlayerData += jwMark + 'id=' + jwSegData.content.id; // add the content id first

for (var i = 0; i < maxLength; i++) {
jwPlayerData += '|' + jwMark + jwSegData.segments[i] + '=1';
}
const ext = imp.ext;
(ext && ext.key_val === undefined)
? ext.key_val = jwPlayerData
: ext.key_val += '|' + jwPlayerData;
}

function _createImpressionObject(bid, conf) {
var impObj = {};
var bannerObj;
Expand All @@ -627,6 +647,7 @@ function _createImpressionObject(bid, conf) {

_addPMPDealsInImpression(impObj, bid);
_addDealCustomTargetings(impObj, bid);
_addJWPlayerSegmentData(impObj, bid);
if (bid.hasOwnProperty('mediaTypes')) {
for (mediaTypes in bid.mediaTypes) {
switch (mediaTypes) {
Expand Down
63 changes: 63 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,69 @@ describe('PubMatic adapter', function () {
expect(data2.regs).to.equal(undefined);// USP/CCPAs
});

it('Request params check with JW player params', function() {
let bidRequests = [
{
bidder: 'pubmatic',
params: {
publisherId: '301',
adSlot: '/15671365/DMDemo@300x250:0',
dctr: 'key1=val1|key2=val2,val3'
},
placementCode: '/19968336/header-bid-tag-1',
sizes: [[300, 250], [300, 600]],
bidId: '23acc48ad47af5',
requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99',
bidderRequestId: '1c56ad30b9b8ca8',
transactionId: '92489f71-1bf2-49a0-adf9-000cea934729',
rtd: {
jwplayer: {
targeting: {
content: { id: 'jw_d9J2zcaA' },
segments: ['80011026', '80011035']
}
}
}
}];
let key_val_output = 'key1=val1|key2=val2,val3|jw-id=jw_d9J2zcaA|jw-80011026=1|jw-80011035=1'
let request = spec.buildRequests(bidRequests, {
auctionId: 'new-auction-id'
});
let data = JSON.parse(request.data);
expect(data.imp[0].ext).to.exist.and.to.be.an('object');
expect(data.imp[0].ext.key_val).to.exist.and.to.equal(key_val_output);

// jw player data not available. Only dctr sent.
delete bidRequests[0].rtd;
request = spec.buildRequests(bidRequests, {
auctionId: 'new-auction-id'
});
data = JSON.parse(request.data);

expect(data.imp[0].ext).to.exist.and.to.be.an('object'); // dctr parameter
expect(data.imp[0].ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr);

// jw player data is available, but dctr is not present
bidRequests[0].rtd = {
jwplayer: {
targeting: {
content: { id: 'jw_d9J2zcaA' },
segments: ['80011026', '80011035']
}
}
};

delete bidRequests[0].params.dctr;
key_val_output = 'jw-id=jw_d9J2zcaA|jw-80011026=1|jw-80011035=1';
request = spec.buildRequests(bidRequests, {
auctionId: 'new-auction-id'
});
data = JSON.parse(request.data);

expect(data.imp[0].ext).to.exist.and.to.be.an('object');
expect(data.imp[0].ext.key_val).to.exist.and.to.equal(key_val_output);
});

describe('FPD', function() {
let newRequest;

Expand Down