Skip to content

feat(self-driving): propose product analytics setup when events are default-only - #880

Closed
dkarasiewicz wants to merge 1 commit into
mainfrom
self-driving-events-check
Closed

dkarasiewicz wants to merge 1 commit into
mainfrom
self-driving-events-check

Conversation

@dkarasiewicz

Copy link
Copy Markdown

Problem

when posthog is already in the repo, self-driving skips straight to setup even if the project captures only default events ($pageview, autocapture) or none. scouts then have almost no product behavior to watch.

Changes

  • new events-check step + screen after auth (already-present path only): probes /event_definitions?event_type=event_custom and, when only default events exist, proposes setting up product analytics
  • accepting reuses the existing composed integrate path (integrate-detect → integrate-run → handoff), so the standard integration program does the analytics setup
  • detect-agentic gains an instrumentExisting mode so already-integrated projects are pickable targets instead of collapsing into "continue with existing"
  • probe fails open (never nags on api errors), adds event_definition:read (already in the prod ceiling)

Test plan

  • pnpm build && pnpm test && pnpm lint green locally (1323 tests)
  • new unit tests for the step predicates and the instrumentExisting classification

LLM context

built with claude code; grounded in self-driving/ARCHITECTURE.md (updated in lockstep).

🤖 Generated with Claude Code

…efault-only

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dkarasiewicz
dkarasiewicz requested review from a team as code owners July 13, 2026 15:18
Copilot AI review requested due to automatic review settings July 13, 2026 15:18
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the self-driving flow for repos where PostHog is already installed but the project has no (or only default) tracked events, by adding an authenticated “events-check” probe that can route users into the existing integration flow to set up product analytics instrumentation.

Changes:

  • Add a new SelfDriving “events-check” step/screen after auth (already-present path) that probes for custom events and offers a product analytics setup when only default events exist.
  • Extend self-driving integration detection to support an instrumentExisting mode so already-integrated projects can be selected as instrumentation targets (instead of only “continue with existing”).
  • Add fetchHasCustomEvents API helper, update self-driving OAuth scope additions, and add unit tests + architecture documentation updates.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/ui/tui/screens/SelfDrivingIntegrationDetectScreen.tsx Passes instrumentExisting to detection and adjusts copy when instrumenting existing installs.
src/ui/tui/screens/SelfDrivingHandoffScreen.tsx Updates handoff copy to reflect “product analytics set up” vs “PostHog installed” based on the events-check path.
src/ui/tui/screens/SelfDrivingEventsCheckScreen.tsx New screen that probes custom events and offers a “set up product analytics” choice.
src/ui/tui/screen-sequences.ts Adds a new ScreenId for the events-check screen.
src/ui/tui/screen-registry.tsx Registers the new events-check screen.
src/lib/programs/self-driving/steps.ts Inserts the new events-check step into the self-driving program flow.
src/lib/programs/self-driving/detect.ts Adds SELF_DRIVING_CUSTOM_EVENTS_KEY frameworkContext key for probe results.
src/lib/programs/self-driving/detect-agentic.ts Adds IntegrationDetectOptions.instrumentExisting and updates classification logic accordingly.
src/lib/programs/self-driving/ARCHITECTURE.md Documents the new step/flow and new scope; contains a couple of factual drift issues noted in comments.
src/lib/programs/tests/self-driving-detect.test.ts Adds unit tests for the new step predicates and instrumentExisting classification.
src/lib/oauth/program-scopes.ts Adds event_definition:read to self-driving scope additions and documents why.
src/lib/api.ts Adds fetchHasCustomEvents API helper to query event definitions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -97,7 +97,15 @@ are a cross-repo contract — change one, change both repos.
**Program definition** (`src/lib/programs/self-driving/`, five files):
`index.ts` (config + lifecycle), `prompt.ts` (the 9 steps + mechanics + project URLs),
Comment on lines 144 to 146
**OAuth scopes** (`src/lib/oauth/program-scopes.ts`). Base `WIZARD_OAUTH_SCOPES`
(`src/lib/constants.ts`) ∪ `SELF_DRIVING_SCOPE_ADDITIONS` — **12 strings**, requested via a PKCE
(`src/lib/constants.ts`) ∪ `SELF_DRIVING_SCOPE_ADDITIONS` — **14 strings**, requested via a PKCE
auth-code flow:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants