fix(logging): render heartbeat payloads in debug output#226
fix(logging): render heartbeat payloads in debug output#226TimeToBuildBob wants to merge 2 commits into
Conversation
Greptile SummaryAdds a small formatter function to render heartbeat payloads as readable text in debug logs. The two debug log calls inside the core heartbeat function are updated to use it.
Confidence Score: 5/5Safe to merge — the change is additive and scoped to debug logging with no impact on heartbeat send logic. The formatter is a pure string-building utility with no side effects. Both updated log sites call it only inside existing conditional branches, leaving the heartbeat send path unchanged. All expected value types are handled correctly by JSON.stringify. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[heartbeat called] --> B{tab valid?}
B -- No --> C[warn + return]
B -- Yes --> D[build data object]
D --> E[getHeartbeatData]
E --> F{previousData exists AND differs?}
F -- Yes --> G[formatHeartbeatLogData previousData]
G --> H[console.debug previous payload]
H --> I[sendHeartbeat previousData]
F -- No --> J[formatHeartbeatLogData current data]
I --> J
J --> K[console.debug current payload]
K --> L[sendHeartbeat current data]
L --> M[setHeartbeatData]
Reviews (2): Last reviewed commit: "fix(logging): quote string heartbeat log..." | Re-trigger Greptile |
| const formattedValue = | ||
| typeof value === 'string' | ||
| ? value | ||
| : value === undefined | ||
| ? 'undefined' | ||
| : JSON.stringify(value) |
There was a problem hiding this comment.
Unquoted string values may make the log ambiguous when a URL or page title contains the
, separator. For example, url=https://example.com, title=Hello, World is hard to parse visually. Wrapping string values in quotes makes field boundaries unambiguous.
| const formattedValue = | |
| typeof value === 'string' | |
| ? value | |
| : value === undefined | |
| ? 'undefined' | |
| : JSON.stringify(value) | |
| const formattedValue = | |
| typeof value === 'string' | |
| ? JSON.stringify(value) | |
| : value === undefined | |
| ? 'undefined' | |
| : JSON.stringify(value) |
Fixes #196.
Summary
key=valuetext instead of raw objectsVerification
npx tsc --noEmitnpx vite buildnpx prettier --check src/background/heartbeat.ts