Skills2026年4月16日·1 分钟阅读

PostHog — Open Source Product Analytics & Session Replay

PostHog is a self-hosted product analytics platform with event tracking, session replay, feature flags, A/B testing, and a data warehouse built in.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
PostHog Overview
直接安装命令
npx -y tokrepo@latest install 53fe9ca0-39c1-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

TL;DR
PostHog provides self-hosted product analytics with session replay, feature flags, and A/B testing in one platform.
§01

What it is

PostHog is an open-source product analytics platform that combines event tracking, session replay, feature flags, A/B testing, and a data warehouse in a single self-hosted application. It replaces the need for separate tools like Google Analytics, Hotjar, LaunchDarkly, and Optimizely.

PostHog is for product teams who want full control over their analytics data. It suits startups and enterprises that need product insights without sending user behavior data to third-party services.

§02

How it saves time or tokens

This workflow provides a single Docker command that launches a working PostHog instance. Instead of configuring multiple analytics tools separately, you get everything in one deployment. The included JavaScript snippet auto-captures page views, clicks, and form submissions without manual event instrumentation.

§03

How to use

  1. Deploy PostHog with Docker:
docker run -d --name posthog \
  -p 8000:8000 \
  -v posthog_data:/var/lib/postgresql/data \
  posthog/posthog:release
  1. Open http://localhost:8000 and complete the setup wizard. Create your organization and first project.
  1. Add the PostHog snippet to your application:
<script>
  !function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
  posthog.init('your-project-api-key', {api_host: 'http://localhost:8000'})
</script>
§04

Example

// Custom event tracking
posthog.capture('purchase_completed', {
  product_id: 'prod_123',
  amount: 49.99,
  currency: 'USD'
});

// Feature flag check
if (posthog.isFeatureEnabled('new_checkout_flow')) {
  renderNewCheckout();
} else {
  renderClassicCheckout();
}

// Identify users
posthog.identify('user_123', {
  email: 'user@example.com',
  plan: 'pro'
});
§05

Related on TokRepo

§06

Common pitfalls

  • The Docker single-container deployment is for evaluation only. Production deployments need separate PostgreSQL, Redis, ClickHouse, and Kafka instances. Use the PostHog Helm chart for Kubernetes.
  • Auto-capture records every click and page view, which can generate high event volumes. Use the autocapture config option to filter unnecessary events.
  • Session replay recordings consume significant storage. Set retention policies to avoid running out of disk space.

常见问题

What does PostHog include?+

PostHog includes product analytics (event tracking, funnels, retention), session replay (video recordings of user sessions), feature flags (gradual rollouts), A/B testing (experiments), and a data warehouse for SQL queries on your analytics data.

Is PostHog free?+

PostHog is open source under the MIT license. Self-hosted deployments are free with no event limits. PostHog Cloud offers a free tier with generous limits and paid plans for higher volumes.

How does PostHog compare to Google Analytics?+

PostHog focuses on product analytics (user behavior, funnels, retention) while GA focuses on marketing analytics (traffic sources, campaigns). PostHog includes session replay, feature flags, and A/B testing. PostHog can be self-hosted for full data control.

Can I use PostHog with mobile apps?+

Yes. PostHog provides SDKs for iOS, Android, React Native, and Flutter. Mobile SDKs support event tracking, feature flags, and user identification. Session replay for mobile is available on select platforms.

Does PostHog support A/B testing?+

Yes. PostHog experiments let you run A/B tests with statistical significance calculations. You define variants, target user segments, and track conversion goals. Results include confidence intervals and sample size recommendations.

引用来源 (3)

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产