Skip to content

Commit

Permalink
move files into dydxAnalytics
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dydx committed May 16, 2024
1 parent 1a7966c commit 0c62862
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 40 deletions.
11 changes: 10 additions & 1 deletion dydx/dydx.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "1c0055be4aba3ed4d97a2f62f05486877839310f65e2cbdd18b067bef06a04a3",
"originHash" : "975d00e29efb8d2ca017c5e61df90418ac01f7d7143e85a3f9ddb4eb982154e4",
"pins" : [
{
"identity" : "bigint",
Expand Down Expand Up @@ -46,6 +46,15 @@
"revision" : "48134b5460435cc9d048223ad7560ee2e40f3d4a"
}
},
{
"identity" : "percy-xcui-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/percy/percy-xcui-swift",
"state" : {
"revision" : "a2e9a86dfc3f5b69ef53cbda28a0ea71098c9f77",
"version" : "1.0.0"
}
},
{
"identity" : "qrcode",
"kind" : "remoteSourceControl",
Expand Down
28 changes: 28 additions & 0 deletions dydx/dydxAnalytics/dydxAnalytics.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
2742BEB82BF6860100E13C09 /* dydxAnalytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2742BEAD2BF6860100E13C09 /* dydxAnalytics.framework */; };
2742BEBD2BF6860100E13C09 /* dydxAnalyticsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2742BEBC2BF6860100E13C09 /* dydxAnalyticsTests.swift */; };
2742BEBE2BF6860100E13C09 /* dydxAnalytics.h in Headers */ = {isa = PBXBuildFile; fileRef = 2742BEB02BF6860100E13C09 /* dydxAnalytics.h */; settings = {ATTRIBUTES = (Public, ); }; };
2742C0312BF6887100E13C09 /* Utilities.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2742C0302BF6887100E13C09 /* Utilities.framework */; platformFilter = ios; };
2742C0352BF6888500E13C09 /* PlatformParticles.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2742C0342BF6888500E13C09 /* PlatformParticles.framework */; };
2742C0382BF6888A00E13C09 /* dydxStateManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2742C0372BF6888A00E13C09 /* dydxStateManager.framework */; platformFilter = ios; };
2742C04A2BF688BD00E13C09 /* AnalyticsEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2742C03C2BF688B400E13C09 /* AnalyticsEvent.swift */; };
2742C04B2BF688BD00E13C09 /* OnboardingAnalytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2742C03A2BF688B400E13C09 /* OnboardingAnalytics.swift */; };
2742C04C2BF688BD00E13C09 /* TransferAnalytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2742C03B2BF688B400E13C09 /* TransferAnalytics.swift */; };
B0A26DA7EA1E90F936ECE27B /* Pods_iOS_dydxAnalytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2FCEC9737902553D7EB58EF0 /* Pods_iOS_dydxAnalytics.framework */; };
/* End PBXBuildFile section */

