Posthog Instrumentation

posthog/posthog-for-claude/skills/posthog-instrumentation

作者 posthog412211932258無授權條款13 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫7 個月前更新

Automatically add PostHog analytics instrumentation to code. Triggers when user asks to add tracking, instrument events, add analytics, or implement feature flags in their codebase.

已封存僅含說明Software Development
AI 產生的概覽

為應用程式碼加入 PostHog 分析、事件追蹤與功能旗標埋點,支援多種框架。

功能
引導代理為程式碼庫接入 PostHog 分析。它會辨識所用框架、檢查是否已有 PostHog 設定,並加入事件追蹤、使用者識別與功能旗標程式碼。它提供 JavaScript/TypeScript、Python 與 React 的程式碼範例,以及命名與漸進式發布的最佳實務。
適用情境
適用於使用者要求為程式碼加入 PostHog 或分析功能、追蹤事件或使用者行為,或實作功能旗標的情境。適合在既有應用程式碼庫中進行埋點工作。
執行需求
不含指令碼,僅為說明文件。使用時需要能存取目標程式碼庫,並為被埋點的應用程式準備 PostHog 專案 API 金鑰。

PostHog 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

  1. Identify the framework (React, Next.js, Python, Node.js, etc.)
  2. Check for existing PostHog setup
  3. Add appropriate instrumentation

Code Patterns

JavaScript/TypeScript

javascript
// Event trackingposthog.capture('button_clicked', { button_name: 'signup' })
// Feature flagsif (posthog.isFeatureEnabled('new-feature')) {  // Show new feature}
// User identificationposthog.identify(userId, { email: user.email })

Python

python
from posthog import Posthogposthog = Posthog(api_key='<ph_project_api_key>')
# Event trackingposthog.capture(distinct_id='user_123', event='purchase_completed')
# Feature flagsif posthog.feature_enabled('new-feature', 'user_123'):    # Show new feature

React

jsx
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/posthog-for-claude位於skills/posthog-instrumentation提交4122119

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架