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

IX Bid Adapter: Signal video.plcmt #10058

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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