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