Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defaultDistinctId refactoring #448

Merged
merged 1 commit into from
Jun 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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