:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(onboarding): skip onboarding for provisioned accounts (#74097)
Rafael Audibert170ebfafa70f
diff --git a/ee/api/agentic_provisioning/accounts.py b/ee/api/agentic_provisioning/accounts.pyindex 45165f1dbeaf..fe306dc1e3e0 100644--- a/ee/api/agentic_provisioning/accounts.py+++ b/ee/api/agentic_provisioning/accounts.py@@ -29,7 +29,11 @@ from ee.api.agentic_provisioning.constants import ()from ee.api.agentic_provisioning.exceptions import ProvisioningErrorfrom ee.api.agentic_provisioning.regions import region_to_host-from ee.api.agentic_provisioning.wizard import create_wizard_run, link_github_grant_to_team+from ee.api.agentic_provisioning.wizard import (+ apply_provisioned_onboarding_flags,+ create_wizard_run,+ link_github_grant_to_team,+)def partner_label(partner: OAuthApplication | None) -> str:@@ -262,6 +266,11 @@ def handle_new_user(team_id=team.id,)+ # Every provisioned account is treated as already onboarded — apply the flags at+ # bootstrap so the account is covered regardless of which follow-up blocks (if any)+ # run, rather than only on the GitHub wizard path.+ apply_provisioned_onboarding_flags(user, team)+# Emit the standard signup event so provisioned accounts flow into the shared# signup / activation / billing analyses, segmentable by client. Vercel does the# same (ee/vercel/integration.py); the agentic path previously skipped it entirely.diff --git a/ee/api/agentic_provisioning/test/test_account_requests_wizard.py b/ee/api/agentic_provisioning/test/test_account_requests_wizard.pyindex 30cbfd30aa97..17fa08e030f8 100644--- a/ee/api/agentic_provisioning/test/test_account_requests_wizard.py+++ b/ee/api/agentic_provisioning/test/test_account_requests_wizard.py@@ -68,6 +68,13 @@ class TestAccountRequestsWizardBlock(ProvisioningTestBase):assert len(args) == 3assert kwargs == {}+ user = User.objects.get(email="[email protected]")+ team = user.teams.get()+ assert user.onboarding_skipped_reason == OnboardingSkippedReason.PROVISIONED+ assert user.onboarding_skipped_at is not None+ assert user.onboarding_skipped_organization_id == team.organization_id+ assert team.completed_snippet_onboarding is True+def test_bundled_happy_path_runs_wizard_then_emails(self):grant = self._grant("[email protected]")created = MagicMock(task_id="task-uuid", latest_run=MagicMock(id="run-uuid", status="queued"))diff --git a/ee/api/agentic_provisioning/test/test_wizard_resource_actions.py b/ee/api/agentic_provisioning/test/test_wizard_resource_actions.pyindex a9a87a6344c6..dcd7b0488b1f 100644--- a/ee/api/agentic_provisioning/test/test_wizard_resource_actions.py+++ b/ee/api/agentic_provisioning/test/test_wizard_resource_actions.py@@ -11,7 +11,6 @@ from parameterized import parameterizedfrom posthog.models.integration import GitHubInstallationAccess, GitHubIntegration, GitHubUserAuthorization, Integrationfrom posthog.models.team.team import Team-from posthog.models.user import OnboardingSkippedReasonfrom posthog.models.user_integration import UserIntegrationfrom ee.api.agentic_provisioning import github_grants@@ -88,26 +87,14 @@ class TestWizardResourceActions(ProvisioningTestBase):assert cache.get(f"{GITHUB_GRANT_CACHE_PREFIX}{grant.grant_id}") is None+ # Onboarding flags are set at account bootstrap, never on the GitHub linking path,+ # so linking a grant must not touch them.self.user.refresh_from_db()self.team.refresh_from_db()- assert self.user.onboarding_skipped_reason == OnboardingSkippedReason.PROVISIONED- assert self.user.onboarding_skipped_at is not None- assert self.user.onboarding_skipped_organization_id == self.team.organization_id- assert self.team.completed_snippet_onboarding is True-- def test_github_integration_does_not_touch_onboarding_for_claimed_user(self):- grant = self._grant()- with (- patch.object(GitHubIntegration, "verify_user_installation_access", return_value=True),- patch.object(GitHubIntegration, "fetch_installation_access", return_value=_installation_access()),- ):- response = self._post_github_integration(- self.team.id, {"grant_id": grant.grant_id, "installation_id": INSTALLATION_ID}- )- assert response.status_code == 200- self.user.refresh_from_db()assert self.user.onboarding_skipped_reason is Noneassert self.user.onboarding_skipped_at is None+ assert self.user.onboarding_skipped_organization_id is None+ assert self.team.completed_snippet_onboarding is Falsedef test_github_integration_unknown_grant_returns_404(self):response = self._post_github_integration(@@ -131,11 +118,10 @@ class TestWizardResourceActions(ProvisioningTestBase):assert response.status_code == 200assert response.json()["github_integration"]["already_linked"] is True- # Onboarding flags are re-applied on the already-linked retry so a crash between- # grant consumption and the flag write doesn't leave the account routed into onboarding.+ # The GitHub linking path never touches onboarding flags; they are set at bootstrap.self.user.refresh_from_db()- assert self.user.onboarding_skipped_reason == OnboardingSkippedReason.PROVISIONED- assert self.user.onboarding_skipped_at is not None+ assert self.user.onboarding_skipped_reason is None+ assert self.user.onboarding_skipped_at is None@parameterized.expand([diff --git a/ee/api/agentic_provisioning/wizard.py b/ee/api/agentic_provisioning/wizard.pyindex c9ceee741d06..e9b1f8ee76fa 100644--- a/ee/api/agentic_provisioning/wizard.py+++ b/ee/api/agentic_provisioning/wizard.py@@ -67,10 +67,6 @@ def link_github_grant_to_team(# response must not fail if the installation is already linked to this team.existing = Integration.objects.first_github_for_team_installation(team.id, str(installation_id))if existing is not None:- # Re-apply onboarding flags idempotently: the grant is consumed as the last step,- # so a crash between consume and the flag write would otherwise leave them unset- # on a retry (this branch runs only once the grant is already gone).- apply_provisioned_onboarding_flags(user, team)return existing, Truecapture_provisioning_event("github_integration", "error", partner=partner, error_code="grant_not_found")raise ProvisioningError("grant_not_found", "Grant not found or expired", resource_id=str(team.id), status=404)@@ -111,7 +107,6 @@ def link_github_grant_to_team()github_grants.consume_grant(grant_id)- apply_provisioned_onboarding_flags(user, team)capture_provisioning_event("github_integration", "success", partner=partner, team_id=team.id)return integration, False