diff --git a/Sources/VitalHealthKit/HealthKit/Storage/SyncProgressStore.swift b/Sources/VitalHealthKit/HealthKit/Storage/SyncProgressStore.swift index bb6a061e..482ded32 100644 --- a/Sources/VitalHealthKit/HealthKit/Storage/SyncProgressStore.swift +++ b/Sources/VitalHealthKit/HealthKit/Storage/SyncProgressStore.swift @@ -29,6 +29,8 @@ public struct SyncProgress: Codable { } public enum SystemEventType: Int, Codable { + case healthKitCalloutAppTerminating = 4 + case healthKitCalloutAppLaunching = 3 case healthKitCalloutBackground = 0 case healthKitCalloutForeground = 1 case backgroundProcessingTask = 2 diff --git a/Sources/VitalHealthKit/HealthKit/VitalHealthKitClient.swift b/Sources/VitalHealthKit/HealthKit/VitalHealthKitClient.swift index c699a655..cd7acf63 100644 --- a/Sources/VitalHealthKit/HealthKit/VitalHealthKitClient.swift +++ b/Sources/VitalHealthKit/HealthKit/VitalHealthKitClient.swift @@ -543,9 +543,7 @@ extension VitalHealthKitClient { SyncProgressStore.shared.recordSystem( remapped, - AppStateTracker.shared.state.status == .background - ? .healthKitCalloutBackground - : .healthKitCalloutForeground + healthkitCalloutEventType(AppStateTracker.shared.state.status) ) } } @@ -603,9 +601,7 @@ extension VitalHealthKitClient { SyncProgressStore.shared.recordSystem( remapped, - AppStateTracker.shared.state.status == .background - ? .healthKitCalloutBackground - : .healthKitCalloutForeground + healthkitCalloutEventType(AppStateTracker.shared.state.status) ) } @@ -1263,3 +1259,16 @@ extension ProtectedBox { } } } + +private func healthkitCalloutEventType(_ state: AppState.Status) -> SyncProgress.SystemEventType { + switch state { + case .background: + return .healthKitCalloutBackground + case .foreground: + return .healthKitCalloutForeground + case .launching: + return .healthKitCalloutAppLaunching + case .terminating: + return .healthKitCalloutAppTerminating + } +}