From 0918955dc7c1d8805c0d41efa2001b5abd7a9014 Mon Sep 17 00:00:00 2001 From: "mathieu J." Date: Fri, 22 Nov 2024 12:58:53 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=88=20(AccountKit):=20Set=20User=20pro?= =?UTF-8?q?perty=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 8c3181b20..63c6916d6 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 7ca5abdf5..11b8ea389 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(name: "carereceiver_skip_select", parameters: params) } + + static func setUserPropertyCaregiverProfessions(values: [String]) { + let professions = values.joined(separator: ",") + + Self.setUserProperty(value: professions, name: "caregiver_professions") + } }