Skip to content

Commit

Permalink
VIT-7028: Expand the system event type
Browse files Browse the repository at this point in the history
  • Loading branch information
andersio committed Aug 2, 2024
1 parent 41fe9ac commit ea8a711
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 15 additions & 6 deletions Sources/VitalHealthKit/HealthKit/VitalHealthKitClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,7 @@ extension VitalHealthKitClient {

SyncProgressStore.shared.recordSystem(
remapped,
AppStateTracker.shared.state.status == .background
? .healthKitCalloutBackground
: .healthKitCalloutForeground
healthkitCalloutEventType(AppStateTracker.shared.state.status)
)
}
}
Expand Down Expand Up @@ -603,9 +601,7 @@ extension VitalHealthKitClient {

SyncProgressStore.shared.recordSystem(
remapped,
AppStateTracker.shared.state.status == .background
? .healthKitCalloutBackground
: .healthKitCalloutForeground
healthkitCalloutEventType(AppStateTracker.shared.state.status)
)
}

Expand Down Expand Up @@ -1263,3 +1259,16 @@ extension ProtectedBox<UIBackgroundTaskIdentifier> {
}
}
}

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
}
}

0 comments on commit ea8a711

Please sign in to comment.