From 519e36e84fdaa1d7c1fbd8af70d937ff949984f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sat, 9 May 2026 16:23:44 +0200 Subject: [PATCH] perf(dashboard): skip checklist API fetches once onboarding is complete MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../onboarding/getting-started-checklist.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/onboarding/getting-started-checklist.tsx b/src/components/onboarding/getting-started-checklist.tsx index 7eab0eb1a..db535f2ec 100644 --- a/src/components/onboarding/getting-started-checklist.tsx +++ b/src/components/onboarding/getting-started-checklist.tsx @@ -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({ 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({ @@ -193,7 +202,7 @@ export function GettingStartedChecklist() { const json = await res.json(); return json.data; }, - enabled: !!user, + enabled: onboardingPending, }); const measurementCount = useMemo(() => {