From d4958f5933b6110793ef13b0ed319f65ffbdde4e Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Mon, 3 Jan 2022 15:37:21 -0500 Subject: [PATCH 01/20] alt outstream support --- modules/tripleliftBidAdapter.js | 27 ++++++++++---- .../spec/modules/tripleliftBidAdapter_spec.js | 35 ++++++++++++++++++- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 215769e9812..4259f9109e8 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -119,11 +119,13 @@ function _buildPostBody(bidRequests) { floor: _getFloor(bidRequest) }; // remove the else to support multi-imp - if (_isInstreamBidRequest(bidRequest)) { + if (_videoMediaType(bidRequest) === 'instream') { imp.video = _getORTBVideo(bidRequest); } else if (bidRequest.mediaTypes.banner) { imp.banner = { format: _sizes(bidRequest.sizes) }; - }; + } else if (_videoMediaType(bidRequest) === 'outstream') { + imp.video = _getORTBVideo(bidRequest); + } if (!isEmpty(bidRequest.ortb2Imp)) { imp.fpd = _getAdUnitFpd(bidRequest.ortb2Imp); } @@ -151,22 +153,35 @@ function _buildPostBody(bidRequests) { return data; } -function _isInstreamBidRequest(bidRequest) { +function _isVideoBidRequest(bidRequest) { if (!bidRequest.mediaTypes.video) return false; if (!bidRequest.mediaTypes.video.context) return false; - if (bidRequest.mediaTypes.video.context.toLowerCase() === 'instream') { + if ( + bidRequest.mediaTypes.video.context.toLowerCase() === 'instream' || + bidRequest.mediaTypes.video.context.toLowerCase() === 'outstream' + ) { return true; } else { return false; } } +function _videoMediaType(bidRequest) { + if (!_isVideoBidRequest(bidRequest)) return null + if (bidRequest.mediaTypes.video.context.toLowerCase() === 'instream') { + return 'instream' + } else if (bidRequest.mediaTypes.video.context.toLowerCase() === 'outstream') { + return 'outstream' + } +} + function _getORTBVideo(bidRequest) { // give precedent to mediaTypes.video let video = { ...bidRequest.params.video, ...bidRequest.mediaTypes.video }; if (!video.w) video.w = video.playerSize[0][0]; if (!video.h) video.h = video.playerSize[0][1]; if (video.context === 'instream') video.placement = 1; + if (video.context === 'outstream') video.placement = 3; // clean up oRTB object delete video.playerSize; return video; @@ -177,7 +192,7 @@ function _getFloor (bid) { if (typeof bid.getFloor === 'function') { const floorInfo = bid.getFloor({ currency: 'USD', - mediaType: _isInstreamBidRequest(bid) ? 'video' : 'banner', + mediaType: _isVideoBidRequest(bid) ? 'video' : 'banner', size: '*' }); if (typeof floorInfo === 'object' && @@ -335,7 +350,7 @@ function _buildResponseObject(bidderRequest, bid) { meta: {} }; - if (_isInstreamBidRequest(breq)) { + if (_isVideoBidRequest(breq)) { bidResponse.vastXml = bid.ad; bidResponse.mediaType = 'video'; bidResponse.ttl = INSTREAM_TIME_TO_LIVE; diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 6f2674dadc5..1b84348b3b3 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -346,7 +346,35 @@ describe('triplelift adapter', function () { auctionId: '1d1a030790a475', userId: {}, schain, - } + }, + // outstream video only + { + 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] + } + }, + adUnitCode: 'adunit-code-outstream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + }, ]; bidderRequest = { @@ -403,6 +431,7 @@ describe('triplelift adapter', function () { it('should be a post request and populate the payload', function () { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const payload = request.data; + console.log(JSON.stringify(payload)) expect(payload).to.exist; expect(payload.imp[0].tagid).to.equal('12345'); expect(payload.imp[0].floor).to.equal(1.0); @@ -430,6 +459,10 @@ describe('triplelift adapter', function () { expect(payload.imp[6]).to.not.have.property('video'); expect(payload.imp[6]).to.have.property('banner'); expect(payload.imp[6].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); + // outstream video only + expect(payload.imp[7]).to.have.property('video'); + expect(payload.imp[7]).to.not.have.property('banner'); + expect(payload.imp[7].video).to.deep.equal({'mimes': ['video/mp4'], 'maxduration': 30, 'minduration': 6, 'w': 640, 'h': 480, 'context': 'outstream', 'placement': 3}); }); it('should add tdid to the payload if included', function () { From dc9915e86fa3f50161a7f45d1c42966b84f9fc81 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Mon, 3 Jan 2022 15:50:20 -0500 Subject: [PATCH 02/20] removes consoleLog --- test/spec/modules/tripleliftBidAdapter_spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 1b84348b3b3..708d9cc3da6 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -431,7 +431,6 @@ describe('triplelift adapter', function () { it('should be a post request and populate the payload', function () { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const payload = request.data; - console.log(JSON.stringify(payload)) expect(payload).to.exist; expect(payload.imp[0].tagid).to.equal('12345'); expect(payload.imp[0].floor).to.equal(1.0); From 834f1c37ee3840cd1ab96935d16e618762d9ca35 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Mon, 3 Jan 2022 15:54:24 -0500 Subject: [PATCH 03/20] rename video ttl --- modules/tripleliftBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 4259f9109e8..e751e374700 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -7,7 +7,7 @@ const GVLID = 28; const BIDDER_CODE = 'triplelift'; const STR_ENDPOINT = 'https://tlx.3lift.com/header/auction?'; const BANNER_TIME_TO_LIVE = 300; -const INSTREAM_TIME_TO_LIVE = 3600; +const VIDEO_TIME_TO_LIVE = 3600; let gdprApplies = true; let consentString = null; @@ -353,7 +353,7 @@ function _buildResponseObject(bidderRequest, bid) { if (_isVideoBidRequest(breq)) { bidResponse.vastXml = bid.ad; bidResponse.mediaType = 'video'; - bidResponse.ttl = INSTREAM_TIME_TO_LIVE; + bidResponse.ttl = VIDEO_TIME_TO_LIVE; }; if (bid.advertiser_name) { From acd0a39b99980ec924826d5f3eaee7275f6dfc9d Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Wed, 5 Jan 2022 10:00:06 -0500 Subject: [PATCH 04/20] multi-imp --- modules/tripleliftBidAdapter.js | 20 +++++---- .../spec/modules/tripleliftBidAdapter_spec.js | 42 ++++++++++++++++++- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index e751e374700..5f5c968fdae 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -118,14 +118,15 @@ function _buildPostBody(bidRequests) { tagid: bidRequest.params.inventoryCode, floor: _getFloor(bidRequest) }; - // remove the else to support multi-imp - if (_videoMediaType(bidRequest) === 'instream') { + // Check for video bidrequest + if (_videoMediaType(bidRequest) === 'instream' || _videoMediaType(bidRequest) === 'outstream') { imp.video = _getORTBVideo(bidRequest); - } else if (bidRequest.mediaTypes.banner) { + } + // append banner if applicable and request is not for instream + if (bidRequest.mediaTypes.banner && _videoMediaType(bidRequest) !== 'instream') { imp.banner = { format: _sizes(bidRequest.sizes) }; - } else if (_videoMediaType(bidRequest) === 'outstream') { - imp.video = _getORTBVideo(bidRequest); } + if (!isEmpty(bidRequest.ortb2Imp)) { imp.fpd = _getAdUnitFpd(bidRequest.ortb2Imp); } @@ -178,8 +179,12 @@ function _videoMediaType(bidRequest) { function _getORTBVideo(bidRequest) { // give precedent to mediaTypes.video let video = { ...bidRequest.params.video, ...bidRequest.mediaTypes.video }; - if (!video.w) video.w = video.playerSize[0][0]; - if (!video.h) video.h = video.playerSize[0][1]; + try { + if (!video.w) video.w = video.playerSize[0][0]; + if (!video.h) video.h = video.playerSize[0][1]; + } catch (err) { + logWarn('Video size not defined', err); + } if (video.context === 'instream') video.placement = 1; if (video.context === 'outstream') video.placement = 3; // clean up oRTB object @@ -364,6 +369,7 @@ function _buildResponseObject(bidderRequest, bid) { bidResponse.meta.advertiserDomains = bid.adomain; } + // what should this be for outstream? if (bid.tl_source && bid.tl_source == 'hdx') { bidResponse.meta.mediaType = 'banner'; } diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 708d9cc3da6..46ac3f3d5fe 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -375,6 +375,37 @@ describe('triplelift adapter', function () { userId: {}, schain, }, + // banner and incomplete outstream (missing size) + { + bidder: 'triplelift', + params: { + inventoryCode: 'outstream_test', + floor: 1.0, + video: { + mimes: ['video/mp4'], + maxduration: 30, + minduration: 6 + } + }, + mediaTypes: { + video: { + context: 'outstream' + }, + 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, + }, ]; bidderRequest = { @@ -439,9 +470,10 @@ describe('triplelift adapter', function () { expect(payload.imp[1].floor).to.equal(1.0); expect(payload.imp[1].video).to.exist.and.to.be.a('object'); // banner and outstream video - expect(payload.imp[2]).to.not.have.property('video'); + expect(payload.imp[2]).to.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}]); + expect(payload.imp[2].video).to.deep.equal({'mimes': ['video/mp4'], 'maxduration': 30, 'minduration': 6, 'w': 640, 'h': 480, 'context': 'outstream', 'placement': 3}); // banner and incomplete video expect(payload.imp[3]).to.not.have.property('video'); expect(payload.imp[3]).to.have.property('banner'); @@ -455,13 +487,19 @@ describe('triplelift adapter', function () { expect(payload.imp[5]).to.have.property('video'); expect(payload.imp[5].video).to.exist.and.to.be.a('object'); // banner and outream video and native - expect(payload.imp[6]).to.not.have.property('video'); + expect(payload.imp[6]).to.have.property('video'); expect(payload.imp[6]).to.have.property('banner'); expect(payload.imp[6].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); + expect(payload.imp[6].video).to.deep.equal({'mimes': ['video/mp4'], 'maxduration': 30, 'minduration': 6, 'w': 640, 'h': 480, 'context': 'outstream', 'placement': 3}); // outstream video only expect(payload.imp[7]).to.have.property('video'); expect(payload.imp[7]).to.not.have.property('banner'); expect(payload.imp[7].video).to.deep.equal({'mimes': ['video/mp4'], 'maxduration': 30, 'minduration': 6, 'w': 640, 'h': 480, 'context': 'outstream', 'placement': 3}); + // banner and incomplete outstream (missing size); video request is permitted so banner can still monetize + expect(payload.imp[8]).to.have.property('video'); + expect(payload.imp[8]).to.have.property('banner'); + expect(payload.imp[8].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); + expect(payload.imp[8].video).to.deep.equal({'mimes': ['video/mp4'], 'maxduration': 30, 'minduration': 6, 'context': 'outstream', 'placement': 3}); }); it('should add tdid to the payload if included', function () { From 65815571e19b3fadfede8dd057a1048cd3466f7b Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Wed, 5 Jan 2022 16:07:45 -0500 Subject: [PATCH 05/20] simplify video if statement in buildPostBody --- modules/tripleliftBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 5f5c968fdae..f3010fcb452 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -119,7 +119,7 @@ function _buildPostBody(bidRequests) { floor: _getFloor(bidRequest) }; // Check for video bidrequest - if (_videoMediaType(bidRequest) === 'instream' || _videoMediaType(bidRequest) === 'outstream') { + if (_isVideoBidRequest(bidRequest)) { imp.video = _getORTBVideo(bidRequest); } // append banner if applicable and request is not for instream From 192cf7d6bee4650ed43f8cf713f6d855d7dcf542 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Thu, 6 Jan 2022 10:37:22 -0500 Subject: [PATCH 06/20] distinguish banner from video bid; temp solution for testing --- modules/tripleliftBidAdapter.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index f3010fcb452..71a235f3d94 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -355,7 +355,8 @@ function _buildResponseObject(bidderRequest, bid) { meta: {} }; - if (_isVideoBidRequest(breq)) { + // replace includes with something better; write tests + if (_isVideoBidRequest(breq) && bid.ad.includes('VAST')) { bidResponse.vastXml = bid.ad; bidResponse.mediaType = 'video'; bidResponse.ttl = VIDEO_TIME_TO_LIVE; @@ -369,9 +370,11 @@ function _buildResponseObject(bidderRequest, bid) { bidResponse.meta.advertiserDomains = bid.adomain; } - // what should this be for outstream? if (bid.tl_source && bid.tl_source == 'hdx') { bidResponse.meta.mediaType = 'banner'; + if (_isVideoBidRequest(breq) && bid.ad.includes('VAST')) { + bidResponse.meta.mediaType = 'video' + } } if (bid.tl_source && bid.tl_source == 'tlx') { From 84e82ce865a9ee7ecf9784bcf26058421dafbdf6 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Thu, 6 Jan 2022 12:33:11 -0500 Subject: [PATCH 07/20] adds tests for mediatype --- modules/tripleliftBidAdapter.js | 1 + .../spec/modules/tripleliftBidAdapter_spec.js | 131 +++++++++++++++++- 2 files changed, 125 insertions(+), 7 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 71a235f3d94..372ecd59a51 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -68,6 +68,7 @@ export const tripleliftAdapterSpec = { }, interpretResponse: function(serverResponse, {bidderRequest}) { + // console.log('interpretResponse', serverResponse, bidderRequest) let bids = serverResponse.body.bids || []; return bids.map(function(bid) { return _buildResponseObject(bidderRequest, bid); diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 46ac3f3d5fe..ff465619eec 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -916,8 +916,30 @@ describe('triplelift adapter', function () { imp_id: 1, crid: '10092_76480_i2j6qm8u', cpm: 9.99, - ad: 'The Trade Desk', - tlx_source: 'hdx' + ad: 'The Trade Desk', + tl_source: 'hdx' + }, + // video bid on banner+outstream request + { + imp_id: 2, + crid: '5989_33264_352817187', + cpm: 20, + ad: '\n \n \t', + tl_source: 'hdx', + advertiser_name: 'zennioptical.com', + adomain: ['zennioptical.com'] + }, + // banner bid on banner+outstream request + { + imp_id: 3, + crid: '5989_33264_352817187', + cpm: 20, + width: 970, + height: 250, + ad: 'ad-markup', + tl_source: 'hdx', + advertiser_name: 'zennioptical.com', + adomain: ['zennioptical.com'] } ] } @@ -943,13 +965,13 @@ describe('triplelift adapter', function () { ] } }, - bidId: '30b31c1838de1e', + bidId: '30b31c1838de1e' }, { imp_id: 1, crid: '10092_76480_i2j6qm8u', cpm: 9.99, - ad: 'The Trade Desk', + ad: 'The Trade Desk', tlx_source: 'hdx', mediaTypes: { video: { @@ -957,7 +979,89 @@ describe('triplelift adapter', function () { playerSize: [640, 480] } }, - bidId: '30b31c1838de1e', + bidId: '30b31c1838de1e' + }, + // banner and outstream + { + bidder: 'triplelift', + params: { + inventoryCode: 'Mediavine_desktop_outstream', + floor: 1 + }, + nativeParams: {}, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [[640, 480]], + mimes: ['video/mp4'], + protocols: [1, 2, 3, 4, 5, 6, 7, 8], + playbackmethod: [2], + skip: 1 + }, + banner: { + sizes: [ + [728, 90], + [970, 250], + [970, 90] + ] + }, + native: {} + }, + adUnitCode: 'video-outstream', + transactionId: '135061c3-f546-4e28-8a07-44c2fb58a958', + sizes: [ + [728, 90], + [970, 250], + [970, 90] + ], + bidId: '73edc0ba8de203', + bidderRequestId: '3d81143328560b', + auctionId: 'f6427dc0-b954-4010-a76c-d498380796a2', + src: 'client', + bidRequestsCount: 2, + bidderRequestsCount: 2, + bidderWinsCount: 0 + }, + // banner and outstream + { + bidder: 'triplelift', + params: { + inventoryCode: 'Mediavine_desktop_outstream', + floor: 1 + }, + nativeParams: {}, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [[640, 480]], + mimes: ['video/mp4'], + protocols: [1, 2, 3, 4, 5, 6, 7, 8], + playbackmethod: [2], + skip: 1 + }, + banner: { + sizes: [ + [728, 90], + [970, 250], + [970, 90] + ] + }, + native: {} + }, + adUnitCode: 'video-outstream', + transactionId: '135061c3-f546-4e28-8a07-44c2fb58a958', + sizes: [ + [728, 90], + [970, 250], + [970, 90] + ], + bidId: '73edc0ba8de203', + bidderRequestId: '3d81143328560b', + auctionId: 'f6427dc0-b954-4010-a76c-d498380796a2', + src: 'client', + bidRequestsCount: 2, + bidderRequestsCount: 2, + bidderWinsCount: 0 } ], refererInfo: { @@ -1004,16 +1108,29 @@ describe('triplelift adapter', function () { } ]; let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest}); - expect(result).to.have.length(2); + expect(result).to.have.length(4); expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); expect(Object.keys(result[1])).to.have.members(Object.keys(expectedResponse[1])); expect(result[0].ttl).to.equal(300); expect(result[1].ttl).to.equal(3600); }); + it('should identify format of bid and respond accordingly', function() { + let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest}); + expect(result[0].meta.mediaType).to.equal('native'); + expect(result[1].mediaType).to.equal('video'); + expect(result[1].meta.mediaType).to.equal('video'); + // video bid on banner+outstream request + expect(result[2].mediaType).to.equal('video'); + expect(result[2].meta.mediaType).to.equal('video'); + expect(result[2].vastXml).to.include('aid=148508128401385324170&inv_code=Mediavine_mobile_outstream'); + // banner bid on banner+outstream request + expect(result[3].meta.mediaType).to.equal('banner'); + }) + it('should return multiple responses to support SRA', function () { let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest}); - expect(result).to.have.length(2); + expect(result).to.have.length(4); }); it('should include the advertiser name in the meta field if available', function () { From 76d16e05c650d9d2677a7adff9e0d5a168ce3aae Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Thu, 6 Jan 2022 13:09:56 -0500 Subject: [PATCH 08/20] remove console log --- modules/tripleliftBidAdapter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 372ecd59a51..71a235f3d94 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -68,7 +68,6 @@ export const tripleliftAdapterSpec = { }, interpretResponse: function(serverResponse, {bidderRequest}) { - // console.log('interpretResponse', serverResponse, bidderRequest) let bids = serverResponse.body.bids || []; return bids.map(function(bid) { return _buildResponseObject(bidderRequest, bid); From 3d72c330f2451d5d2ef5ef3fc849a575219cb4f8 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Tue, 11 Jan 2022 11:31:53 -0500 Subject: [PATCH 09/20] individual instream/outstream tests --- modules/tripleliftBidAdapter.js | 48 +++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 71a235f3d94..e5bfd983717 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -123,7 +123,7 @@ function _buildPostBody(bidRequests) { imp.video = _getORTBVideo(bidRequest); } // append banner if applicable and request is not for instream - if (bidRequest.mediaTypes.banner && _videoMediaType(bidRequest) !== 'instream') { + if (bidRequest.mediaTypes.banner && !_IsInstream(bidRequest)) { imp.banner = { format: _sizes(bidRequest.sizes) }; } @@ -155,27 +155,47 @@ function _buildPostBody(bidRequests) { } function _isVideoBidRequest(bidRequest) { - if (!bidRequest.mediaTypes.video) return false; - if (!bidRequest.mediaTypes.video.context) return false; - if ( - bidRequest.mediaTypes.video.context.toLowerCase() === 'instream' || - bidRequest.mediaTypes.video.context.toLowerCase() === 'outstream' - ) { - return true; + if (_isValidVideoObject(bidRequest)) { + if (_IsInstream(bidRequest) || _IsOutstream(bidRequest)) { + return true; + } else { + return false; + } + } else { + return false; + } +} + +function _IsInstream(bidRequest) { + if (_isValidVideoObject(bidRequest)) { + if (bidRequest.mediaTypes.video.context.toLowerCase() === 'instream') { + return true; + } else { + return false; + } } else { return false; } } -function _videoMediaType(bidRequest) { - if (!_isVideoBidRequest(bidRequest)) return null - if (bidRequest.mediaTypes.video.context.toLowerCase() === 'instream') { - return 'instream' - } else if (bidRequest.mediaTypes.video.context.toLowerCase() === 'outstream') { - return 'outstream' +function _IsOutstream(bidRequest) { + if (_isValidVideoObject(bidRequest)) { + if (bidRequest.mediaTypes.video.context.toLowerCase() === 'outstream') { + return true; + } else { + return false; + } + } else { + return false; } } +function _isValidVideoObject(bidRequest) { + if (!bidRequest.mediaTypes.video) return false; + if (!bidRequest.mediaTypes.video.context) return false; + return true; +} + function _getORTBVideo(bidRequest) { // give precedent to mediaTypes.video let video = { ...bidRequest.params.video, ...bidRequest.mediaTypes.video }; From 8dd055b3623d018c2cd753aa197fe4c0455200e4 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Tue, 11 Jan 2022 11:43:45 -0500 Subject: [PATCH 10/20] simplify some functions --- modules/tripleliftBidAdapter.js | 38 ++++++--------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index e5bfd983717..6f6d8a2cf42 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -155,45 +155,19 @@ function _buildPostBody(bidRequests) { } function _isVideoBidRequest(bidRequest) { - if (_isValidVideoObject(bidRequest)) { - if (_IsInstream(bidRequest) || _IsOutstream(bidRequest)) { - return true; - } else { - return false; - } - } else { - return false; - } + return _isValidVideoObject(bidRequest) && (_IsInstream(bidRequest) || _IsOutstream(bidRequest)); } -function _IsInstream(bidRequest) { - if (_isValidVideoObject(bidRequest)) { - if (bidRequest.mediaTypes.video.context.toLowerCase() === 'instream') { - return true; - } else { - return false; - } - } else { - return false; - } +function _IsOutstream(bidRequest) { + return _isValidVideoObject(bidRequest) && bidRequest.mediaTypes.video.context.toLowerCase() === 'outstream'; } -function _IsOutstream(bidRequest) { - if (_isValidVideoObject(bidRequest)) { - if (bidRequest.mediaTypes.video.context.toLowerCase() === 'outstream') { - return true; - } else { - return false; - } - } else { - return false; - } +function _IsInstream(bidRequest) { + return _isValidVideoObject(bidRequest) && bidRequest.mediaTypes.video.context.toLowerCase() === 'instream'; } function _isValidVideoObject(bidRequest) { - if (!bidRequest.mediaTypes.video) return false; - if (!bidRequest.mediaTypes.video.context) return false; - return true; + return bidRequest.mediaTypes.video && bidRequest.mediaTypes.video.context; } function _getORTBVideo(bidRequest) { From 735a137dad22f9ed24483260190c08e7b1d5e8ce Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Tue, 11 Jan 2022 17:25:07 -0500 Subject: [PATCH 11/20] nitpick --- modules/tripleliftBidAdapter.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 6f6d8a2cf42..05defab0a5f 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -123,7 +123,7 @@ function _buildPostBody(bidRequests) { imp.video = _getORTBVideo(bidRequest); } // append banner if applicable and request is not for instream - if (bidRequest.mediaTypes.banner && !_IsInstream(bidRequest)) { + if (bidRequest.mediaTypes.banner && !_isInstream(bidRequest)) { imp.banner = { format: _sizes(bidRequest.sizes) }; } @@ -155,14 +155,14 @@ function _buildPostBody(bidRequests) { } function _isVideoBidRequest(bidRequest) { - return _isValidVideoObject(bidRequest) && (_IsInstream(bidRequest) || _IsOutstream(bidRequest)); + return _isValidVideoObject(bidRequest) && (_isInstream(bidRequest) || _isOutstream(bidRequest)); } -function _IsOutstream(bidRequest) { +function _isOutstream(bidRequest) { return _isValidVideoObject(bidRequest) && bidRequest.mediaTypes.video.context.toLowerCase() === 'outstream'; } -function _IsInstream(bidRequest) { +function _isInstream(bidRequest) { return _isValidVideoObject(bidRequest) && bidRequest.mediaTypes.video.context.toLowerCase() === 'instream'; } From 343ae519b77beadab3050d07055bb2c3f6280f75 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Fri, 4 Feb 2022 14:19:03 -0500 Subject: [PATCH 12/20] adds media_type check --- modules/tripleliftBidAdapter.js | 8 ++++---- test/spec/modules/tripleliftBidAdapter_spec.js | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 05defab0a5f..4fd647d67aa 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -349,8 +349,7 @@ function _buildResponseObject(bidderRequest, bid) { meta: {} }; - // replace includes with something better; write tests - if (_isVideoBidRequest(breq) && bid.ad.includes('VAST')) { + if (_isVideoBidRequest(breq) && bid.media_type === "video") { bidResponse.vastXml = bid.ad; bidResponse.mediaType = 'video'; bidResponse.ttl = VIDEO_TIME_TO_LIVE; @@ -365,9 +364,10 @@ function _buildResponseObject(bidderRequest, bid) { } if (bid.tl_source && bid.tl_source == 'hdx') { - bidResponse.meta.mediaType = 'banner'; - if (_isVideoBidRequest(breq) && bid.ad.includes('VAST')) { + if (_isVideoBidRequest(breq) && bid.media_type === "video") { bidResponse.meta.mediaType = 'video' + } else { + bidResponse.meta.mediaType = 'banner' } } diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index ff465619eec..f95b4bb1b67 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -910,14 +910,16 @@ describe('triplelift adapter', function () { iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg', tl_source: 'tlx', advertiser_name: 'fake advertiser name', - adomain: ['basspro.com', 'internetalerts.org'] + adomain: ['basspro.com', 'internetalerts.org'], + media_type: 'banner' }, { imp_id: 1, crid: '10092_76480_i2j6qm8u', cpm: 9.99, ad: 'The Trade Desk', - tl_source: 'hdx' + tl_source: 'hdx', + media_type: 'video' }, // video bid on banner+outstream request { @@ -927,7 +929,8 @@ describe('triplelift adapter', function () { ad: '\n \n \t', tl_source: 'hdx', advertiser_name: 'zennioptical.com', - adomain: ['zennioptical.com'] + adomain: ['zennioptical.com'], + media_type: 'video' }, // banner bid on banner+outstream request { @@ -939,7 +942,8 @@ describe('triplelift adapter', function () { ad: 'ad-markup', tl_source: 'hdx', advertiser_name: 'zennioptical.com', - adomain: ['zennioptical.com'] + adomain: ['zennioptical.com'], + media_type: 'banner' } ] } From dfba5d873aa3e7d70a5b6f9b9d5697779574421b Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Tue, 15 Mar 2022 11:31:07 -0400 Subject: [PATCH 13/20] adds placement options to outstream --- modules/tripleliftBidAdapter.js | 14 +- .../spec/modules/tripleliftBidAdapter_spec.js | 174 ++++++++++++++++++ 2 files changed, 185 insertions(+), 3 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 4fd647d67aa..d731894555b 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -180,7 +180,15 @@ function _getORTBVideo(bidRequest) { logWarn('Video size not defined', err); } if (video.context === 'instream') video.placement = 1; - if (video.context === 'outstream') video.placement = 3; + if (video.context === 'outstream') { + if (!video.placement) { + video.placement = 3 + } else if ([3, 4, 5].indexOf(video.placement) === -1) { + logMessage(`video.placement value of ${video.placement} is invalid for outstream context. Setting placement to 3`) + video.placement = 3 + } + } + // clean up oRTB object delete video.playerSize; return video; @@ -349,7 +357,7 @@ function _buildResponseObject(bidderRequest, bid) { meta: {} }; - if (_isVideoBidRequest(breq) && bid.media_type === "video") { + if (_isVideoBidRequest(breq) && bid.media_type === 'video') { bidResponse.vastXml = bid.ad; bidResponse.mediaType = 'video'; bidResponse.ttl = VIDEO_TIME_TO_LIVE; @@ -364,7 +372,7 @@ function _buildResponseObject(bidderRequest, bid) { } if (bid.tl_source && bid.tl_source == 'hdx') { - if (_isVideoBidRequest(breq) && bid.media_type === "video") { + if (_isVideoBidRequest(breq) && bid.media_type === 'video') { bidResponse.meta.mediaType = 'video' } else { bidResponse.meta.mediaType = 'banner' diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index f95b4bb1b67..2277f9c23b9 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -406,6 +406,150 @@ describe('triplelift adapter', function () { userId: {}, schain, }, + // outstream video; valid placement + { + 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], + placement: 3 + } + }, + adUnitCode: 'adunit-code-instream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + }, + // outstream video; valid placement + { + 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], + placement: 4 + } + }, + adUnitCode: 'adunit-code-instream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + }, + // outstream video; valid placement + { + 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], + placement: 5 + } + }, + adUnitCode: 'adunit-code-instream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + }, + // outstream video; undefined placement + { + 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] + } + }, + adUnitCode: 'adunit-code-instream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + }, + // outstream video; invalid placement + { + 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], + placement: 6 + } + }, + adUnitCode: 'adunit-code-instream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + } ]; bidderRequest = { @@ -502,6 +646,36 @@ describe('triplelift adapter', function () { expect(payload.imp[8].video).to.deep.equal({'mimes': ['video/mp4'], 'maxduration': 30, 'minduration': 6, 'context': 'outstream', 'placement': 3}); }); + it('should check for valid outstream placement values', function () { + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + const payload = request.data; + // outstream video; valid placement + expect(payload.imp[9]).to.not.have.property('banner'); + expect(payload.imp[9]).to.have.property('video'); + expect(payload.imp[9].video).to.exist.and.to.be.a('object'); + expect(payload.imp[9].video.placement).to.equal(3); + // outstream video; valid placement + expect(payload.imp[10]).to.not.have.property('banner'); + expect(payload.imp[10]).to.have.property('video'); + expect(payload.imp[10].video).to.exist.and.to.be.a('object'); + expect(payload.imp[10].video.placement).to.equal(4); + // outstream video; valid placement + expect(payload.imp[11]).to.not.have.property('banner'); + expect(payload.imp[11]).to.have.property('video'); + expect(payload.imp[11].video).to.exist.and.to.be.a('object'); + expect(payload.imp[11].video.placement).to.equal(5); + // outstream video; undefined placement + expect(payload.imp[12]).to.not.have.property('banner'); + expect(payload.imp[12]).to.have.property('video'); + expect(payload.imp[12].video).to.exist.and.to.be.a('object'); + expect(payload.imp[12].video.placement).to.equal(3); + // outstream video; invalid placement + expect(payload.imp[13]).to.not.have.property('banner'); + expect(payload.imp[13]).to.have.property('video'); + expect(payload.imp[13].video).to.exist.and.to.be.a('object'); + expect(payload.imp[13].video.placement).to.equal(3); + }); + it('should add tdid to the payload if included', function () { const id = '6bca7f6b-a98a-46c0-be05-6020f7604598'; bidRequests[0].userId.tdid = id; From e18efc11b2028352039d41fff42b6613cc34a55d Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Wed, 16 Mar 2022 12:18:37 -0400 Subject: [PATCH 14/20] checks instream placement values --- test/spec/modules/tripleliftBidAdapter_spec.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 2277f9c23b9..134f58d6e50 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -610,9 +610,11 @@ describe('triplelift adapter', function () { expect(payload.imp[0].tagid).to.equal('12345'); expect(payload.imp[0].floor).to.equal(1.0); expect(payload.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); + // instream 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[1].video.placement).to.equal(1); // banner and outstream video expect(payload.imp[2]).to.have.property('video'); expect(payload.imp[2]).to.have.property('banner'); @@ -630,6 +632,7 @@ describe('triplelift adapter', function () { expect(payload.imp[5]).to.not.have.property('banner'); expect(payload.imp[5]).to.have.property('video'); expect(payload.imp[5].video).to.exist.and.to.be.a('object'); + expect(payload.imp[5].video.placement).to.equal(1); // banner and outream video and native expect(payload.imp[6]).to.have.property('video'); expect(payload.imp[6]).to.have.property('banner'); From 33c780c16a970a9c5e6eab510e792d42e18f3ae4 Mon Sep 17 00:00:00 2001 From: Patrick Loughrey Date: Mon, 4 Apr 2022 22:24:02 -0400 Subject: [PATCH 15/20] TL-19850 Finished log error logic around floors functionality --- modules/tripleliftBidAdapter.js | 22 +++++++++++-------- .../spec/modules/tripleliftBidAdapter_spec.js | 22 +++++++++++++++++++ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 215769e9812..934070e13a8 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -1,4 +1,4 @@ -import { tryAppendQueryString, logMessage, isEmpty, isStr, isPlainObject, isArray, logWarn } from '../src/utils.js'; +import { tryAppendQueryString, logMessage, logError, isEmpty, isStr, isPlainObject, isArray, logWarn } from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; @@ -175,14 +175,18 @@ function _getORTBVideo(bidRequest) { function _getFloor (bid) { let floor = null; if (typeof bid.getFloor === 'function') { - const floorInfo = bid.getFloor({ - currency: 'USD', - mediaType: _isInstreamBidRequest(bid) ? 'video' : 'banner', - size: '*' - }); - if (typeof floorInfo === 'object' && - floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) { - floor = parseFloat(floorInfo.floor); + try { + const floorInfo = bid.getFloor({ + currency: 'USD', + mediaType: _isInstreamBidRequest(bid) ? 'video' : 'banner', + size: '*' + }); + if (typeof floorInfo === 'object' && + floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) { + floor = parseFloat(floorInfo.floor); + } + } catch (err) { + logError('Triplelift: getFloor threw an error: ', err); } } return floor !== null ? floor : bid.params.floor; diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 6f2674dadc5..196a95349bf 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -787,6 +787,28 @@ describe('triplelift adapter', function () { size: '*' })).to.be.true; }); + it('should not set bid floor if currency is not USD', function() { + bidRequests.forEach(request => { + request.getFloor = () => {}; + sinon.spy(request, 'getFloor') + }); + + tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + + // banner request with non-USD currency + expect(bidRequests[0].getFloor.calledWith({ + currency: 'EUR', + mediaType: 'banner', + size: '*' + })).to.be.false; + + // banner request with non-USD currency + expect(bidRequests[1].getFloor.calledWith({ + currency: 'CAD', + mediaType: 'video', + size: '*' + })).to.be.false; + }); it('should send global config fpd if kvps are available', function() { const sens = null; const category = ['news', 'weather', 'hurricane']; From 905e884ca7d87344b27bfe890d5b795fa87f423b Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Thu, 7 Apr 2022 16:41:33 -0400 Subject: [PATCH 16/20] deprecates getlegacyFpd --- modules/tripleliftBidAdapter.js | 4 ++-- test/spec/modules/tripleliftBidAdapter_spec.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 215769e9812..830d26eda61 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -192,9 +192,9 @@ function _getGlobalFpd() { const fpd = {}; const context = {} const user = {}; - const ortbData = config.getLegacyFpd(config.getConfig('ortb2')) || {}; + const ortbData = config.getConfig('ortb2') || {}; - const fpdContext = Object.assign({}, ortbData.context); + const fpdContext = Object.assign({}, ortbData.site); const fpdUser = Object.assign({}, ortbData.user); _addEntries(context, fpdContext); diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 6f2674dadc5..1f17c67c99c 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -812,8 +812,9 @@ describe('triplelift adapter', function () { }); const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const { data: payload } = request; + console.log(JSON.stringify(payload)) expect(payload.ext.fpd.user).to.not.exist; - expect(payload.ext.fpd.context.data).to.haveOwnProperty('category'); + expect(payload.ext.fpd.context.ext.data).to.haveOwnProperty('category'); expect(payload.ext.fpd.context).to.haveOwnProperty('pmp_elig'); }); it('should send ad unit fpd if kvps are available', function() { From c2650c2c4a526a416b04e7976ddf4cbce964710b Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Thu, 7 Apr 2022 16:57:45 -0400 Subject: [PATCH 17/20] remove console log --- test/spec/modules/tripleliftBidAdapter_spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 1f17c67c99c..164188804a3 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -812,7 +812,6 @@ describe('triplelift adapter', function () { }); const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const { data: payload } = request; - console.log(JSON.stringify(payload)) expect(payload.ext.fpd.user).to.not.exist; expect(payload.ext.fpd.context.ext.data).to.haveOwnProperty('category'); expect(payload.ext.fpd.context).to.haveOwnProperty('pmp_elig'); From 0ebf51ca012afc0c95e5c9278e4f8e39e665c644 Mon Sep 17 00:00:00 2001 From: Patrick Loughrey Date: Wed, 20 Apr 2022 10:28:57 -0400 Subject: [PATCH 18/20] TL-19850 Changed functionlity of tests --- .../spec/modules/tripleliftBidAdapter_spec.js | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 196a95349bf..0d463912cc6 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -787,27 +787,16 @@ describe('triplelift adapter', function () { size: '*' })).to.be.true; }); - it('should not set bid floor if currency is not USD', function() { - bidRequests.forEach(request => { - request.getFloor = () => {}; - sinon.spy(request, 'getFloor') - }); + it('should catch error if getFloor throws error', function() { + let logErrorSpy = sinon.spy(utils, 'logError'); - tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + bidRequests[0].getFloor = () => { + throw new Error('An exception!'); + }; - // banner request with non-USD currency - expect(bidRequests[0].getFloor.calledWith({ - currency: 'EUR', - mediaType: 'banner', - size: '*' - })).to.be.false; + tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); - // banner request with non-USD currency - expect(bidRequests[1].getFloor.calledWith({ - currency: 'CAD', - mediaType: 'video', - size: '*' - })).to.be.false; + expect(logErrorSpy.calledOnce).to.equal(true); }); it('should send global config fpd if kvps are available', function() { const sens = null; From 3b347240484c7399a969bfbd793e990ccad65f70 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Fri, 29 Apr 2022 12:22:58 -0400 Subject: [PATCH 19/20] restore logErrorSpy aftereach --- test/spec/modules/tripleliftBidAdapter_spec.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 2a326376532..fc33a7cd676 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -11,8 +11,7 @@ const GDPR_CONSENT_STR = 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7V describe('triplelift adapter', function () { const adapter = newBidder(tripleliftAdapterSpec); - let bid, instreamBid; - let sandbox; + let bid, instreamBid, sandbox, logErrorSpy; this.beforeEach(() => { bid = { @@ -379,9 +378,11 @@ describe('triplelift adapter', function () { }, }; sandbox = sinon.sandbox.create(); + logErrorSpy = sinon.spy(utils, 'logError'); }); afterEach(() => { sandbox.restore(); + utils.logError.restore(); }); it('exists and is an object', function () { @@ -788,8 +789,6 @@ describe('triplelift adapter', function () { })).to.be.true; }); it('should catch error if getFloor throws error', function() { - let logErrorSpy = sinon.spy(utils, 'logError'); - bidRequests[0].getFloor = () => { throw new Error('An exception!'); }; From d1b617ef436773a12fb57b57f15adf621b29571c Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Tue, 19 Jul 2022 11:56:57 -0400 Subject: [PATCH 20/20] removing pub name from test --- test/spec/modules/tripleliftBidAdapter_spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 8d0099367dc..bfcfce1ccb4 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -1176,7 +1176,7 @@ describe('triplelift adapter', function () { imp_id: 2, crid: '5989_33264_352817187', cpm: 20, - ad: '\n \n \t', + ad: '\n \n \t', tl_source: 'hdx', advertiser_name: 'zennioptical.com', adomain: ['zennioptical.com'], @@ -1239,7 +1239,7 @@ describe('triplelift adapter', function () { { bidder: 'triplelift', params: { - inventoryCode: 'Mediavine_desktop_outstream', + inventoryCode: 'testing_desktop_outstream', floor: 1 }, nativeParams: {}, @@ -1280,7 +1280,7 @@ describe('triplelift adapter', function () { { bidder: 'triplelift', params: { - inventoryCode: 'Mediavine_desktop_outstream', + inventoryCode: 'testing_desktop_outstream', floor: 1 }, nativeParams: {}, @@ -1377,7 +1377,7 @@ describe('triplelift adapter', function () { // video bid on banner+outstream request expect(result[2].mediaType).to.equal('video'); expect(result[2].meta.mediaType).to.equal('video'); - expect(result[2].vastXml).to.include('aid=148508128401385324170&inv_code=Mediavine_mobile_outstream'); + expect(result[2].vastXml).to.include('aid=148508128401385324170&inv_code=testing_mobile_outstream'); // banner bid on banner+outstream request expect(result[3].meta.mediaType).to.equal('banner'); })