Skip to content

Commit

Permalink
add default events
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dydx committed May 16, 2024
1 parent 0c62862 commit dad49a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dydx/dydxAnalytics/dydxAnalytics/AnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public extension AnalyticsEventV2 {
case market(market: String)
case trade(market: String)
case addSlTp
case custom(path: String)

/// a path that uniquely identifies the mobile screen
var mobilePath: String {
Expand All @@ -67,6 +68,8 @@ public extension AnalyticsEventV2 {
return "/market/\(market)"
case .addSlTp:
return "/trade/take_profit_stop_loss"
case .custom(let path):
return path
}
}

Expand All @@ -75,6 +78,8 @@ public extension AnalyticsEventV2 {
switch self {
case .addSlTp:
return nil // displayed as a modal on web
case .custom:
return nil
case .market(let market):
// web does not have the /market/ETH-USD path and routes back to `/trade/ETH-USD`
return Page.trade(market: market).correspondingWebPath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import UIToolkits
import PlatformRouting
import FloatingPanel
import Utilities
import dydxAnalytics

public struct HostingViewControllerConfiguration {
public init(ignoreSafeArea: Bool = true, fixedHeight: CGFloat? = nil, gradientTabbar: Bool = false, disableNavigationController: Bool = false) {
Expand All @@ -38,6 +39,11 @@ public struct HostingViewControllerConfiguration {

open class HostingViewController<V: View, VM: PlatformViewModel>: TrackingViewController, UIViewControllerEmbeddingProtocol {

open override var navigationEvent: TrackableEvent? {
guard let path = history?.path else { assertionFailure("no path?"); return nil }
return AnalyticsEventV2.navigatePage(page: .custom(path: path))
}

private var hostingController: UIHostingController<AnyView>?
private let presenterView = ObjectPresenterView()
private var configuration: HostingViewControllerConfiguration = .default
Expand Down

0 comments on commit dad49a5

Please sign in to comment.