Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRCL-3698 Add user property tracking for push notification #259

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading