Skip to content

Commit

Permalink
♻️ (Analytics): Use Event enum in logEven(,)
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Nov 22, 2024
1 parent b3f4f94 commit b7d8648
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
}
10 changes: 5 additions & 5 deletions Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand All @@ -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
Expand All @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public extension AnalyticsManager {
params[AnalyticsParameterScreenClass] = screenClass
}

Self.logEvent(name: AnalyticsEventScreenView, parameters: params)
Self.logEvent(.screenView, parameters: params)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
4 changes: 2 additions & 2 deletions Modules/AnalyticsKit/Sources/Manager/AnalyticsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class AnalyticsManager {
}
}

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)
}
}

0 comments on commit b7d8648

Please sign in to comment.