error-tracking-nextjs

为 Next.js 应用提供基于 PostHog 的错误追踪说明与配置建议,聚焦在将错误事件捕获并上报到 PostHog 的流程与实践。

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "error-tracking-nextjs":https://skillpi.com/zh/skills/deepskill-2e94ef81076a603422ad5926cdfc5ce5dc37486cd38e6925d1eb9f2fb840d67e。安装前核对上游来源和版本:https://skills.sh/posthog/skills/error-tracking-nextjs。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

skills.sh

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

为 Next.js 应用提供基于 PostHog 的错误追踪说明与配置建议,聚焦在将错误事件捕获并上报到 PostHog 的流程与实践。

0 下载

介绍来源: third_party · posthog · 1.0.0 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: error-tracking-nextjs
description: PostHog error tracking for Next.js
metadata:
  author: PostHog
  version: 1.9.4

PostHog error tracking for Next.js

This skill helps you add PostHog error tracking to Next.js applications.

Reference files

  • references/nextjs.md - Next.js error tracking installation - docs
  • references/fingerprints.md - Fingerprints - docs
  • references/alerts.md - Send error tracking alerts - docs
  • references/monitoring.md - Monitor and search issues - docs
  • references/assigning-issues.md - Assign issues to teammates - docs
  • references/upload-source-maps.md - Upload source maps - docs

Consult the documentation for API details and framework-specific patterns.

Key principles

  • Environment variables: Always use environment variables for PostHog keys and host URLs. Never hardcode them.
  • Minimal changes: Add error tracking alongside existing error handling. Don't replace or restructure existing error handling code.
  • Autocapture first: Enable exception autocapture in the SDK initialization before adding manual captures.
  • Source maps: Upload source maps so stack traces resolve to original source code, not minified bundles.
  • Manual capture for boundaries: Use captureException() at error boundaries and catch blocks for errors that don't propagate to the global handler.

Framework guidelines

  • For Next.js 15.3+, initialize PostHog in instrumentation-client.ts for the simplest setup
  • For feature flags, use useFeatureFlagEnabled() or useFeatureFlagPayload() hooks - they handle loading states and external sync automatically
  • Add analytics capture in event handlers where user actions occur, NOT in useEffect reacting to state changes
  • Do NOT use useEffect for data transformation - calculate derived values during render instead
  • Do NOT use useEffect to respond to user events - put that logic in the event handler itself
  • Do NOT use useEffect to chain state updates - calculate all related updates together in the event handler
  • Do NOT use useEffect to notify parent components - call the parent callback alongside setState in the event handler
  • To reset component state when a prop changes, pass the prop as the component's key instead of using useEffect
  • useEffect is ONLY for synchronizing with external systems (non-React widgets, browser APIs, network subscriptions)

当前收录版本

1.0.0

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值78/100

亮点

  • 提供 Next.js 集成 PostHog 错误追踪的完整指南,解决开发者实际痛点
  • 涵盖环境变量、最小化变更、自动捕获、Source Map 上传等关键原则
  • 引用多个官方文档,信息来源可靠
触发精准92/100

亮点

  • description 字段完整且位置正确,清晰描述 Skill 核心功能
  • 触发词精准,边界明确,覆盖合理
结构规范75/100

待提升项

  • 缺少端到端示例 原报告严重程度:轻微

    文档提供了原则和指南,但未包含完整的端到端代码示例(如 instrumentation-client.ts 的具体实现)

    改进建议:建议补充一个完整的 Next.js 项目集成 PostHog 错误追踪的端到端示例,包括初始化、错误捕获和 Source Map 上传的完整流程

亮点

  • 文档结构清晰,包含 Key principles 和 Framework guidelines 等章节
  • 提供了 Next.js 特定的最佳实践和常见陷阱避免指南
执行可靠68/100

待提升项

  • 主要异常未处理 原报告严重程度:重大

    未覆盖 PostHog 服务不可用、网络错误、初始化失败等主要异常场景的处理建议

    改进建议:建议添加异常处理指南,包括 PostHog 服务不可用时的降级策略、网络错误的重试机制以及初始化失败的兜底方案

亮点

  • 强调使用环境变量和最小化变更,提升配置安全性
  • 提及 Source Map 上传以解析堆栈,提升调试效率
证据可验 (前四项均值)78/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。