Skip to content

Commit

Permalink
📈 (AccountKit): Set User property caregiver_professions
Browse files Browse the repository at this point in the history
  • Loading branch information
macteuts committed Nov 22, 2024
1 parent de700a4 commit 0918955
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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] = [:]) {
Expand All @@ -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")
}
}

0 comments on commit 0918955

Please sign in to comment.