[No QA] fix: move AppStartTime recording from MainApplication to MainActivity#86468
[No QA] fix: move AppStartTime recording from MainApplication to MainActivity#86468war-in wants to merge 2 commits intoExpensify:mainfrom
AppStartTime recording from MainApplication to MainActivity#86468Conversation
|
|
|
@mananjadhav Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
AppStartTime recording from MainApplication to MainActivityAppStartTime recording from MainApplication to MainActivity
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eecf5af8dd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| getSharedPreferences(APP_START_TIME_PREFERENCES, MODE_PRIVATE) | ||
| .edit() | ||
| .putLong(APP_START_TIME_PREFERENCES, System.currentTimeMillis()) | ||
| .apply() |
There was a problem hiding this comment.
Preserve app-start timestamp for headless JS launches
Writing AppStartTime only in MainActivity.onCreate() drops the update path for Android headless/background JS startups, which are documented in src/setup/index.ts (telemetry runs even when no Activity exists). In that path, AppStartTimeNitroModule.appStartTime can now come from a previous foreground session, so when ManualAppStartup is started from telemetry during early startup states (where app state may be undefined/active), durations can be inflated by long idle gaps and skew production startup metrics.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
In that path, AppStartTimeNitroModule.appStartTime can now come from a previous foreground session, so when ManualAppStartup is started from telemetry during early startup states
What flow would this be? Push notifications? I'm not sure what this problem is.
Explanation of Change
On Android, when the app is closed and quickly reopened, the system reuses the still-alive process. Since MainApplication.onCreate() only runs once per process — not on each app reopen — the startup timestamp stored in SharedPreferences becomes stale, causing the ManualAppStartup Sentry span duration to grow with each close+reopen cycle.
This PR moves the System.currentTimeMillis() recording from MainApplication.onCreate() to MainActivity.onCreate(). The Activity is recreated on every app open (even with process reuse), so the timestamp is always fresh.
Fixed Issues
$ #86474
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari