{"id":48083673,"url":"https://github.com/posthog/posthog-vscode","last_synced_at":"2026-04-04T15:02:13.967Z","repository":{"id":343109735,"uuid":"1176269548","full_name":"PostHog/posthog-vscode","owner":"PostHog","description":"PostHog for VS Code — feature flags, analytics, and product insights without leaving your editor.","archived":false,"fork":false,"pushed_at":"2026-03-30T14:11:58.000Z","size":262,"stargazers_count":4,"open_issues_count":13,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-30T16:16:37.589Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PostHog.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-08T20:53:47.000Z","updated_at":"2026-03-30T14:11:47.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/PostHog/posthog-vscode","commit_stats":null,"previous_names":["posthog/posthog-vscode"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PostHog/posthog-vscode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostHog%2Fposthog-vscode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostHog%2Fposthog-vscode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostHog%2Fposthog-vscode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostHog%2Fposthog-vscode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PostHog","download_url":"https://codeload.github.com/PostHog/posthog-vscode/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostHog%2Fposthog-vscode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31403952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-04T15:02:08.238Z","updated_at":"2026-04-04T15:02:13.852Z","avatar_url":"https://github.com/PostHog.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"resources/icons/ph-logo2.png\" width=\"128\" alt=\"PostHog\" /\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003ePostHog for VS Code\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003eFeature flags, experiments, event analytics, and session replay — inline in your editor.\u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://marketplace.visualstudio.com/items?itemName=PostHog.posthog-vscode\"\u003e\u003cimg src=\"https://img.shields.io/visual-studio-marketplace/v/PostHog.posthog-vscode?label=VSCode\" alt=\"VSCode Marketplace\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://marketplace.visualstudio.com/items?itemName=PostHog.posthog-vscode\"\u003e\u003cimg src=\"https://img.shields.io/visual-studio-marketplace/i/PostHog.posthog-vscode?label=Downloads\" alt=\"VSCode Installs\" /\u003e\u003c/a\u003e\n  \u003cbr/\u003e\n  \u003ca href=\"https://open-vsx.org/extension/posthog/posthog-vscode\"\u003e\u003cimg src=\"https://img.shields.io/open-vsx/v/posthog/posthog-vscode?label=VSX\n  \" alt=\"VSX Marketplace\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://open-vsx.org/extension/posthog/posthog-vscode\"\u003e\u003cimg src=\"https://img.shields.io/open-vsx/dt/posthog/posthog-vscode?label=Downloads\n  \" alt=\"VSCode Installs\" /\u003e\u003c/a\u003e\n  \u003cbr/\u003e\n  \u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/PostHog/posthog-vscode\" alt=\"License\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## What it does\n\nPostHog for VS Code - and any other VSCode-based editor - brings your product analytics stack into the editor. See feature flag status, experiment results, event volumes, and session replay data right next to the code that uses them — no browser tab required.\n\n---\n\n## Quick Start\n\n1. **Install** the extension from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=PostHog.posthog-vscode) or [VSX Marketplace](https://open-vsx.org/extension/posthog/posthog-vscode)\n2. **Sign in** — open the PostHog sidebar (hedgehog icon in the activity bar) and click \"Sign In with PostHog\" to authenticate with your PostHog account\n3. **Select your project** when prompted\n4. **Done** — the sidebar populates with your flags, experiments, and analytics. Inline decorations appear in your code automatically.\n\n---\n\n## Features\n\n### Inline Code Intelligence\n\nThe core of the extension. Your PostHog data appears directly in your editor as you write code.\n\n- **SDK init detection** — detects `posthog.init()` calls and shows project name, host region, and configuration summary inline. Highlights potential issues:\n  - `⚠ no reverse proxy` — suggests setting up a reverse proxy when pointing directly to PostHog cloud (improves data accuracy by avoiding ad blockers)\n  - `⚠ missing ui_host` — warns when using a custom `api_host` without `ui_host` (the PostHog toolbar won't work)\n  - `⚠ invalid ui_host` — warns when `ui_host` is not `https://us.posthog.com` or `https://eu.posthog.com`\n  - `⚠ invalid token` — warns when the token doesn't start with `phc_`\n- **Flag status decorations** — see flag state inline after every flag call: `● enabled`, `○ inactive`, rollout %, variant count, or `⚠ not in PostHog`\n- **Event volume and sparklines** — 7-day event count and inline sparkline chart next to every `capture()` call\n- **Experiment results inline** — flags linked to experiments show live status like `⚗ test leading 72%`\n- **Variant code path highlighting** — color-coded highlighting of if/else and switch branches behind experiment variants, with rollout percentages\n- **Flag key autocomplete** — suggestions from your PostHog project inside `isFeatureEnabled('`, `getFeatureFlag('`, etc.\n- **Event name autocomplete** — suggestions inside `posthog.capture('`\n- **Event property autocomplete** — property names, types, and top values as you build event payloads\n- **Variant autocomplete** — variant keys for multivariate flags\n- **Unknown flag detection** — yellow wavy underline on flag keys that don't exist in PostHog, with a quick-fix to create them\n- **Event naming diagnostics** — Levenshtein-based typo detection for event names that look similar to existing events\n- **Flag CodeLens** — contextual actions above flag calls (open detail, view experiment)\n- **Session CodeLens** — \"X sessions / Y users in 24h\" above capture and flag calls\n- **Cmd+click navigation** — flag keys become links that open the flag or experiment detail panel\n\n### Sidebar Dashboard\n\nA tabbed overview of your PostHog project, accessible from the activity bar.\n\n- **Flags tab** — all feature flags with search, filter by status, toggle, and rollout editing\n- **Experiments tab** — experiments with status indicators, results summary, and start/stop actions\n- **Analytics tab** — saved insights from your PostHog project with auto-refresh\n- **X-ray tab** — shows 14-day event trends for `capture()` calls found in the currently open file. Click any event to open a detailed insight in PostHog.\n- **\"My Flags\" filter** — quickly show only flags you created\n- **Stale Flags tree view** — dedicated tree view below the sidebar for codebase-wide flag hygiene\n\n### Flag Management\n\nCreate, toggle, and configure flags without leaving the editor.\n\n- **Toggle flags from code** — code action with confirmation dialog\n- **Edit rollout %, variants, and payloads** — full flag editor in a detail panel\n- **Create flags from unknown keys** — quick-fix on unrecognized flag keys creates the flag in PostHog\n- **Generate TypeScript types** — right-click context menu action to generate types from flag payload configurations\n- **Copy flag key** — one-click copy to clipboard\n- **Open in PostHog** — jump to the flag in the PostHog dashboard\n- **Wrap selection in flag** — code action to wrap a code block in a feature flag check\n\n### Stale Flag Cleanup\n\nFind and remove tech debt from shipped or abandoned flags.\n\n- **AST-based codebase scanning** — finds all flag references across your project using tree-sitter\n- **4 staleness categories** — fully rolled out, inactive, experiment complete, not in PostHog\n- **Tree view** — grouped by staleness reason, click to navigate to each reference\n- **Inline refactoring** — code actions to remove flag checks and keep the correct code branch (handles if/else and ternary patterns)\n- **Batch cleanup** — clean up all references for a stale flag at once\n- **Report export** — export stale flag findings\n\n### Session Replay\n\nConnect code to real user sessions.\n\n- **Session count CodeLens** — see session and user counts above capture and flag calls\n- **Embedded replay** — watch session recordings in detail panels without leaving VS Code\n\n### Team Configuration\n\nShare PostHog settings across your team and manage multi-project workspaces.\n\n- **Shared `.posthog.json` config** — commit project settings to your repo so the whole team connects automatically\n- **Multi-project workspace support** — different workspace folders can target different PostHog projects\n- **RBAC awareness** — read-only mode when your account lacks write permissions\n- **Status bar indicator** — shows active project, host, and last sync time. Click to switch projects.\n- **Periodic cache refresh** — flags, events, and experiments stay in sync automatically\n\n---\n\n## Commands\n\nAll commands are available via the Command Palette (`Cmd+Shift+P` / `Ctrl+Shift+P`):\n\n| Command                           | Description                                                 |\n| --------------------------------- | ----------------------------------------------------------- |\n| `PostHog: Sign In`                | Authenticate with your PostHog account                      |\n| `PostHog: Sign Out`               | Disconnect from PostHog                                     |\n| `PostHog: Select Project`         | Switch between projects                                     |\n| `PostHog: Refresh Feature Flags`  | Re-fetch flags, events, and experiments                     |\n| `PostHog: Create Feature Flag`    | Create a new flag in PostHog                                |\n| `PostHog: Copy Flag Key`          | Copy a flag key to clipboard                                |\n| `PostHog: Open in PostHog`        | Open the flag in the PostHog dashboard                      |\n| `PostHog: Show Flag Detail`       | Open flag detail panel in an editor tab                     |\n| `PostHog: Show Experiment Detail` | Open experiment detail panel in an editor tab               |\n| `PostHog: Find Flag References`   | Find all usages of a flag in the codebase                   |\n| `PostHog: Watch Sessions`         | Open session replay for a flag or event                     |\n| `PostHog: Generate Flag Types`    | Generate TypeScript types from all flag configs             |\n| `PostHog: Generate Type`          | Generate TypeScript type for a specific flag (context menu) |\n| `PostHog: Scan for Stale Flags`   | Find stale flag references across the codebase              |\n| `PostHog: Clean Up Stale Flag`    | Remove a stale flag check from code                         |\n| `PostHog: Run Setup Wizard`       | Launch the PostHog setup wizard in a terminal               |\n\n---\n\n## Configuration\n\n### VS Code Settings\n\nAll settings live under `posthog.*` in VS Code settings (JSON or UI).\n\n**Code detection**\n\n| Setting                           | Type       | Default | Description                                                                                                                                                                                                                 |\n| --------------------------------- | ---------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `posthog.additionalClientNames`   | `string[]` | `[]`    | Extra variable names to recognize as PostHog clients (e.g. `analytics`, `telemetry`, `phClient`). The built-in names `posthog`, `client`, and `ph` are always detected, plus any variable assigned from `new PostHog(...)`. |\n| `posthog.additionalFlagFunctions` | `string[]` | `[]`    | Extra bare function names that accept a flag key as the first argument. React hooks (`useFeatureFlag`, `useFeatureFlagPayload`, `useFeatureFlagVariantKey`, `useActiveFeatureFlags`) are detected automatically.            |\n| `posthog.detectNestedClients`     | `boolean`  | `true`  | Detect PostHog calls through nested member expressions like `window.posthog?.capture()`.                                                                                                                                    |\n\n**Display**\n\n| Setting                         | Type      | Default  | Description                                                                                                        |\n| ------------------------------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------------ |\n| `posthog.showInlineDecorations` | `boolean` | `true`   | Show inline flag status and event volume decorations in the editor. Set to `false` to hide all inline annotations. |\n| `posthog.inlineHintsMode`       | `string`  | `always` | When to show inline hints: `always` (all lines) or `currentLine` (only the line where the cursor is located, like git blame). |\n\n**Stale flag detection**\n\n| Setting                            | Type       | Default | Description                                                                                                                                                   |\n| ---------------------------------- | ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `posthog.staleFlagAgeDays`         | `number`   | `30`    | Minimum age in days before a fully-rolled-out flag is considered stale. Flags rolled out more recently than this are not flagged.                             |\n| `posthog.staleFlagExcludePatterns` | `string[]` | `[]`    | Additional glob patterns to exclude from stale flag scanning (e.g. `**/tests/**`, `**/fixtures/**`). `node_modules`, `dist`, and `build` are always excluded. |\n\n**Workspace**\n\n| Setting                             | Type      | Default | Description                                                                                                 |\n| ----------------------------------- | --------- | ------- | ----------------------------------------------------------------------------------------------------------- |\n| `posthog.useWorkspaceConfig`        | `boolean` | `true`  | Automatically load team settings from `.posthog.json` in the workspace root.                                |\n| `posthog.multiProjectNotifications` | `boolean` | `true`  | Show a notification when opening a file from a workspace folder configured for a different PostHog project. |\n\n### Team Configuration (`.posthog.json`)\n\nShare PostHog settings across your team by committing a `.posthog.json` file to your workspace root:\n\n```json\n{\n  \"projectId\": 12345,\n  \"additionalClientNames\": [\"analytics\"],\n  \"additionalFlagFunctions\": [\"useMyFlag\"]\n}\n```\n\nWhen present, the extension loads this file on startup and merges the settings with your VS Code configuration. Each developer still authenticates individually with their own PostHog account. If a `projectId` is specified, the user must have access to that project.\n\nIn a multi-root workspace, each folder can have its own `.posthog.json` targeting a different project — the extension prompts to switch projects as you navigate between folders.\n\n### Supported Languages\n\nCode intelligence (autocomplete, decorations, diagnostics, code actions) works in:\n\n| Language     | File Types     | SDKs                     |\n| ------------ | -------------- | ------------------------ |\n| JavaScript   | `.js`, `.jsx`  | posthog-js, posthog-node |\n| TypeScript   | `.ts`, `.tsx`  | posthog-js, posthog-node |\n| React Native | `.jsx`, `.tsx` | posthog-react-native     |\n\nPowered by [tree-sitter](https://tree-sitter.github.io/tree-sitter/) for accurate AST-based detection. Both client-side (`posthog.capture('event')`) and server-side (`client.capture({ event: 'event' })`) patterns are recognized.\n\n---\n\n## Requirements\n\n- VS Code 1.109.0 or later\n- A [PostHog](https://posthog.com) account with a personal API key\n\n---\n\n## Contributing\n\nContributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.\n\n---\n\n## License\n\n[MIT](LICENSE)\n\n\u003cp align=\"center\"\u003e\n  Built by the [🌳 team](https://posthog.com/teams/growth) at [🦔 PostHog](https://posthog.com/)\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthog%2Fposthog-vscode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposthog%2Fposthog-vscode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthog%2Fposthog-vscode/lists"}