Terminal
Terminal/Skill
Adds exception capture and source map uploads to an app, so errors show up with readable stack traces.
By PostHog
Works with
npx skills add posthog/ai-plugin --skill instrument-error-trackingUse this skill to add PostHog error tracking that captures and monitors exceptions in your application. Use it after implementing features or reviewing PRs to ensure errors are tracked with full stack traces and source maps. If PostHog is not yet installed, this skill also covers initial SDK setup. Supports any platform or language.
Supported platforms: React, Next.js, Web (JavaScript), Node.js, Python, PHP, Ruby, Ruby on Rails, Go, Elixir, Angular, Svelte, Nuxt, React Native, Flutter, iOS, Android, and Hono.
Follow these steps IN ORDER:
Look for lockfiles (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lockb, go.sum, pubspec.lock, Podfile.lock, Package.resolved, mix.lock) to determine the package manager.
STEP 2: Research instrumentation. (Skip if PostHog is already set up.) 2.1. Find the reference file below that matches the detected platform — it is the source of truth for SDK initialization, exception autocapture, and framework-specific error tracking patterns. Read it now. 2.2. If no reference matches, fall back to your general knowledge and web search. Use posthog.com/docs as the primary search source.
STEP 3: Install and initialize the PostHog SDK. (Skip if PostHog is already set up.)
STEP 4: Enable exception autocapture.
STEP 5: Add manual error captures.
posthog.captureException() or the platform-equivalent at these locations.STEP 6: Upload source maps (frontend/mobile only).
STEP 7: Set up environment variables.
.env, .env.local, or framework-specific env files). If valid values already exist, skip this step.projects-get tool to retrieve the project's api_token. If multiple projects are returned, ask the user which project to use. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead.projects-get MCP response for a region field — US maps to https://us.i.posthog.com, EU maps to https://eu.i.posthog.com. If the region is not available from the MCP response or from existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud.STEP 8: Verify and clean up.
references/react.md - React error tracking installationreferences/web.md - Web error tracking installationreferences/nextjs.md - Next.js error tracking installationreferences/node.md - Node.js error tracking installationreferences/python.md - Python error tracking installationreferences/django.md - Djangoreferences/flask.md - Flaskreferences/php.md - Php error tracking installationreferences/laravel.md - Laravelreferences/ruby.md - Ruby error tracking installationreferences/ruby-on-rails.md - Ruby on rails error tracking installationreferences/ruby-on-rails.md - Ruby on railsreferences/go.md - Go error tracking installationreferences/dotnet.md - .net error tracking installationreferences/dotnet.md - .netreferences/elixir.md - Elixir error tracking installationreferences/angular.md - Angular error tracking installationreferences/svelte.md - Sveltekit error tracking installationreferences/nuxt-3-7.md - Nuxt error tracking installation (v3.7 and above)references/nuxt-3-6.md - Nuxt error tracking installation (v3.6 and below)references/react-native.md - React native error tracking installationreferences/flutter.md - Flutter error tracking installationreferences/ios.md - Ios error tracking installationreferences/android.md - Android error tracking installationreferences/hono.md - Hono error tracking installationreferences/fingerprints.md - Fingerprintsreferences/alerts.md - Send error tracking alertsreferences/monitoring.md - Monitor and search issuesreferences/assigning-issues.md - Assign issues to teammatesreferences/upload-source-maps.md - Upload source mapsreferences/COMMANDMENTS.md - Framework-specific rules the integration must followEach platform reference contains SDK-specific installation and manual capture patterns. Find the one matching the user's stack.
captureException() at error boundaries and catch blocks for errors that don't propagate to the global handler.