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

未关闭
#616 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
58/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
typescript

调研方向

从 src/lib/programs/posthog-integration/steps.ts 和 PostHogIntegrationIntroScreen.tsx 开始,然后阅读 package-scanning.ts、posthog-integration/index.ts 和 program-registry.ts。跟踪现有的依赖检测和可用的子命令程序。完成的标准是:现有设置获得一个带有路由的 skills 菜单,以及一种明确的方式来重新运行集成,同时不改变新设置当前的默认流程。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
208
派生
58
平均合并
2 天 7 小时
30 天内合并 PR
76

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

PostHog/wizard 的其他 Issue

查看 PostHog/wizard 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。