@@ -4,6 +4,8 @@ const DEFAULT_PORT = 8080;
44const DEFAULT_LIVERELOAD_PORT = 35729 ;
55const DEFAULT_DEV_ASSETS_MAX_AGE = 0 ;
66const 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
911var fs = require ( 'fs' ) ;
@@ -26,6 +28,7 @@ handlebars_helper.help( Handlebars );
2628var express_handlebars = require ( 'express3-handlebars' ) ;
2729var chokidar = require ( 'chokidar' ) ;
2830var glob = require ( 'glob' ) ;
31+ var raven = require ( 'raven' ) ;
2932
3033// our party! \o/
3134var Page = require ( './page.js' ) ;
@@ -99,6 +102,15 @@ 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
106+ // log uncaught exceptions to sentry and exit
107+ if ( SENTRY_DSN ) {
108+ router . use ( raven . middleware . express ( SENTRY_DSN ) ) ;
109+ var raven_client = solidus_server . raven_client = new raven . Client ( SENTRY_DSN ) ;
110+ raven_client . patchGlobal ( function ( ) {
111+ process . exit ( 1 ) ;
112+ } ) ;
113+ }
102114 router . use ( function ( req , res , next ) {
103115 res . status ( 404 ) ;
104116 // it's cheaper to check this than to fs.exists the notfound path
0 commit comments