Skip to content

Commit

Permalink
Debug update and remove setConfig hook (prebid#4007)
Browse files Browse the repository at this point in the history
* Debug update and remove setConfig hook

* fix config failing on circular dependency with utils
  • Loading branch information
jsnellbaker authored and leonardlabat committed Jul 30, 2019
1 parent 5c0b06d commit 0e40b77
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
10 changes: 6 additions & 4 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import { isValidPriceConfig } from './cpmBucketManager';
import find from 'core-js/library/fn/array/find';
import includes from 'core-js/library/fn/array/includes';
import { hook } from './hook';
import { parseQS } from './url';

const utils = require('./utils');
const CONSTANTS = require('./constants');

const DEFAULT_DEBUG = false;
const DEFAULT_DEBUG = (parseQS(window.location.search)[CONSTANTS.DEBUG_MODE] || '').toUpperCase() === 'TRUE';
const DEFAULT_BIDDER_TIMEOUT = 3000;
const DEFAULT_PUBLISHER_DOMAIN = window.location.origin;
const DEFAULT_ENABLE_SEND_ALL_BIDS = true;
Expand Down Expand Up @@ -231,7 +233,7 @@ export function newConfig() {
* Sets configuration given an object containing key-value pairs and calls
* listeners that were added by the `subscribe` function
*/
let setConfig = hook('async', function setConfig(options) {
function setConfig(options) {
if (typeof options !== 'object') {
utils.logError('setConfig options must be an object');
return;
Expand All @@ -251,7 +253,7 @@ export function newConfig() {
});

callSubscribers(topicalConfig);
});
}

/**
* Sets configuration defaults which setConfig values can be applied on top of
Expand Down
8 changes: 0 additions & 8 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import includes from 'core-js/library/fn/array/includes';
import { parse } from './url';
const CONSTANTS = require('./constants');

var _loggingChecked = false;

var tArr = 'Array';
var tStr = 'String';
var tFn = 'Function';
Expand Down Expand Up @@ -354,12 +352,6 @@ export function hasConsoleLogger() {
}

export function debugTurnedOn() {
if (config.getConfig('debug') === false && _loggingChecked === false) {
const debug = getParameterByName(CONSTANTS.DEBUG_MODE).toUpperCase() === 'TRUE';
config.setConfig({ debug });
_loggingChecked = true;
}

return !!config.getConfig('debug');
}

Expand Down
1 change: 1 addition & 0 deletions test/spec/debugging_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('bid overrides', function () {

afterEach(function () {
window.sessionStorage.clear();
config.resetConfig();
sandbox.restore();
});

Expand Down

0 comments on commit 0e40b77

Please sign in to comment.