Skip to content

feat(code): Enrich renderer crash events for Error Tracking#2514

Open
charlesvien wants to merge 4 commits into
06-06-claude-adapter-upgradefrom
06-06-add-crash-telemetry
Open

feat(code): Enrich renderer crash events for Error Tracking#2514
charlesvien wants to merge 4 commits into
06-06-claude-adapter-upgradefrom
06-06-add-crash-telemetry

Conversation

@charlesvien

@charlesvien charlesvien commented Jun 6, 2026

Copy link
Copy Markdown
Member

Problem

Renderer OOM crashes landed in Error Tracking as one collapsed, undiagnosable issue: the stack pointed at the handler, with no memory, no native logs, and no linked replay.

Changes

  1. Attach chromium log tail and per-process memory (getAppMetrics) to render/child crash events
  2. Fingerprint crashes per reason so crashed/killed/oom stop collapsing into one issue
  3. Main owns a UUIDv7 session id; every window bootstraps posthog-js with it before the first event
  4. Stamp $session_id on captured exceptions so crashes link the session replay
  5. Hold the session open through long idle (10h) so the id survives background tasks and reload

How did you test this?

Manually

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

charlesvien commented Jun 6, 2026

Copy link
Copy Markdown
Member Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@charlesvien charlesvien changed the title enrich renderer crash events for error tracking feat: Jun 6, 2026
@charlesvien charlesvien changed the title feat: feat: Enrich renderer crash events for Error Tracking Jun 6, 2026
@charlesvien charlesvien marked this pull request as ready for review June 6, 2026 23:44
@charlesvien charlesvien changed the title feat: Enrich renderer crash events for Error Tracking feat(code): Enrich renderer crash events for Error Tracking Jun 6, 2026
@greptile-apps

greptile-apps Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

T-Rex T-Rex Logs

What T-Rex did

  • Generated targeted checks for the new crash analytics path.
  • Verified UUIDv7 formatting for bootstrap.sessionID, memory snapshot aggregation and serialization, session ID singleton behavior, captureException session properties, and crash fingerprint passthrough.
  • Ran the standalone targeted check script and confirmed 23 passing checks.
  • Could not use the project test runner in this environment because a bundled dependency requires a newer Node export, so the focused checks were executed with a standalone assertion script.
Artifacts

Standalone targeted check script

  • The standalone script used to perform the crash analytics path checks and validation.

Targeted check output

  • The log showing the results of the targeted checks, used to verify 23 passing checks.

T-Rex Ran code and verified through T-Rex

Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
apps/code/src/main/services/posthog-analytics.ts:122-127
**Protect session stamping**

`captureException` adds the main-owned `$session_id`, then lets `additionalProperties` overwrite it. If a caller passes a stale or incorrect `$session_id`, the exception is sent with that value instead of the session main minted for replay linking, so crash events can detach from the intended replay. Put caller properties before the system-owned fields so `$session_id` is protected like `app_version` already is.

```suggestion
  posthogClient.captureException(error, distinctId, {
    team: "posthog-code",
    ...additionalProperties,
    ...(sessionId ? { $session_id: sessionId } : {}),
    app_version: getAppVersion(),
  });
```

### Issue 2 of 2
apps/code/src/main/services/posthog-analytics.ts:49-53
**Mint before crashes**

`sessionId` is created only after the renderer calls `analytics.getSessionId`, but the main crash handlers and main PostHog client are active before the renderer `useEffect` can make that tRPC call. A renderer crash during startup can therefore be captured without `$session_id`, which loses the crash-to-replay link this change is adding. Mint the main-owned ID before creating the first window, or make crash capture call `getOrCreateSessionId()` when it needs to stamp a crash event.

Reviews (1): Last reviewed commit: "enrich renderer crash events for error t..." | Re-trigger Greptile

Comment thread apps/code/src/main/services/posthog-analytics.ts
Comment thread apps/code/src/main/services/posthog-analytics.ts
@charlesvien charlesvien force-pushed the 06-06-claude-adapter-upgrade branch from 2f2ae16 to c7cb373 Compare June 6, 2026 23:59
@charlesvien charlesvien force-pushed the 06-06-add-crash-telemetry branch 3 times, most recently from f9ee6d9 to d223dfe Compare June 7, 2026 00:21
@charlesvien charlesvien force-pushed the 06-06-claude-adapter-upgrade branch 2 times, most recently from 8c6bc8d to fec00b8 Compare June 8, 2026 00:53
@charlesvien charlesvien force-pushed the 06-06-add-crash-telemetry branch from d223dfe to 072d2a7 Compare June 8, 2026 00:53
@charlesvien charlesvien force-pushed the 06-06-claude-adapter-upgrade branch from fec00b8 to a51aca3 Compare June 9, 2026 01:37
@charlesvien charlesvien force-pushed the 06-06-add-crash-telemetry branch from 072d2a7 to 5a37f67 Compare June 9, 2026 01:37
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 11dabe3.

@charlesvien charlesvien force-pushed the 06-06-claude-adapter-upgrade branch from a51aca3 to da4b88a Compare June 9, 2026 02:01
@charlesvien charlesvien force-pushed the 06-06-add-crash-telemetry branch from 5a37f67 to 11dabe3 Compare June 9, 2026 02:01
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.

1 participant