Skip to content
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

Autocapture of screen views doesn't handle custom container view controllers #244

Open
jadar opened this issue Nov 8, 2024 · 3 comments
Assignees
Labels

Comments

@jadar
Copy link

jadar commented Nov 8, 2024

Version

3.13.3

Steps to Reproduce

  1. Add a custom container view controller that will swap views based on some state. For example, we have an InitialViewController that either shows the login screen or our app depending on the login state.
  2. Add PostHog with autocapture enabled
  3. Observe events coming in as screen view for the Initial screen, 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 jadar added the bug Something isn't working label Nov 8, 2024
@ioannisj
Copy link
Contributor

ioannisj commented Nov 8, 2024

@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

@ioannisj ioannisj self-assigned this Nov 8, 2024
@jadar
Copy link
Author

jadar commented Nov 8, 2024

Hey @ioannisj, here is an example project.

PostHogIssue244Example.zip

@marandaneto
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants