error-tracking-nextjs
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "error-tracking-nextjs" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-2e94ef81076a603422ad5926cdfc5ce5dc37486cd38e6925d1eb9f2fb840d67e. Verify the upstream source and version against https://skills.sh/posthog/skills/error-tracking-nextjs before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skills.sh
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Provides guidance and configuration advice for PostHog-based error tracking in Next.js applications, focusing on the process and practices for capturing and reporting error events to PostHog.
Introduction source: third_party · posthog · 1.0.0 Reference
SkillPi interpretation
- Tasks
- PostHog error tracking for Next.js
- Testing
- Not tested
Browse files
Frontmatter
name: error-tracking-nextjs
description: PostHog error tracking for Next.js
metadata:
author: PostHog
version: 1.9.4PostHog 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 - docsreferences/fingerprints.md- Fingerprints - docsreferences/alerts.md- Send error tracking alerts - docsreferences/monitoring.md- Monitor and search issues - docsreferences/assigning-issues.md- Assign issues to teammates - docsreferences/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)
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 Next.js 集成 PostHog 错误追踪的完整指南,解决开发者实际痛点
- 涵盖环境变量、最小化变更、自动捕获、Source Map 上传等关键原则
- 引用多个官方文档,信息来源可靠
Highlights
- description 字段完整且位置正确,清晰描述 Skill 核心功能
- 触发词精准,边界明确,覆盖合理
Areas to improve
-
缺少端到端示例 Reported severity: Minor
文档提供了原则和指南,但未包含完整的端到端代码示例(如 instrumentation-client.ts 的具体实现)
Recommendation: 建议补充一个完整的 Next.js 项目集成 PostHog 错误追踪的端到端示例,包括初始化、错误捕获和 Source Map 上传的完整流程
Highlights
- 文档结构清晰,包含 Key principles 和 Framework guidelines 等章节
- 提供了 Next.js 特定的最佳实践和常见陷阱避免指南
Areas to improve
-
主要异常未处理 Reported severity: Major
未覆盖 PostHog 服务不可用、网络错误、初始化失败等主要异常场景的处理建议
Recommendation: 建议添加异常处理指南,包括 PostHog 服务不可用时的降级策略、网络错误的重试机制以及初始化失败的兜底方案
Highlights
- 强调使用环境变量和最小化变更,提升配置安全性
- 提及 Source Map 上传以解析堆栈,提升调试效率
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.