Browse Source

Not sending if email or serial number isn't present!

pull/92/head
Abhishek 5 years ago
parent
commit
79706ec989
  1. 13
      Clocker/Onboarding/FinalOnboardingViewController.swift

13
Clocker/Onboarding/FinalOnboardingViewController.swift

@ -8,6 +8,7 @@ struct EmailSignupConstants {
static let CLOperatingSystemVersion = "OS" static let CLOperatingSystemVersion = "OS"
static let CLClockerVersion = "Clocker version" static let CLClockerVersion = "Clocker version"
static let CLAppFeedbackDateProperty = "date" static let CLAppFeedbackDateProperty = "date"
static let CLLocale = "locale"
} }
class FinalOnboardingViewController: NSViewController { class FinalOnboardingViewController: NSViewController {
@ -58,15 +59,15 @@ class FinalOnboardingViewController: NSViewController {
return dateFormatter.string(from: Date()) return dateFormatter.string(from: Date())
} }
private func extraData() -> [String: String] { private func extraData() -> [String: String]? {
guard let validEmail = emailValidator.validate(field: emailTextField) else { guard let validEmail = emailValidator.validate(field: emailTextField) else {
print("Not sending up email because it was invalid") print("Not sending up email because it was invalid")
return [:] return nil
} }
guard let shortVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String, guard let shortVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String,
let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String else { let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String else {
return [:] return nil
} }
let operatingSystem = ProcessInfo.processInfo.operatingSystemVersion let operatingSystem = ProcessInfo.processInfo.operatingSystemVersion
let osVersion = "\(operatingSystem.majorVersion).\(operatingSystem.minorVersion).\(operatingSystem.patchVersion)" let osVersion = "\(operatingSystem.majorVersion).\(operatingSystem.minorVersion).\(operatingSystem.patchVersion)"
@ -77,13 +78,13 @@ class FinalOnboardingViewController: NSViewController {
EmailSignupConstants.CLOperatingSystemVersion: osVersion, EmailSignupConstants.CLOperatingSystemVersion: osVersion,
EmailSignupConstants.CLClockerVersion: versionInfo, EmailSignupConstants.CLClockerVersion: versionInfo,
EmailSignupConstants.CLAppFeedbackDateProperty: todaysDate(), EmailSignupConstants.CLAppFeedbackDateProperty: todaysDate(),
EmailSignupConstants.CLLocale: Locale.current.identifier,
] ]
} }
func sendUpEmailIfValid() { func sendUpEmailIfValid() {
let annotations = extraData() guard let identifier = serialNumber, let annotations = extraData() else {
guard let identifier = serialNumber else { // Either serial number wasn't present or email wasn't added. Abort.
assertionFailure("Serial Identifier was unexpectedly nil")
return return
} }

Loading…
Cancel
Save