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

[CHORE] Remove user from crash reports #2368

Merged
merged 1 commit into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions Rocket.Chat/AppDelegate.swift
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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)
}
}
Original file line number Diff line number Diff line change
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