diff --git a/Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift b/Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift index 089b55a..5b459a8 100644 --- a/Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift +++ b/Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift @@ -2,6 +2,7 @@ import Cocoa import CoreLoggerKit +import CoreModelKit import FirebaseDatabase extension NSNib.Name { @@ -24,6 +25,7 @@ enum AppFeedbackConstants { static let CLFeedbackAlertButtonTitle = "Close" static let CLFeedbackNotEnteredErrorMessage = "Please enter some feedback." static let CLAppFeedbackDateProperty = "date" + static let CLAppFeedbackUserPreferences = "Prefs" static let CLCaliforniaTimezoneIdentifier = "America/Los_Angeles" } @@ -111,6 +113,8 @@ class AppFeedbackWindowController: NSWindowController { } let feedbackInfo = retrieveDataForSending() + Logger.info("About to send \(feedbackInfo)") + sendDataToFirebase(feedbackInfo: feedbackInfo) showSucccessOnSendingInfo() } @@ -130,6 +134,52 @@ class AppFeedbackWindowController: NSWindowController { return true } + + private func generateUserPreferences() -> String { + let preferences = DataStore.shared().timezones() + + guard let theme = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber, + let displayFutureSliderKey = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber, + let relativeDateKey = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber, + let country = Locale.autoupdatingCurrent.regionCode + else { + return "Error" + } + + let selectedTimezones = preferences.compactMap { data -> String? in + guard let timezoneObject = TimezoneData.customObject(from: data) else { + return nil + } + return "Timezone: \(timezoneObject.timezone()) Name: \(timezoneObject.formattedAddress ?? "No") Favourited: \((timezoneObject.isFavourite == 1) ? "Yes": "No") Note: \(timezoneObject.note ?? "No Note") System: \(timezoneObject.isSystemTimezone ? "Yes": "No")" + } + + var relativeDate = "Relative" + + if relativeDateKey.isEqual(to: NSNumber(value: 1)) { + relativeDate = "Actual Day" + } else if relativeDateKey.isEqual(to: NSNumber(value: 2)) { + relativeDate = "Date" + } + + var themeInfo = "Light" + if theme.isEqual(to: NSNumber(value: 1)) { + themeInfo = "Dark" + } else if theme.isEqual(to: NSNumber(value: 2)) { + themeInfo = "System" + } + + var futureSlider = "Modern" + if displayFutureSliderKey.isEqual(to: NSNumber(value: 1)) { + futureSlider = "Legacy" + } else if theme.isEqual(to: NSNumber(value: 2)) { + futureSlider = "Hidden" + } + + return """ + "Theme: \(themeInfo), "Display Future Slider": \(futureSlider), "Relative Date": \(relativeDate), "Country": \(country), "Timezones": \(selectedTimezones) + """ + + } private func retrieveDataForSending() -> [String: String] { guard let shortVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String, @@ -145,16 +195,15 @@ class AppFeedbackWindowController: NSWindowController { let osVersion = "\(operatingSystem.majorVersion).\(operatingSystem.minorVersion).\(operatingSystem.patchVersion)" let versionInfo = "Clocker \(shortVersion) (\(appVersion))" - let feedbackInfo = [ + return [ AppFeedbackConstants.CLAppFeedbackNameProperty: name, AppFeedbackConstants.CLAppFeedbackEmailProperty: email, AppFeedbackConstants.CLAppFeedbackFeedbackProperty: appFeedbackProperty, AppFeedbackConstants.CLOperatingSystemVersion: osVersion, AppFeedbackConstants.CLClockerVersion: versionInfo, AppFeedbackConstants.CLAppFeedbackDateProperty: todaysDate(), + AppFeedbackConstants.CLAppFeedbackUserPreferences: generateUserPreferences(), ] - - return feedbackInfo } private func todaysDate() -> String { diff --git a/Clocker/Preferences/Menu Bar/StatusItemHandler.swift b/Clocker/Preferences/Menu Bar/StatusItemHandler.swift index 6439d8a..6f49a8a 100644 --- a/Clocker/Preferences/Menu Bar/StatusItemHandler.swift +++ b/Clocker/Preferences/Menu Bar/StatusItemHandler.swift @@ -32,7 +32,7 @@ class StatusItemHandler: NSObject { private var userNotificationsDidChangeNotif: NSObjectProtocol? - // Current State is set twice when the user first launches an app. + // Current State might be set twice when the user first launches an app. // First, when StatusItemHandler() is instantiated in AppDelegate // Second, when AppDelegate.fetchLocalTimezone() is called triggering a customLabel didSet. // TODO: Make sure it's set just once.