Skip to content

Commit

Permalink
Fix Rollbar config check
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Nason committed Oct 19, 2016
1 parent ae23546 commit 6c634cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/client.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* @module we-js-logger/client
* @description A logger than can be used in browsers
*/
import Logger from './util/common/logger';
import ClientConsoleLogger from './util/client/consoleLogger';
import ClientLogentriesLogger from './util/client/logentriesLogger';
import ClientRollbarLogger from './util/client/rollbarLogger';

/**
* @module we-js-logger/client
* @description A logger than can be used in browsers
*/
export default class ClientLogger extends Logger {
getStreams() {
// Any passed in streams
Expand Down
6 changes: 5 additions & 1 deletion src/util/client/rollbarLogger.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import Rollbar from 'rollbar';
import bunyan from 'bunyan';
import omit from 'lodash/omit';
import get from 'lodash/get';
import { bunyanLevelToRollbarLevelName } from '../common/rollbar';

// An unconfigured Rollbar has an accessToken of "undefined" by default
const isGlobalRollbarConfigured = () => _.get(global.Rollbar, 'options.accessToken', 'undefined') !== 'undefined';

/**
* Custom rollbar stream that transports to logentries from a browser
* Includes logic for handling global Rollbar instance, else initializing Rollbar here.
Expand All @@ -14,7 +18,7 @@ import { bunyanLevelToRollbarLevelName } from '../common/rollbar';
* @param {String} options.codeVersion
*/
export default function RollbarLogger({ token, environment, codeVersion }) {
if (global.Rollbar && global.Rollbar.options.accessToken && global.Rollbar.accessToken !== 'undefined') {
if (global.Rollbar && isGlobalRollbarConfigured()) {
// Rollbar is loaded globally (ie, the quick-start snippet has been pasted into the document's head)
} else {
// Init Rollbar here
Expand Down

0 comments on commit 6c634cb

Please # to comment.