You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, both ScreenViewedEvent and ElementInteractionEvent include the screenName as one of their properties.
The value of screenName is determined by a logic implemented inside UIKitScreenViews:
staticfunc screenName(for viewController:UIViewController)->String{iflet title = viewController.title, !title.isEmpty {return title
}letclassName=String(describing:type(of: viewController)).replacingOccurrences(of:"ViewController", with:"")if !className.isEmpty {return className
}return"Unknown"}
In many cases, a view controller’s title can be dynamic and may not accurately represent the actual screen name.
Proposed solution:
In the UIKitScreenViews create a new static method for the class name
staticfunc screenName(for viewController:UIViewController)->String{iflet title = viewController.title, !title.isEmpty {return title
}returnSelf.className(for: viewController)}staticfunc className(for viewController:UIViewController)->String{letclassName=String(describing:type(of: viewController)).replacingOccurrences(of:"ViewController", with:"")if !className.isEmpty {return className
}return"Unknown"}
@objcfunc amp_viewDidAppear(_ animated:Bool){amp_viewDidAppear(animated)
// Only record screen events for view controllers owned by the app
letviewControllerBundlePath=Bundle(for: classForCoder).bundleURL.resolvingSymlinksInPath().path
letmainBundlePath=Bundle.main.bundleURL.resolvingSymlinksInPath().path
guard viewControllerBundlePath.hasPrefix(mainBundlePath)else{return}guardlet rootViewController = viewIfLoaded?.window?.rootViewController else{return}guardlet top =Self.amp_topViewController(rootViewController),
top !==UIKitScreenViews.lastTopViewController else{return}UIKitScreenViews.lastTopViewController = top
letscreenName=UIKitScreenViews.screenName(for: top)letclassName=UIKitScreenViews.className(for: top)foramplitudeinUIKitScreenViews.amplitudes.allObjects {
amplitude.track(event:ScreenViewedEvent(screenName: screenName, className: className))}}
In many cases, a view controller’s title can be dynamic and may not accurately represent the actual screen name.
For example, the title might display a device name (such as a camera), a status, or any other dynamic value.
In these scenarios, using the view controller’s class name can provide a more consistent and reliable identifier for dashboards, making it easier to track specific screens within the app.
Therefore, having the class name available in the event properties list can lead to more accurate and flexible analytics.
The text was updated successfully, but these errors were encountered:
Summary
Currently, both ScreenViewedEvent and ElementInteractionEvent include the screenName as one of their properties.
The value of screenName is determined by a logic implemented inside UIKitScreenViews:
In many cases, a view controller’s title can be dynamic and may not accurately represent the actual screen name.
Proposed solution:
In the UIKitScreenViews create a new static method for the class name
ScreenViewedEvent
ElementInteractionEvent:
UIKitScreenViews file, @objc func amp_viewDidAppear(_ animated: Bool) ->
UIKitElementInteractions
UIKitElementInteractions.EventData
Motivations
In many cases, a view controller’s title can be dynamic and may not accurately represent the actual screen name.
For example, the title might display a device name (such as a camera), a status, or any other dynamic value.
In these scenarios, using the view controller’s class name can provide a more consistent and reliable identifier for dashboards, making it easier to track specific screens within the app.
Therefore, having the class name available in the event properties list can lead to more accurate and flexible analytics.
The text was updated successfully, but these errors were encountered: