How to use raven - 10 common examples

To help you get started, we’ve selected a few raven 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 GreenInfo-Network / caliparks.org / server.js View on Github external
// Track response times
app.use(responseTime());

//
// Set up Sentry logging
//

if (process.env.SENTRY_DSN) {
  raven.patchGlobal(function(logged, err) {
    console.log('Uncaught error. Reporting to Sentry and exiting.');
    console.error(err.stack);
    process.exit(1);
  });

  app.use(raven.middleware.express());
}

if (process.env.NODE_ENV !== 'production') {
  app.use(morgan('dev'));
}

// you'll need cookies
app.use(cookieParser());

app.use(cors());

//
// Internationalization time (i18n)
//
i18n.configure({
  locales: ['en', 'es'],
github withspectrum / spectrum / iris / utils / create-graphql-error-formatter.js View on Github external
const createGraphQLErrorFormatter = (req?: express$Request) => (
  error: GraphQLError
) => {
  console.log('error', error);
  const isUserError = error.originalError
    ? error.originalError[IsUserError]
    : false;
  let sentryId = 'ID only generated in production';
  if (!isUserError) {
    if (process.env.NODE_ENV === 'production') {
      sentryId = Raven.captureException(
        error,
        req && Raven.parsers.parseRequest(req)
      );
    }
  }
  return {
    message: isUserError ? error.message : `Internal server error: ${sentryId}`,
    // Hide the stack trace in production mode
    stack:
      !process.env.NODE_ENV === 'production' ? error.stack.split('\n') : null,
  };
};
github Turistforeningen / Jotunheimr / lib / sentry.js View on Github external
/* eslint no-console: 0 */
'use strict';

const Client = require('raven').Client;

Client.prototype.captureHeaderSent = function sentryCaptureHeadersSent(req, files) {
  this.captureMessage('Headers already sent', {
    level: 'error',
    extra: { req, files },
  });
};

Client.prototype.captureResClose = function sentryCaptureResClosed(req) {
  this.captureMessage('Response was closed', {
    level: 'warning',
    extra: { req },
  });
};

module.exports = new Client(process.env.SENTRY_DNS);

if (process.env.SENTRY_DNS) {
  module.exports.patchGlobal((id, err) => {
    console.error('Uncaught Exception');
    console.error(err.message);
    console.error(err.stack);
    process.exit(1);
  });
}
github autonomoussoftware / metronome-wallet-desktop / public / electron.js View on Github external
require('electron-debug')({ enabled: true })

    const {
      default: installExtension,
      REACT_DEVELOPER_TOOLS,
      REDUX_DEVTOOLS
    } = require('electron-devtools-installer')

    installExtension([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS])
      .then(extName => logger.debug(`Added Extension:  ${extName}`))
      .catch(err => logger.debug('An error occurred: ', err))
  })
} else {
  // Production
  if (config.sentryDsn) {
    Raven.config(config.sentryDsn, {
      captureUnhandledRejections: true,
      release: app.getVersion(),
      tags: {
        process: process.type,
        electron: process.versions.electron,
        chrome: process.versions.chrome,
        platform: os.platform(),
        platform_release: os.release()
      }
    }).install()
  }
}

