element-hq / element-hq/element-ios
Improvements to PostHog screen tracking
- Dominant language
- Swift
- Stars
- 1.8k
- Forks
- 544
- PR merge metrics
- PR metrics pending
Description
Following on from the review of #5270, there are a few comments/improvements that should be addressed separately:
- [ ] When the app is sent to the background, we should still record the duration that a screen was displayed for before this the timer was paused ([comment](https://github.com/vector-im/element-ios/pull/5270#discussion_r768430215)).
- [ ] Add a `TrackableViewController` class or similar that screens can inherit from to reduce the code required to track (or consider using reflection if inheritance is undesirable) ([comment](https://github.com/vector-im/element-ios/pull/5270#discussion_r768470313)/[detail](https://github.com/vector-im/element-ios/pull/5270#discussion_r768482713)).
- [ ] Consider how to track SwiftUI screens too (possibly via a `track(as screen: AnalyticsScreen)` view modifier or similar).
**Additionally**
- [ ] We need a more robust pattern to detect screen navigation than using `viewDidAppear`/`Disappear` as modals that have the sheet presentation style don't trigger these methods on the presenting views.
Contributor guide
Research direction
No files or tests are named. Start by reviewing the PostHog screen-tracking changes from #5270 and the linked discussions, then trace the current viewDidAppear/viewDidDisappear handling, background transitions, modal navigation, and SwiftUI screens. Done means the agreed tracking pattern covers duration recording, reusable screen tracking, SwiftUI screens, and modal navigation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- analytics, mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100