From f1c738f91907f3a7aee6b2db24b6275e6a252612 Mon Sep 17 00:00:00 2001 From: Chris Corbo Date: Tue, 6 Jun 2023 15:45:38 -0400 Subject: [PATCH] feat: pass video.plcmt [PB-1736] --- modules/ixBidAdapter.js | 13 ++++++++++- test/spec/modules/ixBidAdapter_spec.js | 30 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/modules/ixBidAdapter.js b/modules/ixBidAdapter.js index 736b3336cd8..13ba1a11530 100644 --- a/modules/ixBidAdapter.js +++ b/modules/ixBidAdapter.js @@ -96,7 +96,7 @@ const VIDEO_PARAMS_ALLOW_LIST = [ 'skipafter', 'sequence', 'battr', 'maxextended', 'minbitrate', 'maxbitrate', 'boxingallowed', 'playbackmethod', 'playbackend', 'delivery', 'pos', 'companionad', 'api', 'companiontype', 'ext', - 'playerSize', 'w', 'h' + 'playerSize', 'w', 'h', 'plcmt' ]; const LOCAL_STORAGE_KEY = 'ixdiag'; export const LOCAL_STORAGE_FEATURE_TOGGLES_KEY = `${BIDDER_CODE}_features`; @@ -216,6 +216,8 @@ function bidToVideoImp(bid) { const context = (videoParamRef && videoParamRef.context) || (videoAdUnitRef && videoAdUnitRef.context); + verifyVideoPlcmt(imp); + // if placement not already defined, pick one based on `context` if (context && !imp.video.hasOwnProperty('placement')) { if (context === INSTREAM) { @@ -249,6 +251,15 @@ function bidToVideoImp(bid) { return imp; } +function verifyVideoPlcmt(imp) { + if (imp.video.hasOwnProperty('plcmt') && (!isInteger(imp.video.plcmt) || (imp.video.plcmt < 1 || imp.video.plcmt > 4))) { + logWarn( + `IX Bid Adapter: video.plcmt [${imp.video.plcmt}] must be an integer between 1-4 inclusive` + ); + delete imp.video.plcmt; + } +} + /** * Transform valid bid request config object to native impression object that will be sent to ad server. * diff --git a/test/spec/modules/ixBidAdapter_spec.js b/test/spec/modules/ixBidAdapter_spec.js index 967aec46d71..7c446150b86 100644 --- a/test/spec/modules/ixBidAdapter_spec.js +++ b/test/spec/modules/ixBidAdapter_spec.js @@ -2570,6 +2570,36 @@ describe('IndexexchangeAdapter', function () { expect(impression.video.placement).to.equal(2); }); + it('should use plcmt value when set in video.params', function () { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + bid.params.video.plcmt = 2; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; + + expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId); + expect(impression.video.plcmt).to.equal(2); + }); + + it('invalid plcmt value when set in video.params', function () { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + bid.params.video.plcmt = 5; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; + + expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId); + expect(impression.video.plcmt).to.be.undefined; + }); + + it('invalid plcmt value string when set in video.params', function () { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + bid.params.video.plcmt = '4'; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; + + expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId); + expect(impression.video.plcmt).to.be.undefined; + }); + it('should set imp.ext.sid for video imps if params.id exists', function () { const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); bid.params.id = 50;