app.on('window-all-closed', function () {
  if (process.platform !== 'darwin') {
    app.quit()
github nodecg / nodecg / lib / server / index.js View on Github external
'use strict';

const pjson = require('../../package.json');
const configHelper = require('../config');
const {config} = configHelper;
global.exitOnUncaught = config.exitOnUncaught;

const Raven = require('raven');
const ravenConfig = require('../util/raven-config');
if (config.sentry && config.sentry.enabled) {
	Raven.config(config.sentry.dsn, ravenConfig).install();
	global.sentryEnabled = true;

	process.on('unhandledRejection', (reason, p) => {
		console.error('Unhandled Rejection at:', p, 'reason:', reason);
		Raven.captureException(reason);
	});

	console.info('[nodecg] Sentry enabled.');
}

// Native
const {EventEmitter} = require('events');
const fs = require('fs');
const path = require('path');

// Packages
github CodeHubApp / CodeHub-Push / worker.js View on Github external
#!/usr/bin/node
var  _      = require('underscore'),
    config  = require('./config'),
    fs      = require('fs'),
    async   = require('async'),
    db      = require('./lib/db'),
    github  = require('./lib/github'),
    apn     = require('apn'),
    StatsD  = require('node-statsd'),
    raven   = require('raven');

// Configure Raven for error reporting
var ravenClient;
if (config.raven) {
    ravenClient = new raven.Client(config.raven);
    ravenClient.patchGlobal();
}

// A method to report errors
function reportError(err) {
    if (ravenClient) 
        ravenClient.captureError(err);
    console.error(err);
}

// The statsD client for reporting statistics
var stats = new StatsD({
    host: 'graphite.dillonbuchanan',
    prefix: 'codehub_push.',
    cacheDns: true,
});
github DavidWells / aws-profile-manager / desktop / utils / setupErrorTracking.js View on Github external
module.exports = () => {
  if (process.type === 'browser') {
    // eslint-disable-next-line no-console
    console.log('Setup Browser/Main Process Error Tracking')
    // main process
    // eslint-disable-next-line global-require
    const raven = require('raven')
    const client = new raven.Client('https://2961feaae16a4ae18e4a63a5fa54b67a:71e01192e348489f912684133bdc86d2@sentry.io/111960')
    client.patchGlobal()

    process.on('uncaughtException', (err) => {
      // eslint-disable-next-line global-require
      const dialog = require('electron').dialog

      dialog.showMessageBox({
        type: 'error',
        message: 'An error occurred our side. Please reach out to the Serverless team to resolve the issue.',
        detail: err.stack,
        buttons: ['OK'],
      })
    })
  } else if (process.type === 'renderer') {
    // eslint-disable-next-line no-console
    console.log('Setup Renderer Process Error Tracking')
github CodeHubApp / CodeHub-Push / app.js View on Github external
var express = require('express')
  , config = require('./config')
  , http = require('http')
  , db = require('./lib/db')
  , github = require('./lib/github')
  , raven = require('raven')
  , apn = require('apn')
  , spawn = require('child_process').spawn
  , StatsD  = require('node-statsd')
  , async = require('async');

// Configure Raven for error reporting
var ravenClient;
if (config.raven) {
    ravenClient = new raven.Client(config.raven);
    ravenClient.patchGlobal();
}

// A method to report errors
function reportError(err) {
    if (ravenClient) 
        ravenClient.captureError(err);
    stats.increment('500_error');
    console.error(err);
}

// The statsD client for reporting statistics
var stats = new StatsD({
    host: 'graphite.dillonbuchanan',
    prefix: 'codehub_push.',
    cacheDns: true,
github devfsa / overflow-news / src / server.js View on Github external
const Feed = require('./models/feed');

const app = express();
const { PORT = 8080 } = process.env;

// Start raven to catch exceptions
Raven.config(process.env.SENTRY_DSN).install();
mongoose.connect(process.env.MONGO_URI);
app.locals.moment = moment;

app.set('views', path.join(__dirname, './views'));
app.set('view engine', 'ejs');
app.set('cache', false);

// The request handler must be the first middleware on the app
app.use(Raven.requestHandler());
app.use(cors());
// app.use(graphqlRouter);

app.get('/feeds', async (req, res) => {
  const feeds = await Feed.find({})
    .limit(50)
    .sort({ 'date': -1 });
  res.render('feeds', { feeds });
});

const listPosts = async (req, res) => {
  const perPage = 30;
  const { page = 1 } = req.params;
  const offset = (perPage * page) - perPage;

  const [ posts, count] = await Promise.all([
github openspending / os-packager / app / index.js View on Github external
app.set('trust proxy', true);

    app.set('config', config);
    var usePort = config.get('app:port');
    if (port) {
      usePort = port;
    }
    app.set('port', usePort);
    app.set('views', path.join(__dirname, '/views'));

    // Sentry monitoring
    var sentryDSN = config.get('sentryDSN');
    if (sentryDSN != null) {
      Raven.config(sentryDSN).install();
      app.use(Raven.requestHandler());
      app.use(Raven.errorHandler());

      // Fallthrough error handler
      app.use(function onError(err, req, res, next) {
        // The error id is attached to `res.sentry` to be returned
        // and optionally displayed to the user for support.
        res.statusCode = 500;
        res.end('An error occurred: ' + res.sentry + '\n');
      });
    } else {
      console.log('Sentry DSN not configured');
    }

    // Middlewares
    if (config.get('env') == 'test') {
      app.use(express.static(path.join(__dirname, '/../tests/data')));