log-center/web/src/main.tsx
zyc c8204b6d47
Some checks failed
Build and Deploy Log Center / build-and-deploy (push) Failing after 1m19s
feat(self-report): 日志中台自身接入错误上报
- 新增 app/self_report.py:后端运行时异常直接写入自身数据库
- main.py:添加全局异常处理器 + 启动时注册 log_center_api/web 项目
- web/api.ts:添加 reportError 函数 + Axios 5xx 拦截器
- web/main.tsx:添加 window.onerror / onunhandledrejection 全局捕获
- deploy.yaml:CI/CD 流水线各步骤失败时上报(build/deploy)
- 重写 integration_guide.md:按三类上报(runtime/cicd/deployment)重新组织

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:08:26 +08:00

27 lines
724 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'
import { reportError } from './api'
// 全局错误捕获JS 运行时异常
window.onerror = (_message, source, lineno, colno, error) => {
if (error) {
reportError(error, { source, lineno, colno })
}
}
// 全局错误捕获:未处理的 Promise rejection
window.onunhandledrejection = (event: PromiseRejectionEvent) => {
const error = event.reason instanceof Error
? event.reason
: new Error(String(event.reason))
reportError(error, { type: 'unhandledrejection' })
}
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)