frontend-observability
它能做什么
这个系统可以帮你了解真实用户是如何使用你的网页或移动应用的。它会收集事件、性能和错误等信息,在保护用户隐私的同时,确保数据被可靠地采集。
适用场景
- ✓想知道用户最常点击哪些按钮的时候。
- ✓想监控真实用户的页面加载速度的时候。
- ✓想发现并上报应用中出现的错误的时候。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/frontend-observability/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我想知道用户最常用网站的哪些功能,以及他们有没有遇到报错。”
每周 5 个新技能,1 分钟读完。
工作原理
它会记录应用中发生的重要事件,然后把这些事件发送到不同的分析工具中。即使其中某个工具出了故障,其他工具也会继续工作,不会影响应用运行。它还会测量真实用户的性能表现,并且只有在用户同意的情况下才会发送数据。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Frontend Observability (the field side)
When to Use
Use this skill when you need a portable, framework-agnostic field-side observability system for any React or React Native app. Establishes one typed event taxonomy (canonical event-name constants, never inline strings), a best-effort non-blocking provider fan-out so a failing or absent analytics provider can never...
Portable skill — readable by Claude Code, OpenCode, Codex, Cursor, Windsurf, and others. This skill describes a field-side observability system — event taxonomy, provider fan-out, real-user vitals, error reporting, consent — not a dashboard or a specific vendor. It is the field complement to the frontend-lighthouse skill: Lighthouse is the lab gate (synthetic, pre-merge); this is the field (what real users actually experience). It lives in a
services/analytics/module per the frontend-architecture skill.
The goal: you can answer "what are real users doing, and what are they experiencing?" — with a
typed event vocabulary (no stringly-typed track("clicked_thing") scattered everywhere), a
fan-out that is best-effort (a broken provider never breaks the app), real Core Web Vitals
from the field, and consent respected before anything fires.
0. The five core ideas
- Events are a typed vocabulary. Event names are canonical constants with a union type — never inline string literals. The taxonomy is reviewable in one file and the compiler rejects typos.
- Fan-out is best-effort and non-blocking.
track()dispatches to every provider, each in its own try/catch. A missing global, a thrown provider, an unloaded script — none can throw into the caller or stop the other providers. - One entry point, SSR-safe. A single
track(event, props)is the only way to record. It's reached through a context hook that no-ops outside a provider and on the server, so instrumented components render safely anywhere. - Field vitals complement lab budgets. Real-user LCP/INP/CLS are reported to the same fan-out. Lighthouse proves the build can be fast; field vitals prove it is — together they close the loop.
- Consent gates everything. No telemetry (events, vitals, error reports with PII) fires before opt-in. Consent state is checked at the fan-out boundary, not sprinkled through call sites.
1. Directory layout
The system is one service module plus its constants (per frontend-architecture).
src/
├── constants/
│ └── analytics.ts ← canonical event names + AnalyticsEvent union
├── services/analytics/
│ ├── index.ts ← barrel: track, adapters, types
│ ├── track.ts ← the best-effort fan-out (single entry point)
│ ├── adapters.ts ← one (event, props) => void per provider, window-guarded
│ ├── web-vitals.ts ← report real-user LCP/INP/CLS into track()
│ └── consent.ts ← consent gate read by the fan-out
├── providers/
│ └── AnalyticsProvider.tsx ← 'use client' context exposing useAnalytics().track
└── error/
└── ErrorBoundary.tsx ← reports caught render errors via the fan-out
2. The event taxonomy (typed, never inline)
One file owns every event name. Components reference constants; the union type makes typos a compile error and the catalog a single source of truth.
// constants/analytics.ts
export const ANALYTICS_EVENTS = {
PROJECT_CLICK: "project_click",
GITHUB_CLICK: "github_click",
RESUME_DOWNLOAD: "resume_download",
CONTACT_SUBMISSION: "contact_submission",
} as const;
export type AnalyticsEvent =
(typeof ANALYTICS_EVENTS)[keyof typeof ANALYTICS_EVENTS];
// CORRECT — typed constant, autocompletes, can't typo
track(ANALYTICS_EVENTS.GITHUB_CLICK, { url });
// WRONG — stringly-typed, drifts, no compile check
track("github-click"); // ❌ silently a different event from "github_click"
Hard rules:
- No inline event-name strings anywhere; only
ANALYTICS_EVENTS.*. - Event names are snake_case and stable — renaming one breaks historical dashboards, so treat the catalog as a contract.
- Keep
propsshapes small and PII-light (see §6); prefer ids over names, never raw emails.
3. Best-effort, non-blocking fan-out
track() is the single entry point. It iterates the adapter registry, guarding each call so one
provider can't affect the caller or the others.
// services/analytics/track.ts
…
常见问题
“与框架无关”(framework-agnostic)是什么意思?
意思是这个系统可以用在任何类型的网页或移动项目中,不受开发所用技术(框架)的限制,比如 React 或 React Native 都可以使用。
什么是 Core Web Vitals?
这是一组重要的指标,用来衡量网页在加载速度、交互响应和视觉稳定性方面的用户体验。
用户隐私是如何得到保护的?
只有在用户明确同意之后,系统才会收集并发送遥测数据,而且收集的数据不包含可以识别个人身份的信息。
详情
作者的原始描述
A portable, framework-agnostic field-side observability system for any React or React Native app.
热度
- GitHub 星标
- 48k
- 排名
- #4670
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。