Skip to content

Count backfilled glucose in the daily analytics summary - #2578

Merged
ps2 merged 1 commit into
next-devfrom
glucose-backfill-analytics-next-dev
Oct 14, 2026
Merged

ps2 merged 1 commit into
next-devfrom
glucose-backfill-analytics-next-dev

Conversation

@ps2

@ps2 ps2 commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

#2575 was merged into its stacked base branch (analytics-daily-summary-and-privacy) a minute after #2574 was squash-merged, so its change never reached next-dev. This is the same commit, cherry-picked onto next-dev without conflicts.

The daily summary's cgmFetchCount only counted readings fetched by polling; CGMs that push readings through cgmManager(_:hasNew:) were never counted. It's replaced by counts of CGM readings actually stored, taken from what addGlucoseSamples returns (duplicates the store drops aren't counted):

  • glucoseCount: CGM readings stored that day (user-entered readings excluded)
  • backfillCount: how many of those were tagged backfill by the CGM plugin
  • maxBackfillAgeMinutes: the longest gap between a backfilled reading's time and when Loop received it

The per-fetch "CGM Fetch" hook is removed. Uses StoredGlucoseSample.isBackfill and receivedDate from LoopKit/LoopKit#646 (merged).

The workspace build succeeds against LoopKit next-dev.

The daily summary replaces cgmFetchCount, which only counted readings fetched by polling and missed CGMs that push readings, with counts of CGM readings actually stored: glucoseCount, backfillCount, and maxBackfillAgeMinutes (the longest gap between a backfilled reading's time and when Loop received it).
@ps2
ps2 merged commit bb2e7eb into next-dev Oct 14, 2026
ps2 added a commit that referenced this pull request Oct 18, 2026
Backport of #2574, #2578 and #2582
from next-dev.

- Replace the per-cycle "Loop success", "Loop error" and "CGM Fetch"
  events with one "Daily summary" per local day: loop success count and
  mean/max duration, loop error counts by issue id, the count of stored
  CGM readings, the day's UTC offset, and the settings state (closed
  loop, dosing strategy, integral retrospective correction, glucose based
  partial application). Running totals are kept in UserDefaults and the
  summary is sent on the first loop or CGM reading of the next day.
- Send that settings state as user properties at launch and whenever it
  changes, with "Closed loop enabled change", "Dosing strategy change"
  and "Algorithm experiment change" events. Also send Pump Type and CGM
  Type at launch, and set them to "None" when the device is removed.
- Send Pump Model and CGM Model user properties from the managers'
  HKDevice.model at setup and launch, and when a status update reports a
  different model.
- Stop sending health data: drop bolus units and carb grams, and send
  only the kind of override, and its duration, not preset names, targets
  or sensitivity.
- Send "Override Ended" when a preset is deactivated and "Settings
  Screen" when Settings opens.
- Carb and bolus events from the phone are now in session; from the
  watch and remote commands they stay out of session.
- Replace "Alert Issued" with "Alert Displayed": immediate alerts when
  issued, delayed and repeating alerts after a loop once they have come
  due without being retracted, and loop-not-running notifications when
  Loop infers their delivery.

dev's glucose samples don't record backfill, so the summary counts CGM
readings but has no backfill counts. The summary and state are updated
on the main queue, since dev reports loops and readings from other
queues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant