- This is the fallback component that gets rendered after a rendering error!
+ This is the fallback component that gets rendered after a rendering error within the main
+ ErrorBoundary!
Check your Backtrace console to see the Error and Component stacks!
diff --git a/examples/sdk/react/src/components/InnerFallback.tsx b/examples/sdk/react/src/components/InnerFallback.tsx
new file mode 100644
index 00000000..4c46abd7
--- /dev/null
+++ b/examples/sdk/react/src/components/InnerFallback.tsx
@@ -0,0 +1,9 @@
+import { useEffect } from 'react';
+import { toast } from 'react-toastify';
+
+export default function InnerFallback() {
+ useEffect(() => {
+ toast('Inner ErrorBoundary Triggered! Check your Backtrace console to see the Error and Component stacks.');
+ });
+ return null;
+}
diff --git a/examples/sdk/react/src/index.tsx b/examples/sdk/react/src/index.tsx
index fdcf8b84..f3724af1 100644
--- a/examples/sdk/react/src/index.tsx
+++ b/examples/sdk/react/src/index.tsx
@@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import { ErrorBoundary, BacktraceClient } from '@backtrace/react';
-import { Fallback } from './Fallback';
+import Fallback from './components/Fallback';
import { SUBMISSION_URL } from './consts';
BacktraceClient.initialize({
@@ -21,7 +21,7 @@ BacktraceClient.initialize({
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
root.render(
- }>
+ }>
,
From 1c30aa0cedbd785d903950caf1a227283ea416aa Mon Sep 17 00:00:00 2001
From: Adam Cronin
Date: Tue, 8 Aug 2023 17:26:09 -0400
Subject: [PATCH 4/6] Adding error.type when sending via the ErrorBoundary
---
packages/react/src/ErrorBoundary.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/react/src/ErrorBoundary.tsx b/packages/react/src/ErrorBoundary.tsx
index 2f12fd55..863f3cf1 100644
--- a/packages/react/src/ErrorBoundary.tsx
+++ b/packages/react/src/ErrorBoundary.tsx
@@ -34,7 +34,7 @@ export class ErrorBoundary extends Component {
public async componentDidCatch(error: Error, info: ErrorInfo) {
const { name } = this.props;
- const report = new BacktraceReport(error, { 'errorboundary.name': name });
+ const report = new BacktraceReport(error, { 'errorboundary.name': name, 'error.type': 'Rendering error' });
report.addStackTrace(this.COMPONENT_THREAD_NAME, info.componentStack);
await this._client.send(report);
}
From 4bed35559fa26823759fcedb02bc0c55b5a24994 Mon Sep 17 00:00:00 2001
From: Adam Cronin
Date: Tue, 8 Aug 2023 17:30:38 -0400
Subject: [PATCH 5/6] Changing the ErrorBoundary name to be optional with a
default
---
packages/react/src/ErrorBoundary.tsx | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/packages/react/src/ErrorBoundary.tsx b/packages/react/src/ErrorBoundary.tsx
index 863f3cf1..9355f6a7 100644
--- a/packages/react/src/ErrorBoundary.tsx
+++ b/packages/react/src/ErrorBoundary.tsx
@@ -7,7 +7,7 @@ type RenderFallback = () => ReactElement;
export interface Props {
children: ReactNode;
fallback?: ReactElement | RenderFallback;
- name: string;
+ name?: string;
}
export interface State {
@@ -34,7 +34,10 @@ export class ErrorBoundary extends Component {
public async componentDidCatch(error: Error, info: ErrorInfo) {
const { name } = this.props;
- const report = new BacktraceReport(error, { 'errorboundary.name': name, 'error.type': 'Rendering error' });
+ const report = new BacktraceReport(error, {
+ 'errorboundary.name': name ?? 'main',
+ 'error.type': 'Rendering error',
+ });
report.addStackTrace(this.COMPONENT_THREAD_NAME, info.componentStack);
await this._client.send(report);
}
From 550f5dbbc69082eb658cfeeeb8c7bbc63d526a84 Mon Sep 17 00:00:00 2001
From: Adam Cronin
Date: Wed, 9 Aug 2023 10:24:36 -0400
Subject: [PATCH 6/6] Updating error.type in ErrorBoundary
---
packages/react/src/ErrorBoundary.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/react/src/ErrorBoundary.tsx b/packages/react/src/ErrorBoundary.tsx
index 9355f6a7..0e6bfb14 100644
--- a/packages/react/src/ErrorBoundary.tsx
+++ b/packages/react/src/ErrorBoundary.tsx
@@ -36,7 +36,7 @@ export class ErrorBoundary extends Component {
const { name } = this.props;
const report = new BacktraceReport(error, {
'errorboundary.name': name ?? 'main',
- 'error.type': 'Rendering error',
+ 'error.type': 'Unhandled exception',
});
report.addStackTrace(this.COMPONENT_THREAD_NAME, info.componentStack);
await this._client.send(report);