[DevTools] Log errors occurring or reported to the frontend (#22948)
jstejada committed
Dec 13, 2021 at 11:38 UTC
a049aa015563c2e50f44214c28d186c0bae09ba6
2 files changed
+13
packages/react-devtools-shared/src/Logger.js
+6
@@ -13,6 +13,12 @@ export type LogEvent =
13
| {|
14
+event_name: 'loaded-dev-tools',
15
|}
16
+ | {|
17
+ +event_name: 'error',
18
+ +error_message: string | null,
19
+ +error_stack: string | null,
20
+ +error_component_stack: string | null,
21
+ |}
22
| {|
23
+event_name: 'selected-components-tab',
24
|}
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ErrorBoundary.js
+7
@@ -15,6 +15,7 @@ import SearchingGitHubIssues from './SearchingGitHubIssues';
15
import SuspendingErrorView from './SuspendingErrorView';
16
import TimeoutView from './TimeoutView';
17
import TimeoutError from 'react-devtools-shared/src/TimeoutError';
18
+import {logEvent} from 'react-devtools-shared/src/Logger';
19
20
type Props = {|
21
children: React$Node,
@@ -73,6 +74,12 @@ export default class ErrorBoundary extends Component<Props, State> {
74
}
75
76
componentDidCatch(error: any, {componentStack}: any) {
77
+ logEvent({
78
+ event_name: 'error',
79
+ error_message: error.message ?? null,
80
+ error_stack: error.stack ?? null,
81
+ error_component_stack: componentStack ?? null,
82
+ });
83
this.setState({
84
componentStack,
85
});