posthog-instrumentation
作者: posthog
自動化跨多個框架的PostHog分析、事件追蹤與功能開關檢測。支援JavaScript/TypeScript、React、Python及Node.js,並提供框架專屬的設定模式。涵蓋三大核心功能:含自訂屬性的事件擷取、用於逐步發布的功能開關評估,以及使用者識別。能偵測現有PostHog設定,在不重複配置的情況下加入檢測功能。包含事件命名慣例、屬性...的最佳實踐。
npx skills add https://github.com/posthog/posthog-for-claude --skill posthog-instrumentationPostHog Instrumentation Skill
Help users add PostHog analytics, event tracking, and feature flags to their code.
When to Use
- User asks to "add PostHog" or "add analytics"
- User wants to track events or user actions
- User needs to implement feature flags
- User asks about instrumenting their code
Workflow
- Identify the framework (React, Next.js, Python, Node.js, etc.)
- Check for existing PostHog setup
- Add appropriate instrumentation
Code Patterns
JavaScript/TypeScript
// Event tracking
posthog.capture('button_clicked', { button_name: 'signup' })
// Feature flags
if (posthog.isFeatureEnabled('new-feature')) {
// Show new feature
}
// User identification
posthog.identify(userId, { email: user.email })
Python
from posthog import Posthog
posthog = Posthog(api_key='<ph_project_api_key>')
# Event tracking
posthog.capture(distinct_id='user_123', event='purchase_completed')
# Feature flags
if posthog.feature_enabled('new-feature', 'user_123'):
# Show new feature
React
import { usePostHog } from 'posthog-js/react'
function MyComponent() {
const posthog = usePostHog()
const handleClick = () => {
posthog.capture('button_clicked')
}
}
Best Practices
- Use consistent event naming (snake_case recommended)
- Include relevant properties with events
- Identify users early in their session
- Use feature flags for gradual rollouts
來自 posthog 的更多技能
error-tracking-go
posthog
PostHog 錯誤追蹤 for Go
official
integration-laravel
posthog
PostHog 整合至 Laravel 應用程式
official
integration-nextjs-app-router
posthog
PostHog 整合,適用於 Next.js App Router 應用程式
official
logs-other
posthog
PostHog 其他語言的日誌
official
logs-python
posthog
PostHog 的 Python 日誌
official
analyzing-experiment-session-replays
posthog
分析實驗變體中的會話重播模式,以了解使用者行為差異。當使用者想了解使用者如何與……互動時使用。
official
auditing-experiments-flags
posthog
稽核 PostHog 實驗與功能開關的設定問題、過時狀態及最佳實務違規。當使用者要求稽核、健康檢查…時讀取。
official
auditing-warehouse-data-health
posthog
此技能會產生專案層級的資料倉儲管線稽核。當使用者想要了解所有異常項目的摘要,而非深入探討單一同步時,請使用此技能。深入分析個別失敗的項目屬於 diagnosing-failed-warehouse-syncs 技能;此技能則是提供掃描結果,指引使用者優先檢查的方向。
official