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

Pubmatic Bid Adapter: video.placement param missing message in debug #7561

Merged
merged 3 commits into from
Oct 12, 2021
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
9 changes: 9 additions & 0 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const DEFAULT_HEIGHT = 0;
const PREBID_NATIVE_HELP_LINK = 'http://prebid.org/dev-docs/show-native-ads.html';
const PUBLICATION = 'pubmatic'; // Your publication on Blue Billywig, potentially with environment (e.g. publication.bbvms.com or publication.test.bbvms.com)
const RENDERER_URL = 'https://pubmatic.bbvms.com/r/'.concat('$RENDERER', '.js'); // URL of the renderer application
const MSG_VIDEO_PLACEMENT_MISSING = 'Video.Placement param missing';
const CUSTOM_PARAMS = {
'kadpageurl': '', // Custom page url
'gender': '', // User gender
Expand Down Expand Up @@ -537,12 +538,20 @@ function _createBannerRequest(bid) {
return bannerObj;
}

export function checkVideoPlacement(videoData, adUnitCode) {
// Check for video.placement property. If property is missing display log message.
if (!deepAccess(videoData, 'placement')) {
logWarn(MSG_VIDEO_PLACEMENT_MISSING + ' for ' + adUnitCode);
};
}

function _createVideoRequest(bid) {
var videoData = mergeDeep(deepAccess(bid.mediaTypes, 'video'), bid.params.video);
var videoObj;

if (videoData !== UNDEFINED) {
videoObj = {};
checkVideoPlacement(videoData, bid.adUnitCode);
for (var key in VIDEO_CUSTOM_PARAMS) {
if (videoData.hasOwnProperty(key)) {
videoObj[key] = _checkParamDataType(key, videoData[key], VIDEO_CUSTOM_PARAMS[key]);
Expand Down
40 changes: 39 additions & 1 deletion test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expect} from 'chai';
import {spec} from 'modules/pubmaticBidAdapter.js';
import {spec, checkVideoPlacement} from 'modules/pubmaticBidAdapter.js';
import * as utils from 'src/utils.js';
import {config} from 'src/config.js';
import { createEidsArray } from 'modules/userId/eids.js';
Expand Down Expand Up @@ -3822,5 +3822,43 @@ describe('PubMatic adapter', function () {
expect(bidRequests[0].params.dctr).to.equal('key1:val1,val2|key2:val1');
});
})

describe('Checking for Video.Placement property', function() {
let sandbox, utilsMock;
const adUnit = 'Div1';
const msg_placement_missing = 'Video.Placement param missing for Div1';
let videoData = {
battr: [6, 7],
skipafter: 15,
maxduration: 50,
context: 'instream',
playerSize: [640, 480],
skip: 0,
connectiontype: [1, 2, 6],
skipmin: 10,
minduration: 10,
mimes: ['video/mp4', 'video/x-flv'],
}
beforeEach(() => {
utilsMock = sinon.mock(utils);
sandbox = sinon.sandbox.create();
sandbox.spy(utils, 'logWarn');
});

afterEach(() => {
utilsMock.restore();
sandbox.restore();
})

it('should log Video.Placement param missing', function() {
checkVideoPlacement(videoData, adUnit);
sinon.assert.calledWith(utils.logWarn, msg_placement_missing);
})
it('shoud not log Video.Placement param missing', function() {
videoData['placement'] = 1;
checkVideoPlacement(videoData, adUnit);
sinon.assert.neverCalledWith(utils.logWarn, msg_placement_missing);
})
});
});
});