Approve org AI data processing inline during onboarding#2091
Draft
Approve org AI data processing inline during onboarding#2091
Conversation
The AI approval onboarding screen used to dead-end on a button that opened PostHog web, asking the user to flip the org-level "AI data processing approval" toggle there and come back. This is a painful context switch and easy to abandon, especially since the screen sits between the user and the rest of the app. The screen now calls `PATCH /api/organizations/<id>/` with the single field `is_ai_data_processing_approved: true` directly. The matching backend change (posthog-code/allow-code-app-org-ai-toggle) carves out a narrow exemption for project-scoped OAuth tokens to flip exactly this one field. After the call succeeds we invalidate the `useCurrentUser` query so the `needsAiApproval` gate clears automatically and onboarding continues without a refresh. Robustness: - If the inline call fails for any reason (older backend without the exemption, transient 403, network error), we fall back to the original "Approve in PostHog" button so the user is never stuck. - The screen still sits behind an "isAdmin" check, and dismissal is handled by the existing Log out footer, not a skip-and-loop. Generated-By: PostHog Code Task-Id: d739b1d2-b053-45ec-967b-5521802d275b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The AI approval onboarding screen used to dead-end on a button that opened PostHog web, asking the user to flip the org-level "AI data processing approval" toggle there and come back. The user note describes this as painful and easy to abandon, especially because the screen sits between the user and the rest of the app.
The screen now calls
PATCH /api/organizations/<id>/with{is_ai_data_processing_approved: true}directly. The matching backend change (posthog-code/allow-code-app-org-ai-toggle) carves out a narrow exemption for project-scoped OAuth tokens to flip exactly this one field. After the call succeeds we invalidate theuseCurrentUserquery so theneedsAiApprovalgate clears automatically and onboarding continues without a refresh.Robustness
fellBackToWeband render the original "Approve in PostHog" button so the user is never stuck on a non-functional screen.Log outhandles "I want out" without a loop.Test plan
pnpm --filter code typecheck(passes)pnpm lint(passes)pnpm --filter code test(1145 tests passing)Created with PostHog Code