Skip to content

Commit

Permalink
Update instream logic to account for multimp (#5872)
Browse files Browse the repository at this point in the history
* initial commit, instream poc done

* push in poc changes

* push in poc changes

* restore instream.html

* push in poc changes

* restore instream.html

* restore instream.html v2

* adding instream unit tests v1

* catch up to bidfloor changes

* unit tests finalized!

* update adapter md

* add support for mediaTypes.video

* merge in prebid master

* add instream validation

* add unit test for instream validation

Co-authored-by: Sy Dao <iam.sydao@gmail.com>
  • Loading branch information
sdao-tl and iam-sydao authored Oct 21, 2020
1 parent 9c1d1a2 commit 01eb953
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
13 changes: 12 additions & 1 deletion modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ function _buildPostBody(bidRequests) {
tagid: bidRequest.params.inventoryCode,
floor: _getFloor(bidRequest)
};
if (bidRequest.mediaTypes.video) {
// remove the else to support multi-imp
if (_isInstreamBidRequest(bidRequest)) {
imp.video = _getORTBVideo(bidRequest);
} else if (bidRequest.mediaTypes.banner) {
imp.banner = { format: _sizes(bidRequest.sizes) };
Expand Down Expand Up @@ -147,6 +148,16 @@ function _buildPostBody(bidRequests) {
return data;
}

function _isInstreamBidRequest(bidRequest) {
if (!bidRequest.mediaTypes.video) return false;
if (!bidRequest.mediaTypes.video.context) return false;
if (bidRequest.mediaTypes.video.context.toLowerCase() === 'instream') {
return true;
} else {
return false;
}
}

function _getORTBVideo(bidRequest) {
// give precedent to mediaTypes.video
let video = { ...bidRequest.params.video, ...bidRequest.mediaTypes.video };
Expand Down
37 changes: 37 additions & 0 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,39 @@ describe('triplelift adapter', function () {
auctionId: '1d1a030790a475',
userId: {},
schain,
},
{
bidder: 'triplelift',
params: {
inventoryCode: 'outstream_test',
floor: 1.0,
video: {
mimes: ['video/mp4'],
maxduration: 30,
minduration: 6,
w: 640,
h: 480
}
},
mediaTypes: {
video: {
context: 'outstream',
playerSize: [640, 480]
},
banner: {
sizes: [
[970, 250],
[1, 1]
]
}
},
adUnitCode: 'adunit-code-instream',
sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
userId: {},
schain,
}
];

Expand Down Expand Up @@ -228,6 +261,10 @@ describe('triplelift adapter', function () {
expect(payload.imp[1].tagid).to.equal('insteam_test');
expect(payload.imp[1].floor).to.equal(1.0);
expect(payload.imp[1].video).to.exist.and.to.be.a('object');

expect(payload.imp[2]).to.not.have.property('video');
expect(payload.imp[2]).to.have.property('banner');
expect(payload.imp[2].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]);
});

it('should add tdid to the payload if included', function () {
Expand Down

0 comments on commit 01eb953

Please sign in to comment.