feat: 更新 sentry 错误上报

This commit is contained in:
claude-code-best
2026-04-03 09:39:25 +08:00
parent 1f0a2e44c8
commit 119518599e
11 changed files with 493 additions and 2 deletions

View File

@@ -1,7 +1,10 @@
import * as React from 'react'
import { captureException } from 'src/utils/sentry.js'
interface Props {
children: React.ReactNode
/** Optional label for identifying which component boundary caught the error */
name?: string
}
interface State {
@@ -18,6 +21,13 @@ export class SentryErrorBoundary extends React.Component<Props, State> {
return { hasError: true }
}
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {
captureException(error, {
componentBoundary: this.props.name || 'SentryErrorBoundary',
componentStack: errorInfo.componentStack,
})
}
render(): React.ReactNode {
if (this.state.hasError) {
return null