-
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
analyticsv2 PoC #169
Conversation
bae30e4
to
dad49a5
Compare
6814a5a
to
d722c9b
Compare
override open func view(_ path: String?, action: String?, data: [String: Any]?, from: String?, time: Date?, revenue: NSNumber?, contextViewController: UIViewController?) { | ||
// Only track the ones required by growth | ||
} |
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.
all view
functions were removed in favor of navigatePage
analytics v2 event
140e99f
to
48a7ca2
Compare
@@ -11,31 +11,25 @@ import PlatformRouting | |||
import UIToolkits | |||
import Utilities | |||
|
|||
open class TrackingViewController: NavigableViewController, TrackingViewProtocol { | |||
public var trackingData: TrackingData? |
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.
tracking data moved into ScreenIdentifiable
(effectively)
if success, request.path?.hasPrefix("/action") ?? false { | ||
Tracking.shared?.view(request.path, data: request.params, from: nil, time: nil) | ||
} |
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.
actions should not be view events, should be dedicated action events. Did not make scope for this PR
override open func previousTracking() -> TrackingData? { | ||
if let vc = UIViewController.topmost() as? TrackingViewProtocol { | ||
return vc.trackingData | ||
} else { | ||
return nil | ||
} | ||
} |
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.
TrackingData was removed in this PR, functionality was replaced
if let viewController = data as? TrackingViewProtocol { | ||
viewController.logView(path: transformed.path, data: nil, from: previousTracking?.path, time: previousTracking?.startTime) | ||
} | ||
completion?(nil, true) | ||
} else { | ||
self?.route(dependencies: map, request: transformed, completion: { [weak self] _, successful in | ||
if successful { | ||
self?.navigate(to: map, request: transformed, presentation: presentation ?? transformed.presentation, animated: animated, completion: { /* [weak self] */ data, successful in | ||
if successful, let viewController = data as? TrackingViewProtocol { | ||
viewController.logView(path: transformed.path, data: nil, from: previousTracking?.path, time: previousTracking?.startTime) | ||
} |
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.
we were logging a view event both here and in the viewDidAppear
lifecycle method which resulted in double logging. Removed logging from within Routing Kit in favor of TrackingViewController
lmk if u disagree with this decision or if i am missing something
a713e01
to
774547b
Compare
case appStart | ||
case navigatePage(screen: ScreenIdentifiable) | ||
case deepLinkHandled(url: String, succeeded: Bool) | ||
case notificationPermissionsChanged(isAuthorized: Bool) | ||
case onboardingStepChanged(step: OnboardingStep, state: OnboardingState) |
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.
note these 5 events are just a proof of concept for how this enum would work for all events. see the TODO on ln 71
@@ -0,0 +1,35 @@ | |||
// | |||
// OnboardingAnalytics.swift |
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.
this file was just moved from dydxPresenters to here
@@ -9,12 +9,15 @@ import Foundation | |||
import Abacus | |||
import Utilities | |||
|
|||
final class TransferAnalytics { | |||
func logDeposit(transferInput: TransferInput) { | |||
public final class TransferAnalytics { |
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.
this file was also just moved from dydxPresenters to here
da1a058
to
b04643f
Compare
if let transformed = transform(events: onboardingEvents, path: path), let event = parser.asString(transformed["event"]) { | ||
var info = parser.asDictionary(transformed["info"]) ?? data ?? [String: Any]() | ||
if event == "OnboardingStepChanged" { | ||
if let time = time, let previous = transform(events: onboardingEvents, path: from), parser.asString(transformed["event"]) == "OnboardingStepChanged" { | ||
let seconds = Int(Date().timeIntervalSince(time)) | ||
info["secondsOnPreviousStep"] = NSNumber(value: seconds) | ||
info["previousStep"] = (previous["info"] as? [String: Any])?["currentStep"] | ||
} | ||
} | ||
log(event: event, data: info, revenue: revenue) | ||
} |
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.
this functionality was not doing anything, the custom data is nowhere to be found in bigquery. OnboardingStepChanged
event is still logged in other files though via the OnboardingAnalytics
class. That functionality did not change
log(event: AnalyticsEventScreenView, | ||
data: [ | ||
AnalyticsParameterScreenName: path as Any, | ||
AnalyticsParameterScreenClass: String(describing: type(of: contextViewController)) |
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.
this logic was moved to AnalyticsEvent.swift
@@ -0,0 +1,59 @@ | |||
// | |||
// TrackingViewController+Ext.swift |
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.
this files serves the purpose of creating paths to identify the screen based on RoutingRequest data.
if successful { | ||
if let type = deeplink.params?["notification_type"] { | ||
Tracking.shared?.view("/notification/deeplink/" + type, data: data) | ||
} | ||
Tracking.shared?.view("/notification/deeplink/success", data: data) | ||
} else { | ||
Tracking.shared?.view("/notification/deeplink/failure", data: data) | ||
} |
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.
condensed into a single event with an event name instead of a path. Lmk if u disagree with this decision
@@ -13,6 +13,7 @@ import RoutingKit | |||
import ParticlesKit | |||
import PlatformUI | |||
import dydxCartera | |||
import dydxAnalytics |
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.
these import statements are necessary because some classes were moved into dydxAnalytics
b04643f
to
33cdd69
Compare
case notificationPermissionsChanged(isAuthorized: Bool) | ||
case onboardingStepChanged(step: OnboardingStep, state: OnboardingState) | ||
|
||
public var name: String { |
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.
The long switch statement can be messy when more events are added. Maybe it's cleaner to define each event as a separate struct, e.g.,
struct NavigatePageEvent: TrackableEvent {
let screen: ScreenIdentifiable
override var name: String ...
}
8e2dbc4
to
6bb5c99
Compare
return "OnboardingStepChanged" | ||
case .notificationPermissionsChanged: | ||
return "NotificationPermissionsChanged" | ||
public enum AnalyticsEventV2 { |
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.
@ruixhuang note I am nesting them in AnalyticsEventV2
so that we can use Xcode's autofill after typing AnalyticsEventV2.
, also to keep them contained. Lmk if u think this is not worth it and I can put them at the global level.
// func log(trackableEvent: TrackableEvent) { | ||
// log(event: trackableEvent.name, data: trackableEvent.customParameters, revenue: nil) | ||
// } |
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 😓
e785940
to
fd4206b
Compare
* analyticsv2 example * added dydxAnalytics * move files into dydxAnalytics * add default events * remove duplicative tracking * example replacement of app start event * add firebase to dydxAnalytics * interim commit * remove view(...) functions * sorting by name * clean up * address comment, make events unique structs * clean up
* analyticsv2 example * added dydxAnalytics * move files into dydxAnalytics * add default events * remove duplicative tracking * example replacement of app start event * add firebase to dydxAnalytics * interim commit * remove view(...) functions * sorting by name * clean up * address comment, make events unique structs * clean up
* analyticsv2 example * added dydxAnalytics * move files into dydxAnalytics * add default events * remove duplicative tracking * example replacement of app start event * add firebase to dydxAnalytics * interim commit * remove view(...) functions * sorting by name * clean up * address comment, make events unique structs * clean up
Description / Intuition
note this is a proof of concept, serves as a starting point to replace all events in the app with a more organized, enumerated set of events.
dydxAnalytics
moduleAnalyticsEventV2
which is a more prescribed way to log events with metadata.view
functions across the project in favor of logging newnavigatePage(screen:)
event (see comments)notification/deeplink
event with an event name that more closely follows other non-screen view event standardsmobile_path
tonavigatePage
events so that all view controller navigations have at least that.path
is reserved for the case when there is a directly corresponding web url path.Before/After Screenshots or Videos
rec.mov
Type of Change