Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix #3040, invoke and use Raven correctly (#3044)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianb authored and jaredhirsch committed Jun 16, 2017
1 parent 3a17475 commit 839995d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions server/src/ravenclient.js
@@ -1,16 +1,16 @@
const config = require("./config").getProperties();
const raven = require("raven");
const Raven = require("raven");


let ravenClient = null;
let useRaven = false;

if (config.sentryDSN) {
ravenClient = new raven.Client(config.sentryDSN);
ravenClient.install();
Raven.config(config.sentryDSN).install();
useRaven = true;
}

exports.sendRavenMessage = function(req, message, options) {
if (!ravenClient) {
if (!useRaven) {
return;
}
options = options || {};
Expand All @@ -20,24 +20,24 @@ exports.sendRavenMessage = function(req, message, options) {
options.extra.userAgent = req.headers['user-agent'];
options.extra.referrer = req.headers['referer'];
options.extra.authenticated = !!req.deviceId;
ravenClient.captureMessage(message, options);
Raven.captureMessage(message, options);
};

exports.captureRavenException = function() {
if (ravenClient) {
return ravenClient.captureException.apply(ravenClient, arguments);
if (useRaven) {
return Raven.captureException.apply(Raven, arguments);
}
return null;
};

exports.addRavenRequestHandler = function(app) {
if (ravenClient) {
app.use(raven.requestHandler());
if (useRaven) {
app.use(Raven.requestHandler());
}
};

exports.addRavenErrorHandler = function(app) {
if (ravenClient) {
app.use(raven.errorHandler());
if (useRaven) {
app.use(Raven.errorHandler());
}
};

0 comments on commit 839995d

Please sign in to comment.