How to use the config function from raven

Find comprehensive JavaScript raven.config code examples handpicked from public code repositorys.

raven.config is a method in the Raven.js library that sets the configuration options for the Raven client.

19
20
21
22
23
24
25
26
27

const { ASSET_CACHE_DURATION } = process.env;
const MAX_ASSET_AGE = ASSET_CACHE_DURATION === 'Infinity' ? Infinity : 0;

if (USE_SENTRY) {
  Raven.config(SENTRY_DSN).install();
}

const app = express();
fork icon10
star icon72
watch icon8

5
6
7
8
9
10
11
12
13
14
15
16
const {Pool} = require('pg');
const Raven = require('raven');
const crypto = require('crypto');


if(process.env.SENTRY_DSN) {
    Raven.config(process.env.SENTRY_DSN).install();
};


function raven_report(e, context_opts) {
    if(process.env.SENTRY_DSN) {
fork icon38
star icon63
watch icon0

How does raven.config work?

raven.config is a method in the Raven.js library that is used to configure the Raven client with a DSN (data source name), options, and additional context. It is used to set up the client and establish a connection to the Sentry error tracking service.

57
58
59
60
61
62
63
64
65
    options.extra
  );
}

// expose the instance on the transport
this.raven = options.raven || Raven.config(options.dsn, options.config);

if (_.isFunction(options.errorHandler) && this.raven.listeners('error').length === 0)
  this.raven.on('error', options.errorHandler);
fork icon13
star icon48
watch icon0

