spencerpauly/awesome-cursor-skills/adding-analytics

Claude Code and agent skill by spencerpauly/awesome-cursor-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Add PostHog analytics to a web application, including event tracking, page views, feature flags, and session replay.

Install

npx vskill@latest install spencerpauly/awesome-cursor-skills/adding-analytics

SKILL.md

The same SKILL.md was published earlier as spencerpauly/awesome-cursor-skills/adding-analytics.

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

  1. Detect the framework — check for next.config.*, vite.config.*, package.json scripts, or index.html to determine if this is Next.js, React (Vite/CRA), Vue, Svelte, or plain HTML.
  1. 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
  1. Create a provider / init module
  • For Next.js App Router, create app/providers.tsx:

```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.tsx inside a useEffect.
  1. Add page-view tracking — for SPAs, create a component that calls posthog.capture('$pageview') on route change using the framework's router events.
  1. Add `.env` variables — prompt the user for their PostHog project API key and host:

`` NEXT_PUBLIC_POSTHOG_KEY=phc_... NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com ``

Add these keys to .env.example as well.

  1. 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.
  1. Feature flags (optional) — if requested, show how to use posthog.isFeatureEnabled("flag-name") or the useFeatureFlagEnabled hook.
  1. 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-js to the Content Security Policy if the project has one.
  • For monorepos, install in the package that renders the UI, not the root.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
683
Repository forks
108
7-day trend score
33

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/spencerpauly/awesome-cursor-skills/adding-analytics/badge)](https://verified-skill.com/skills/spencerpauly/awesome-cursor-skills/adding-analytics)

Something wrong with this skill or its page? Tell us.