@@ -19,6 +19,13 @@ import createHistory from 'react-router/lib/createMemoryHistory';
19
19
import { Provider } from 'react-redux' ;
20
20
import getRoutes from './routes' ;
21
21
22
+ import { ExceptionlessClient } from 'exceptionless' ;
23
+ const exceptionlessClient = ExceptionlessClient . default ;
24
+ exceptionlessClient . config . apiKey = 'YOUR_API_KEY_HERE' ;
25
+ exceptionlessClient . config . useDebugLogger ( ) ; // Testing only
26
+ exceptionlessClient . config . useLocalStorage ( ) ;
27
+ exceptionlessClient . config . defaultTags . push ( 'Universal' , 'Server' ) ;
28
+
22
29
const targetUrl = 'http://' + config . apiHost + ':' + config . apiPort ;
23
30
const pretty = new PrettyError ( ) ;
24
31
const app = new Express ( ) ;
@@ -35,19 +42,24 @@ app.use(Express.static(path.join(__dirname, '..', 'static')));
35
42
36
43
// Proxy to API server
37
44
app . use ( '/api' , ( req , res ) => {
45
+ exceptionlessClient . createFeatureUsage ( '/api' ) . addRequestInfo ( req ) . submit ( ) ;
38
46
proxy . web ( req , res , { target : targetUrl } ) ;
39
47
} ) ;
40
48
41
49
app . use ( '/ws' , ( req , res ) => {
50
+ exceptionlessClient . createFeatureUsage ( '/ws' ) . addRequestInfo ( req ) . submit ( ) ;
42
51
proxy . web ( req , res , { target : targetUrl + '/ws' } ) ;
43
52
} ) ;
44
53
45
54
server . on ( 'upgrade' , ( req , socket , head ) => {
55
+ exceptionlessClient . createFeatureUsage ( 'upgrade' ) . addRequestInfo ( req ) . submit ( ) ;
46
56
proxy . ws ( req , socket , head ) ;
47
57
} ) ;
48
58
49
59
// added the error handling to avoid https://github.com/nodejitsu/node-http-proxy/issues/527
50
60
proxy . on ( 'error' , ( error , req , res ) => {
61
+ exceptionlessClient . createUnhandledException ( error , 'proxy' ) . addRequestInfo ( req ) . submit ( ) ;
62
+
51
63
let json ;
52
64
if ( error . code !== 'ECONNRESET' ) {
53
65
console . error ( 'proxy error' , error ) ;
@@ -82,6 +94,8 @@ app.use((req, res) => {
82
94
}
83
95
84
96
match ( { history, routes : getRoutes ( store ) , location : req . originalUrl } , ( error , redirectLocation , renderProps ) => {
97
+ exceptionlessClient . createUnhandledException ( error , 'router' ) . addRequestInfo ( req ) . submit ( ) ;
98
+
85
99
if ( redirectLocation ) {
86
100
res . redirect ( redirectLocation . pathname + redirectLocation . search ) ;
87
101
} else if ( error ) {
0 commit comments