How to use the rollbar function in rollbar

To help you get started, we’ve selected a few rollbar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wework / we-js-logger / src / util / server / rollbarLogger.js View on Github external
export default function ServerRollbarLogger({ token, codeVersion, environment }) {
  // https://rollbar.com/docs/notifier/rollbar.js/#quick-start-server
  this._rollbar = new Rollbar({
    accessToken: token,
    captureUncaught: true,
    captureUnhandledRejections: true,
    code_version: codeVersion,
    environment,
  });
}
github feross / bitmidi.com / src / server / rollbar.js View on Github external
import Rollbar from 'rollbar'
import { isProd } from '../config'
import { rollbar as rollbarSecret } from '../../secret'

if (isProd) {
  global.rollbar = new Rollbar({
    accessToken: rollbarSecret.accessToken,
    captureUncaught: true,
    captureUnhandledRejections: true,
    checkIgnore: (isUncaught, args) => {
      const err = args[0]

      // Never ignore uncaught errors
      if (isUncaught) return false

      // Ignore 'Bad Request' errors
      if (err.status === 400) return true

      // Ignore 'Forbidden' errors
      if (err.status === 403) return true

      // Ignore 'Not Found' errors
github devilesk / dota-interactive-map / src / js / rollbar.js View on Github external
environment: '#rollbar_environment',
        client: {
            javascript: {
                source_map_enabled: true,
                code_version: '#code_version',
                // Optionally have Rollbar guess which frames the error was thrown from
                // when the browser does not provide line and column numbers.
                guess_uncaught_frames: true,
            },
        },
    },
};

let rollbar = {};
if ('#rollbar_client_token') {
    rollbar = new Rollbar(rollbarConfig);
}

export default rollbar;
github studentinsights / studentinsights / ui / rollbar.js View on Github external
function loadRollbar() {
  window.Rollbar = new rollbar({
    enabled: true,
    accessToken: readEnv().rollbarJsAccessToken,
    captureUncaught: true,
    captureUnhandledRejections: true,
    transform: transform, // see note below
    sendConfig: false, // not sure why, but this does not appear to work and we still see `notifier.configured_options``

    // Throttle, mostly for limiting the impact of bugs in browser extensions
    itemsPerMinute: 5,
    maxItems: 20,
    ignoreDuplicateErrors: true,

    // Limit the data we send to Rollbar
    captureIp: 'anonymize',
    captureUsername: false,
    captureEmail: false,
github freeCodeCamp / freeCodeCamp / server / middlewares / error-reporter.js View on Github external
import debug from 'debug';
import Rollbar from 'rollbar';
import {
  isHandledError,
  unwrapHandledError
} from '../utils/create-handled-error.js';

const { ROLLBAR_APP_ID } = process.env;

const rollbar = new Rollbar(ROLLBAR_APP_ID);
const log = debug('fcc:middlewares:error-reporter');

const errTemplate = ({message, ...restError}, req) => `
Time: ${new Date(Date.now()).toISOString()}
Error: ${message}
Is authenticated user: ${!!req.user}
Route: ${JSON.stringify(req.route, null, 2)}

${JSON.stringify(restError, null, 2)}

`;

export default function errrorReporter() {
  if (process.env.NODE_ENV !== 'production' && process.env.ERROR_REPORTER) {
    return (err, req, res, next) => {
      console.error(errTemplate(err, req));
github CodeForSocialGood / calltocode.org / server / lib / logger.js View on Github external
import Rollbar from 'rollbar'

import { rollbarConfig } from '../config'

const rollbarLogger = new Rollbar(rollbarConfig)
const localLogger = console

function handleLog (rollbarLevel = 'debug', localLevel = rollbarLevel) {
  return function () {
    if (process.env.SILENT) return

    if (rollbarConfig.enabled) {
      rollbarLogger[rollbarLevel](...arguments)
    } else if (rollbarConfig.verbose) {
      localLogger[localLevel](...arguments)
    }
  }
}

export default {
  critical: handleLog('critical', 'error'),
github rollbar / rollbar.js / examples / react / src / index.js View on Github external
constructor(props) {
    super(props);

    this.state = {
      rollbar: new Rollbar({
        accessToken: 'POST_CLIENT_ITEM_TOKEN',
        captureUncaught: true,
        captureUnhandledRejections: true,
      })
    };

    this.logInfo = this.logInfo.bind(this);
    this.throwError = this.throwError.bind(this);
  }
github ArkEcosystem / core / packages / core-error-tracker-rollbar / src / index.ts View on Github external
async register(container: Container.IContainer, options) {
        return new Rollbar(options);
    },
};