feat(insights): surface ring/strap HRV and rank wearable activity sources

This commit is contained in:
Marc-André Bombeck committed 2026-06-14 21:22:41 +02:00
1 parent 46f9dfa47f
commit bd9f03805c
7 files changed
+166 -13

No files matched your search

@@ -247,6 +247,49 @@ describe("DEFAULT_SOURCE_PRIORITY", () => {
expect(ladder.indexOf("WHOOP")).toBeLessThan(ladder.indexOf("OURA"));
}
});
it("appends Oura + Polar to the activity ladders below Apple Health (v1.17)", () => {
// v1.17.0 — Oura + Polar write ACTIVITY_STEPS + ACTIVE_ENERGY_BURNED;
// they belong on the activity ladders as legitimate sources, ranked
// below the phone-aggregated APPLE_HEALTH but above a MANUAL entry, so
// an Oura/Polar-only day is not dropped when another source coexists.
for (const key of [
"steps",
"activeEnergy",
"walkingRunningDistance",
] as const) {
const ladder = DEFAULT_SOURCE_PRIORITY[key];
expect(ladder).toContain("OURA");
expect(ladder).toContain("POLAR");
// Below the phone-aggregated all-day Apple Health stream.
expect(ladder.indexOf("APPLE_HEALTH")).toBeLessThan(
ladder.indexOf("OURA"),
);
expect(ladder.indexOf("APPLE_HEALTH")).toBeLessThan(
ladder.indexOf("POLAR"),
);
// Above a hand-typed MANUAL entry — a real device beats nothing.
expect(ladder.indexOf("OURA")).toBeLessThan(ladder.indexOf("MANUAL"));
expect(ladder.indexOf("POLAR")).toBeLessThan(ladder.indexOf("MANUAL"));
// No existing source loses its rank: Apple Health still leads.
expect(ladder[0]).toBe("APPLE_HEALTH");
}
});
it("ranks the pulse wearables above a MANUAL reading (v1.17)", () => {
// v1.17.0 — a copy-paste slip had Polar / Oura ranked BELOW a hand-typed
// MANUAL pulse. Continuous optical-HR wearables must sit above MANUAL,
// matching the device-source order on the rhr / hrv ladders.
const ladder = DEFAULT_SOURCE_PRIORITY.pulse;
for (const device of ["FITBIT", "OURA", "POLAR"] as const) {
expect(ladder.indexOf(device)).toBeLessThan(ladder.indexOf("MANUAL"));
}
// Device-source order matches the rhr / hrv ladders (FITBIT > OURA > POLAR).
expect(ladder.indexOf("FITBIT")).toBeLessThan(ladder.indexOf("OURA"));
expect(ladder.indexOf("OURA")).toBeLessThan(ladder.indexOf("POLAR"));
// Withings stays the primary point-measurement source.
expect(ladder[0]).toBe("WITHINGS");
});
});
describe("DEFAULT_DEVICE_TYPE_PRIORITY", () => {
+19 -4
View File
@@ -217,9 +217,20 @@ export const DEFAULT_SOURCE_PRIORITY: Required<MetricPriority> = {
// v1.12.0 — Fitbit/Pixel rides below Apple Health for cumulative metrics:
// HealthKit still aggregates the broadest device set, and a Fitbit-only
// self-hoster has no Apple stream to compete with anyway.
steps: ["APPLE_HEALTH", "WITHINGS", "FITBIT", "MANUAL"],
activeEnergy: ["APPLE_HEALTH", "WITHINGS", "FITBIT", "MANUAL"],
walkingRunningDistance: ["APPLE_HEALTH", "WITHINGS", "FITBIT", "MANUAL"],
// v1.17.0 — Oura + Polar both write `ACTIVITY_STEPS` + `ACTIVE_ENERGY_BURNED`;
// they rank below the phone-aggregated Apple Health (which sees all-day
// steps) but as legitimate sources above MANUAL, so an Oura/Polar-only day
// is not dropped when another source coexists.
steps: ["APPLE_HEALTH", "WITHINGS", "FITBIT", "OURA", "POLAR", "MANUAL"],
activeEnergy: ["APPLE_HEALTH", "WITHINGS", "FITBIT", "OURA", "POLAR", "MANUAL"],
walkingRunningDistance: [
"APPLE_HEALTH",
"WITHINGS",
"FITBIT",
"OURA",
"POLAR",
"MANUAL",
],
flightsClimbed: ["APPLE_HEALTH", "WITHINGS", "FITBIT", "MANUAL"],
// v1.11.0 — WHOOP leads the recovery-input ladders (sleep / HRV / RHR):
// a worn-all-night strap has higher-resolution overnight sampling than
@@ -242,7 +253,11 @@ export const DEFAULT_SOURCE_PRIORITY: Required<MetricPriority> = {
// A real scale beats a strap's body-measurement estimate for weight.
weight: ["WITHINGS", "APPLE_HEALTH", "MANUAL", "WHOOP", "FITBIT"],
bloodPressure: ["WITHINGS", "APPLE_HEALTH", "MANUAL"],
pulse: ["WITHINGS", "APPLE_HEALTH", "MANUAL", "FITBIT", "POLAR", "OURA"],
// v1.17.0 — continuous optical-HR wearables (Fitbit / Polar / Oura) rank
// above a hand-typed MANUAL pulse; the device-source order matches the
// rhr / hrv ladders (FITBIT > OURA > POLAR). Withings BPM cuff + the
// HealthKit relay stay the primary point-measurement sources.
pulse: ["WITHINGS", "APPLE_HEALTH", "FITBIT", "OURA", "POLAR", "MANUAL"],
bodyFat: ["WITHINGS", "APPLE_HEALTH", "MANUAL", "FITBIT"],
bodyTemperature: ["WITHINGS", "APPLE_HEALTH", "MANUAL", "FITBIT"],
// Withings ScanWatch pulse-ox is the primary SpO2 sensor; WHOOP second,