From 30c8def642ae3303c0d8f5f485b341934305eee3 Mon Sep 17 00:00:00 2001 From: Roman Podymov Date: Fri, 14 May 2021 17:34:29 +0200 Subject: [PATCH] Update MixpanelInstance.swift --- Sources/MixpanelInstance.swift | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Sources/MixpanelInstance.swift b/Sources/MixpanelInstance.swift index 658248ea..f819b648 100644 --- a/Sources/MixpanelInstance.swift +++ b/Sources/MixpanelInstance.swift @@ -604,22 +604,23 @@ open class MixpanelInstance: CustomDebugStringConvertible, FlushDelegate, AEDele } func defaultDistinctId() -> String { + let distinctId: String? #if MIXPANEL_UNIQUE_DISTINCT_ID - #if !os(OSX) && !os(watchOS) - var distinctId: String? = nil + #if os(OSX) + distinctId = MixpanelInstance.macOSIdentifier() + #elseif !os(watchOS) if NSClassFromString("UIDevice") != nil { distinctId = UIDevice.current.identifierForVendor?.uuidString + } else { + distinctId = nil } - #elseif os(OSX) - let distinctId = MixpanelInstance.macOSIdentifier() + #else + distinctId = nil #endif - #else // use a random UUID by default - let distinctId: String? = UUID().uuidString + #else + distinctId = nil #endif - guard let distId = distinctId else { - return UUID().uuidString - } - return distId + return distinctId ?? UUID().uuidString // use a random UUID by default } #if os(OSX)