Skip to content

Commit

Permalink
feat: pass video.plcmt [PB-1736] (#10058)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Corbo <[email protected]>
  • Loading branch information
ccorbo and Chris Corbo authored Jun 6, 2023
1 parent 68d4150 commit c2900ea
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
13 changes: 12 additions & 1 deletion modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
*
Expand Down
30 changes: 30 additions & 0 deletions test/spec/modules/ixBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c2900ea

Please sign in to comment.