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

Aperta
#616 3 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
58/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
typescript

Direzione di ricerca

Inizia con src/lib/programs/posthog-integration/steps.ts e PostHogIntegrationIntroScreen.tsx, poi leggi package-scanning.ts, posthog-integration/index.ts e program-registry.ts. Traccia il rilevamento delle dipendenze esistente e i programmi di sottocomando disponibili. Il lavoro è completo quando una configurazione esistente riceve un menu di skills con routing e un modo esplicito per rieseguire l'integrazione, senza modificare il flusso predefinito attuale per le nuove configurazioni.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement P1 wizard-pain

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 (detect → intro → ...).
  • PostHog-installed detection already exists in pieces and could be reused/centralized:
    • src/lib/programs/shared/package-scanning.ts — findPackageJsons() 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.

Lingua principale
TypeScript
Stelle
208
Fork
58
Merge medio
2g 7h
PR unite (30g)
76

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PostHog/wizard

Tutte le issue di PostHog/wizard

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.