adding-analytics
БесплатноБез исполняемых скриптовНе проверенAdd PostHog analytics to a web application, including event tracking, page views, feature flags, and session replay.
от spencerpauly★ 905 звёзд на GitHubОб этом скилле
Add Analytics (PostHog)
Use this skill when the user asks to add analytics, event tracking, page views, feature flags, or session replay to a web application.
Steps
Detect the framework — check for
next.config.*,vite.config.*,package.jsonscripts, orindex.htmlto determine if this is Next.js, React (Vite/CRA), Vue, Svelte, or plain HTML.Install the SDK
- Next.js / React:
npm install posthog-js - Next.js (server-side):
npm install posthog-js posthog-node - Python:
pip install posthog - Node.js backend:
npm install posthog-node
- Next.js / React:
Create a provider / init module
For Next.js App Router, create
app/providers.tsx:"use client"; import posthog from "posthog-js"; import { PostHogProvider as PHProvider } from "posthog-js/react"; import { useEffect } from "react"; export function PostHogProvider({ children }: { children: React.ReactNode }) { useEffect(() => { posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, { api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST ?? "https://us.i.posthog.com", capture_pageview: false, // we capture manually for SPAs }); }, []); return <PHProvider client={posthog}>{children}</PHProvider>; }Wrap
{children}in the root layout with<PostHogProvider>.For Pages Router, init in
_app.tsxinside auseEffect.
Add page-view tracking — for SPAs, create a component that calls
posthog.capture('$pageview')on route change using the framework's router events.Add
.envvariables — prompt the user for their PostHog project API key and host:NEXT_PUBLIC_POSTHOG_KEY=phc_... NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.comAdd these keys to
.env.exampleas well.Add custom events — if the user specifies events to track (e.g. sign-up, purchase), add
posthog.capture("event_name", { ...properties })calls in the relevant handlers.Feature flags (optional) — if requested, show how to use
posthog.isFeatureEnabled("flag-name")or theuseFeatureFlagEnabledhook.Session replay (optional) — enable by adding
session_recording: { maskAllInputs: false }to the init config if requested.
Notes
- Never hardcode API keys — always use environment variables.
- Add
posthog-jsto the Content Security Policy if the project has one. - For monorepos, install in the package that renders the UI, not the root.
Установить adding-analytics в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл adding-analytics?
Add PostHog analytics to a web application, including event tracking, page views, feature flags, and session replay.
Как установить скилл adding-analytics?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл adding-analytics запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic