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

feat: add support for ph-label in autocapture elements #271

Merged
merged 10 commits into from
Dec 10, 2024

Conversation

ioannisj
Copy link
Contributor

@ioannisj ioannisj commented Dec 5, 2024

💡 Motivation and Context

Private slack thread: https://posthog.slack.com/archives/C03PB072FMJ/p1733219779409259
Docs: PostHog/posthog.com#10085

Autocapture elements can now be given a PostHog label which can then be used in analytics to filter for a specific element (using Tag Name and/or CSS Selector)

Autocapture elements now get class and id attributes:

  • class: the superclass of the element if not a common type like UIView, UIControl, NSObject or UIResponder
  • id: the value of the custom label defined through postHogLabel (UIKit) or .postHogLabel(_ label: String?) (SwiftUI)

SwiftUI

  • I think most of the interactions in a SwiftUI app are already autocaptured (since most of interactive SwiftUI controls map to a UIKit counterpart). List includes collection views, scroll views, table views, text fields, text views, switches etc
  • An important element we are missing is support for UIButton (SwiftUI renders buttons as images)

Minor

  • Some minor improvements/corrections
  • New simpler implementation of ForwardingPickerViewDelegate

Notes

The implementation uses $elements_chain (constructed by the client) since $elements will be deprecated soon https://github.com/PostHog/posthog/blob/f9be4fa28668e242d56bab9651cf9c79b40d9249/plugin-server/src/worker/ingestion/process-event.ts#L119

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

@ioannisj ioannisj requested a review from marandaneto as a code owner December 5, 2024 06:50
@ioannisj ioannisj requested a review from a team December 5, 2024 06:50
.swiftlint.yml Outdated Show resolved Hide resolved
@ioannisj ioannisj merged commit 3db5aeb into main Dec 10, 2024
6 checks passed
@ioannisj ioannisj deleted the feat/autocapture-custom-label branch December 10, 2024 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants