Skip to content

Commit 7f7c01c

Browse files
committed
Added Exceptionless integration
1 parent 214de0d commit 7f7c01c

File tree

6 files changed

+56
-0
lines changed

6 files changed

+56
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"babel-runtime": "^6.3.19",
105105
"body-parser": "^1.14.1",
106106
"compression": "^1.6.0",
107+
"exceptionless": "^1.5.0",
107108
"express": "^4.13.3",
108109
"express-session": "^1.12.1",
109110
"file-loader": "^0.8.5",

src/client.js

+9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ import useScroll from 'scroll-behavior/lib/useStandardScroll';
1515

1616
import getRoutes from './routes';
1717

18+
import { ExceptionlessClient } from 'exceptionless';
19+
const exceptionlessClient = ExceptionlessClient.default;
20+
exceptionlessClient.config.apiKey = 'YOUR_API_KEY_HERE';
21+
exceptionlessClient.config.useDebugLogger(); // Testing only
22+
exceptionlessClient.config.useLocalStorage();
23+
exceptionlessClient.config.defaultTags.push('Universal', 'Client');
24+
1825
const client = new ApiClient();
1926
const _browserHistory = useScroll(() => browserHistory)();
2027
const dest = document.getElementById('content');
@@ -34,6 +41,7 @@ function initSocket() {
3441
return socket;
3542
}
3643

44+
exceptionlessClient.submitFeatureUsage(location.pathname || '/');
3745
global.socket = initSocket();
3846

3947
const component = (
@@ -55,6 +63,7 @@ if (process.env.NODE_ENV !== 'production') {
5563
window.React = React; // enable debugger
5664

5765
if (!dest || !dest.firstChild || !dest.firstChild.attributes || !dest.firstChild.attributes['data-react-checksum']) {
66+
exceptionlessClient.submitLog('client', 'Server-side React render was discarded.', 'Error');
5867
console.error('Server-side React render was discarded. Make sure that your initial render does not contain any client-side code.');
5968
}
6069
}

src/redux/modules/counter.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { ExceptionlessClient } from 'exceptionless';
2+
const exceptionlessClient = ExceptionlessClient.default;
3+
14
const INCREMENT = 'redux-example/counter/INCREMENT';
25

36
const initialState = {
@@ -8,6 +11,7 @@ export default function reducer(state = initialState, action = {}) {
811
switch (action.type) {
912
case INCREMENT:
1013
const {count} = state;
14+
exceptionlessClient.createFeatureUsage('Increment').setValue(count + 1).setProperty('state', state).submit();
1115
return {
1216
count: count + 1
1317
};

src/server.js

+14
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ import createHistory from 'react-router/lib/createMemoryHistory';
1919
import {Provider} from 'react-redux';
2020
import getRoutes from './routes';
2121

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+
2229
const targetUrl = 'http://' + config.apiHost + ':' + config.apiPort;
2330
const pretty = new PrettyError();
2431
const app = new Express();
@@ -35,19 +42,24 @@ app.use(Express.static(path.join(__dirname, '..', 'static')));
3542

3643
// Proxy to API server
3744
app.use('/api', (req, res) => {
45+
exceptionlessClient.createFeatureUsage('/api').addRequestInfo(req).submit();
3846
proxy.web(req, res, {target: targetUrl});
3947
});
4048

4149
app.use('/ws', (req, res) => {
50+
exceptionlessClient.createFeatureUsage('/ws').addRequestInfo(req).submit();
4251
proxy.web(req, res, {target: targetUrl + '/ws'});
4352
});
4453

4554
server.on('upgrade', (req, socket, head) => {
55+
exceptionlessClient.createFeatureUsage('upgrade').addRequestInfo(req).submit();
4656
proxy.ws(req, socket, head);
4757
});
4858

4959
// added the error handling to avoid https://github.com/nodejitsu/node-http-proxy/issues/527
5060
proxy.on('error', (error, req, res) => {
61+
exceptionlessClient.createUnhandledException(error, 'proxy').addRequestInfo(req).submit();
62+
5163
let json;
5264
if (error.code !== 'ECONNRESET') {
5365
console.error('proxy error', error);
@@ -82,6 +94,8 @@ app.use((req, res) => {
8294
}
8395

8496
match({ history, routes: getRoutes(store), location: req.originalUrl }, (error, redirectLocation, renderProps) => {
97+
exceptionlessClient.createUnhandledException(error, 'router').addRequestInfo(req).submit();
98+
8599
if (redirectLocation) {
86100
res.redirect(redirectLocation.pathname + redirectLocation.search);
87101
} else if (error) {

webpack/dev.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ module.exports = {
9292
{ test: webpackIsomorphicToolsPlugin.regular_expression('images'), loader: 'url-loader?limit=10240' }
9393
]
9494
},
95+
// don't polyfill or mock node requires (causes exceptionless universial to fail on browser)
96+
// http://webpack.github.io/docs/configuration.html#node
97+
node: {
98+
child_process: false,
99+
fs: false,
100+
http: false,
101+
https: false,
102+
os: false,
103+
path: false,
104+
process: false,
105+
clearImmediate: false,
106+
setImmediate: false,
107+
url: false
108+
},
95109
progress: true,
96110
resolve: {
97111
modulesDirectories: [

webpack/prod.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ module.exports = {
4444
{ test: webpackIsomorphicToolsPlugin.regular_expression('images'), loader: 'url-loader?limit=10240' }
4545
]
4646
},
47+
// don't polyfill or mock node requires (causes exceptionless universial to fail on browser)
48+
// http://webpack.github.io/docs/configuration.html#node
49+
node: {
50+
child_process: false,
51+
fs: false,
52+
http: false,
53+
https: false,
54+
os: false,
55+
path: false,
56+
process: false,
57+
clearImmediate: false,
58+
setImmediate: false,
59+
url: false
60+
},
4761
progress: true,
4862
resolve: {
4963
modulesDirectories: [

0 commit comments

Comments
 (0)