Skip to content

Commit

Permalink
reduce the amount of noise being logged to single entries
Browse files Browse the repository at this point in the history
  • Loading branch information
erikng committed Aug 22, 2021
1 parent 62b51d7 commit 352eedf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Nudge/UI/ContentView.swift
Expand Up @@ -18,9 +18,12 @@ class ViewState: ObservableObject {
@Published var deferRunUntil = nudgeDefaults.object(forKey: "deferRunUntil") as? Date
@Published var hasLoggedDeferralCountPastThreshhold = false
@Published var hasLoggedDeferralCountPastThresholdDualQuitButtons = false
@Published var hasLoggedPastRequiredInstallationDate = false
@Published var hasLoggedRequireDualQuitButtons = false
@Published var lastRefreshTime = Utils().getInitialDate()
@Published var requireDualQuitButtons = false
@Published var shouldExit = false
@Published var timerCycle = 0
@Published var userDeferrals = nudgeDefaults.object(forKey: "userDeferrals") as? Int ?? 0
@Published var userQuitDeferrals = nudgeDefaults.object(forKey: "userQuitDeferrals") as? Int ?? 0
@Published var userRequiredMinimumOSVersion = nudgeDefaults.object(forKey: "requiredMinimumOSVersion") as? String ?? "0.0"
Expand Down
27 changes: 21 additions & 6 deletions Nudge/Utilities/Utils.swift
Expand Up @@ -33,19 +33,25 @@ struct Utils {

func allow1HourDeferral() -> Bool {
let allow1HourDeferralButtons = getNumberOfHoursBetween() > 0
uiLog.info("Device allow1HourDeferralButtons: \(allow1HourDeferralButtons, privacy: .public)")
if !nudgePrimaryState.afterFirstRun {
uiLog.info("Device allow1HourDeferralButtons: \(allow1HourDeferralButtons, privacy: .public)")
}
return allow1HourDeferralButtons
}

func allow24HourDeferral() -> Bool {
let allow24HourDeferralButtons = getNumberOfHoursBetween() > imminentWindowTime
uiLog.info("Device allow24HourDeferralButtons: \(allow24HourDeferralButtons, privacy: .public)")
if !nudgePrimaryState.afterFirstRun {
uiLog.info("Device allow24HourDeferralButtons: \(allow24HourDeferralButtons, privacy: .public)")
}
return allow24HourDeferralButtons
}

func allowCustomDeferral() -> Bool {
let allowCustomDeferralButtons = getNumberOfHoursBetween() > approachingWindowTime
uiLog.info("Device allowCustomDeferralButtons: \(allowCustomDeferralButtons, privacy: .public)")
if !nudgePrimaryState.afterFirstRun {
uiLog.info("Device allowCustomDeferralButtons: \(allowCustomDeferralButtons, privacy: .public)")
}
return allowCustomDeferralButtons
}

Expand Down Expand Up @@ -307,7 +313,10 @@ struct Utils {

func getTimerController() -> Int {
let timerCycle = getTimerControllerInt()
utilsLog.info("Timer cycle: \(timerCycle, privacy: .public)")
if timerCycle != nudgePrimaryState.timerCycle {
utilsLog.info("Timer cycle: \(timerCycle, privacy: .public)")
nudgePrimaryState.timerCycle = timerCycle
}
return timerCycle
}

Expand Down Expand Up @@ -371,7 +380,10 @@ struct Utils {

func pastRequiredInstallationDate() -> Bool {
let pastRequiredInstallationDate = getCurrentDate() > requiredInstallationDate
utilsLog.notice("Device pastRequiredInstallationDate: \(pastRequiredInstallationDate, privacy: .public)")
if !nudgePrimaryState.hasLoggedPastRequiredInstallationDate {
nudgePrimaryState.hasLoggedPastRequiredInstallationDate = true
utilsLog.notice("Device pastRequiredInstallationDate: \(pastRequiredInstallationDate, privacy: .public)")
}
return pastRequiredInstallationDate
}

Expand All @@ -381,7 +393,10 @@ struct Utils {
return false
}
let requireDualQuitButtons = (approachingWindowTime / 24) >= getNumberOfDaysBetween()
uiLog.info("Device requireDualQuitButtons: \(requireDualQuitButtons, privacy: .public)")
if !nudgePrimaryState.hasLoggedRequireDualQuitButtons {
nudgePrimaryState.hasLoggedRequireDualQuitButtons = true
uiLog.info("Device requireDualQuitButtons: \(requireDualQuitButtons, privacy: .public)")
}
return requireDualQuitButtons
}

Expand Down

0 comments on commit 352eedf

Please sign in to comment.