Skip to content

Commit

Permalink
Pubmatic Bid Adapter: video.placement param missing message in debug (p…
Browse files Browse the repository at this point in the history
…rebid#7561)

* Added video.placement param missing debug message

* Added Adunit code along with message

* Updated test cases for video placement missing scenario

Co-authored-by: Kapil Tuptewar <[email protected]>
  • Loading branch information
kapil-tuptewar and Kapil Tuptewar authored Oct 12, 2021
1 parent a9e1060 commit 7123eae
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
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);
})
});
});
});

0 comments on commit 7123eae

Please sign in to comment.