mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 22:32:04 +00:00
fix(analytics,ci): merge health-score meta annotations, migrate integration tests, remove dead exports, raise bundle budget
This commit is contained in:
1 parent
668e3ca6b6
commit
1d784c6367
6 files changed
+166
-203
No files matched your search
@@ -21,7 +21,7 @@ import { userDayKey } from "@/lib/tz/format";
|
||||
import { getAgeFromDateOfBirth } from "@/lib/analytics/pulse-targets";
|
||||
import { toProfileSex } from "@/lib/profile/sex";
|
||||
import { healthScoreAlgorithmItemKey } from "@/lib/daily/priority-item-key";
|
||||
import { annotate } from "@/lib/logging/context";
|
||||
import { annotate, getEvent } from "@/lib/logging/context";
|
||||
|
||||
import { ACTIVITY_WINDOW_DAYS } from "./activity";
|
||||
import { SLEEP_WINDOW_DAYS } from "./sleep";
|
||||
@@ -109,12 +109,31 @@ async function capture<T>(
|
||||
? [failure]
|
||||
: [];
|
||||
if (failures.length > 0) {
|
||||
// `addMeta` replaces the whole `analytics` key wholesale (it does
|
||||
// not deep-merge), so writing `{ health_score: {...} }` directly
|
||||
// here would silently erase whatever `computeSummariesSlice` (or a
|
||||
// sibling pillar's own capture() failure) already wrote under
|
||||
// `meta.analytics` earlier in the same request. Read the event's
|
||||
// current `analytics` value first and merge into it instead.
|
||||
const existing = getEvent()?.toJSON().meta?.analytics;
|
||||
const existingHealthScore =
|
||||
existing &&
|
||||
typeof existing === "object" &&
|
||||
"health_score" in existing &&
|
||||
typeof existing.health_score === "object" &&
|
||||
existing.health_score !== null
|
||||
? (existing.health_score as Record<string, string>)
|
||||
: {};
|
||||
annotate({
|
||||
meta: {
|
||||
analytics: {
|
||||
health_score: Object.fromEntries(
|
||||
failures.map((failed) => [failed, "read_failed"]),
|
||||
),
|
||||
...(existing && typeof existing === "object" ? existing : {}),
|
||||
health_score: {
|
||||
...existingHealthScore,
|
||||
...Object.fromEntries(
|
||||
failures.map((failed) => [failed, "read_failed"]),
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -10,12 +10,7 @@ import type {
|
||||
DerivedProvenanceSource,
|
||||
} from "@/lib/insights/derived/types";
|
||||
|
||||
import type {
|
||||
DomainReadState,
|
||||
PillarValue,
|
||||
ScoreBand,
|
||||
ScorePillarId,
|
||||
} from "./types";
|
||||
import type { PillarValue, ScoreBand, ScorePillarId } from "./types";
|
||||
|
||||
export const DAY_MS = 86_400_000;
|
||||
|
||||
@@ -191,7 +186,3 @@ export function coverage(args: {
|
||||
missing: args.missing ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
export function readFailure(state: DomainReadState): boolean {
|
||||
return state.readFailed;
|
||||
}
|
||||
@@ -117,12 +117,6 @@ export interface HealthScoreReport {
|
||||
restMode?: RestModeAnnotation | null;
|
||||
}
|
||||
|
||||
export interface ScoreProfile {
|
||||
ageYears: number | null;
|
||||
sex: ProfileSex;
|
||||
heightCm: number | null;
|
||||
}
|
||||
|
||||
export interface DomainReadState {
|
||||
source: DerivedProvenanceSource;
|
||||
readFailed: boolean;
|
||||
|
||||
Reference in new issue
Block a user