From 575791925697c7e23966e6934b577e69aef736f3 Mon Sep 17 00:00:00 2001 From: jstejada Date: Mon, 13 Dec 2021 12:02:14 -0500 Subject: [PATCH] DevTools: Correctly log errors reported from the store (#22950) --- .../views/ErrorBoundary/ErrorBoundary.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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,