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.

fix(onboarding): skip the onboarding redirect while impersonating (#121457)

Felipe Rosa de Almeida7780c474a649
diff --git a/frontend/src/scenes/sceneLogic.test.tsx b/frontend/src/scenes/sceneLogic.test.tsx
index cb31569777b0..55553757981a 100644
--- a/frontend/src/scenes/sceneLogic.test.tsx
+++ b/frontend/src/scenes/sceneLogic.test.tsx
@@ -566,6 +566,36 @@ describe('sceneLogic', () => {
}
})
+ it('keeps an impersonating staff member on the page when the first project has no data', async () => {
+ const priorAppContext = window.POSTHOG_APP_CONTEXT
+ try {
+ logic.unmount()
+ window.POSTHOG_APP_CONTEXT = {
+ ...priorAppContext,
+ current_user: { ...MOCK_DEFAULT_USER, organization: MOCK_DEFAULT_ORGANIZATION, is_impersonated: true },
+ } 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(urls.eventDefinitions())
+ await expectLogic(logic).delay(1)
+
+ expect(removeProjectIdIfPresent(router.values.location.pathname)).toEqual(
+ removeProjectIdIfPresent(urls.eventDefinitions())
+ )
+ } finally {
+ window.POSTHOG_APP_CONTEXT = priorAppContext
+ }
+ })
+
it.each([
[
'sends the homepage to the welcome page and keeps the side panel prompt',
diff --git a/frontend/src/scenes/sceneLogic.tsx b/frontend/src/scenes/sceneLogic.tsx
index 13cdf5245bd3..03a16d2df349 100644
--- a/frontend/src/scenes/sceneLogic.tsx
+++ b/frontend/src/scenes/sceneLogic.tsx
@@ -187,6 +187,7 @@ function isRefusedProjectPath(pathname: string): boolean {
function isFirstProjectWithoutData(user: UserType): boolean {
const { currentTeam, hasOnboardedAnyProduct } = teamLogic.values
return (
+ !user.is_impersonated &&
user.organization?.teams.length === 1 &&
!!currentTeam &&
!currentTeam.is_demo &&