Skip to content

Commit

Permalink
Merge pull request #448 from RomanPodymov/master
Browse files Browse the repository at this point in the history
defaultDistinctId refactoring
  • Loading branch information
jaredmixpanel authored Jun 4, 2021
2 parents 5c99800 + 30c8def commit 747904d
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions Sources/MixpanelInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 747904d

Please sign in to comment.