Add receipt capture-to-upload observability logging#94212
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts: # src/libs/Network/SequentialQueue.ts # src/libs/actions/IOU/Receipt.ts
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c46f9e481b
ℹ️ 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".
| const receiptTraceId = mintAndStampReceiptTraceId(file); | ||
| logReceiptCaptured({file, captureSource, receiptTraceId}); | ||
| receiptFiles.push({file, source, transactionID}); | ||
| setMoneyRequestReceipt(transactionID, source, file.name ?? '', true, file.type); |
There was a problem hiding this comment.
Persist the trace ID before leaving scan
When a receipt is captured through the scan flow, this stamps only the transient File object, but the confirmation screen does not reuse that object; ReceiptFileValidator rebuilds receiptFiles from the draft transaction.receipt written by setMoneyRequestReceipt. Because the saved draft receipt still contains only source/name/type, normal scan submissions lose receiptTraceId, so the later submitted/enqueued logs and Sentry breadcrumbs cannot be correlated back to the captured line. Persist the trace ID in the draft receipt and copy it onto the validated file before submit.
Useful? React with 👍 / 👎.
| const now = Date.now(); | ||
| const pendingTransactionIDs = new Set<string>(); | ||
|
|
||
| for (const request of getAllPersistedRequests()) { |
There was a problem hiding this comment.
Include ongoing requests in lifecycle snapshots
When the app backgrounds or signs out while a receipt upload is actively being processed, processNextRequest() has already moved that request out of getAll() and into the ongoing request slot. Since this snapshot iterates only getAllPersistedRequests(), it skips the riskiest mid-upload receipt and then treats its timing entry as drained during cleanup, leaving no lifecycle snapshot for a crash/kill during the actual upload. Include getOngoingRequest() in the snapshot and pending-ID cleanup.
Useful? React with 👍 / 👎.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The copy of this PR with recent fixes - ready for review -> #94950 |
|
closing here since we have another copy |
Explanation of Change
Adds structured logging so we can follow a single receipt from capture through to upload. Each receipt gets a unique trace id at capture time, and we log
[Receipt]lines at three points: captured, submitted to the API, and enqueued in the network queue. We also log a snapshot of any still-pending receipts at sign-out, app backgrounding, and foregrounding.The trace id and transaction id are also sent to Sentry as a breadcrumb and tag, so if the app crashes mid-upload the crash report shows the receipt's trail.
Fixed Issues
$ #92139
PROPOSAL:
Tests
Offline tests
N/A
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)Avatar, 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.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