diff --git a/packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ErrorBoundary.js b/packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ErrorBoundary.js index affc98eb13..b78f7406ad 100644 --- a/packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ErrorBoundary.js +++ b/packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ErrorBoundary.js @@ -74,12 +74,7 @@ export default class ErrorBoundary extends Component { } componentDidCatch(error: any, {componentStack}: any) { - logEvent({ - event_name: 'error', - error_message: error.message ?? null, - error_stack: error.stack ?? null, - error_component_stack: componentStack ?? null, - }); + this._logError(error, componentStack); this.setState({ componentStack, }); @@ -146,6 +141,15 @@ export default class ErrorBoundary extends Component { return children; } + _logError = (error: any, componentStack: string | null) => { + logEvent({ + event_name: 'error', + error_message: error.message ?? null, + error_stack: error.stack ?? null, + error_component_stack: componentStack ?? null, + }); + }; + _dismissError = () => { const onBeforeDismissCallback = this.props.onBeforeDismissCallback; if (typeof onBeforeDismissCallback === 'function') { @@ -157,6 +161,7 @@ export default class ErrorBoundary extends Component { _onStoreError = (error: Error) => { if (!this.state.hasError) { + this._logError(error, null); this.setState({ ...ErrorBoundary.getDerivedStateFromError(error), canDismiss: true,