Skip to content

: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.

feat(onboarding): send connector signups to the welcome page (#118854)

Rafael Audibertc49ad90a9f0b
diff --git a/docs/published/handbook/engineering/oauth-development-guide.md b/docs/published/handbook/engineering/oauth-development-guide.md
index f999ca82ce1a..422cb6a1736c 100644
--- a/docs/published/handbook/engineering/oauth-development-guide.md
+++ b/docs/published/handbook/engineering/oauth-development-guide.md
@@ -352,7 +352,7 @@ The redirect also sets the `ph_pending_oauth_connection` cookie so those screens
- Cleared when the person grants or denies the authorization.
- A CIMD client seen for the first time has no application row yet, so the cookie carries the host of its `client_id` URL as the name.
-An account created while the cookie is present skips in-app onboarding. Signup sets `onboarding_skipped_reason` to `connector`, pinned to the signup organization, so another organization the person joins later still shows onboarding. A delegated invitee keeps onboarding, because running it is the reason for the invite.
+An account created while the cookie is present skips in-app onboarding. Signup sets `onboarding_skipped_reason` to `connector`, pinned to the signup organization, so another organization the person joins later still shows onboarding. A delegated invitee keeps onboarding, because running it is the reason for the invite. Until the project ingests its first event, opening the project homepage sends that person to `/welcome`. Other pages open as linked, so a deep link from the connecting application still works.
While the cookie is present, the signup form pins the data region to the region the form is served from. An OAuth client is registered in one region only, so an account created in the other region could not finish the connection.
diff --git a/frontend/src/scenes/sceneLogic.test.tsx b/frontend/src/scenes/sceneLogic.test.tsx
index ccdeb138a250..4f0e5a772716 100644
--- a/frontend/src/scenes/sceneLogic.test.tsx
+++ b/frontend/src/scenes/sceneLogic.test.tsx
@@ -30,6 +30,7 @@ import {
AccessControlResourceType,
ActivityTab,
type AppContext,
+ type InsightShortId,
type OrganizationType,
type TeamType,
} from '~/types'
@@ -562,6 +563,54 @@ describe('sceneLogic', () => {
}
})
+ it.each([
+ [
+ 'sends the homepage to the welcome page and keeps the side panel prompt',
+ `${urls.projectHomepage()}#panel=max:hello`,
+ urls.onboardingWelcome(),
+ { panel: 'max:hello' },
+ ],
+ [
+ 'keeps a deep link open',
+ urls.insightView('abc123' as InsightShortId),
+ urls.insightView('abc123' as InsightShortId),
+ {},
+ ],
+ ])('connector signup with no data: %s', async (_name, target, expectedRoute, expectedHashParams) => {
+ const priorAppContext = window.POSTHOG_APP_CONTEXT
+ try {
+ logic.unmount()
+ window.POSTHOG_APP_CONTEXT = {
+ ...priorAppContext,
+ current_user: {
+ ...MOCK_DEFAULT_USER,
+ organization: MOCK_DEFAULT_ORGANIZATION,
+ onboarding_skipped_at: '2026-01-01T00:00:00Z',
+ onboarding_skipped_reason: 'connector',
+ onboarding_skipped_organization_id: MOCK_DEFAULT_ORGANIZATION.id,
+ },
+ } as AppContext
+ initKeaTests(true, {
+ ...MOCK_DEFAULT_TEAM,
+ ingested_event: false,
+ completed_snippet_onboarding: false,
+ has_completed_onboarding_for: {},
+ })
+ await expectLogic(teamLogic).toDispatchActions(['loadCurrentTeamSuccess'])
+ featureFlagLogic.mount()
+ logic = sceneLogic.build({ scenes: testScenes })
+ logic.mount()
+
+ router.actions.push(target)
+ await expectLogic(logic).delay(1)
+
+ expect(removeProjectIdIfPresent(router.values.location.pathname)).toEqual(expectedRoute)
+ expect(router.values.hashParams).toEqual(expectedHashParams)
+ } finally {
+ window.POSTHOG_APP_CONTEXT = priorAppContext
+ }
+ })
+
describe('/home honors the configured homepage', () => {
const dashboardHomepage = {
id: 'homepage-dashboard-42',
diff --git a/frontend/src/scenes/sceneLogic.tsx b/frontend/src/scenes/sceneLogic.tsx
index fa3fca2b9a0d..13cdf5245bd3 100644
--- a/frontend/src/scenes/sceneLogic.tsx
+++ b/frontend/src/scenes/sceneLogic.tsx
@@ -53,7 +53,7 @@ import { urls } from 'scenes/urls'
import { isSharedView } from '~/exporter/exporterViewLogic'
import { FileSystemIconType, ProductKey } from '~/queries/schema/schema-general'
-import { AccessControlLevel } from '~/types'
+import { AccessControlLevel, UserType } from '~/types'
import { handleLoginRedirect } from './authentication/login/loginLogic'
import { parseCouponCampaign } from './coupons/utils'
@@ -184,6 +184,19 @@ function isRefusedProjectPath(pathname: string): boolean {
return !!refusedProject && getProjectIdentifierInPath(pathname) === refusedProject
}
+function isFirstProjectWithoutData(user: UserType): boolean {
+ const { currentTeam, hasOnboardedAnyProduct } = teamLogic.values
+ return (
+ user.organization?.teams.length === 1 &&
+ !!currentTeam &&
+ !currentTeam.is_demo &&
+ !hasOnboardedAnyProduct &&
+ !currentTeam.ingested_event &&
+ // The access denied page must show, else the link silently opens the onboarding of the user's own project.
+ !isRefusedProjectPath(router.values.location.pathname)
+ )
+}
+
export function isOnboardingNotRequiredForPath(pathname: string): boolean {
const path = removeProjectIdIfPresent(pathname)
return pathPrefixesOnboardingNotRequiredFor.some((prefix) => path.startsWith(prefix))
@@ -995,19 +1008,13 @@ export const sceneLogic = kea<sceneLogicType>([
}
} else if (
// Or redirect to onboarding in case we detect people have to do onboarding for their first project
- user.organization?.teams.length === 1 &&
- teamLogic.values.currentTeam &&
- !teamLogic.values.currentTeam.is_demo &&
- !teamLogic.values.hasOnboardedAnyProduct &&
- !teamLogic.values.currentTeam?.ingested_event &&
+ isFirstProjectWithoutData(user) &&
// Suppress the redirect when the user has explicitly exited onboarding
// (skipped for later, or delegated to a teammate with a pending invite).
// If the delegation invite is cancelled or expires, the backend clears
// onboarding_delegated_to_invite and the redirect re-fires.
!isOnboardingRedirectSuppressed(user) &&
- !isOnboardingNotRequiredForPath(location.pathname) &&
- // The access denied page must show, else the link silently opens the onboarding of the user's own project.
- !isRefusedProjectPath(router.values.location.pathname)
+ !isOnboardingNotRequiredForPath(location.pathname)
) {
const nextUrl =
getRelativeNextPath(params.searchParams.next, location) ??
@@ -1022,6 +1029,22 @@ export const sceneLogic = kea<sceneLogicType>([
router.actions.replace(urls.onboarding(), nextUrl ? { next: nextUrl } : undefined)
return
+ } else if (
+ isFirstProjectWithoutData(user) &&
+ user.onboarding_skipped_reason === 'connector' &&
+ user.onboarding_skipped_organization_id === user.organization?.id &&
+ // Only the homepage redirects, so a deep link the connecting assistant hands out still opens.
+ removeProjectIdIfPresent(router.values.location.pathname) === urls.projectHomepage()
+ ) {
+ router.actions.replace(
+ withForwardedHashAndSearchParams(
+ urls.onboardingWelcome(),
+ params.searchParams,
+ params.hashParams,
+ forwardedRedirectQueryParams
+ )
+ )
+ return
}
}
}