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

BlueBillyWig Bid Adapter: add renderer customization options #6540

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
10 changes: 8 additions & 2 deletions modules/bluebillywigBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const BB_CONSTANTS = {
const getConfig = config.getConfig;

// Helper Functions
export const BB_HELPERS = {
const BB_HELPERS = {
addSiteAppDevice: function(request, pageUrl) {
if (typeof getConfig('app') === 'object') request.app = getConfig('app');
else {
Expand Down Expand Up @@ -151,7 +151,7 @@ const BB_RENDERER = {
const ele = document.getElementById(bid.adUnitCode); // NB convention
const renderer = find(window.bluebillywig.renderers, r => r._id === rendererId);

if (renderer) renderer.bootstrap(config, ele);
if (renderer) renderer.bootstrap(config, ele, bid.rendererSettings || {});
else utils.logWarn(`${BB_CONSTANTS.BIDDER_CODE}: Couldn't find a renderer with ${rendererId}`);
},
newRenderer: function(rendererUrl, adUnitCode) {
Expand Down Expand Up @@ -235,6 +235,11 @@ export const spec = {
return false;
}

if (bid.params.hasOwnProperty('rendererSettings') && (bid.params.rendererSettings === null || typeof bid.params.rendererSettings !== 'object')) {
utils.logError(`${BB_CONSTANTS.BIDDER_CODE}: params.rendererSettings must be of type object. Rejecting bid: `, bid);
return false;
}

if (bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty(VIDEO)) {
if (!bid.mediaTypes[VIDEO].hasOwnProperty('context')) {
utils.logError(`${BB_CONSTANTS.BIDDER_CODE}: no context specified in bid. Rejecting bid: `, bid);
Expand Down Expand Up @@ -330,6 +335,7 @@ export const spec = {
bid.publicationName = bidParams.publicationName;
bid.rendererCode = bidParams.rendererCode;
bid.accountId = bidParams.accountId;
bid.rendererSettings = bidParams.rendererSettings;

const rendererUrl = BB_HELPERS.getRendererUrl(bid.publicationName, bid.rendererCode);
bid.renderer = BB_RENDERER.newRenderer(rendererUrl, bid.adUnitCode);
Expand Down
19 changes: 19 additions & 0 deletions test/spec/modules/bluebillywigBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,25 @@ describe('BlueBillywigAdapter', () => {
bid.params.video = void (0);
expect(spec.isBidRequestValid(bid)).to.equal(false);
});

it('should fail if rendererSettings is specified but is not an object', () => {
const bid = deepClone(baseValidBid);

bid.params.rendererSettings = null;
expect(spec.isBidRequestValid(bid)).to.equal(false);

bid.params.rendererSettings = 'string';
expect(spec.isBidRequestValid(bid)).to.equal(false);

bid.params.rendererSettings = 123;
expect(spec.isBidRequestValid(bid)).to.equal(false);

bid.params.rendererSettings = false;
expect(spec.isBidRequestValid(bid)).to.equal(false);

bid.params.rendererSettings = void (0);
expect(spec.isBidRequestValid(bid)).to.equal(false);
});
});

describe('buildRequests', () => {
Expand Down