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

📈 (Analytics): Improve logEvent App/OS update alert #1612

Merged
merged 1 commit into from
Nov 28, 2024
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
8 changes: 4 additions & 4 deletions Apps/LekaApp/Sources/Views/MainView/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@
title: Text(l10n.MainView.AppUpdateAlert.title),
message: Text(l10n.MainView.AppUpdateAlert.message),
primaryButton: .default(Text(l10n.MainView.AppUpdateAlert.action), action: {
AnalyticsManager.logEventAppUpdateOpenAppStore()
AnalyticsManager.logEventAppUpdateAlertResponse(.openAppStore)
if let url = URL(string: "https://apps.apple.com/app/leka/id6446940339") {
UIApplication.shared.open(url)
}
}),
secondaryButton: .cancel(Text(l10n.MainView.AppUpdateAlert.reminder)) {
AnalyticsManager.logEventAppUpdateRemindLater()
AnalyticsManager.logEventAppUpdateAlertResponse(.remindLater)
}
)
}
Expand All @@ -142,13 +142,13 @@
title: Text(l10n.MainView.OSUpdateAlert.title),
message: Text(l10n.MainView.OSUpdateAlert.message),
primaryButton: .default(Text(l10n.MainView.OSUpdateAlert.action), action: {
AnalyticsManager.logEventOSUpdateOpenSettings()
AnalyticsManager.logEventOSUpdateAlertResponse(.openSettings)
if let url = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(url)
}
}),
secondaryButton: .cancel(Text(l10n.MainView.OSUpdateAlert.reminder)) {
AnalyticsManager.logEventOSUpdateRemindLater()
AnalyticsManager.logEventOSUpdateAlertResponse(.remindLater)
}
)
}
Expand Down Expand Up @@ -445,4 +445,4 @@

#Preview {
MainView()
}

Check warning on line 448 in Apps/LekaApp/Sources/Views/MainView/MainView.swift

View workflow job for this annotation

GitHub Actions / swiftlint

File should contain 400 lines or less: currently contains 448 (file_length)
52 changes: 26 additions & 26 deletions Modules/AnalyticsKit/Sources/Analytics/AnalyticsManager+App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,43 @@
import FirebaseAnalytics

public extension AnalyticsManager {
// TODO: (@ladislas) add real versions
static func logEventAppUpdateRemindLater(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 }

logEvent(.appUpdateRemindLater, parameters: params)
enum AppUpdateAlertResponseAction: String {
case remindLater = "remind_later"
case openAppStore = "open_app_store"
}

// TODO: (@ladislas) add real versions
static func logEventAppUpdateOpenAppStore(currentVersion: String = "(lk_not_set)", newVersion: String = "(lk_not_set)", parameters: [String: Any] = [:]) {
static func logEventAppUpdateAlertResponse(
_ action: AppUpdateAlertResponseAction,
currentVersion _: String = "", // TODO: (@ladislas) add current/new versions

Check warning on line 15 in Modules/AnalyticsKit/Sources/Analytics/AnalyticsManager+App.swift

View workflow job for this annotation

GitHub Actions / swiftlint

TODOs should be resolved ((@ladislas) add current/new ve...) (todo)
newVersion _: String = "",
parameters: [String: Any] = [:]
) {
let params: [String: Any] = [
"current_version": currentVersion,
"new_version": newVersion,
"lk_app_version_current": NSNull(),
"lk_app_version_update": NSNull(),
"lk_response_action": action.rawValue,
].merging(parameters) { _, new in new }

logEvent(.appUpdateOpenAppStore, parameters: params)
logEvent(.appUpdateAlertResponse, parameters: params)
}

// TODO: (@ladislas) add real versions
static func logEventOSUpdateRemindLater(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 }

logEvent(.osUpdateRemindLater, parameters: params)
enum OSUpdateAlertResponseAction: String {
case remindLater = "remind_later"
case openSettings = "open_settings"
}

// TODO: (@ladislas) add real versions
static func logEventOSUpdateOpenSettings(currentVersion: String = "(lk_not_set)", newVersion: String = "(lk_not_set)", parameters: [String: Any] = [:]) {
static func logEventOSUpdateAlertResponse(
_ action: OSUpdateAlertResponseAction,
currentVersion _: String = "", // TODO: (@ladislas) add current/new versions

Check warning on line 35 in Modules/AnalyticsKit/Sources/Analytics/AnalyticsManager+App.swift

View workflow job for this annotation

GitHub Actions / swiftlint

TODOs should be resolved ((@ladislas) add current/new ve...) (todo)
newVersion _: String = "",
parameters: [String: Any] = [:]
) {
let params: [String: Any] = [
"current_version": currentVersion,
"new_version": newVersion,
"lk_os_version_current": NSNull(),
"lk_os_version_update": NSNull(),
"lk_response_action": action.rawValue,
].merging(parameters) { _, new in new }

logEvent(.osUpdateOpenSettings, parameters: params)
logEvent(.osUpdateAlertResponse, parameters: params)
}
}
20 changes: 6 additions & 14 deletions Modules/AnalyticsKit/Sources/Analytics/AnalyticsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ public class AnalyticsManager {
case activityStart
case activityEnd

case appUpdateRemindLater
case appUpdateOpenAppStore

case osUpdateRemindLater
case osUpdateOpenSettings
case appUpdateAlertResponse
case osUpdateAlertResponse

case login
case logout
Expand Down Expand Up @@ -55,15 +52,10 @@ public class AnalyticsManager {
case .activityEnd:
"activity_end"

case .appUpdateRemindLater:
"app_update_remind_later"
case .appUpdateOpenAppStore:
"app_update_open_app_store"

case .osUpdateRemindLater:
"os_update_remind_later"
case .osUpdateOpenSettings:
"os_update_open_settings"
case .appUpdateAlertResponse:
"app_update_alert_response"
case .osUpdateAlertResponse:
"os_update_alert_response"

case .login:
AnalyticsEventLogin // ? "login"
Expand Down
Loading