Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

posthog

БесплатноБез исполняемых скриптовНе проверен

PostHog is an open-source product analytics platform: event tracking, funnels, retention, session replay, feature flags and experiments in one tool, on…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

PostHog

Overview

PostHog combines product analytics (events, funnels, retention, cohorts), session replay, feature flags, A/B experiments and surveys. Events are captured by SDKs (browser autocapture plus custom events) and stored per project. Use PostHog Cloud (US https://us.i.posthog.com, EU https://eu.i.posthog.com) unless you must self-host.

Two kinds of keys, often confused:

  • Project token (phc_...): public, goes into browser code and servers, can only send events and read flags.
  • Personal API key (phx_..., created with scopes in account settings): secret, used for the REST API and for server-side local flag evaluation. Never ship it to a browser or commit it.

The old host app.posthog.com is the legacy US address; new setups use https://us.i.posthog.com as api_host (and ui_host: "https://us.posthog.com" if you proxy events through your own domain).

Instructions

1. Browser: posthog-js

npm install posthog-js
// lib/posthog.ts
import posthog from "posthog-js";

export function initPostHog() {
  posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
    api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST ?? "https://us.i.posthog.com",
    defaults: "2025-05-24",            // dated defaults set (pageviews on route change); newer dates exist
    person_profiles: "identified_only", // no profile (and no cost) for anonymous visitors
    capture_pageleave: true,
  });
}

defaults pins behavior to a date; with 2025-05-24 or later capture_pageview becomes 'history_change', which is what single-page apps need. Without it, pageviews are captured only on full loads. In Next.js call initPostHog() once in a client component ("use client" + useEffect), not on the server.

// Custom events, identification, and reset
posthog.capture("user_signed_up", { method: "github" });
posthog.capture("checkout_completed", { plan: "growth", amount_usd: 49 });

posthog.identify("user_8f31c2", { email: "[email protected]", plan: "growth" }); // after login
posthog.reset();                                                               // on logout

Name events object_action in snake_case, keep the list small and documented, and put variations in properties, not new event names.

2. Python server events

pip install posthog
import os
from posthog import Posthog

posthog = Posthog(
    os.environ["POSTHOG_PROJECT_TOKEN"],
    host="https://us.i.posthog.com",
)

posthog.capture(
    "subscription_created",
    distinct_id="user_8f31c2",
    properties={"plan": "growth", "amount_cents": 4900, "currency": "usd"},
)

posthog.set(distinct_id="user_8f31c2", properties={"plan": "growth"})  # person properties

posthog.shutdown()   # flush the queue before the process exits

The signature is capture(event, distinct_id=..., properties=...); the old identify() method is gone, use set(). The client batches in a background thread, so short scripts and serverless handlers must call posthog.flush() or shutdown(). For web frameworks, v6+ has a context API (new_context, identify_context) and Django/Flask middleware that attach the distinct ID automatically; see the Python library docs. Use the same distinct_id as posthog.identify() in the browser so both sides join one person.

3. Feature flags

posthog.onFeatureFlags(() => {
  if (posthog.isFeatureEnabled("new-checkout")) showNewCheckout();
});
const variant = posthog.getFeatureFlag("pricing-test");      // true | "control" | "test" | undefined
const payload = posthog.getFeatureFlagPayload("pricing-test");

React: import { useFeatureFlagEnabled } from "posthog-js/react" (inside PostHogProvider). Flags load asynchronously, so render a safe default until they arrive.

if posthog.feature_enabled("new-checkout", "user_8f31c2", person_properties={"plan": "growth"}):
    ...
variant = posthog.get_feature_flag("pricing-test", "user_8f31c2")

Server-side flag calls hit the network unless local evaluation is on: construct the client with secret_key=os.environ["POSTHOG_PERSONAL_API_KEY"] (the older personal_api_key name is a deprecated alias) and pass person_properties the flag depends on. Each evaluation also sends a $feature_flag_called event, which experiments rely on.

4. Session replay and privacy

Replay is enabled per project in settings; once on, the SDK records unless disable_session_recording: true. Inputs are masked by default (maskAllInputs), and password fields always are.

posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
  api_host: "https://us.i.posthog.com",
  defaults: "2025-05-24",
  session_recording: {
    maskTextSelector: "[data-ph-mask]",  // blur text in matching elements
    blockSelector: "[data-ph-block]",    // replace matching elements entirely
    maskAllInputs: true,
  },
});

Add the class ph-no-capture to anything that must never be recorded (card f

Полный SKILL.md на GitHub

Установить posthog в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл posthog?

PostHog is an open-source product analytics platform: event tracking, funnels, retention, session replay, feature flags and experiments in one tool, on PostHog Cloud or self-hosted. Use when someone asks to "add product analytics", "track events with PostHog", "set up session replay", "roll out a feature flag", "build a funnel", or "send backend events to PostHog". Covers the JavaScript and Python SDKs, privacy masking, server-side flags, and querying data through the API.

Как установить скилл posthog?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл posthog запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить posthog с