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

Support SwiftUI screen names through accessibilityIdentifier and friends #167

Open
marandaneto opened this issue Aug 21, 2024 · 2 comments
Labels
enhancement New feature or request Session Replay

Comments

@marandaneto
Copy link
Member

marandaneto commented Aug 21, 2024

Problem Statement

Screen names are auto generated, so autocapture does not work well nor the detection of the current screen for session replay

Solution Brainstorm

fallback to accessibilityIdentifier or friends if available

private func captureScreenView(_ window: UIWindow?) {

@marandaneto marandaneto added enhancement New feature or request Session Replay labels Aug 21, 2024
@marandaneto
Copy link
Member Author

afaik accessibilityIdentifier isn't available at runtime for production builds, what we could do is wrap the view:

var body: some View {
    PostHogView("Name"){
        List {
            ...
        }
    }
}

in this case, we can read the Name at runtime but it's not much different than calling PostHog.screen("Name"), all screens need to be wrapped.

@marandaneto
Copy link
Member Author

marandaneto commented Aug 26, 2024

Another option would be to use the objc_getAssociatedObject and objc_setAssociatedObject as an extension method to UIKit and SwiftUI views

Edit: not possible either since the associated objects are different when scanning the view tree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Session Replay
Projects
None yet
Development

No branches or pull requests

1 participant