Skip to content

[No QA] Add flash, capture method and time since app start to the shutter-to-confirmation span - #104829

Open
OlimpiaZurek wants to merge 7 commits into
Expensify:mainfrom
callstack-internal:feat/scan-shutter-span-attributes
Open

OlimpiaZurek wants to merge 7 commits into
Expensify:mainfrom
callstack-internal:feat/scan-shutter-span-attributes

Conversation

@OlimpiaZurek

@OlimpiaZurek OlimpiaZurek commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

ManualShutterToConfirmation only carries platform. The flash and capture method are set on the child ManualReceiptCapture span, so splitting the parent's p95 by flash needs a join on trace ID. On Android, flash captures are about 4% of captures but they set the p95, so we need that split to be a simple query.

This PR sets three attributes on the parent span when the shutter is pressed on native:

  • capture_method (photo or snapshot) and flash_used, from the same values the child capture span already uses. The child span keeps them too.
  • duration_since_native_app_startup_ms: how long the native process had been running when the scan started. We want to know whether slow confirmation mounts on low-end Android devices happen soon after a cold launch. The constant already existed but nothing used it.

The native app start time is read once during telemetry setup. A new nativeAppStartTime module keeps it so later spans can use it. When setup discards the start time as stale (prewarmed process), it stores nothing and the attribute is left out, so no span reports a duration of hours.

flash_used means the user turned flash on and the device has a flash. It does not tell us whether the flash fired.

Fixed Issues

$ #104482
PROPOSAL:

Tests

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@OlimpiaZurek

Copy link
Copy Markdown
Contributor Author

@MelvinBot review

@OlimpiaZurek

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T13:34:00.553695Z 93a8afa Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@MelvinBot

Copy link
Copy Markdown
Contributor

Review: looks good, with no blocking issues. The logic is correct, the child span still gets the same attributes, and CI passes except for the approval check. I found one data-interpretation point and some PR housekeeping.

1. A missing duration_since_native_app_startup_ms doesn't only mean "prewarmed process." Setup discards the start time whenever NewDot JS boots 60 s or more after the process started (index.native.ts:94). On HybridApp, that also covers a user who spent more than a minute in OldDot before opening NewDot. It also covers a failed Nitro read. Queries filtered on this attribute will only see fresh cold starts. That bias is probably fine for the "slow mount soon after cold launch" question. Consider noting it in the code comment or the PR description so nobody reads "missing" as "prewarm."

2. Nit: nativeAppStartTime.ts has no header comment. A one-line comment would help, for example: "Holds the start time telemetry setup accepted; undefined means setup discarded it as stale."

3. PR housekeeping:

  • Fix the title typo: "shytter" should be "shutter".
  • Fill in the Fixed Issues link. $ is empty right now.
  • Replace the placeholder Tests steps.
  • Remove the // TODO line in QA Steps, since the title has [No QA].
  • Add native screenshots or a Sentry span showing the new attributes.

I didn't run an app test. The change only affects native code, and this run only has a web tester.


view run

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9fb27eef8a

ℹ️ 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".

if (nativeAppStartTimeMs === undefined) {
return undefined;
}
return Math.round(Date.now() - nativeAppStartTimeMs);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep app-start elapsed time monotonic

If the device wall clock is corrected while the process remains alive (for example by automatic time synchronization or a manual clock change), subtracting the startup epoch from a fresh Date.now() can produce a negative or greatly inflated duration_since_native_app_startup_ms, corrupting the telemetry this change is intended to analyze. Anchor the accepted startup age to a monotonic clock such as performance.now() when setting it, then compute later elapsed values from that same clock.

Useful? React with 👍 / 👎.

@OlimpiaZurek OlimpiaZurek changed the title [No QA] Add flash, capture method and time since app start to the shytter-to-confirmation span [No QA] Add flash, capture method and time since app start to the shutter-to-confirmation span Oct 23, 2026
@OlimpiaZurek
OlimpiaZurek marked this pull request as ready for review October 26, 2026 13:19
@OlimpiaZurek
OlimpiaZurek requested review from a team as code owners October 26, 2026 13:19
@melvin-bot
melvin-bot Bot requested review from DylanDylann and dylanexpensify and removed request for a team October 26, 2026 13:19
@melvin-bot

melvin-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

@DylanDylann 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]

@melvin-bot
melvin-bot Bot removed the request for review from a team October 26, 2026 13:19

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 93a8afa07b

ℹ️ 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".

if (appStartAgeAtSetupMs === undefined) {
return undefined;
}
return Math.round(appStartAgeAtSetupMs + performance.now() - performanceNowAtSetupMs);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use a suspend-aware clock for startup age

On Android, when the app process survives while the device enters deep sleep between telemetry setup and the shutter tap, React Native's performance.now() clock does not advance through that sleep. The reported duration_since_native_app_startup_ms can therefore omit hours and classify a resumed, warm process as a scan immediately after cold launch, skewing the analysis this attribute is intended for; use a suspend-aware monotonic native clock or explicitly account for suspended elapsed time.

Useful? React with 👍 / 👎.

@dylanexpensify dylanexpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Product input not required

Log.warn('[Telemetry] Failed to read native app start time from NitroModule', {error});
nativeAppStartTimeMs = undefined;
}
setNativeAppStartTime(nativeAppStartTimeMs);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duration_since_native_app_startup_ms reuses the 60s prewarm guard from the startup span. So the value is missing for every session where RN boots more than 60s after the native process starts, not only prewarmed iOS processes.

In HybridApp that happens a lot. RN setup only starts after OldDot hands off (OldDotToRNHandoff), so these sessions get no value:

  • an OldDot user who switches to NewDot after a minute
  • an Android process started in the background (e.g. by a push) and opened later

In those sessions the native process is old but JS/RN is cold. That's the case most likely to look like "slow right after launch". Dropping them, and lumping them in with NitroModule read failures, skews the p95-by-startup-age split this PR is meant to enable.

Suggestion: always record the setup clocks, and also report time since JS setup. Then set a second attribute (e.g. duration_since_js_start_ms) on ManualShutterToConfirmation next to the native one. With both, process old + RN cold can be told apart from "true cold" launch

@DylanDylann

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Screenshot 2026-10-28 at 14 36 18

@DylanDylann

Copy link
Copy Markdown
Contributor

@OlimpiaZurek Can you also fix the failed Reassure Performance Tests?

@melvin-bot
melvin-bot Bot requested a review from cristipaval October 28, 2026 10:15
@melvin-bot
melvin-bot Bot requested a review from Julesssss October 28, 2026 10:15

This branch has not been deployed

No deployments
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.

4 participants