33
34
35
36
37
38
39
40
41
42
if (useRaven()) {
    let statusJson = {};
    if (fs.existsSync(statusJsonPath)) {
        statusJson = JSON.parse(fs.readFileSync(statusJsonPath).toString());
    }
    Raven.config(process.env.ACTION_HUB_RAVEN_DSN, {
        captureUnhandledRejections: true,
        release: statusJson.git_commit,
        autoBreadcrumbs: false,
        environment: process.env.ACTION_HUB_BASE_URL,
fork icon96
star icon47
watch icon68

+ 16 other calls in file

Ai Example

1
2
3
4
5
6
7
8
9
const Raven = require("raven");

Raven.config("YOUR_DSN").install();

try {
  // your code that could throw an error
} catch (err) {
  Raven.captureException(err);
}

In this example, raven.config is used to configure the Raven client with your Data Source Name (DSN). The install method is called to set up error tracking. In the try...catch block, any errors that occur are caught and reported to the Raven server using the captureException method.

12
13
14
15
16
17
18
19
20
21
22
const Game = require('../game/game.js');
const Socket = require('../socket.js');
const version = require('../../version.js');


if(config.sentryDsn) {
    Raven.config(config.sentryDsn, { 
        release: version.build,
        environment: process.env.NODE_ENV
    }).install();
}
fork icon13
star icon16
watch icon6

42
43
44
45
46
47
48
49
50
51
/**
 * @param {{}} options
 * @return {{}}
 */
const createRaven = (options) => {
    const raven = Raven.config(options.dsn, options);
    raven.captureException = util.promisify(raven.captureException);
    raven.captureMessage = util.promisify(raven.captureMessage);

    if (options.install || options.patchGlobal) {
fork icon7
star icon7
watch icon3

64
65
66
67
68
69
70
71
72
73
 * enabled by default)
 * @returns {Log}
 * @private
 */
init(url, opts) {
  Raven.config(url, opts).install();

  this.setTags({
    appId: this._manifest.id,
    appVersion: this._manifest.version,
fork icon5
star icon3
watch icon8

+ 13 other calls in file

1
2
3
4
5
6
7
8
9
10
const config = require(path.join(__dirname, '/../config'))
const raven = require('raven')

const ErrorHandler = function () {
  if (config.get('sentryDSN')) {
    raven.config(config.get('sentryDSN')).install()
  }

  this.ERROR_MESSAGES = {
    'missing-input-secret': 'reCAPTCHA: The secret parameter is missing',
fork icon496
star icon2
watch icon2

69
70
71
72
73
74
75
76
77
78
});

// sentry is remote error reporting
if (isProfileErrorHandlerEnabled) {
  logger.info('Sentry Enabled.');
  Raven.config(sentryUrl, {
    parseUser: req => {
      const userData = {
        ipAddress: req.headers['x-forwarded-for'],
        user_agent: req.headers['user-agent'],
fork icon3
star icon4
watch icon2

2
3
4
5
6
7
8
9
10
const ignoreErros = [400, 401, 404]

module.exports = app => {
  if (!config.sentry.url) { return app.on('error', err => console.error(err)) }

  Raven.config(config.sentry.url).install()

  app.on('error', err => {
    if (ignoreErros.indexOf(err.output.statusCode) >= 0) { return }
fork icon3
star icon1
watch icon0

+ 3 other calls in file

16
17
18
19
20
21
22
23
24
25
if (SENTRY_DSN) {
  // Configure the Sentry client. As is, this catches unhandled
  // exceptions from starting the server etc. but does not catch the
  // ones thrown from Express.js middleware functions. For those
  // an error handler has to be added to the Express app.
  Raven.config(SENTRY_DSN, {
    environment: ENV,
    autoBreadcrumbs: {
      http: true,
    },
fork icon958
star icon0
watch icon4

25
26
27
28
29
30
31
32
33
34
        serverName: this.options.serverName
    };
    if (this.options.disableConsoleAlerts === true) {
        SentryLib.disableConsoleAlerts();
    }
    global.sentry = SentryLib.config(dsnPublic, reject(options)).install();
};

/**
 * Loaded?
fork icon0
star icon2
watch icon19

36
37
38
39
40
41
42
43
44
45
let filename = '';
const emitter = null;
const socketObj = {};

if (sentryUrl) {
  Raven.config(sentryUrl).install();
}

app.use(compression());
app.use(require('cookie-parser')());
fork icon864
star icon0
watch icon39

1
2
3
4
5
6
7
8
9
10
const keys = require('../config/keys');

const sentryEnabled = keys.SENTRY_DSN && keys.IS_ENV_PRODUCTION;

if (sentryEnabled) {
  Raven.config(keys.SENTRY_DSN, {
    autoBreadcrumbs: true,
    captureUnhandledRejections: true,
    environment: keys.EXECUTION_ENV,
  }).install();
fork icon20
star icon0
watch icon2

15
16
17
18
19
20
21
22
23
24
if (!process.env.SENTRY_DSN) {
  robot.logger.warning(
    'The SENTRY_DSN environment variable not set. Sentry not configured.')
}

Raven.config().install()

robot.error((err, res) => {
  robot.logger.error(err)
  if (typeof res !== 'undefined' && res !== null) {
fork icon1
star icon0
watch icon0

56
57
58
59
60
61
62
63
64
65
        }
    }
}
const Raven = require('raven');
if (!remConfig.no_error_tracking) {
    Raven.config(remConfig.sentry_token, {
        release: version,
        environment: remConfig.environment
    }).install(() => {
        winston.error('Oh no I died because of an unhandled error!');
fork icon0
star icon0
watch icon2

13
14
15
16
17
18
19
20
21
22
23
24
module.exports = function (app) {
  app.root = path.resolve(__dirname, '..', '..');


  if (config.app.sentry.secret) {
    const dsn = `https://${config.app.sentry.public}:${config.app.sentry.secret}@sentry.io/1249936`;
    Raven.config(dsn).install();
  }


  const transports = config.app.logging
    ? [new winston.transports.Console()]
fork icon0
star icon0
watch icon0

10
11
12
13
14
15
16
17
18
19
20
    const environment = process.env.NODE_ENV
    enabled = false(environment === 'dev')
  }
  if (enabled && !initialized) {
    initialized = true
    Raven.config(sentryDsn).install()
  }
}


function isEnabled () {
fork icon0
star icon0
watch icon0

45
46
47
48
49
50
51
52
53
54
  });
}

_setupSentry() {
  Raven.disableConsoleAlerts();
  Raven.config(
    'https://18d04acdd03b4389a36ef7d1d39f8025:5cb2e99bd3634856bfb3711461201439@sentry.io/196829',
    {
      name: this.deviceHash,
      release: this.getVersion(),
fork icon0
star icon0
watch icon0

26
27
28
29
30
31
32
33
34
35
if ('tags' in opts) config.tags = opts.tags;
if ('extra' in opts) config.extra = opts.extra;

const dsn = ('dsn' in opts) ? opts.dsn : env.SENTRY_DSN;

Raven.config(dsn, config).install(function () {
  if (config.exitOnUnhandledException) {
    console.error('Unhandled Exception or Rejection', new Date(), '(Shutting Down)');
    process.exit(1);
  }
fork icon0
star icon0
watch icon0