From 79706ec989df821aed05489d56d5bc43994c0b9d Mon Sep 17 00:00:00 2001 From: Abhishek Date: Thu, 19 Sep 2019 16:27:40 -0700 Subject: [PATCH] Not sending if email or serial number isn't present! --- .../Onboarding/FinalOnboardingViewController.swift | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Clocker/Onboarding/FinalOnboardingViewController.swift b/Clocker/Onboarding/FinalOnboardingViewController.swift index f985511..b3843f4 100644 --- a/Clocker/Onboarding/FinalOnboardingViewController.swift +++ b/Clocker/Onboarding/FinalOnboardingViewController.swift @@ -8,6 +8,7 @@ struct EmailSignupConstants { static let CLOperatingSystemVersion = "OS" static let CLClockerVersion = "Clocker version" static let CLAppFeedbackDateProperty = "date" + static let CLLocale = "locale" } class FinalOnboardingViewController: NSViewController { @@ -58,15 +59,15 @@ class FinalOnboardingViewController: NSViewController { return dateFormatter.string(from: Date()) } - private func extraData() -> [String: String] { + private func extraData() -> [String: String]? { guard let validEmail = emailValidator.validate(field: emailTextField) else { print("Not sending up email because it was invalid") - return [:] + return nil } guard let shortVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String, let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String else { - return [:] + return nil } let operatingSystem = ProcessInfo.processInfo.operatingSystemVersion let osVersion = "\(operatingSystem.majorVersion).\(operatingSystem.minorVersion).\(operatingSystem.patchVersion)" @@ -77,13 +78,13 @@ class FinalOnboardingViewController: NSViewController { EmailSignupConstants.CLOperatingSystemVersion: osVersion, EmailSignupConstants.CLClockerVersion: versionInfo, EmailSignupConstants.CLAppFeedbackDateProperty: todaysDate(), + EmailSignupConstants.CLLocale: Locale.current.identifier, ] } func sendUpEmailIfValid() { - let annotations = extraData() - guard let identifier = serialNumber else { - assertionFailure("Serial Identifier was unexpectedly nil") + guard let identifier = serialNumber, let annotations = extraData() else { + // Either serial number wasn't present or email wasn't added. Abort. return }