0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Added error reporting when editor instances fail to load (#19284)

no issue

- recently we introduced code that broke the editor in older versions of
Safari but we weren't alerted to it until we started getting customer
reports
- we have an `ErrorBoundary` around the React editor components but this
wasn't reporting the error anywhere and simply showed an error message
- updated the boundary to report to Sentry when configured so we can
notice and fix any editor-breaking issues faster
This commit is contained in:
Kevin Ansfield 2023-12-07 14:11:07 +00:00 committed by GitHub
parent 845d3cf759
commit 4b5718f6e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 2 deletions

View file

@ -14,6 +14,18 @@ class ErrorHandler extends React.Component {
return {hasError: true};
}
componentDidCatch(error) {
if (this.props.config.sentry_dsn) {
Sentry.captureException(error, {
tags: {
lexical: true
}
});
}
console.error(error, errorInfo); // eslint-disable-line
}
render() {
if (this.state.hasError) {
return (
@ -82,7 +94,7 @@ export default class KoenigLexicalEditorInput extends Component {
ReactComponent = (props) => {
return (
<div className={['koenig-react-editor', this.args.className].filter(Boolean).join(' ')}>
<ErrorHandler>
<ErrorHandler config={this.config}>
<Suspense fallback={<p className="koenig-react-editor-loading">Loading editor...</p>}>
<KoenigComposer
editorResource={this.editorResource}

View file

@ -49,6 +49,18 @@ class ErrorHandler extends React.Component {
return {hasError: true};
}
componentDidCatch(error) {
if (this.props.config.sentry_dsn) {
Sentry.captureException(error, {
tags: {
lexical: true
}
});
}
console.error(error, errorInfo); // eslint-disable-line
}
render() {
if (this.state.hasError) {
return (
@ -513,7 +525,7 @@ export default class KoenigLexicalEditor extends Component {
return (
<div className={['koenig-react-editor', 'koenig-lexical', this.args.className].filter(Boolean).join(' ')}>
<ErrorHandler>
<ErrorHandler config={this.config}>
<Suspense fallback={<p className="koenig-react-editor-loading">Loading editor...</p>}>
<KoenigComposer
editorResource={this.editorResource}