Expand All @@ -31,6 +37,12 @@
2742BEB12BF6860100E13C09 /* dydxAnalytics.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = dydxAnalytics.docc; sourceTree = "<group>"; };
2742BEB72BF6860100E13C09 /* dydxAnalyticsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = dydxAnalyticsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
2742BEBC2BF6860100E13C09 /* dydxAnalyticsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxAnalyticsTests.swift; sourceTree = "<group>"; };
2742C0302BF6887100E13C09 /* Utilities.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Utilities.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2742C0342BF6888500E13C09 /* PlatformParticles.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PlatformParticles.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2742C0372BF6888A00E13C09 /* dydxStateManager.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = dydxStateManager.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2742C03A2BF688B400E13C09 /* OnboardingAnalytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingAnalytics.swift; sourceTree = "<group>"; };
2742C03B2BF688B400E13C09 /* TransferAnalytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransferAnalytics.swift; sourceTree = "<group>"; };
2742C03C2BF688B400E13C09 /* AnalyticsEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsEvent.swift; sourceTree = "<group>"; };
2FCEC9737902553D7EB58EF0 /* Pods_iOS_dydxAnalytics.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iOS_dydxAnalytics.framework; sourceTree = BUILT_PRODUCTS_DIR; };
7D0A5DAA1E87EA50A32BE597 /* Pods-iOS-dydxAnalytics.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iOS-dydxAnalytics.debug.xcconfig"; path = "Target Support Files/Pods-iOS-dydxAnalytics/Pods-iOS-dydxAnalytics.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand All @@ -41,6 +53,9 @@
buildActionMask = 2147483647;
files = (
B0A26DA7EA1E90F936ECE27B /* Pods_iOS_dydxAnalytics.framework in Frameworks */,
2742C0352BF6888500E13C09 /* PlatformParticles.framework in Frameworks */,
2742C0312BF6887100E13C09 /* Utilities.framework in Frameworks */,
2742C0382BF6888A00E13C09 /* dydxStateManager.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -58,6 +73,9 @@
1D21DCC99EA6EE27EE38A5E2 /* Frameworks */ = {
isa = PBXGroup;
children = (
2742C0372BF6888A00E13C09 /* dydxStateManager.framework */,
2742C0342BF6888500E13C09 /* PlatformParticles.framework */,
2742C0302BF6887100E13C09 /* Utilities.framework */,
2FCEC9737902553D7EB58EF0 /* Pods_iOS_dydxAnalytics.framework */,
);
name = Frameworks;
Expand Down Expand Up @@ -96,6 +114,9 @@
2742BEAF2BF6860100E13C09 /* dydxAnalytics */ = {
isa = PBXGroup;
children = (
2742C03A2BF688B400E13C09 /* OnboardingAnalytics.swift */,
2742C03B2BF688B400E13C09 /* TransferAnalytics.swift */,
2742C03C2BF688B400E13C09 /* AnalyticsEvent.swift */,
2742BEB02BF6860100E13C09 /* dydxAnalytics.h */,
2742BEB12BF6860100E13C09 /* dydxAnalytics.docc */,
);
Expand Down Expand Up @@ -245,7 +266,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2742C04B2BF688BD00E13C09 /* OnboardingAnalytics.swift in Sources */,
2742BEB22BF6860100E13C09 /* dydxAnalytics.docc in Sources */,
2742C04A2BF688BD00E13C09 /* AnalyticsEvent.swift in Sources */,
2742C04C2BF688BD00E13C09 /* TransferAnalytics.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -408,6 +432,7 @@
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -441,6 +466,7 @@
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -462,6 +488,7 @@
2742BEC52BF6860100E13C09 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 75C6UARB5H;
Expand All @@ -478,6 +505,7 @@
2742BEC62BF6860100E13C09 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 75C6UARB5H;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Utilities
//
// Events defined in the v4-web repo. Ideally, we should keep this in-sync with v4-web
//
enum AnalyticsEvent: String {
public enum AnalyticsEvent: String {
// App
case appStart = "AppStart"
case networkStatus = "NetworkStatus"
Expand Down Expand Up @@ -48,7 +48,7 @@ enum AnalyticsEvent: String {
case notificationAction = "NotificationAction"
}

extension AnalyticsEventV2 {
public extension AnalyticsEventV2 {
// probably move this to like a dydxRouter, next to where `routing_swift.json` currently lives
enum Page {
case markets
Expand Down Expand Up @@ -85,7 +85,7 @@ extension AnalyticsEventV2 {
}
}

extension AnalyticsEventV2 {
public extension AnalyticsEventV2 {
enum OnboardingStep: String {
case chooseWallet = "ChooseWallet"
case keyDerivation = "KeyDerivation"
Expand All @@ -94,22 +94,22 @@ extension AnalyticsEventV2 {
}
}

extension AnalyticsEventV2 {
public extension AnalyticsEventV2 {
enum OnboardingState: String {
case disconnected = "Disconnected"
case walletConnected = "WalletConnected"
case accountConnected = "AccountConnected"
}
}

enum AnalyticsEventV2: TrackableEvent {
public enum AnalyticsEventV2: TrackableEvent {
case appStart
case navigatePage(page: Page)
case navigateDialog(page: Page)
case navigateDialogClose(page: Page)
case onboardingStepChanged(step: OnboardingStep, state: OnboardingState)

var name: String {
public var name: String {
switch self {
case .navigatePage:
return "NavigatePage"
Expand All @@ -124,7 +124,7 @@ enum AnalyticsEventV2: TrackableEvent {
}
}

var customParameters: [String: Any] {
public var customParameters: [String: Any] {
switch self {
case .appStart:
return [:]
Expand All @@ -142,7 +142,7 @@ enum AnalyticsEventV2: TrackableEvent {
}
}

extension TrackingProtocol {
public extension TrackingProtocol {
/// convenience wrapper of log(trackableEvent:)
func log(event: AnalyticsEventV2) {
Tracking.shared?.log(trackableEvent: event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
// Created by Rui Huang on 26/03/2024.
//

import Foundation
import Utilities
import dydxStateManager
import Combine
import Foundation
import Utilities
import dydxStateManager
import Combine

public final class OnboardingAnalytics {

public init() {}

final class OnboardingAnalytics {
public var subscriptions = Set<AnyCancellable>()

func log(step: AnalyticsEventV2.OnboardingStep) {
AbacusStateManager.shared.state.currentWallet
public func log(step: AnalyticsEventV2.OnboardingStep) {
AbacusStateManager.shared.state.currentWallet
.prefix(1)
.sink { wallet in
let state: AnalyticsEventV2.OnboardingState
Expand All @@ -29,4 +32,4 @@
}
.store(in: &subscriptions)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import Foundation
import Abacus
import Utilities

final class TransferAnalytics {
func logDeposit(transferInput: TransferInput) {
public final class TransferAnalytics {

public init() {}

public func logDeposit(transferInput: TransferInput) {
log(event: .transferDeposit, transferInput: transferInput)
}

func logWithdrawal(transferInput: TransferInput) {
public func logWithdrawal(transferInput: TransferInput) {
log(event: .transferWithdraw, transferInput: transferInput)
}

Expand Down
Loading

0 comments on commit 0c62862

Please sign in to comment.