-
Notifications
You must be signed in to change notification settings - Fork 2
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
analyticsv2 PoC #169
Merged
Merged
analyticsv2 PoC #169
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3e1b199
analyticsv2 example
mike-dydx 1a7966c
added dydxAnalytics
mike-dydx 0c62862
move files into dydxAnalytics
mike-dydx dad49a5
add default events
mike-dydx 48fecd2
remove duplicative tracking
mike-dydx c89ee2d
example replacement of app start event
mike-dydx afd52e5
add firebase to dydxAnalytics
mike-dydx d722c9b
interim commit
mike-dydx 1541e31
remove view(...) functions
mike-dydx bb93b08
sorting by name
mike-dydx 33cdd69
clean up
mike-dydx 6bb5c99
address comment, make events unique structs
mike-dydx fd4206b
clean up
mike-dydx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,76 +67,85 @@ public extension AnalyticsEventV2 { | |
} | ||
} | ||
|
||
public enum AnalyticsEventV2: TrackableEvent, CustomDebugStringConvertible { | ||
// TODO: add and replace all events | ||
case appStart | ||
case navigatePage(screen: ScreenIdentifiable) | ||
case deepLinkHandled(url: String, succeeded: Bool) | ||
case notificationPermissionsChanged(isAuthorized: Bool) | ||
case onboardingStepChanged(step: OnboardingStep, state: OnboardingState) | ||
|
||
public var name: String { | ||
switch self { | ||
case .navigatePage: | ||
return "NavigatePage" | ||
case .deepLinkHandled: | ||
return "DeeplinkHandled" | ||
case .appStart: | ||
return "AppStart" | ||
case .onboardingStepChanged: | ||
return "OnboardingStepChanged" | ||
case .notificationPermissionsChanged: | ||
return "NotificationPermissionsChanged" | ||
public enum AnalyticsEventV2 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ruixhuang note I am nesting them in |
||
public struct AppStart: TrackableEvent { | ||
public var name: String { "AppStart" } | ||
public var customParameters: [String: Any] { [:] } | ||
|
||
public init() {} | ||
} | ||
|
||
public struct NavigatePage: TrackableEvent { | ||
public let screen: ScreenIdentifiable | ||
|
||
public var name: String { "NavigatePage" } | ||
public var customParameters: [String: Any] {[ | ||
"mobile_path": screen.mobilePath, | ||
"path": screen.correspondingWebPath as Any, | ||
// for firebase auto-generated dashboard(s) | ||
"\(AnalyticsParameterScreenClass)": screen.screenClass, | ||
"\(AnalyticsParameterScreenName)": screen.mobilePath | ||
]} | ||
|
||
public init(screen: ScreenIdentifiable) { | ||
self.screen = screen | ||
} | ||
} | ||
|
||
public var customParameters: [String: Any] { | ||
switch self { | ||
case .appStart: | ||
return [:] | ||
case .navigatePage(let screen): | ||
return [ | ||
"mobile_path": screen.mobilePath, | ||
"path": screen.correspondingWebPath as Any, | ||
// for firebase auto-generated dashboard(s) | ||
"\(AnalyticsParameterScreenClass)": screen.screenClass, | ||
"\(AnalyticsParameterScreenName)": screen.mobilePath | ||
] | ||
case .deepLinkHandled(let url, let succeeded): | ||
return [ | ||
"successfully_handled": succeeded, | ||
"url": url | ||
] | ||
case .onboardingStepChanged(let step, let state): | ||
return [ | ||
"step": step.rawValue, | ||
"state": state.rawValue | ||
] | ||
case .notificationPermissionsChanged(let isAuthorized): | ||
return [ | ||
"is_authorized": isAuthorized | ||
] | ||
public struct DeepLinkHandled: TrackableEvent { | ||
let url: String | ||
let succeeded: Bool | ||
|
||
public var name: String { "DeeplinkHandled" } | ||
public var customParameters: [String: Any] {[ | ||
"url": url, | ||
"succeeded": succeeded | ||
]} | ||
|
||
public init(url: String, succeeded: Bool) { | ||
self.url = url | ||
self.succeeded = succeeded | ||
} | ||
} | ||
|
||
public var debugDescription: String { | ||
let sorted = customParameters.sorted { $0.key < $1.key } | ||
return "dydxAnalytics event \(name) with data: \(sorted)" | ||
public struct NotificationPermissionsChanged: TrackableEvent { | ||
let isAuthorized: Bool | ||
|
||
public var name: String { "NotificationPermissionsChanged" } | ||
public var customParameters: [String: Any] {[ | ||
"is_authorized": isAuthorized | ||
]} | ||
|
||
public init(isAuthorized: Bool) { | ||
self.isAuthorized = isAuthorized | ||
} | ||
} | ||
|
||
public struct OnboardingStepChanged: TrackableEvent { | ||
let step: OnboardingStep | ||
let state: OnboardingState | ||
|
||
public var name: String { "OnboardingStepChanged" } | ||
public var customParameters: [String: Any] {[ | ||
"step": step.rawValue, | ||
"state": state.rawValue | ||
]} | ||
|
||
public init(step: OnboardingStep, state: OnboardingState) { | ||
self.step = step | ||
self.state = state | ||
} | ||
} | ||
} | ||
|
||
public extension TrackingProtocol { | ||
func log(event: AnalyticsEventV2) { | ||
log(event: event.name, data: event.customParameters) | ||
switch event { | ||
case .navigatePage: | ||
// for firebase auto-generated dashboard(s) | ||
func log(event: TrackableEvent) { | ||
if let event = event as? AnalyticsEventV2.NavigatePage { | ||
log(event: AnalyticsEventScreenView, data: event.customParameters) | ||
default: | ||
break | ||
} | ||
log(event: event.name, data: event.customParameters) | ||
#if DEBUG | ||
Console.shared.log(event.debugDescription) | ||
Console.shared.log(event.description) | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted this in another commit 😓