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

Đang mở
#616 3 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
58/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
typescript
Lĩnh vực
cli, developer-experience

Hướng nghiên cứu

Bắt đầu với src/lib/programs/posthog-integration/steps.ts và PostHogIntegrationIntroScreen.tsx, sau đó đọc package-scanning.ts, posthog-integration/index.ts và program-registry.ts. Truy vết cơ chế phát hiện dependency hiện có và các chương trình subcommand khả dụng. Hoàn thành khi một thiết lập hiện có nhận được menu skills có routing và một cách rõ ràng để chạy lại integration, mà không thay đổi flow mặc định hiện tại cho các thiết lập mới.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
208
Fork
58
Merge trung bình
2 ngày 7 giờ
Pull request đã merge (30 ngày)
76

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PostHog/wizard

Tất cả issue của PostHog/wizard

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.