返回顶部
p

posthogPosthog

>

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
796
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

posthog

PostHog API 技能

通过 REST API 与 PostHog 交互。两种端点类型:

  • - 公共端点(仅 POST,项目 API 密钥):捕获事件、评估标志——无速率限制
  • 私有端点(个人 API 密钥):查询、CRUD 所有资源——有速率限制

设置

  1. 1. 获取个人 API 密钥:https://us.posthog.com/settings/user-api-keys
  2. 获取项目 ID:https://us.posthog.com/settings/project#variables
  3. 设置环境变量:
bash export POSTHOGAPIKEY=phx_... export POSTHOGPROJECTID=12345 export POSTHOGPROJECTAPIKEY=phc... # 可选,用于捕获/标志 # 对于 EU 云: # export POSTHOG_HOST=https://eu.posthog.com # export POSTHOGINGESTHOST=https://eu.i.posthog.com
  1. 4. 验证:bash scripts/posthog.sh whoami

辅助脚本

scripts/posthog.sh 封装了常用操作。运行 bash scripts/posthog.sh help 查看完整用法。

示例

bash

捕获事件


bash scripts/posthog.sh capture signup user_123 {plan:pro}

评估功能标志

bash scripts/posthog.sh evaluate-flags user_123

HogQL 查询——最近 7 天的热门事件

bash scripts/posthog.sh query SELECT event, count() FROM events WHERE timestamp >= now() - INTERVAL 7 DAY GROUP BY event ORDER BY count() DESC LIMIT 20

列出用户

bash scripts/posthog.sh list-persons 10 | jq .results[] | {name, distinct_ids}

列出功能标志

bash scripts/posthog.sh list-flags | jq .results[] | {id, key, active}

创建功能标志

echo {key:new-dashboard,name:New Dashboard,active:true,filters:{groups:[{rollout_percentage:50}]}} | \ bash scripts/posthog.sh create-flag

列出仪表板

bash scripts/posthog.sh list-dashboards | jq .results[] | {id, name}

关键概念

两种 API 类型

  • - 公共端点(/i/v0/e/、/batch/、/flags):在请求体中使用项目 API 密钥。无需认证头。无速率限制。
  • 私有端点(/api/projects/:project_id/...):通过 Authorization: Bearer 使用个人 API 密钥。有速率限制。

HogQL 查询

查询端点(POST /api/projects/:project_id/query/)是提取数据最强大的方式。使用类似 SQL 的 HogQL 语法,针对表:events、persons、sessions、groups,以及数据仓库表。

始终包含时间范围和 LIMIT。对于大量导出,使用基于时间戳的分页。

速率限制(私有端点)
类型限制
分析(洞察、用户、录制)240/分钟,1200/小时
查询端点
2400/小时 |

| 功能标志本地评估 | 600/分钟 | | 其他 CRUD | 480/分钟,4800/小时 |

限制按组织应用。遇到 429:退避重试。

域名
公共私有
美国us.i.posthog.comus.posthog.com
欧盟
eu.i.posthog.com | eu.posthog.com |

事件 API(已弃用)

/api/projects/:project_id/events/ 端点已弃用。请改用 HogQL 查询或批量导出。

直接使用 curl

bash

私有端点


curl -H Authorization: Bearer $POSTHOGAPIKEY \
$POSTHOGHOST/api/projects/$POSTHOGPROJECTID/featureflags/

HogQL 查询

curl -H Authorization: Bearer $POSTHOGAPIKEY \ -H Content-Type: application/json \ -X POST -d {query:{kind:HogQLQuery,query:SELECT count() FROM events WHERE timestamp >= now() - INTERVAL 1 DAY}} \ $POSTHOGHOST/api/projects/$POSTHOGPROJECT_ID/query/

捕获事件(公共)

curl -H Content-Type: application/json \ -X POST -d {apikey:$POSTHOGPROJECTAPIKEY,event:test,distinct_id:u1} \ $POSTHOGINGESTHOST/i/v0/e/

完整 API 参考

参见 references/api-endpoints.md 获取包含参数、请求体模式、作用域和响应格式的完整端点列表。

章节:公共端点(捕获、批量、标志)、私有端点(用户、功能标志、洞察、仪表板、注释、群体、实验、调查、操作、会话录制、用户、定义)、查询 API(HogQL)。

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 posthog-1776180376 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 posthog-1776180376 技能

通过命令行安装

skillhub install posthog-1776180376

下载

⬇ 下载 posthog v1.0.0(免费)

文件大小: 7.78 KB | 发布时间: 2026-4-15 13:09

v1.0.0 最新 2026-4-15 13:09
Initial release: Full PostHog API skill with HogQL queries, event capture, feature flags, persons, insights, dashboards, experiments, surveys, and more

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部