Skip to content

Commit

Permalink
TRCL-3698 Add user property tracking for push notification (#259)
Browse files Browse the repository at this point in the history
* Add user property tracking

* Update to "Not Now"
  • Loading branch information
ruixhuang authored Sep 20, 2024
1 parent 56a8913 commit ec99284
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
9 changes: 9 additions & 0 deletions dydx/dydxAnalytics/dydxAnalytics/UserProperty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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?()
}
Expand Down
6 changes: 0 additions & 6 deletions dydxV4/dydxV4/_Tracking/dydxCompositeTracking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit ec99284

Please sign in to comment.