PostHog / PostHog/wizard

Detect existing PostHog setup and serve a menu of skills instead of re-running instrumentation

Open
#616 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement P1 wizard-pain
Dominant language
TypeScript
Stars
197
Forks
51
Avg merge
1d 23h
Merged PRs (30d)
94

Description

Problem

When you run npx @posthog/wizard (the default integration flow) on a project that already has PostHog set up, the wizard doesn't notice. It walks you straight into the full instrumentation program — detect → intro ("Continue") → health check → setup → auth → run (plan event tracking, install posthog, instrument events) → outro.

From a user who tried this on an already-instrumented project:

It seemed like it didn't know I'd already set up PostHog. I feel like it should notice that and say something like "Looks like you already have PostHog set up, what can we help you with?" (with a list of skills) — instead I clicked Continue and it started the whole instrumentation process. I would've been worried it was about to start changing whatever I had set up previously.

Once I finished the wizard, it wasn't clear to me how to interact with it again. If I wanted to audit my events or run the product tours skill, where would I go?

The skills are runnable (npx @posthog/wizard audit, npx @posthog/wizard events-audit, etc.), but nothing surfaces them — so re-running the wizard on an existing project is both confusing and a little scary (looks like it might overwrite existing setup).

Proposed behavior

When the default flow detects PostHog is already installed in the target project, intervene instead of starting instrumentation: show a menu of available wizard skills/programs and ask what the user wants to do, e.g.

Looks like you already have PostHog set up. What can we help you with?
  › Audit my events
    Events audit
    Revenue analytics setup
    Error tracking source maps
    SDK doctor
    ...
    Re-run integration anyway

Selecting an option routes into that program. "Re-run integration anyway" preserves the current behavior for anyone who genuinely wants it.

Relevant code

  • Default program steps: src/lib/programs/posthog-integration/steps.ts (detectintro → ...).
  • PostHog-installed detection already exists in pieces and could be reused/centralized:
    • src/lib/programs/shared/package-scanning.tsfindPackageJsons() scans for POSTHOG_SDKS (posthog-js, posthog-node, etc.).
    • hasDeclaredDependency(...) in src/lib/programs/posthog-integration/index.ts (currently only logs a warning and continues).
    • hasPostHogSdk(...) used by the source-maps / revenue prerequisite gates.
  • Intro screen that currently just offers "Continue": src/ui/tui/screens/PostHogIntegrationIntroScreen.tsx.
  • Program registry (the source of truth for a skills menu): src/lib/programs/program-registry.ts (getSubcommandPrograms()).

Notes / open questions

  • "Already installed" should probably be more than just a dependency in package.json — ideally an actual init/API key — to avoid false positives on half-finished setups.
  • This also addresses discoverability: the menu doubles as the answer to "how do I run a skill again later?" Worth coordinating with the docs update in PostHog/posthog.com#17438.
  • Keep an escape hatch to force the integration flow (menu option and/or a flag) for users who explicitly want to re-instrument.

Filed from team triage of a wizard run-through on an existing PostHog project.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/lib/programs/posthog-integration/steps.ts and PostHogIntegrationIntroScreen.tsx, then read package-scanning.ts, posthog-integration/index.ts, and program-registry.ts. Trace the existing dependency detection and available subcommand programs. Done means an existing setup receives a skills menu with routing and an explicit way to rerun integration, without changing the current default flow for new setups.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, developer-experience
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.