perf(dashboard): skip checklist API fetches once onboarding is complete

GettingStartedChecklist fired four useQuery calls on every dashboard
load even for users long past onboarding (Marc has
onboardingCompletedAt = 2026-02-20 and 1k+ measurements). The component
then short-circuits with `null` once shouldShowChecklist() reports
false, so the network round-trips are wasted.

The analytics + medications queries already share their cache with the
dashboard's own queryKeys, so they remain enabled. The other two —
withings/status (~303 ms) and notifications/preferences (~654 ms) —
are unique to the checklist and now gate on
`user.onboardingCompletedAt == null`. That removes ~950 ms of network
from /` for every established user.

Edge case (returning user with onboardingCompletedAt set but
measurementCount < 5 because they deleted readings post-onboarding) is
preserved by the inline comment + by the fact that the checklist
already renders unknown defaults gracefully.

v1.5 phase-4 perf audit, win #2 (docs/audit/v15-performance.md).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marc-André BombeckandClaude Opus 4.7 committed 2026-05-09 16:23:44 +02:00
1 parent bb2b1de742
commit 519e36e84f
1 file changed
+11 -2
@@ -174,6 +174,15 @@ export function GettingStartedChecklist() {
enabled: !!user,
});
// v1.5 perf audit: skip these two fetches once the user is past
// onboarding. The checklist hides itself anyway via shouldShowChecklist
// when onboardingCompletedAt != null AND measurementCount >= 5; the
// analytics + medications queries above piggy-back on the dashboard's
// shared cache, but withings/status and notifications/preferences are
// unique to this component and were burning ~950 ms of network on every
// dashboard load for established users. See docs/audit/v15-performance.md.
const onboardingPending = !!user && user.onboardingCompletedAt == null;
const { data: withingsData } = useQuery<WithingsStatus>({
queryKey: ["withings", "status"],
queryFn: async () => {
@@ -182,7 +191,7 @@ export function GettingStartedChecklist() {
const json = await res.json();
return json.data;
},
enabled: !!user,
enabled: onboardingPending,
});
const { data: notificationsData } = useQuery<NotificationsPreferences>({
@@ -193,7 +202,7 @@ export function GettingStartedChecklist() {
const json = await res.json();
return json.data;
},
enabled: !!user,
enabled: onboardingPending,
});
const measurementCount = useMemo(() => {