feat(self-driving): provision an account when no PostHog is found#774
feat(self-driving): provision an account when no PostHog is found#774rafaeelaudibert wants to merge 1 commit into
Conversation
When self-driving falls back to "no PostHog found", the integration-check screen now asks whether the user already has a PostHog account instead of just confirming setup: - "Yes — log me in" → integrate the SDK and authenticate via OAuth (unchanged default). - "No — create one for me" → collect email + cloud region, flip session.signup, and let authenticate() take the existing provisioning path (create the account, email a login link). No --signup/--email flags needed. Also treat signup as auto-consent in the AI opt-in gate: a provisioning access token omits the organization:read scope, so apiUser stays null and the gate would otherwise never clear (this also fixes the same latent hang in the base `wizard --signup` flow). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🧙 Wizard CIRun 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:
Test all apps in a directory:
Test an individual app:
Show more apps
Results will be posted here when complete. |
gewenyu99
left a comment
There was a problem hiding this comment.
Good stuff. Some comments for sanity. I will need to test this when I get a lil time.
Thanks for doing this <3
Did you want to include provisioning logic/paths for headless here too?
| * OAuth. The "yes, I have an account" branch uses `setIntegrate(true)` and | ||
| * leaves `signup` false so auth runs the normal OAuth login. | ||
| */ | ||
| chooseProvisionAccount(email: string, region: CloudRegion): void { |
There was a problem hiding this comment.
I don't like this method name. I understand it's used by the provision path, but this is business logic about how that provisioning works.
This business logic should live with the provisioning code and that provisioning code should update the store from there.
|
|
||
| if (stage === 'region') { | ||
| return ( | ||
| <Box flexDirection="column" flexGrow={1}> |
There was a problem hiding this comment.
Can we split this UI into it's own component? Flow is confusing to read. This UI shows up after you select log me in vs sign up right?
|
@gewenyu99 I don't think we need that for headless right now because the only usecase we have for it is when someone's already logged in |
What
Builds on the #760 self-driving "integrate first" flow. When self-driving falls back to "no PostHog found", we now ask the user whether they already have a PostHog account, and route auth accordingly — instead of always assuming OAuth.
The merged integration-check screen now offers two answers (both still integrate the SDK first):
session.signup, and letauthenticate()take the existing provisioning path (askForProvisioningSignup→provisionNewAccount: create the account, email a login link). No--signup/--emailflags needed — it's all interactive now.Why
A project with no PostHog SDK is often a project whose owner has no PostHog account yet. Previously that user hit OAuth and had to go create an account out-of-band first. Now the wizard provisions one for them in place.
Notable detail — AI opt-in gate
A provisioning access token deliberately omits the
organization:readscope (WIZARD_PROVISIONING_SCOPES), soapiUserstaysnullandorganization.is_ai_data_processing_approvedcan never be read back. The AI opt-in gate (session.ci || aiApproved) would therefore never clear for a provisioned account and the run would hang. This treatssignupas auto-consent alongsideci(they're already grouped as one non-interactive mode inshouldDisableAsk) — which also fixes the same latent hang in the basewizard --signupflow.Changes
SelfDrivingIntegrationCheckScreen.tsx— rewritten to a 3-stage screen: ask → email input → region picker.store.ts—chooseProvisionAccount(email, region)setssignup/email/region/integratein one atomic emit.ai-opt-in-gate.ts—signupauto-consents likeci.self-driving.ts— refreshed--integratehelp text and the--signup-rejection message (points users at the interactive flow).wizard-session.ts— corrected the staleintegratedoc comment.store.test.tsandprograms.test.ts.Testing
pnpm build✅ ·pnpm lint✅ (0 errors) · targeted unit tests ✅. The only failing tests in the full suite are 3 pre-existingprovision-cli.test.tsfailures present onmainbefore this change.🤖 Generated with Claude Code