Skip to content
This repository has been archived by the owner on Jun 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #2373 from RocketChat/release/3.1.2
Browse files Browse the repository at this point in the history
[RELEASE] Merge release 3.1.2 into MASTER
  • Loading branch information
rafaelks committed Nov 28, 2018
2 parents 64b4ae9 + a137f12 commit 830e7c4
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 53 deletions.
4 changes: 0 additions & 4 deletions Rocket.Chat/AppDelegate.swift
Expand Up @@ -33,10 +33,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
AuthManager.persistAuthInformation(auth)
AuthSettingsManager.shared.updateCachedSettings()
WindowManager.open(.subscriptions)

if let user = auth.user {
AnalyticsCoordinator.identifyCrashReports(withUser: user)
}
} else {
WindowManager.open(.auth(serverUrl: "", credentials: nil))
}
Expand Down
4 changes: 0 additions & 4 deletions Rocket.Chat/Managers/AppManager.swift
Expand Up @@ -190,10 +190,6 @@ extension AppManager {
SocketManager.disconnect { (_, _) in
DispatchQueue.main.async {
if AuthManager.isAuthenticated() != nil {
if let currentUser = AuthManager.currentUser() {
AnalyticsCoordinator.identifyCrashReports(withUser: currentUser)
}

WindowManager.open(.subscriptions)

let server = AuthManager.selectedServerHost()
Expand Down
44 changes: 1 addition & 43 deletions Rocket.Chat/Managers/Launcher/AnalyticsCoordinator.swift
Expand Up @@ -24,9 +24,7 @@ struct AnalyticsCoordinator: LauncherProtocol {
static func toggleCrashReporting(disabled: Bool) {
UserDefaults.standard.set(disabled, forKey: kCrashReportingDisabledKey)

if disabled {
anonymizeCrashReports()
} else {
if !disabled {
AnalyticsCoordinator().prepareToLaunch(with: nil)
}
}
Expand Down Expand Up @@ -57,45 +55,5 @@ struct AnalyticsCoordinator: LauncherProtocol {

private func launchFabric() {
Fabric.with([Crashlytics.self])

if let currentUser = AuthManager.currentUser() {
AnalyticsCoordinator.identifyCrashReports(withUser: currentUser)
} else {
AnalyticsCoordinator.anonymizeCrashReports()
}
}

static func identifyCrashReports(withUser user: User) {
guard let id = user.identifier else {
return
}

let crashlytics = Crashlytics.sharedInstance()
crashlytics.setUserIdentifier(id)

if let name = user.name {
crashlytics.setUserName(name)
}

if let email = user.emails.first?.email {
crashlytics.setUserEmail(email)
}

if let serverURL = AuthManager.selectedServerInformation()?[ServerPersistKeys.serverURL] {
crashlytics.setObjectValue(serverURL, forKey: ServerPersistKeys.serverURL)
}

if let serverVersion = AuthManager.selectedServerInformation()?[ServerPersistKeys.serverVersion] {
crashlytics.setObjectValue(serverVersion, forKey: ServerPersistKeys.serverVersion)
}
}

static func anonymizeCrashReports() {
let crashlytics = Crashlytics.sharedInstance()

crashlytics.setUserEmail(nil)
crashlytics.setUserName(nil)
crashlytics.setUserIdentifier(nil)
crashlytics.setObjectValue(nil, forKey: ServerPersistKeys.serverURL)
}
}
Expand Up @@ -257,8 +257,6 @@ extension AuthManager {
*/
static func logout(completion: @escaping VoidCompletion) {
SocketManager.disconnect { (_, _) in
AnalyticsCoordinator.anonymizeCrashReports()

DraftMessageManager.clearServerDraftMessages()

Realm.executeOnMainThread({ (realm) in
Expand Down

0 comments on commit 830e7c4

Please sign in to comment.