From 5166d3a0f7d5ef39eac9f419cf379ff5f5d82b55 Mon Sep 17 00:00:00 2001 From: "mathieu J." Date: Fri, 22 Nov 2024 11:41:42 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=93=88=20(AccountKit):=20Set=20User?= =?UTF-8?q?=20Property=20user=5Fis=5Flogged=5Fin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Authentication/AuthManagerViewModel.swift | 5 ++++- .../AnalyticsKit/Sources/Manager/AnalyticsManager+Auth.swift | 4 ++++ Modules/AnalyticsKit/Sources/Manager/AnalyticsManager.swift | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Modules/AccountKit/Sources/Authentication/AuthManagerViewModel.swift b/Modules/AccountKit/Sources/Authentication/AuthManagerViewModel.swift index a020c4ddf0..58ba1b097e 100644 --- a/Modules/AccountKit/Sources/Authentication/AuthManagerViewModel.swift +++ b/Modules/AccountKit/Sources/Authentication/AuthManagerViewModel.swift @@ -2,6 +2,7 @@ // Copyright APF France handicap // SPDX-License-Identifier: Apache-2.0 +import AnalyticsKit import Combine import Foundation import LocalizationKit @@ -100,10 +101,12 @@ public class AuthManagerViewModel: ObservableObject { self.showActionRequestAlert = true } self.resetErrorMessage() + AnalyticsManager.setUserPropertyUserIsLoggedIn(value: true) case .loggedOut: self.resetState() + AnalyticsManager.setUserPropertyUserIsLoggedIn(value: false) case .unknown: - break + AnalyticsManager.setUserPropertyUserIsLoggedIn(value: false) } } diff --git a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Auth.swift b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Auth.swift index 1293abe7cf..d09bf8f0e2 100644 --- a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Auth.swift +++ b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Auth.swift @@ -34,4 +34,8 @@ public extension AnalyticsManager { Self.logEvent(.accountDelete, parameters: params) } + + static func setUserPropertyUserIsLoggedIn(value: Bool) { + Self.setUserProperty(value: value.description, name: "user_is_logged_in") + } } diff --git a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager.swift b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager.swift index e6dd435436..6a519f5571 100644 --- a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager.swift +++ b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager.swift @@ -87,4 +87,8 @@ public class AnalyticsManager { static func logEvent(_ event: Event, parameters: [String: Any] = [:]) { Analytics.logEvent(event.name, parameters: parameters) } + + static func setUserProperty(value: String, name: String) { + Analytics.setUserProperty(value, forName: name) + } } From 6615bd42a3cebde5b5233b378724608746fa6b0f Mon Sep 17 00:00:00 2001 From: "mathieu J." Date: Fri, 22 Nov 2024 12:41:32 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=88=20(RobotKit):=20Set=20User=20p?= =?UTF-8?q?roperty=20robot=5Fis=5Fconnected?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AnalyticsKit/Sources/Manager/AnalyticsManager+Robot.swift | 4 ++++ Modules/RobotKit/Sources/Robot+BLE.swift | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Robot.swift b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Robot.swift index 476b1fb471..6c4deb6257 100644 --- a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Robot.swift +++ b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Robot.swift @@ -64,4 +64,8 @@ public extension AnalyticsManager { Self.logEvent(.robotRename, parameters: params) } + + static func setUserPropertyUserRobotIsConnected(value: Bool) { + Self.setUserProperty(value: value.description, name: "robot_is_connected") + } } diff --git a/Modules/RobotKit/Sources/Robot+BLE.swift b/Modules/RobotKit/Sources/Robot+BLE.swift index 38720ada59..5ceb7c9e70 100644 --- a/Modules/RobotKit/Sources/Robot+BLE.swift +++ b/Modules/RobotKit/Sources/Robot+BLE.swift @@ -33,6 +33,7 @@ extension Robot { isCharging: self.isCharging.value, batteryLevel: self.battery.value ) + AnalyticsManager.setUserPropertyUserRobotIsConnected(value: false) } .store(in: &cancellables) } @@ -56,6 +57,7 @@ extension Robot { isCharging: self.isCharging.value, batteryLevel: self.battery.value ) + AnalyticsManager.setUserPropertyUserRobotIsConnected(value: true) } .store(in: &self.cancellables) } From c59eb132c6ee75699609667152510e1d2dd369ec Mon Sep 17 00:00:00 2001 From: "mathieu J." Date: Fri, 22 Nov 2024 12:58:53 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=88=20(AccountKit):=20Set=20User?= =?UTF-8?q?=20property=20caregiver=5Fprofessions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Managers/Caregivers/CaregiverManager.swift | 6 ++++-- .../Sources/Manager/AnalyticsManager+Users.swift | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Modules/AccountKit/Sources/Managers/Caregivers/CaregiverManager.swift b/Modules/AccountKit/Sources/Managers/Caregivers/CaregiverManager.swift index 8c3181b202..63c6916d64 100644 --- a/Modules/AccountKit/Sources/Managers/Caregivers/CaregiverManager.swift +++ b/Modules/AccountKit/Sources/Managers/Caregivers/CaregiverManager.swift @@ -95,6 +95,7 @@ public class CaregiverManager { public func setCurrentCaregiver(to caregiver: Caregiver) { self.currentCaregiver.send(caregiver) AnalyticsManager.setDefaultEventParameterCaregiverUid(caregiver.id) + AnalyticsManager.setUserPropertyCaregiverProfessions(values: caregiver.professions) } public func setCurrentCaregiver(byID id: String) { @@ -103,20 +104,21 @@ public class CaregiverManager { } self.currentCaregiver.send(currentCaregiver) AnalyticsManager.setDefaultEventParameterCaregiverUid(currentCaregiver.id) + AnalyticsManager.setUserPropertyCaregiverProfessions(values: currentCaregiver.professions) } public func resetCurrentCaregiver() { self.currentCaregiver.send(nil) AnalyticsManager.setDefaultEventParameterCaregiverUid(nil) + AnalyticsManager.setUserPropertyCaregiverProfessions(values: []) } public func resetData() { - self.currentCaregiver.send(nil) + self.resetCurrentCaregiver() self.caregiverList.send([]) self.dbOps.clearAllListeners() self.cancellables.forEach { $0.cancel() } self.cancellables.removeAll() - AnalyticsManager.setDefaultEventParameterCaregiverUid(nil) } // MARK: Private diff --git a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Users.swift b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Users.swift index 7c1701a42e..45adaf357d 100644 --- a/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Users.swift +++ b/Modules/AnalyticsKit/Sources/Manager/AnalyticsManager+Users.swift @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 import FirebaseAnalytics +import Foundation public extension AnalyticsManager { static func logEventCaregiverSelect(id: String?, parameters: [String: Any] = [:]) { @@ -18,4 +19,10 @@ public extension AnalyticsManager { Self.logEvent(.carereceiverSkipSelect, parameters: params) } + + static func setUserPropertyCaregiverProfessions(values: [String]) { + let professions = values.joined(separator: ",") + + Self.setUserProperty(value: professions, name: "caregiver_professions") + } }