Skip to content

Commit 93b5cb4

Browse files
committed
add raven exception tracking
1 parent 7910117 commit 93b5cb4

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/server.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const DEFAULT_PORT = 8080;
44
const DEFAULT_LIVERELOAD_PORT = 35729;
55
const DEFAULT_DEV_ASSETS_MAX_AGE = 0;
66
const DEFAULT_PROD_ASSETS_MAX_AGE = 1000 * 60 * 60 * 24 * 365; // 1 year, in ms
7+
const SENTRY_DSN = process.env.SENTRY_DSN;
8+
const SENTRY_LEVEL = process.env.SENTRY_LEVEL;
79

810
// native
911
var fs = require('fs');
@@ -26,6 +28,7 @@ handlebars_helper.help( Handlebars );
2628
var express_handlebars = require('express3-handlebars');
2729
var chokidar = require('chokidar');
2830
var glob = require('glob');
31+
var raven = require('raven');
2932

3033
// our party! \o/
3134
var Page = require('./page.js');
@@ -99,6 +102,14 @@ var SolidusServer = function( options ){
99102
}));
100103
// catch-all middleware at the end of the stack for 404 handling
101104
router.use( router.router );
105+
// log express errors to sentry if defined
106+
if( SENTRY_DSN ){
107+
router.use( raven.middleware.express( SENTRY_DSN ) );
108+
var raven_client = solidus_server.raven_client = new raven.Client( SENTRY_DSN );
109+
raven_client.patchGlobal( function(){
110+
process.exit(1);
111+
});
112+
}
102113
router.use( function( req, res, next ){
103114
res.status( 404 );
104115
// it's cheaper to check this than to fs.exists the notfound path

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"glob": "~3.2.6",
3535
"handlebars": "~1.0.12",
3636
"handlebars-helper": "~0.0.9",
37-
"worker-farm": "~0.3.1"
37+
"worker-farm": "~0.3.1",
38+
"raven": "^0.6.2"
3839
},
3940
"devDependencies": {
4041
"mocha": "~1.9.0",

0 commit comments

Comments
 (0)