perf(android): avoid screen and device-type IPC candidates - #655
Merged
Conversation
marandaneto
marked this pull request as ready for review
July 27, 2026 07:24
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
posthog-android/src/main/java/com/posthog/android/internal/PostHogAndroidUtils.kt:138
**Runtime titles rename screen events**
When an activity changes its title before `onActivityStarted`, this code emits the mutable runtime title instead of the manifest-defined label previously returned by `ActivityInfo.loadLabel`, causing existing screen events to be renamed or split across analytics dashboards.
Reviews (1): Last reviewed commit: "revert: keep synchronous network time ca..." | Re-trigger Greptile |
ioannisj
reviewed
Jul 27, 2026
ioannisj
approved these changes
Jul 27, 2026
ioannisj
left a comment
Contributor
There was a problem hiding this comment.
LG Left a discussion point on greptile thread
marandaneto
enabled auto-merge (squash)
July 27, 2026 08:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Screen autocapture queried
ActivityInfothroughPackageManageron everyActivity.onStart, and device-type detection queriedUiModeManagerwhile building static context. Both paths can run on the main thread and can be served from state already loaded in the process. Screen autocapture now uses the activity's current title, so apps that set titles dynamically may emit a different$screen_namefor$screenevents and change report grouping; this is called out in the changeset.The network-time candidate was also reviewed. Android already caches the synchronized network-time sample, and reading it does not perform an NTP request. This PR therefore keeps the simpler existing once-per-minute synchronous cache and documents that its occasional cached-value IPC is accepted.
💚 How did you test it?
make testmake checkFormatgetActivityInfoand API 28 device-type compatibilityAn API 28 Perfetto Binder trace was considered, but no Android device or emulator was connected locally, so this PR does not claim runtime trace verification.
📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented with the Pi coding agent using repository file, shell, Git, Gradle, and GitHub CLI tools. No shareable agent session link was generated. Activity and UI-mode queries use already-loaded local state instead of adding callback/cache complexity. The proposed asynchronous network-time refresh was rolled back after reviewing AOSP: the OS already caches network time, and the existing once-per-minute synchronous read is the simpler accepted tradeoff.
TelephonyManager.networkOperatorNameremains unchanged because the callback alternative would require location permission.