PostHog / PostHog/wizard

Add support for monorepos

Open
#113 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
197
Forks
51
Avg merge
1d 23h
Merged PRs (30d)
94

Description

Problem
The wizard currently fails when run from monorepo root directories. When executed from the root of a workspace containing multiple apps, it cannot locate the target framework (in our case Next.js) and throws an error instead of discovering and installing PostHog in the appropriate subpackage.

Current Behavior

  • Must be executed from the specific app directory containing the target framework
  • Fails with error when run from monorepo root
  • No automatic discovery of workspace structure

Expected Behavior

  • Should work when run from monorepo root
  • Automatically discover workspace packages containing supported frameworks
  • Install PostHog in all relevant packages or prompt user to select specific ones

Our project directories look something like this:

project/
├── package.json
├── pnpm-workspace.yaml
├── apps/
│   ├── web/                    # Next.js app
│   │   ├── package.json
│   │   └── src/
│   └── api/                    # Fastify API
│       ├── package.json
│       └── src/
└── packages/
    └── shared/
        ├── package.json
        └── src/

Proposed Solution

  1. When framework detection fails in root package.json, check for workspace indicators:
    • pnpm-workspace.yaml
    • "workspaces" field in root package.json
  2. Parse workspace configuration to discover all packages
  3. Scan each package for supported frameworks (Next.js, React, etc.)
  4. Present options to user:
    • Install in all detected compatible packages
    • Select specific packages for installation
    • Skip packages that already have PostHog configured

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 at the wizard's framework-detection entry point and inspect how it reads the root package.json. Then review the proposed workspace indicators in pnpm-workspace.yaml and package.json, and trace how detected packages are presented for installation. Done means the wizard can discover supported framework packages from a monorepo root and install in all, selected, or unconfigured packages as described.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.