← 返回
未分类 Key 中文

PostHog Query

Run SQL queries against PostHog product analytics data using the PostHog CLI. Use when checking pageviews, event counts, trends, or any analytics data from P...
使用 PostHog CLI 对 PostHog 产品分析数据进行 SQL 查询,适用于检查页面浏览量、事件数量、趋势或任何分析数据。
quinlanjager quinlanjager 来源
未分类 clawhub v1.0.0 1 版本 99470.9 Key: 需要
★ 0
Stars
📥 188
下载
💾 0
安装
1
版本
#latest

概述

PostHog Query Skill

Run HogQL (ClickHouse-compatible SQL) queries against PostHog via the CLI.

One-Time Setup

posthog-cli login  # authenticate interactively; stores token in ~/.posthog/credentials.json

Requires API key scope: query:read.

Command

posthog-cli exp query run "<SQL>"

Results are printed as JSON lines to stdout. The CLI reads auth from ~/.posthog/credentials.json (set up via posthog-cli login).

Property Access Syntax

Use bracket notation for event properties — dot notation with quoted keys does not work:

-- ✅ Correct
properties['$current_url']
properties['$browser']

-- ❌ Wrong
properties.'$current_url'

Examples

Count all pageviews:

posthog-cli exp query run "SELECT count() as pageviews FROM events WHERE event = '\$pageview'"

Filter by URL:

posthog-cli exp query run "SELECT count() as pageviews FROM events WHERE event = '\$pageview' AND properties['\$current_url'] LIKE 'https://example.com/%'"

7-day daily trend:

posthog-cli exp query run "SELECT toDate(timestamp) as date, count() as pageviews FROM events WHERE event = '\$pageview' AND timestamp >= now() - INTERVAL 7 DAY GROUP BY date ORDER BY date"

Recent events:

posthog-cli exp query run "SELECT event, timestamp FROM events ORDER BY timestamp DESC LIMIT 10"

Other Subcommands

  • posthog-cli exp query editor — interactive query editor
  • posthog-cli exp query check "" — syntax/type check without running
  • Append --debug to run to get the full JSON response (columns, types, cache info)

Notes

  • HogQL is ClickHouse-compatible SQL — standard ClickHouse functions apply
  • Shell-escape $ in event names: '\$pageview' or use double quotes carefully
  • The --debug flag returns full metadata including column types and cache status

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-12 06:04 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,227 📥 267,937
ai-agent

self-improving agent

pskoett
捕获经验教训、错误及修正内容,以实现持续改进。适用于以下场景:(1)命令或操作意外失败;(2)用户纠正Claude(如“不,那不对……”“实际上……”);(3)用户请求的功能不存在;(4)外部API或工具出现故障;(5)Claude发现自身
★ 4,082 📥 811,099
dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 676 📥 325,527