Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ladislas/bugfix/linter swift format analytics redundant self #1592

Merged
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
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ identifier_name:
- rx
- tag
- tx
- uid
- url
- URL

Expand Down
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(.activityStart, parameters: params)
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(.activityEnd, parameters: params)
logEvent(.activityEnd, parameters: params)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
import FirebaseAnalytics

public extension AnalyticsManager {
// TODO: (@ladislas) add real versions

Check warning on line 8 in Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+App.swift

View workflow job for this annotation

GitHub Actions / swiftlint

TODOs should be resolved ((@ladislas) add real versions) (todo)
static func logEventAppUpdateSkip(currentVersion: String = "(lk_not_set)", newVersion: String = "(lk_not_set)", parameters: [String: Any] = [:]) {
let params: [String: Any] = [
"current_version": currentVersion,
"new_version": newVersion,
].merging(parameters) { _, new in new }

Self.logEvent(.appUpdateSkip, parameters: params)
logEvent(.appUpdateSkip, parameters: params)
}

// TODO: (@ladislas) add real versions

Check warning on line 18 in Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+App.swift

View workflow job for this annotation

GitHub Actions / swiftlint

TODOs should be resolved ((@ladislas) add real versions) (todo)
static func logEventAppUpdateOpenAppStore(currentVersion: String = "(lk_not_set)", newVersion: String = "(lk_not_set)", parameters: [String: Any] = [:]) {
let params: [String: Any] = [
"current_version": currentVersion,
"new_version": newVersion,
].merging(parameters) { _, new in new }

Self.logEvent(.appUpdateOpenAppStore, parameters: params)
logEvent(.appUpdateOpenAppStore, parameters: params)
}
}
12 changes: 6 additions & 6 deletions Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,34 @@ public extension AnalyticsManager {
static func logEventLogin(parameters: [String: Any] = [:]) {
let params: [String: Any] = [:].merging(parameters) { _, new in new }

Self.logEvent(.login, parameters: params)
logEvent(.login, parameters: params)
}

static func logEventLogout(parameters: [String: Any] = [:]) {
let params: [String: Any] = [:].merging(parameters) { _, new in new }

Self.logEvent(.logout, parameters: params)
logEvent(.logout, parameters: params)
}

static func logEventSignUp(parameters: [String: Any] = [:]) {
let params: [String: Any] = [:].merging(parameters) { _, new in new }

Self.logEvent(.signup, parameters: params)
logEvent(.signup, parameters: params)
}

static func logEventSkipAuthentication(parameters: [String: Any] = [:]) {
let params: [String: Any] = [:].merging(parameters) { _, new in new }

Self.logEvent(.skipAuthentication, parameters: params)
logEvent(.skipAuthentication, parameters: params)
}

static func logEventAccountDelete(parameters: [String: Any] = [:]) {
let params: [String: Any] = [:].merging(parameters) { _, new in new }

Self.logEvent(.accountDelete, parameters: params)
logEvent(.accountDelete, parameters: params)
}

static func setUserPropertyUserIsLoggedIn(value: Bool) {
Self.setUserProperty(value: value.description, name: "user_is_logged_in")
setUserProperty(value: value.description, name: "user_is_logged_in")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,15 @@
import FirebaseAnalytics

public extension AnalyticsManager {
static func setDefaultEventParameterRootOwnerUid(_ id: String?) {
self.setDefaultEventParameters(["lk_default_root_owner_uid": id ?? "(lk_not_set)"])
static func setDefaultEventParameterRootOwnerUid(_ uid: String?) {
setDefaultEventParameter(for: .rootOwnerUid(uid))
}

static func setDefaultEventParameterCaregiverUid(_ id: String?) {
self.setDefaultEventParameters(["lk_default_caregiver_uid": id ?? "(lk_not_set)"])
static func setDefaultEventParameterCaregiverUid(_ uid: String?) {
setDefaultEventParameter(for: .caregiverUid(uid))
}

static func clearDefaultEventParameters() {
self.setDefaultEventParameters(nil)
}

// MARK: Private

private static func setDefaultEventParameters(_ parameters: [String: Any]?) {
Analytics.setDefaultEventParameters(parameters)
Analytics.setDefaultEventParameters(nil)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public extension AnalyticsManager {
"lk_battery_level": batteryLevel,
].merging(parameters) { _, new in new }

Self.logEvent(.robotConnect, parameters: params)
logEvent(.robotConnect, parameters: params)
}

static func logEventRobotDisconnect(
Expand All @@ -40,7 +40,7 @@ public extension AnalyticsManager {
"lk_battery_level": batteryLevel,
].merging(parameters) { _, new in new }

Self.logEvent(.robotDisconnect, parameters: params)
logEvent(.robotDisconnect, parameters: params)
}

// swiftlint:disable:next function_parameter_count
Expand All @@ -62,10 +62,10 @@ public extension AnalyticsManager {
"lk_battery_level": batteryLevel,
].merging(parameters) { _, new in new }

Self.logEvent(.robotRename, parameters: params)
logEvent(.robotRename, parameters: params)
}

static func setUserPropertyUserRobotIsConnected(value: Bool) {
Self.setUserProperty(value: value.description, name: "robot_is_connected")
setUserProperty(value: value.description, name: "robot_is_connected")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public extension AnalyticsManager {
params[AnalyticsParameterScreenClass] = screenClass
}

Self.logEvent(.screenView, parameters: params)
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(.selectContent, parameters: params)
logEvent(.selectContent, parameters: params)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ public extension AnalyticsManager {
"lk_caregiver_id": id ?? "(lk_not_set)",
].merging(parameters) { _, new in new }

Self.logEvent(.caregiverSelect, parameters: params)
logEvent(.caregiverSelect, parameters: params)
}

static func logEventCarereceiverSkipSelect(parameters: [String: Any] = [:]) {
let params: [String: Any] = [:].merging(parameters) { _, new in new }

Self.logEvent(.carereceiverSkipSelect, parameters: params)
logEvent(.carereceiverSkipSelect, parameters: params)
}

static func setUserPropertyCaregiverProfessions(values: [String]) {
let professions = values.joined(separator: ",")

Self.setUserProperty(value: professions, name: "caregiver_professions")
setUserProperty(value: professions, name: "caregiver_professions")
}
}
14 changes: 14 additions & 0 deletions Modules/AnalyticsKit/Sources/Manager/AnalyticsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public class AnalyticsManager {

// MARK: Internal

enum DefaultEventParamters {
case rootOwnerUid(String?)
case caregiverUid(String?)
}

enum Event {
case activityStart
case activityEnd
Expand Down Expand Up @@ -91,4 +96,13 @@ public class AnalyticsManager {
static func setUserProperty(value: String, name: String) {
Analytics.setUserProperty(value, forName: name)
}

static func setDefaultEventParameter(for parameter: DefaultEventParamters) {
switch parameter {
case let .rootOwnerUid(uid):
Analytics.setDefaultEventParameters(["root_owner_uid": uid ?? "(lk_not_set)"])
case let .caregiverUid(uid):
Analytics.setDefaultEventParameters(["caregiver_uid": uid ?? "(lk_not_set)"])
}
}
}
Loading