Skip to content

Daily analytics summary, settings state and device models - #2588

Open
ps2 wants to merge 1 commit into
devfrom
analytics-summary-dev
Open

ps2 wants to merge 1 commit into
devfrom
analytics-summary-dev

Conversation

@ps2

@ps2 ps2 commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

Backport of #2574, #2578 and #2582 from next-dev. dev's code had diverged, so this is a hand port in one commit rather than cherry-picks.

  • Daily summary: one "Daily summary" event per local day replaces the per-cycle "Loop success", "Loop error" and "CGM Fetch" events. It has 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.
  • Settings state: closed loop, dosing strategy, integral retrospective correction and glucose based partial application are sent as user properties at launch and when they change, with "Closed loop enabled change", "Dosing strategy change" and "Algorithm experiment change" events.
  • Devices: Pump Type/CGM Type and Pump Model/CGM Model user properties are sent at launch and setup, when a status update reports a different model, and as "None" on removal.
  • No health data: bolus units, carb grams, preset names, targets and sensitivity are no longer sent. Override events carry the kind and duration, and "Override Ended" is now sent.
  • Alerts: "Alert Displayed" replaces "Alert Issued". Immediate alerts are reported when issued, delayed and repeating alerts once they come due without being retracted (checked after each loop), and loop-not-running notifications when Loop infers their delivery.
  • "Settings Screen" is sent when Settings opens. Carb and bolus events from the phone are in session; watch and remote ones stay out of session.

Differences from next-dev

  • dev's glucose samples don't record backfill, so the summary has glucoseCount but no backfillCount or maxBackfillAgeMinutes.
  • dev reports loops and CGM readings from background queues, so the summary and state are updated on the main queue instead of being @MainActor.
  • dev has no activity presets, so override events have no activity type, and the legacy workout override is reported with kind "workout".

Testing

  • The LoopWorkspace scheme builds for the iOS Simulator. All 306 LoopTests pass, including testLookupScheduledAlertsDue, ported from next-dev.
  • In the simulator, the stored summary had the right counts and settings state. Toggling integral retrospective correction logged "Algorithm experiment change" and re-sent the user properties.
  • A temporary test, not included here, checked the day rollover. A summary dated yesterday was sent as "Daily summary" with its counts and replaced by today's, and a changed experiment produced the change event and updated user property.

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.

@marionbarker marionbarker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rely on others for code review.
✅ successful build using Xcode 27 onto iOS 27.0.1 SE 3rd gen phone
❓ successful test local clone to iOS 26.5 simulator
❓ successful test local clone to iOS 27 simulator

Sometimes this test failed. Other times it did not.
testRescheduleMutedLoopNotLoopingAlerts

Failure was on the XCTAssertNil for line 509 of LoopTests/Managers/Alerts/AlertManagerTests.swift.

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.

2 participants