diff --git a/dydx/dydxAnalytics/dydxAnalytics/UserProperty.swift b/dydx/dydxAnalytics/dydxAnalytics/UserProperty.swift index 81de7d053..318a4766c 100644 --- a/dydx/dydxAnalytics/dydxAnalytics/UserProperty.swift +++ b/dydx/dydxAnalytics/dydxAnalytics/UserProperty.swift @@ -5,6 +5,8 @@ // Created by Michael Maguire on 8/8/24. // +import Utilities + // these should be added in firebase as user properties custom definitions https://firebase.google.com/docs/analytics/user-properties?platform=ios public enum UserProperty: String { case walletAddress @@ -15,4 +17,11 @@ public enum UserProperty: String { case subaccountNumber case statsigFlags case statsigStableId + case pushNotificationsEnabled +} + +public extension TrackingProtocol { + func setUserProperty(_ value: Any?, forUserProperty userProperty: UserProperty) { + self.setValue(value, forUserProperty: userProperty.rawValue) + } } diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxPushNotificationToggleWorker.swift b/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxPushNotificationToggleWorker.swift index 0cf8ae4dd..52b2c2545 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxPushNotificationToggleWorker.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxPushNotificationToggleWorker.swift @@ -11,16 +11,20 @@ import dydxStateManager import ParticlesKit import RoutingKit import Utilities +import dydxAnalytics public final class dydxPushNotificationToggleWorker: BaseWorker { public override func start() { super.start() - // Sync the app settings value to the system notification settings + // Sync the app settings value to the system notification settings and log user property changeObservation(from: nil, to: NotificationService.shared, keyPath: #keyPath(NotificationHandler.permission)) { _, _, _, _ in + let pushNotificationEnabled = NotificationService.shared?.permission == .authorized SettingsStore.shared?.setValue(pushNotificationEnabled, forKey: dydxSettingsStoreKey.shouldDisplayInAppNotifications.rawValue) + + Tracking.shared?.setUserProperty(pushNotificationEnabled, forUserProperty: .pushNotificationsEnabled) } } } diff --git a/dydx/dydxViews/dydxViews/_v4/Primers/dydxNotificationPrimerView.swift b/dydx/dydxViews/dydxViews/_v4/Primers/dydxNotificationPrimerView.swift index bef08158e..fadb305c0 100644 --- a/dydx/dydxViews/dydxViews/_v4/Primers/dydxNotificationPrimerView.swift +++ b/dydx/dydxViews/dydxViews/_v4/Primers/dydxNotificationPrimerView.swift @@ -40,7 +40,7 @@ public class dydxNotificationPrimerViewModel: PlatformViewModel { } .createView(parentStyle: style) - let cancelText = Text(DataLocalizer.localize(path: "APP.GENERAL.CANCEL", params: nil)) + let cancelText = Text(DataLocalizer.localize(path: "APP.GENERAL.NOT_NOW", params: nil)) PlatformButtonViewModel(content: cancelText.wrappedViewModel, state: .secondary) { [weak self] in self?.cancelAction?() } diff --git a/dydxV4/dydxV4/_Tracking/dydxCompositeTracking.swift b/dydxV4/dydxV4/_Tracking/dydxCompositeTracking.swift index 7d92ed104..828ae44ea 100644 --- a/dydxV4/dydxV4/_Tracking/dydxCompositeTracking.swift +++ b/dydxV4/dydxV4/_Tracking/dydxCompositeTracking.swift @@ -16,12 +16,6 @@ import dydxAnalytics import StatsigInjections import dydxFormatter -private extension TrackingProtocol { - func setUserProperty(_ value: Any?, forUserProperty userProperty: UserProperty) { - self.setValue(value, forUserProperty: userProperty.rawValue) - } -} - public class dydxCompositeTracking: CompositeTracking { private var viewEvents: DictionaryEntity? private var onboardingEvents: DictionaryEntity?