Exceptions handled by Analytics
This commit is contained in:
@ -28,7 +28,8 @@ export default class Notifications extends React.Component{
|
||||
<div className={notification.type+" notification"} key={notification.key} data-key={notification.key}>
|
||||
<FontAwesome name="close" className="close-button" onClick={ e => this.props.uiActions.removeNotification(notification.key) } />
|
||||
{notification.title ? <h4>{notification.title}</h4> : null}
|
||||
<p dangerouslySetInnerHTML={{__html: notification.content}}></p>
|
||||
<p className="content" dangerouslySetInnerHTML={{__html: notification.content}}></p>
|
||||
{notification.description ? <p className="description" dangerouslySetInnerHTML={{__html: notification.description}}></p> : null }
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@ -19,7 +19,18 @@ const CoreMiddleware = (function(){
|
||||
switch(action.type){
|
||||
|
||||
case 'HANDLE_EXCEPTION':
|
||||
|
||||
// Construct meaningful message and description
|
||||
var message = action.message;
|
||||
var description = null;
|
||||
if (action.data.xhr && action.data.xhr.responseText){
|
||||
var xhr_response = JSON.parse(action.data.xhr.responseText);
|
||||
if (xhr_response.error && xhr_response.error.message){
|
||||
description = xhr_response.error.message;
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare a summary dump of our state
|
||||
var state = store.getState();
|
||||
var exported_state = {
|
||||
core: Object.assign({},state.core),
|
||||
@ -48,25 +59,35 @@ const CoreMiddleware = (function(){
|
||||
{},
|
||||
action.data,
|
||||
{
|
||||
message: message,
|
||||
description: description,
|
||||
state: exported_state
|
||||
}
|
||||
);
|
||||
|
||||
// Log with Raven Sentry
|
||||
Raven.captureException(
|
||||
new Error(action.message),
|
||||
new Error(message),
|
||||
{
|
||||
extra: data
|
||||
}
|
||||
);
|
||||
|
||||
if (action.data.xhr && action.data.xhr.responseText){
|
||||
var xhr_response = JSON.parse(action.data.xhr.responseText);
|
||||
if (xhr_response.error && xhr_response.error.message){
|
||||
message = message+'<p class="description">'+xhr_response.error.message+'</p>';
|
||||
}
|
||||
}
|
||||
// Log with Analytics
|
||||
ReactGA.event({
|
||||
category: "Error",
|
||||
action: message,
|
||||
label: (description ? description : "No description"),
|
||||
nonInteraction: true
|
||||
});
|
||||
|
||||
store.dispatch(uiActions.createNotification(message,'bad'));
|
||||
store.dispatch(uiActions.createNotification(
|
||||
message,
|
||||
'bad',
|
||||
null,
|
||||
null,
|
||||
description
|
||||
));
|
||||
console.error(action.message, data);
|
||||
break;
|
||||
|
||||
|
||||
@ -128,7 +128,7 @@ export function createBrowserNotification(data){
|
||||
}
|
||||
}
|
||||
|
||||
export function createNotification(content, type = 'default', key = null, title = null, sticky = false){
|
||||
export function createNotification(content, type = 'default', key = null, title = null, description = null, sticky = false){
|
||||
if (!key){
|
||||
key = helpers.generateGuid()
|
||||
}
|
||||
@ -138,6 +138,7 @@ export function createNotification(content, type = 'default', key = null, title
|
||||
key: key,
|
||||
type: type,
|
||||
title: title,
|
||||
description: description,
|
||||
content: content,
|
||||
sticky: sticky
|
||||
}
|
||||
|
||||
@ -113,6 +113,7 @@ const UIMiddleware = (function(){
|
||||
'broadcast',
|
||||
(broadcast.key ? broadcast.key : null),
|
||||
(broadcast.title ? broadcast.title : null),
|
||||
null,
|
||||
true
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user