Files
HealthLog/src/lib/dashboard/snapshot-flag.ts
T
Marc-André Bombeck 7802ce1e11 feat(dashboard): enable unified snapshot for atomic first paint
Default the dashboard snapshot flag to ON (disable with
NEXT_PUBLIC_DASHBOARD_SNAPSHOT=false). The legacy four-cell waterfall
let the mood cache resolve first and pop in ahead of the rest of the
strip; the snapshot path hydrates every tile from one un-gated cell so
the whole strip shares a single completion moment.

Defaulting on rather than gating on === "true" sidesteps the
NEXT_PUBLIC_* build-time-baking trap: the production image and dev/e2e
all exercise the snapshot path without a special build flag. Fully
reversible to the legacy path via the env var. Comment-only sync in
page.tsx; no logic change there.
2026-05-31 19:37:02 +02:00

22 lines
1.0 KiB
TypeScript

/**
* Reversible rollout flag for the unified dashboard snapshot
* consumption.
*
* Controls whether the dashboard page reads every above-the-fold tile
* from the single `GET /api/dashboard/snapshot` cell (default) or falls
* back to the legacy four independent cells (slim analytics + thick
* analytics + mood + widget layout). The snapshot path is the desired
* behaviour: one un-gated request hydrates the whole strip so every
* tile shares one completion moment, instead of four parallel cells
* where the mood cache resolves fastest and pops in ahead of the rest.
*
* Default ON. Set `NEXT_PUBLIC_DASHBOARD_SNAPSHOT=false` to fall back
* to the legacy multi-cell path. Defaulting on (rather than gating on
* `=== "true"`) avoids the `NEXT_PUBLIC_*` build-time-baking trap: the
* snapshot path is exercised in dev / e2e without a special build
* flag, and the production image gets it without a Dockerfile ARG.
*/
export function isDashboardSnapshotEnabled(): boolean {
return process.env.NEXT_PUBLIC_DASHBOARD_SNAPSHOT !== "false";
}