Skip to content

fix: Onboarding persistence and update interval#1251

Merged
charlesvien merged 3 commits intoPostHog:mainfrom
littlekirkycode:fix/onboarding-persistence-and-update-interval
Mar 16, 2026
Merged

fix: Onboarding persistence and update interval#1251
charlesvien merged 3 commits intoPostHog:mainfrom
littlekirkycode:fix/onboarding-persistence-and-update-interval

Conversation

@littlekirkycode
Copy link
Contributor

@littlekirkycode littlekirkycode commented Mar 15, 2026

Screenshot 2026-03-15 at 19 28 43

Closes #1228
Related: #1229 (skip button addressed in #1240)

Summary

Fixes the root cause of users(or devs) being forced through re-authentication and the onboarding tutorial
after every auto-update.

The problem

logout() in authStore.ts unconditionally reset hasCompletedOnboarding: false. When the app
restarts after an auto-update and token refresh fails (transient network error, brief API
outage), it triggers logout() — which wiped the onboarding flag. The user then sees the full
tutorial again, even though they completed it. With auto-update checks running every
hour, this happened frequently.

Note: The hasCompletedOnboarding reset in logout() was likely added for
development/testing convenience. Issues #1228 and #1230 show this has become a development pain
point, so i've moved the reset to an explicit developer setting instead.

What changed

1. Preserve onboarding state on logout (authStore.ts)

Removed hasCompletedOnboarding: false from the logout() method. Onboarding completion is a
user-level fact — logging out and back in shouldn't force the tutorial again:

 set({
   oauthAccessToken: null,
   isAuthenticated: false,
   hasCodeAccess: null,
-  hasCompletedOnboarding: false,
   selectedPlan: null,
   // ...
 });

2. Add "Reset onboarding" button in Advanced Settings (AdvancedSettings.tsx)

Replaces the implicit logout-based reset with an explicit developer action. Settings → Advanced
→ "Reset onboarding" sets the flag to false, so the tutorial runs on next restart:

<Button
  variant="soft"
  size="1"
  onClick={() => useAuthStore.setState({ hasCompletedOnboarding: false })}
>
  Reset
</Button>

3. Reduce auto-update check interval to 24 hours (updates/service.ts)

- private static readonly CHECK_INTERVAL_MS = 60 * 60 * 1000; // 1 hour
+ private static readonly CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000; // 24 hours

Updated the corresponding test assertions to match.

Changes

File What
authStore.ts Remove hasCompletedOnboarding: false from logout()
AdvancedSettings.tsx Add "Reset onboarding" button for dev testing
updates/service.ts Change CHECK_INTERVAL_MS from 1h → 24h
updates/service.test.ts Update test to assert 24h interval

Test plan

  • Log in → complete onboarding → log out → log back in → should NOT see onboarding again
  • Settings → Advanced → "Reset onboarding" → tutorial re-appears on next restart
  • Auto-update check interval is 24h (verify in code or via debug logs)
  • pnpm --filter code typecheck passes
  • pnpm --filter code test passes

littlekirkycode added 3 commits March 15, 2026 19:14
Remove hasCompletedOnboarding reset from logout(). Onboarding completion
is a user-level fact that should persist across logouts — a user who logs
out and back in shouldn't redo the tutorial.

This was the root cause of users being forced through onboarding after
auto-updates: token refresh failure triggers logout, which wiped the
onboarding flag.

Closes PostHog#1230
Partially addresses PostHog#1228
Add a button in Settings > Advanced that resets the onboarding state,
allowing developers to re-test the onboarding flow without clearing all
application data.

Related to PostHog#1229 (skip button addressed in PostHog#1240)
Change CHECK_INTERVAL_MS from 1 hour to 24 hours. The previous frequency
was too aggressive and, combined with the onboarding reset bug, made the
app feel unusable — users were forced through auth + tutorial on every
update cycle.

Closes PostHog#1228
Copy link
Contributor

@jonathanlab jonathanlab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! We should probably split this onboarding logic up into the tutorial part and a part that is responsible for actually configuring your organization + project settings (e.g. signals/github integration), since that is not a user level concern.

@charlesvien charlesvien merged commit ebf7ee2 into PostHog:main Mar 16, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-update frequency is too aggressive and forces re-auth + tutorial on each update

3 participants