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 #7450

Merged
merged 24 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 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
0e135b0
Merge branch 'prebid:master' into master
pm-manasi-moghe Aug 12, 2021
03bc138
Merge branch 'prebid:master' into master
pm-manasi-moghe Sep 6, 2021
75e4634
changes to support jwplayer segment data in pubmatic s2s endpoint
pm-manasi-moghe Sep 6, 2021
a8a3ff1
remove additional '|' getting added if dctr is blank
pm-manasi-moghe Sep 21, 2021
2011fda
Merge branch 'prebid:master' into master
pm-manasi-moghe Sep 21, 2021
1696e03
Merge remote-tracking branch 'origin/master' into jwplayer_s2s_support
pm-manasi-moghe Sep 21, 2021
31dcc39
Merge pull request #22 from pm-manasi-moghe/jwplayer_s2s_support
pm-manasi-moghe Sep 22, 2021
9c0d195
Merge branch 'master' into master
pm-manasi-moghe Sep 30, 2021
8334c74
changes utils.convertType to remove reference to utils
pm-manasi-moghe Sep 30, 2021
6122fae
Merge branch 'prebid:master' into master
pm-manasi-moghe Sep 30, 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
19 changes: 13 additions & 6 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ function _addDealCustomTargetings(imp, bid) {
}
}

function _addJWPlayerSegmentData(imp, bid) {
function _addJWPlayerSegmentData(imp, bid, isS2S) {
var jwSegData = (bid.rtd && bid.rtd.jwplayer && bid.rtd.jwplayer.targeting) || undefined;
var jwPlayerData = '';
const jwMark = 'jw-';
Expand All @@ -619,10 +619,15 @@ function _addJWPlayerSegmentData(imp, bid) {
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;

var ext;

if (isS2S) {
(imp.dctr === undefined || imp.dctr.length == 0) ? imp.dctr = jwPlayerData : imp.dctr += '|' + jwPlayerData;
} else {
ext = imp.ext;
ext && ext.key_val === undefined ? ext.key_val = jwPlayerData : ext.key_val += '|' + jwPlayerData;
}
}

function _createImpressionObject(bid, conf) {
Expand Down Expand Up @@ -1322,7 +1327,9 @@ export const spec = {
* @param {Boolean} isOpenRtb boolean to check openrtb2 protocol
* @return {Object} params bid params
*/
transformBidParams: function (params, isOpenRtb) {

transformBidParams: function (params, isOpenRtb, adUnit, bidRequests) {
_addJWPlayerSegmentData(params, adUnit.bids[0], true);
return convertTypes({
'publisherId': 'string',
'adSlot': 'string'
Expand Down
178 changes: 178 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3644,5 +3644,183 @@ describe('PubMatic adapter', function () {
}]);
});
});

describe('JW player segment data for S2S', function() {
let sandbox = sinon.sandbox.create();
beforeEach(function () {
sandbox = sinon.sandbox.create();
});
afterEach(function() {
sandbox.restore();
});
it('Should append JW player segment data to dctr values in auction endpoint', function() {
var videoAdUnit = {
'bidderCode': 'pubmatic',
'bids': [
{
'bidder': 'pubmatic',
'params': {
'publisherId': '156276',
'adSlot': 'pubmatic_video2',
'dctr': 'key1=123|key2=345',
'pmzoneid': '1243',
'video': {
'mimes': ['video/mp4', 'video/x-flv'],
'skippable': true,
'minduration': 5,
'maxduration': 30,
'startdelay': 5,
'playbackmethod': [1, 3],
'api': [1, 2],
'protocols': [2, 3],
'battr': [13, 14],
'linearity': 1,
'placement': 2,
'minbitrate': 10,
'maxbitrate': 10
}
},
'rtd': {
'jwplayer': {
'targeting': {
'segments': ['80011026', '80011035'],
'content': {
'id': 'jw_d9J2zcaA'
}
}
}
},
'bid_id': '17a6771be26cc4',
'ortb2Imp': {
'ext': {
'data': {
'pbadslot': 'abcd',
'jwTargeting': {
'playerID': 'myElement1',
'mediaID': 'd9J2zcaA'
}
}
}
}
}
],
'auctionStart': 1630923178417,
'timeout': 1000,
'src': 's2s'
}

spec.transformBidParams(bidRequests[0].params, true, videoAdUnit);
expect(bidRequests[0].params.dctr).to.equal('key1:val1,val2|key2:val1|jw-id=jw_d9J2zcaA|jw-80011026=1|jw-80011035=1');
});
it('Should send only JW player segment data in auction endpoint, if dctr is missing', function() {
var videoAdUnit = {
'bidderCode': 'pubmatic',
'bids': [
{
'bidder': 'pubmatic',
'params': {
'publisherId': '156276',
'adSlot': 'pubmatic_video2',
'dctr': 'key1=123|key2=345',
'pmzoneid': '1243',
'video': {
'mimes': ['video/mp4', 'video/x-flv'],
'skippable': true,
'minduration': 5,
'maxduration': 30,
'startdelay': 5,
'playbackmethod': [1, 3],
'api': [1, 2],
'protocols': [2, 3],
'battr': [13, 14],
'linearity': 1,
'placement': 2,
'minbitrate': 10,
'maxbitrate': 10
}
},
'rtd': {
'jwplayer': {
'targeting': {
'segments': ['80011026', '80011035'],
'content': {
'id': 'jw_d9J2zcaA'
}
}
}
},
'bid_id': '17a6771be26cc4',
'ortb2Imp': {
'ext': {
'data': {
'pbadslot': 'abcd',
'jwTargeting': {
'playerID': 'myElement1',
'mediaID': 'd9J2zcaA'
}
}
}
}
}
],
'auctionStart': 1630923178417,
'timeout': 1000,
'src': 's2s'
}

delete bidRequests[0].params.dctr;
spec.transformBidParams(bidRequests[0].params, true, videoAdUnit);
expect(bidRequests[0].params.dctr).to.equal('jw-id=jw_d9J2zcaA|jw-80011026=1|jw-80011035=1');
});

it('Should not send any JW player segment data in auction endpoint, if it is not available', function() {
var videoAdUnit = {
'bidderCode': 'pubmatic',
'bids': [
{
'bidder': 'pubmatic',
'params': {
'publisherId': '156276',
'adSlot': 'pubmatic_video2',
'dctr': 'key1=123|key2=345',
'pmzoneid': '1243',
'video': {
'mimes': ['video/mp4', 'video/x-flv'],
'skippable': true,
'minduration': 5,
'maxduration': 30,
'startdelay': 5,
'playbackmethod': [1, 3],
'api': [1, 2],
'protocols': [2, 3],
'battr': [13, 14],
'linearity': 1,
'placement': 2,
'minbitrate': 10,
'maxbitrate': 10
}
},
'bid_id': '17a6771be26cc4',
'ortb2Imp': {
'ext': {
'data': {
'pbadslot': 'abcd',
'jwTargeting': {
'playerID': 'myElement1',
'mediaID': 'd9J2zcaA'
}
}
}
}
}
],
'auctionStart': 1630923178417,
'timeout': 1000,
'src': 's2s'
}
spec.transformBidParams(bidRequests[0].params, true, videoAdUnit);
expect(bidRequests[0].params.dctr).to.equal('key1:val1,val2|key2:val1');
});
})
});
});