Autocapture of screen views doesn't handle custom container view controllers
Version
3.13.3
Steps to Reproduce
- Add a custom container view controller that will swap views based on some state. For example, we have an
InitialViewControllerthat either shows the login screen or our app depending on the login state. - Add PostHog with autocapture enabled
- Observe events coming in as screen view for the
Initialscreen, even when the other screens are being visited.
Expected Result
Each screen even has the unique name of the View controller being visited.
Actual Result
Each event has the same view controller at the base of our hierarchy. Ours is called InitialViewController.
@jadar Do you mind sharing a small sample project with the layout you described? I'm sure it's the way we traverse the view hierarchy to find a root view controller. Having a sample project will help out a lot. Want to be a bit extra careful with screen names so that we don't break any existing user's data either. Thanx
As a workaround, you can use the propertiesSanitizer and change the $screen_name and replace it with the correct name.
Another option is to disable captureScreenViews and capture all screen views with PostHogSDK.shared.screen(name).
I'm not sure we're gonna find a way to make it work with every possible configuration since the naming is based on heuristics and is best-effort, but of course, if there's a fix on our end, that would be cool.