mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
Split the ECG cap and one provenance entry off their label maps
The /insights overview crept a kilobyte over its ceiling: the ECG teaser imported its overview cap from the classification module, which dragged that module's label map and helpers into the eager page, and the Health Score card pulled the whole metric-provenance map for its one citation. The cap now lives in a value-only module and the single provenance entry is split out, so the overview imports the bare number and citation it renders. Both routes are back under budget. The aggregate ceiling rises to hold the six-locale copy the new encounter, mood-context, mood-prognosis and practitioner surfaces added, which the whole-build sum counts independently and no single route downloads.
This commit is contained in:
1 parent
0a9917a09d
commit
08d3cd2c31
8 files changed
+57
-35
No files matched your search
+2
-2
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"$comment": "Client-bundle budgets, enforced by scripts/check-bundle-budget.mjs (--check) after `next build` in CI. Values are KB gzip and include every emitted lazy route and locale chunk, while route budgets include the shared rootMainFiles baseline. Re-measured at v1.35.0: / 431, /insights 421, /measurements 417, /insights/mood 439, total 3286, baseline 130, lazy catalogs 804. Every per-route ceiling is unchanged and every measured route is within a kilobyte of its v1.34.1 value, so nothing a person actually downloads grew. The 48 KB aggregate rise from 3238 is the score-configuration settings route, which is a new mutually exclusive chunk the whole-build sum counts independently, plus about 12 KB of its strings across the six locale catalogs. No catalog is statically route-referenced and Recharts remains exactly one fingerprinted chunk. The aggregate cap therefore moves from 3260 to 3310 (24 KB headroom, matching the previous margin); per-route ceilings, the static-catalog guard and the one-Recharts-chunk guard remain unchanged.",
|
||||
"$comment": "Client-bundle budgets, enforced by scripts/check-bundle-budget.mjs (--check) after `next build` in CI. Values are KB gzip and include every emitted lazy route and locale chunk, while route budgets include the shared rootMainFiles baseline. Re-measured at v1.37.2: / 455, /insights 443, /measurements 441, /insights/mood 453, total 3328, baseline 130, lazy catalogs 849. Every per-route ceiling is unchanged. The /insights overview crept a kilobyte over its 445 ceiling when the ECG teaser began importing its overview cap from the classification module, dragging that module's label map and helpers into the eager page; the cap now lives in its own value-only module, and the Health Score's single provenance entry is split out of the full metric-provenance map, so the overview imports the bare number and citation it renders rather than every metric's label map behind them. Both are back under 445 with room to spare. The 42 KB aggregate rise from 3286 (v1.35.0) is all locale-catalog strings: v1.36 and v1.37 added the encounter, mood-context, mood-prognosis, practitioner, workout-batch and account-sharing surfaces, and their copy lands across the six locale catalogs the whole-build sum counts independently (804 to 849 KB). The non-catalog client chunks are flat against v1.35.0, so nothing a person downloads on a given route grew beyond its own ceiling. The aggregate cap therefore moves from 3310 to 3352 (24 KB headroom, matching the previous margin); per-route ceilings, the static-catalog guard and the one-Recharts-chunk guard remain unchanged.",
|
||||
"routesKbGz": {
|
||||
"/page": 460,
|
||||
"/insights/page": 445,
|
||||
"/measurements/page": 445,
|
||||
"/insights/mood/page": 460
|
||||
},
|
||||
"totalClientKbGz": 3310,
|
||||
"totalClientKbGz": 3352,
|
||||
"maxRechartsChunks": 1
|
||||
}
|
||||
@@ -9,9 +9,10 @@ import { SlidersHorizontal, TrendingUp } from "lucide-react";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { queryKeys } from "@/lib/query-keys";
|
||||
import { apiGet } from "@/lib/api/api-fetch";
|
||||
// Pure constant — importing it here does NOT pull the dynamically-loaded ECG
|
||||
// component into this bundle, which is exactly why it lives in the lib module.
|
||||
import { ECG_OVERVIEW_LIMIT } from "@/lib/insights/ecg-classification";
|
||||
// Bare number — its own React- and label-map-free module, so importing it here
|
||||
// pulls neither the ECG label map/helpers nor the dynamically-loaded ECG
|
||||
// component into this eager bundle.
|
||||
import { ECG_OVERVIEW_LIMIT } from "@/lib/insights/ecg-overview-limit";
|
||||
import { useFeatureFlags } from "@/hooks/use-feature-flags";
|
||||
import { useInsightsLayoutQuery } from "@/hooks/use-insights-layout";
|
||||
import { usePullToRefresh } from "@/hooks/use-pull-to-refresh";
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { MetricProvenanceMeta } from "./standards";
|
||||
|
||||
/**
|
||||
* The Health Score's own provenance entry, split out of the full
|
||||
* `METRIC_PROVENANCE` map.
|
||||
*
|
||||
* The eager insights overview reaches this value through
|
||||
* HeroStrip → HealthScoreCard, and it needs only this one metric's method key
|
||||
* and cited standard. Importing the whole map there dragged every derived
|
||||
* metric's citation (~30 entries of DOIs and key strings) into the overview's
|
||||
* initial bundle. Isolating the entry keeps the eager page down to the number
|
||||
* it renders; `METRIC_PROVENANCE.HEALTH_SCORE` re-exports this same value, so
|
||||
* the lazy score surfaces still read one source.
|
||||
*
|
||||
* Cited for the risk-factor set the pillars are drawn from, and for nothing
|
||||
* beyond it. HEARTS names the cardiometabolic factors worth following; it does
|
||||
* not prescribe an equal-weighted average of them, and since v1.35.0 it could
|
||||
* not, because which pillars enter that average is the account's own
|
||||
* selection. Naming the package plainly, as this entry used to, reads as a
|
||||
* standard endorsing whatever recipe the person happens to have chosen, which
|
||||
* is a claim nobody can make. The pillar-level citations in the map are
|
||||
* unaffected: each of those really does describe the band its pillar is graded
|
||||
* against.
|
||||
*/
|
||||
export const HEALTH_SCORE_PROVENANCE: MetricProvenanceMeta = {
|
||||
methodKey: "insights.healthScore.method",
|
||||
standard: {
|
||||
name: "WHO HEARTS technical package (risk-factor set)",
|
||||
url: "https://www.who.int/publications/i/item/9789240001367",
|
||||
},
|
||||
};
|
||||
@@ -23,6 +23,7 @@
|
||||
* covers has to live in `insights.healthScore.method` — the standard entry
|
||||
* alone would say it to nobody.
|
||||
*/
|
||||
import { HEALTH_SCORE_PROVENANCE } from "./health-score-provenance";
|
||||
import type { ProvenanceStandard } from "./provenance-explainer";
|
||||
import type { DerivedMetricId } from "@/lib/insights/derived/registry";
|
||||
|
||||
@@ -198,21 +199,8 @@ export const METRIC_PROVENANCE: Record<DerivedMetricId, MetricProvenanceMeta> =
|
||||
},
|
||||
caveatKey: "insights.derived.composite.SAME_TIME_BASELINE.caveat",
|
||||
},
|
||||
HEALTH_SCORE: {
|
||||
methodKey: "insights.healthScore.method",
|
||||
standard: {
|
||||
// Cited for the risk-factor set the pillars are drawn from, and for
|
||||
// nothing beyond it. HEARTS names the cardiometabolic factors worth
|
||||
// following; it does not prescribe an equal-weighted average of
|
||||
// them, and since v1.35.0 it could not, because which pillars enter
|
||||
// that average is the account's own selection. Naming the package
|
||||
// plainly, as this entry used to, reads as a standard endorsing
|
||||
// whatever recipe the person happens to have chosen, which is a
|
||||
// claim nobody can make. The pillar-level citations elsewhere in
|
||||
// this map are unaffected: each of those really does describe the
|
||||
// band its pillar is graded against.
|
||||
name: "WHO HEARTS technical package (risk-factor set)",
|
||||
url: "https://www.who.int/publications/i/item/9789240001367",
|
||||
},
|
||||
},
|
||||
// The HEALTH_SCORE entry lives in its own module so the eager insights
|
||||
// overview can import just this metric's citation without pulling the whole
|
||||
// map; the rationale for its wording is documented there.
|
||||
HEALTH_SCORE: HEALTH_SCORE_PROVENANCE,
|
||||
};
|
||||
@@ -12,9 +12,9 @@ import { cn } from "@/lib/utils";
|
||||
import { SectionHeading } from "@/components/ui/section-heading";
|
||||
import {
|
||||
ecgResultLabel,
|
||||
ECG_OVERVIEW_LIMIT,
|
||||
type EcgClassification,
|
||||
} from "@/lib/insights/ecg-classification";
|
||||
import { ECG_OVERVIEW_LIMIT } from "@/lib/insights/ecg-overview-limit";
|
||||
import { InsightSectionCard } from "./insight-section-card";
|
||||
|
||||
// Re-exported so the tests (and any teaser call site) can keep importing the
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
} from "@/components/insights/derived/band-tokens";
|
||||
import { CoverageMeter } from "@/components/insights/derived/coverage-meter";
|
||||
import { ProvenanceExplainer } from "@/components/insights/derived/provenance-explainer";
|
||||
import { METRIC_PROVENANCE } from "@/components/insights/derived/standards";
|
||||
import { HEALTH_SCORE_PROVENANCE } from "@/components/insights/derived/health-score-provenance";
|
||||
import {
|
||||
pillarDetailLines,
|
||||
pillarObservedText,
|
||||
@@ -643,8 +643,8 @@ export function HealthScoreCard({
|
||||
)}
|
||||
<ProvenanceExplainer
|
||||
provenance={composite.provenance}
|
||||
method={t(METRIC_PROVENANCE.HEALTH_SCORE.methodKey)}
|
||||
standard={METRIC_PROVENANCE.HEALTH_SCORE.standard}
|
||||
method={t(HEALTH_SCORE_PROVENANCE.methodKey)}
|
||||
standard={HEALTH_SCORE_PROVENANCE.standard}
|
||||
className="block"
|
||||
/>
|
||||
{/* v1.35.0 — the one way into the surface that decides what
|
||||
|
||||
@@ -13,15 +13,6 @@
|
||||
export type EcgClassification =
|
||||
"IRREGULAR" | "NOT_DETECTED" | "INCONCLUSIVE" | null;
|
||||
|
||||
/**
|
||||
* How many strips the OVERVIEW teaser paints. It is a glance, not a history;
|
||||
* the dedicated `/insights/ecg` page passes no limit and shows every
|
||||
* recording. The constant lives here — a pure value with no React import — so
|
||||
* the `/insights` page can pass it without pulling the ECG component eagerly
|
||||
* across its dynamic boundary.
|
||||
*/
|
||||
export const ECG_OVERVIEW_LIMIT = 5;
|
||||
|
||||
/** i18n key per device verdict, under `insights.ecg.result.*`. */
|
||||
export const ECG_RESULT_LABEL_KEYS: Record<string, string> = {
|
||||
IRREGULAR: "insights.ecg.result.irregular",
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* How many strips the OVERVIEW teaser paints. It is a glance, not a history;
|
||||
* the dedicated `/insights/ecg` page passes no limit and shows every
|
||||
* recording.
|
||||
*
|
||||
* The value lives in its own React- and label-map-free module so the
|
||||
* `/insights` overview page can pass it without pulling the ECG label map,
|
||||
* its helpers, or the recording component across the dynamic boundary — a
|
||||
* bare number is all the eager page imports.
|
||||
*/
|
||||
export const ECG_OVERVIEW_LIMIT = 5;
|
||||
Reference in new issue
Block a user