From 9ce536e8630b6ce72a9837767d7967d33d30329d Mon Sep 17 00:00:00 2001 From: Khoren Markosyan Date: Fri, 17 Apr 2020 01:19:31 +0400 Subject: [PATCH] refactor analytics --- SwiftHub/Managers/AnalyticsManager.swift | 87 +++++++++---------- .../Settings/SettingsViewController.swift | 1 - 2 files changed, 39 insertions(+), 49 deletions(-) diff --git a/SwiftHub/Managers/AnalyticsManager.swift b/SwiftHub/Managers/AnalyticsManager.swift index 1ef50d20..0eaa60f8 100644 --- a/SwiftHub/Managers/AnalyticsManager.swift +++ b/SwiftHub/Managers/AnalyticsManager.swift @@ -19,7 +19,6 @@ enum SwifthubEvent { case appTheme(color: String) case appLanguage(language: String) case appCacheRemoved - case acknowledgements case userInvited(success: Bool) case whatsNew case flexOpened @@ -42,64 +41,56 @@ extension SwifthubEvent: Umbrella.EventType { func name(for provider: ProviderType) -> String? { switch self { - case .appAds: return "Ads Changed" - case .appNightMode: return "Night Mode Changed" - case .appTheme: return "Theme" - case .appLanguage: return "Language" - case .appCacheRemoved: return "Cache Removed" - case .acknowledgements: return "Acknowledgements" - case .userInvited: return "User Invited" - case .whatsNew: return "Whats New" - case .flexOpened: return "Flex Opened" - case .login: return "Login" - case .logout: return "Logout" - case .search: return "Search" - case .repoLanguage: return "Repo Language" - case .repository: return "Repository" - case .user: return "User" - case .userEvents: return "User Events" - case .repositoryEvents: return "Repository Events" - case .issues: return "Issues" - case .source: return "Source" - case .readme: return "Readme" - case .linesCount: return "Lines Count" + case .appAds: return "ads_changed" + case .appNightMode: return "night_mode_changed" + case .appTheme: return "theme" + case .appLanguage: return "language" + case .appCacheRemoved: return "cache_removed" + case .userInvited: return "user_invited" + case .whatsNew: return "whats_new" + case .flexOpened: return "flex_opened" + case .login: return "login" + case .logout: return "logout" + case .search: return "search" + case .repoLanguage: return "repo_language" + case .repository: return "repository" + case .user: return "user" + case .userEvents: return "user_events" + case .repositoryEvents: return "repository_events" + case .issues: return "issues" + case .source: return "source" + case .readme: return "readme" + case .linesCount: return "lines_count" } } func parameters(for provider: ProviderType) -> [String: Any]? { switch self { - case .appAds(let enabled): - return ["Enabled": enabled] - case .appNightMode(let enabled): - return ["Enabled": enabled] + case .appAds(let enabled), + .appNightMode(let enabled): + return ["enabled": enabled] case .appTheme(let color): - return ["Color": color] + return ["color": color] case .appLanguage(let language): - return ["Language": language] + return ["language": language] case .userInvited(let success): - return ["Success": success] + return ["success": success] case .login(let login, let type): - return ["Login": login, "Type": type] + return ["login": login, "type": type] case .search(let keyword): - return ["Keyword": keyword] + return ["keyword": keyword] case .repoLanguage(let language): - return ["Language": language] - case .repository(let fullname): - return ["Fullname": fullname] - case .user(let login): - return ["Login": login] - case .userEvents(let login): - return ["Login": login] - case .repositoryEvents(let fullname): - return ["Fullname": fullname] - case .issues(let fullname): - return ["Fullname": fullname] - case .source(let fullname): - return ["Fullname": fullname] - case .readme(let fullname): - return ["Fullname": fullname] - case .linesCount(let fullname): - return ["Fullname": fullname] + return ["language": language] + case .user(let login), + .userEvents(let login): + return ["login": login] + case .repository(let fullname), + .repositoryEvents(let fullname), + .issues(let fullname), + .source(let fullname), + .readme(let fullname), + .linesCount(let fullname): + return ["fullname": fullname] default: return nil } diff --git a/SwiftHub/Modules/Settings/SettingsViewController.swift b/SwiftHub/Modules/Settings/SettingsViewController.swift index 183de84e..63371431 100644 --- a/SwiftHub/Modules/Settings/SettingsViewController.swift +++ b/SwiftHub/Modules/Settings/SettingsViewController.swift @@ -111,7 +111,6 @@ class SettingsViewController: TableViewController { self?.deselectSelectedRow() case .acknowledgementsItem: self?.navigator.show(segue: .acknowledgements, sender: self, transition: .detail) - analytics.log(.acknowledgements) case .whatsNewItem: self?.navigator.show(segue: .whatsNew(block: viewModel.whatsNewBlock()), sender: self, transition: .modal) analytics.log(.whatsNew)