docs(changeset): feat(error-manager): implement centralized error reporting system
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { Button, Code, Collapse, Group, Paper, rem, Text } from '@mantine/core';
|
||||
import { IconExclamationCircle } from '@tabler/icons-react';
|
||||
import React, { type PropsWithChildren } from 'react';
|
||||
|
||||
import errorManager from './ErrorManager';
|
||||
|
||||
let ErrorBoundaryOptions = {
|
||||
disabled: false,
|
||||
onError: undefined,
|
||||
@@ -68,7 +71,12 @@ export class ReactErrorBoundary extends React.Component<ErrorBoundaryProps, Erro
|
||||
if (typeof GetErrorBoundaryOptions()?.onError === 'function') {
|
||||
GetErrorBoundaryOptions()?.onError?.(error, errorInfo);
|
||||
}
|
||||
// You can also log error messages to an error reporting service here
|
||||
|
||||
// Report error to error manager (Sentry, custom API, etc.)
|
||||
errorManager.reportError(error, errorInfo, {
|
||||
componentStack: errorInfo?.componentStack,
|
||||
namespace: this.props.namespace,
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -202,6 +210,19 @@ export class ReactErrorBoundary extends React.Component<ErrorBoundaryProps, Erro
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
// Manually report error if user clicks report button
|
||||
if (this.state.error && this.state.errorInfo) {
|
||||
await errorManager.reportError(this.state.error, this.state.errorInfo, {
|
||||
componentStack: this.state.errorInfo?.componentStack,
|
||||
namespace: this.props.namespace,
|
||||
tags: { reportedBy: 'user' },
|
||||
});
|
||||
|
||||
this.setState(() => ({
|
||||
reported: true,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
reset() {
|
||||
|
||||
Reference in New Issue
Block a user