跳到正文
Skillpedia
通用编程12k · #11524

posthog-instrumentation

它能做什么

这个技能帮助你的 AI 在代码中添加 PostHog 跟踪。适合希望衡量用户行为,或通过功能开关测试新功能的人员。

适用场景

  • ✓你想跟踪应用中的按钮点击或其他用户操作的时候。
  • ✓你想为网站或软件项目添加 PostHog 或基础分析的时候。
  • ✓你想通过功能开关为部分用户开启或关闭新功能的时候。

技能链接

https://github.com/trycompai/crm/blob/release/.agents/skills/posthog-instrumentation/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/trycompai/crm/blob/release/.agents/skills/posthog-instrumentation/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请为我的应用添加 PostHog 跟踪,让我能看到人们何时点击注册按钮。”

每周 5 个新技能,1 分钟读完。

工作原理

这个技能查看你的项目使用的框架,检查 PostHog 是否已经设置,然后添加相应的跟踪代码。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

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

// 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
常见问题

这个技能适用于 React 和 Python 项目吗?

适用。这个技能包含 JavaScript、TypeScript、React 和 Python 的代码示例。

我需要 PostHog 账户吗?

示例使用 PostHog 项目 API 密钥,因此你需要从自己的 PostHog 账户获取一个。

事件名称应该是什么样的?

这个技能建议使用 snake_case 格式的简短事件名,例如 button_clicked。

详情

作者的原始描述

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.

repo: trycompai/crm

热度

GitHub 星标
12k
排名
#11524
许可证
MIT
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能