docs(engineering): add project audit report and improvement plan
This commit introduces a comprehensive engineering audit report for the Tootaio Studio project. The report is structured into documents covering architecture, code quality, performance, security, CI/CD, and observability. It also includes a phased improvement roadmap and a set of `.patch` files to apply immediate fixes for content schemas, package scripts, and CI configuration.
This commit is contained in:
40
docs/20251106/observability.md
Normal file
40
docs/20251106/observability.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# 监控、日志与可观测性
|
||||
|
||||
## 目标
|
||||
构建可追踪错误、性能瓶颈与用户关键路径的最小监控闭环。
|
||||
|
||||
## Sentry(推荐)
|
||||
1) 配置 `runtimeConfig.sentryDsn`;
|
||||
2) 插件(示例,待引入依赖后启用):
|
||||
```ts
|
||||
// plugins/sentry.client.ts
|
||||
export default defineNuxtPlugin(() => {
|
||||
const { public: pub, sentryDsn } = useRuntimeConfig()
|
||||
if (!sentryDsn) return
|
||||
// @ts-ignore: add SDK in deps later
|
||||
const Sentry = (window as any).Sentry
|
||||
if (Sentry) {
|
||||
Sentry.init({ dsn: sentryDsn, tracesSampleRate: 0.1 })
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## 日志与错误边界
|
||||
- 服务器:使用 Nitro 默认日志(生产应接入集中式日志,如 CloudWatch/ELK)。
|
||||
- 客户端:全局错误捕获(`app:error` 事件)上报到 Sentry/自建网关。
|
||||
|
||||
## Web Vitals(可选)
|
||||
收集 LCP/CLS/INP 等指标(示例):
|
||||
```ts
|
||||
// plugins/web-vitals.client.ts
|
||||
import { onCLS, onINP, onLCP } from 'web-vitals'
|
||||
export default defineNuxtPlugin(() => {
|
||||
const send = (metric: any) => navigator.sendBeacon('/vitals', JSON.stringify(metric))
|
||||
onLCP(send); onCLS(send); onINP(send)
|
||||
})
|
||||
```
|
||||
|
||||
## Dashboard 路线
|
||||
- 第一步:仅错误计数与关键事务。
|
||||
- 第二步:接口慢查询、资源错误分布、版本追踪(commit SHA)。
|
||||
|
||||
Reference in New Issue
Block a user