Skip to content

Commit

Permalink
refactor analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
khoren93 committed Apr 16, 2020
1 parent 49ec864 commit 9ce536e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 49 deletions.
87 changes: 39 additions & 48 deletions SwiftHub/Managers/AnalyticsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion SwiftHub/Modules/Settings/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9ce536e

Please sign in to comment.