diff --git a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Activities.swift b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Activities.swift index ca0b890a1..75b27010e 100644 --- a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Activities.swift +++ b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Activities.swift @@ -16,7 +16,7 @@ public extension AnalyticsManager { "lk_carereceiver_ids": carereceiverIDs, ].merging(parameters) { _, new in new } - Self.logEvent(name: "activity_start", parameters: params) + Self.logEvent(.activityStart, parameters: params) } static func logEventActivityEnd( @@ -32,6 +32,6 @@ public extension AnalyticsManager { "lk_activity_end_reason": reason.rawValue, ].merging(parameters) { _, new in new } - Self.logEvent(name: "activity_end", parameters: params) + Self.logEvent(.activityEnd, parameters: params) } } diff --git a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+App.swift b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+App.swift index c66b7861c..31e5b8e82 100644 --- a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+App.swift +++ b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+App.swift @@ -12,7 +12,7 @@ public extension AnalyticsManager { "new_version": newVersion, ].merging(parameters) { _, new in new } - Self.logEvent(name: "app_update_skip", parameters: params) + Self.logEvent(.appUpdateSkip, parameters: params) } // TODO: (@ladislas) add real versions @@ -22,6 +22,6 @@ public extension AnalyticsManager { "new_version": newVersion, ].merging(parameters) { _, new in new } - Self.logEvent(name: "app_update_open_app_store", parameters: params) + Self.logEvent(.appUpdateOpenAppStore, parameters: params) } } diff --git a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Auth.swift b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Auth.swift index 99ee074b7..1293abe7c 100644 --- a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Auth.swift +++ b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Auth.swift @@ -8,30 +8,30 @@ public extension AnalyticsManager { static func logEventLogin(parameters: [String: Any] = [:]) { let params: [String: Any] = [:].merging(parameters) { _, new in new } - Self.logEvent(name: AnalyticsEventLogin, parameters: params) + Self.logEvent(.login, parameters: params) } static func logEventLogout(parameters: [String: Any] = [:]) { let params: [String: Any] = [:].merging(parameters) { _, new in new } - Self.logEvent(name: "logout", parameters: params) + Self.logEvent(.logout, parameters: params) } static func logEventSignUp(parameters: [String: Any] = [:]) { let params: [String: Any] = [:].merging(parameters) { _, new in new } - Self.logEvent(name: AnalyticsEventSignUp, parameters: params) + Self.logEvent(.signup, parameters: params) } static func logEventSkipAuthentication(parameters: [String: Any] = [:]) { let params: [String: Any] = [:].merging(parameters) { _, new in new } - Self.logEvent(name: "skip_authentication", parameters: params) + Self.logEvent(.skipAuthentication, parameters: params) } static func logEventAccountDelete(parameters: [String: Any] = [:]) { let params: [String: Any] = [:].merging(parameters) { _, new in new } - Self.logEvent(name: "account_delete", parameters: params) + Self.logEvent(.accountDelete, parameters: params) } } diff --git a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Robot.swift b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Robot.swift index b3a9e8515..476b1fb47 100644 --- a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Robot.swift +++ b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Robot.swift @@ -5,12 +5,6 @@ import FirebaseAnalytics public extension AnalyticsManager { - enum RobotEvent: String { - case connect = "robot_connect" - case disconnect = "robot_disconnect" - case rename = "robot_rename" - } - static func logEventRobotConnect( robotName: String, serialNumber: String, @@ -27,7 +21,7 @@ public extension AnalyticsManager { "lk_battery_level": batteryLevel, ].merging(parameters) { _, new in new } - Self.logEvent(name: RobotEvent.connect.rawValue, parameters: params) + Self.logEvent(.robotConnect, parameters: params) } static func logEventRobotDisconnect( @@ -46,7 +40,7 @@ public extension AnalyticsManager { "lk_battery_level": batteryLevel, ].merging(parameters) { _, new in new } - Self.logEvent(name: RobotEvent.disconnect.rawValue, parameters: params) + Self.logEvent(.robotDisconnect, parameters: params) } // swiftlint:disable:next function_parameter_count @@ -68,6 +62,6 @@ public extension AnalyticsManager { "lk_battery_level": batteryLevel, ].merging(parameters) { _, new in new } - Self.logEvent(name: RobotEvent.rename.rawValue, parameters: params) + Self.logEvent(.robotRename, parameters: params) } } diff --git a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+ScreenView.swift b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+ScreenView.swift index 6ed6900b8..f9a6d507c 100644 --- a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+ScreenView.swift +++ b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+ScreenView.swift @@ -15,7 +15,7 @@ public extension AnalyticsManager { params[AnalyticsParameterScreenClass] = screenClass } - Self.logEvent(name: AnalyticsEventScreenView, parameters: params) + Self.logEvent(.screenView, parameters: params) } } diff --git a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+SelectContent.swift b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+SelectContent.swift index 074b73efb..cf087a479 100644 --- a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+SelectContent.swift +++ b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+SelectContent.swift @@ -37,6 +37,6 @@ public extension AnalyticsManager { "lk_content_origin": origin.rawValue, ].merging(parameters) { _, new in new } - Self.logEvent(name: AnalyticsEventSelectContent, parameters: params) + Self.logEvent(.selectContent, parameters: params) } } diff --git a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Users.swift b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Users.swift index 7ca5abdf5..7c1701a42 100644 --- a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Users.swift +++ b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Users.swift @@ -10,12 +10,12 @@ public extension AnalyticsManager { "lk_caregiver_id": id ?? "(lk_not_set)", ].merging(parameters) { _, new in new } - Self.logEvent(name: "caregiver_select", parameters: params) + Self.logEvent(.caregiverSelect, parameters: params) } static func logEventCarereceiverSkipSelect(parameters: [String: Any] = [:]) { let params: [String: Any] = [:].merging(parameters) { _, new in new } - Self.logEvent(name: "carereceiver_skip_select", parameters: params) + Self.logEvent(.carereceiverSkipSelect, parameters: params) } } diff --git a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager.swift b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager.swift index 64ec52199..e6dd43543 100644 --- a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager.swift +++ b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager.swift @@ -12,13 +12,79 @@ public class AnalyticsManager { // Nothing to do } - // MARK: Public + // MARK: Internal - public static let shared = AnalyticsManager() + enum Event { + case activityStart + case activityEnd - // MARK: Internal + case appUpdateSkip + case appUpdateOpenAppStore + + case login + case logout + case signup + case skipAuthentication + case accountDelete + + case screenView + + case robotConnect + case robotDisconnect + case robotRename + + case selectContent + + case caregiverSelect + case carereceiverSkipSelect + + // MARK: Internal + + var name: String { + switch self { + case .activityStart: + "activity_start" + case .activityEnd: + "activity_end" + + case .appUpdateSkip: + "app_update_skip" + case .appUpdateOpenAppStore: + "app_update_open_app_store" + + case .login: + AnalyticsEventLogin // ? "login" + case .logout: + "logout" + case .signup: + AnalyticsEventSignUp // ? "sign_up" + case .skipAuthentication: + "skip_authentication" + case .accountDelete: + "account_delete" + + case .screenView: + AnalyticsEventScreenView // ? "screen_view" + + case .robotConnect: + "robot_connect" + case .robotDisconnect: + "robot_disconnect" + case .robotRename: + "robot_rename" + + case .selectContent: + AnalyticsEventSelectContent // ? "select_content" + + case .caregiverSelect: + "caregiver_select" + case .carereceiverSkipSelect: + "carereceiver_skip_select" + } + } + } - static func logEvent(name: String, parameters: [String: Any] = [:]) { - Analytics.logEvent(name, parameters: parameters) + static func logEvent(_ event: Event, parameters: [String: Any] = [:]) { + Analytics.logEvent(event.name, parameters: parameters) } }