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

Show warning if bidCpmAdjustment is set for AOL bidder (closes #725) … #1

Merged
merged 1 commit into from
Oct 26, 2016
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: 13 additions & 0 deletions src/adapters/aol.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const bidmanager = require('../bidmanager.js');

const AolAdapter = function AolAdapter() {

let showCpmAdjustmentWarning = true;
const pubapiTemplate = template`${'protocol'}://${'host'}/pubapi/3.0/${'network'}/${'placement'}/${'pageid'}/${'sizeid'}/ADTECH;v=2;cmd=bid;cors=yes;alias=${'alias'}${'bidfloor'};misc=${'misc'}`;
const BIDDER_CODE = 'aol';
const SERVER_MAP = {
Expand Down Expand Up @@ -117,6 +118,18 @@ const AolAdapter = function AolAdapter() {
const pubapiUrl = _buildPubapiUrl(bid);

ajax(pubapiUrl, response => {
// needs to be here in case bidderSettings are defined after requestBids() is called
if (showCpmAdjustmentWarning &&
$$PREBID_GLOBAL$$.bidderSettings && $$PREBID_GLOBAL$$.bidderSettings.aol &&
typeof $$PREBID_GLOBAL$$.bidderSettings.aol.bidCpmAdjustment === 'function'
) {
utils.logWarn(
'bidCpmAdjustment is active for the AOL adapter. ' +
'As of Prebid 0.14, AOL can bid in net – please contact your accounts team to enable.'
);
}
showCpmAdjustmentWarning = false; // warning is shown at most once

if (!response && response.length <= 0) {
utils.logError('Empty bid response', BIDDER_CODE, bid);
_addErrorBidResponse(bid, response);
Expand Down
32 changes: 32 additions & 0 deletions test/spec/adapters/aol_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {expect} from 'chai';
import _ from 'lodash';
import * as utils from 'src/utils';
import AolAdapter from 'src/adapters/aol';
import bidmanager from 'src/bidmanager';

Expand Down Expand Up @@ -430,5 +431,36 @@ describe('AolAdapter', () => {
expect(bidResponse.cpm).to.equal('a9334987');
});
});

describe('when bidCpmAdjustment is set', () => {
let bidderSettingsBackup;
let server;

beforeEach(() => {
bidderSettingsBackup = $$PREBID_GLOBAL$$.bidderSettings;
server = sinon.fakeServer.create();
});

afterEach(() => {
$$PREBID_GLOBAL$$.bidderSettings = bidderSettingsBackup;
server.restore();
if (console.warn.restore) {
console.warn.restore();
}
});

it('should show warning in the console', function() {
sinon.spy(utils, 'logWarn');
server.respondWith(JSON.stringify(DEFAULT_PUBAPI_RESPONSE));
$$PREBID_GLOBAL$$.bidderSettings = {
aol: {
bidCpmAdjustment: function() {}
}
};
adapter.callBids(DEFAULT_BIDDER_REQUEST);
server.respond();
expect(utils.logWarn.calledOnce).to.be.true;
});
});
});
});