Permalink
Browse files

Added Exceptionless integration

  • Loading branch information...
niemyjski committed Jun 29, 2017
1 parent 214de0d commit 7f7c01ca1b328f3389c3919a53376bccbbfe1f08
Showing with 56 additions and 0 deletions.
  1. +1 −0 package.json
  2. +9 −0 src/client.js
  3. +4 −0 src/redux/modules/counter.js
  4. +14 −0 src/server.js
  5. +14 −0 webpack/dev.config.js
  6. +14 −0 webpack/prod.config.js
@@ -104,6 +104,7 @@
"babel-runtime": "^6.3.19",
"body-parser": "^1.14.1",
"compression": "^1.6.0",
"exceptionless": "^1.5.0",
"express": "^4.13.3",
"express-session": "^1.12.1",
"file-loader": "^0.8.5",
@@ -15,6 +15,13 @@ import useScroll from 'scroll-behavior/lib/useStandardScroll';
import getRoutes from './routes';
import { ExceptionlessClient } from 'exceptionless';
const exceptionlessClient = ExceptionlessClient.default;
exceptionlessClient.config.apiKey = 'YOUR_API_KEY_HERE';
exceptionlessClient.config.useDebugLogger(); // Testing only
exceptionlessClient.config.useLocalStorage();
exceptionlessClient.config.defaultTags.push('Universal', 'Client');
const client = new ApiClient();
const _browserHistory = useScroll(() => browserHistory)();
const dest = document.getElementById('content');
@@ -34,6 +41,7 @@ function initSocket() {
return socket;
}
exceptionlessClient.submitFeatureUsage(location.pathname || '/');
global.socket = initSocket();
const component = (
@@ -55,6 +63,7 @@ if (process.env.NODE_ENV !== 'production') {
window.React = React; // enable debugger
if (!dest || !dest.firstChild || !dest.firstChild.attributes || !dest.firstChild.attributes['data-react-checksum']) {
exceptionlessClient.submitLog('client', 'Server-side React render was discarded.', 'Error');
console.error('Server-side React render was discarded. Make sure that your initial render does not contain any client-side code.');
}
}
@@ -1,3 +1,6 @@
import { ExceptionlessClient } from 'exceptionless';
const exceptionlessClient = ExceptionlessClient.default;
const INCREMENT = 'redux-example/counter/INCREMENT';
const initialState = {
@@ -8,6 +11,7 @@ export default function reducer(state = initialState, action = {}) {
switch (action.type) {
case INCREMENT:
const {count} = state;
exceptionlessClient.createFeatureUsage('Increment').setValue(count + 1).setProperty('state', state).submit();
return {
count: count + 1
};
@@ -19,6 +19,13 @@ import createHistory from 'react-router/lib/createMemoryHistory';
import {Provider} from 'react-redux';
import getRoutes from './routes';
import { ExceptionlessClient } from 'exceptionless';
const exceptionlessClient = ExceptionlessClient.default;
exceptionlessClient.config.apiKey = 'YOUR_API_KEY_HERE';
exceptionlessClient.config.useDebugLogger(); // Testing only
exceptionlessClient.config.useLocalStorage();
exceptionlessClient.config.defaultTags.push('Universal', 'Server');
const targetUrl = 'http://' + config.apiHost + ':' + config.apiPort;
const pretty = new PrettyError();
const app = new Express();
@@ -35,19 +42,24 @@ app.use(Express.static(path.join(__dirname, '..', 'static')));
// Proxy to API server
app.use('/api', (req, res) => {
exceptionlessClient.createFeatureUsage('/api').addRequestInfo(req).submit();
proxy.web(req, res, {target: targetUrl});
});
app.use('/ws', (req, res) => {
exceptionlessClient.createFeatureUsage('/ws').addRequestInfo(req).submit();
proxy.web(req, res, {target: targetUrl + '/ws'});
});
server.on('upgrade', (req, socket, head) => {
exceptionlessClient.createFeatureUsage('upgrade').addRequestInfo(req).submit();
proxy.ws(req, socket, head);
});
// added the error handling to avoid https://github.com/nodejitsu/node-http-proxy/issues/527
proxy.on('error', (error, req, res) => {
exceptionlessClient.createUnhandledException(error, 'proxy').addRequestInfo(req).submit();
let json;
if (error.code !== 'ECONNRESET') {
console.error('proxy error', error);
@@ -82,6 +94,8 @@ app.use((req, res) => {
}
match({ history, routes: getRoutes(store), location: req.originalUrl }, (error, redirectLocation, renderProps) => {
exceptionlessClient.createUnhandledException(error, 'router').addRequestInfo(req).submit();
if (redirectLocation) {
res.redirect(redirectLocation.pathname + redirectLocation.search);
} else if (error) {
@@ -92,6 +92,20 @@ module.exports = {
{ test: webpackIsomorphicToolsPlugin.regular_expression('images'), loader: 'url-loader?limit=10240' }
]
},
// don't polyfill or mock node requires (causes exceptionless universial to fail on browser)
// http://webpack.github.io/docs/configuration.html#node
node: {
child_process: false,
fs: false,
http: false,
https: false,
os: false,
path: false,
process: false,
clearImmediate: false,
setImmediate: false,
url: false
},
progress: true,
resolve: {
modulesDirectories: [
@@ -44,6 +44,20 @@ module.exports = {
{ test: webpackIsomorphicToolsPlugin.regular_expression('images'), loader: 'url-loader?limit=10240' }
]
},
// don't polyfill or mock node requires (causes exceptionless universial to fail on browser)
// http://webpack.github.io/docs/configuration.html#node
node: {
child_process: false,
fs: false,
http: false,
https: false,
os: false,
path: false,
process: false,
clearImmediate: false,
setImmediate: false,
url: false
},
progress: true,
resolve: {
modulesDirectories: [

0 comments on commit 7f7c01c

Please sign in to comment.