数据分析

Posthog Analytics

试用

Automate PostHog dashboard creation, sync, update, and export via API. Covers dashboard CRUD, insight creation, cohort management, and API-driven analytics w...

它能做什么

Automate PostHog dashboard creation, sync, update, and export via API.

技能文档

PostHog Analytics Skill

Automate PostHog dashboard creation, sync, update, and export via API.

Prerequisites

Required Tools

  • curl - HTTP client (pre-installed on macOS/Linux)
  • jq - JSON processor: brew install jq or apt install jq
  • bash - Shell (the script is bash)

PostHog API Key

  1. Go to PostHog Settings → Personal API Keys
  2. Create a new key with read/write access
  3. Export it:
export POSTHOG_PERSONAL_API_KEY=phx_xxx

Note: The API key determines your organization and project. The script uses @current project context (your default project).

Verify Setup

# Test your API key - should return your project info
curl -s -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
  "https://us.i.posthog.com/api/projects/@current/" | jq '{id, name}'

Expected output:

{
  "id": 209268,
  "name": "Default project"
}

If you get an error, check your API key is correct and has proper permissions.

Quick Start: Blog Analytics Example

Step 1: Write Your Config

Create blog_dashboard.json:

{
  "name": "Blog Analytics",
  "description": "Track blog performance and reader engagement",
  "filter": {"key": "source", "value": "blog"},
  "dashboard_id": null,
  "insights": [
    {"name": "Blog Pageviews (Total)", "type": "pageviews_total"},
    {"name": "Unique Blog Readers", "type": "unique_users"},
    {"name": "Blog Traffic Trend", "type": "traffic_trend"},
    {"name": "Top Blog Posts", "type": "top_pages"}
  ]
}

Note: Set dashboard_id: null for new dashboards.

Step 2: Create Dashboard

./scripts/posthog_sync.sh create blog_dashboard.json

Output:

Creating dashboard: Blog Analytics
Dashboard created: ID 1166599
Creating insight: Blog Pageviews (Total)
{id: 6520531, name: "Blog Pageviews (Total)"}
...
Dashboard URL: https://us.posthog.com/project/209268/dashboard/1166599

The script:

  • Creates a new dashboard in your PostHog project
  • Returns dashboard_id (e.g., 1166599) and project_id (e.g., 209268) in the URL
  • Automatically updates your config file with the dashboard_id

Step 3: Add New Insights (Sync)

Edit config to add new insights, then:

./scripts/posthog_sync.sh sync blog_dashboard.json

Only creates NEW insights. Existing ones (matched by name) are skipped.

Step 4: Update Existing Insights

Changed your filter? Edit config, then:

./scripts/posthog_sync.sh update blog_dashboard.json

Updates ALL insights with current config settings. Use when changing filters.

Step 5: Export Existing Dashboard

./scripts/posthog_sync.sh export 1166599 > exported_dashboard.json

Config Reference

FieldRequiredDescription
nameYesDashboard name
descriptionNoDashboard description
filterNo*Event property filter: {"key": "source", "value": "blog"}
domain_filterNo*URL filter fallback: "blog.sylph.ai"
dashboard_idNoSet to null for create, or existing ID for sync/update
insightsYesArray of insight objects

*At least one filter recommended. filter takes precedence over domain_filter.

Insight Types

TypeDisplayDescription
pageviews_totalBoldNumberTotal pageview count
unique_usersBoldNumberUnique visitors (DAU)
traffic_trendLineGraphTraffic over time
top_pagesTableTop pages breakdown

Optional Insight Fields

FieldDefaultOptions
mathtotaltotal, dau, weekly_active, monthly_active
displayAutoBoldNumber, ActionsLineGraph, ActionsTable
date_range-30d-7d, -30d, -90d, etc.

Environment Variables

VariableRequiredDefaultDescription
POSTHOG_PERSONAL_API_KEYYes-Your API key (determines org/project)
POSTHOG_HOSTNous.i.posthog.comAPI host (EU: eu.i.posthog.com)
POSTHOG_UI_HOSTNous.posthog.comUI host for dashboard URLs

Files

  • scripts/posthog_sync.sh - CLI script (create/sync/update/export)
  • examples/blog_dashboard.json - Example config

References

相关技能

把自然语言描述转为结构化 JSON,并由 mcp-diagram-generator MCP 服务生成 Draw.io、Mermaid 或 Excalidraw 图表文件。

作者 nssa.io1.0k 次安装47 星标

在 Codex 插件目录中生成必需清单、可选子目录与规范化名称。

作者 OpenAI27.5k 星标

基于 git 历史构建代码安全归属图谱,识别孤立敏感代码、bus factor 风险与归属集群。

作者 OpenAI27.5k 星标

从 AdMapix API 拉取广告创意、应用、榜单和收入预估等数据,原样返回结构化 JSON。

作者 fly0pants

Deploy web projects to Netlify using the Netlify CLI (`npx netlify`). Use when the user asks to deploy, host, publish, or link a site/repo on Netlify, including preview and production deploys.

作者 OpenAI27.5k 星标

sentry

官方

Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry CLI; perform read-only queries using the `sentry` command

作者 OpenAI27.5k 星标

solomonneas 的更多技能

浏览全部技能

Essential penetration testing command reference. Quick lookup for nmap, Metasploit, hydra, john, nikto, gobuster, and other offensive security tools. Covers...

作者 Solomon Neas65 次安装1 星标

Memory forensics with Volatility and related tools. Acquire RAM dumps, extract processes and DLLs, investigate rootkits and fileless malware, recover credent...

作者 solomonneas30 次安装1 星标

This skill should be used when the user asks to "run pentest commands", "scan with nmap", "use metasploit exploits", "crack passwords with hydra or john", "s...

作者 solomonneas36 次安装

Expert malware analysis for defensive security research. Static and dynamic analysis, sandbox triage, IOC extraction, unpacking, and malware family identific...

作者 solomonneas31 次安装

Knowledge card memory system with semantic search. Agents wake up fresh each session but remember everything through atomic ~350-token cards with YAML frontm...

作者 solomonneas28 次安装

Network traffic analysis with Wireshark and tshark. Capture packets, write display and BPF filters, follow TCP/UDP/TLS streams, detect C2 beacons, troublesho...

作者 solomonneas27 次安装