-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logging and user reporting to the frontend.
- Loading branch information
Showing
13 changed files
with
355 additions
and
92 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
frontend/src/modules/app/components/report-error/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import * as React from 'react'; | ||
import Button from '@atlaskit/button'; | ||
import Form, { Field } from '@atlaskit/form'; | ||
import ModalDialog, { | ||
ModalFooter, | ||
ModalTransition, | ||
} from '@atlaskit/modal-dialog'; | ||
import Textarea from '@atlaskit/textarea'; | ||
|
||
function ReportError({ open, onCancel, onSubmit }) { | ||
const Container = ({ children, className }) => ( | ||
<Form onSubmit={data => onSubmit(data)}> | ||
{({ formProps }) => ( | ||
<form {...formProps} className={className}> | ||
{children} | ||
</form> | ||
)} | ||
</Form> | ||
); | ||
const Footer = () => ( | ||
<ModalFooter> | ||
<Button onClick={onCancel}>Cancel</Button> | ||
<Button appearance="primary" type="submit"> | ||
Submit | ||
</Button> | ||
</ModalFooter> | ||
); | ||
|
||
return ( | ||
<ModalTransition> | ||
{open && ( | ||
<ModalDialog | ||
components={{ Container, Footer }} | ||
heading="Report an Error" | ||
> | ||
<Field | ||
isRequired | ||
label="Error Description" | ||
name="error" | ||
defaultValue="" | ||
> | ||
{({ fieldProps }) => ( | ||
<Textarea | ||
{...fieldProps} | ||
placeholder="Enter any details that you think might be relevant" | ||
/> | ||
)} | ||
</Field> | ||
</ModalDialog> | ||
)} | ||
</ModalTransition> | ||
); | ||
} | ||
|
||
export default ReportError; |
12 changes: 12 additions & 0 deletions
12
frontend/src/modules/app/containers/report-error-button.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { connect } from 'react-redux'; | ||
|
||
import { toggleReportError } from '../actions'; | ||
|
||
// NOTE: This container just returns the connect function, add it to a button element | ||
// where ever it is needed i.e. `const Button = reportErrorButton(CustomButtonElement)` | ||
export default connect( | ||
null, | ||
{ | ||
onClick: toggleReportError, | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { connect } from 'react-redux'; | ||
import ReportError from '../components/report-error'; | ||
|
||
import { reportError, toggleReportError } from '../actions'; | ||
|
||
const mapStateToProps = state => ({ | ||
open: state.app.viewState.isReportErrorOpen, | ||
}); | ||
|
||
export default connect( | ||
mapStateToProps, | ||
{ | ||
onCancel: toggleReportError, | ||
onSubmit: reportError, | ||
} | ||
)(ReportError); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import ky from 'ky'; | ||
|
||
const logError = (error, state, action) => { | ||
ky.post('/log', { | ||
json: { | ||
state, | ||
action, | ||
error, | ||
}, | ||
}); | ||
}; | ||
|
||
/** | ||
Crash Reporter lifted directly from the Redux docs. | ||
*/ | ||
export const crashReporter = store => next => action => { | ||
try { | ||
return next(action); | ||
} catch (err) { | ||
const state = store.getState(); | ||
console.error('[ERROR]', err); | ||
|
||
logError(err, state, action); | ||
|
||
throw err; | ||
} | ||
}; | ||
|
||
export const errorReporter = store => next => action => { | ||
if (action.error) { | ||
const state = store.getState(); | ||
|
||
logError(action.type, state, action); | ||
} | ||
|
||
return next(action); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters