Skip to content

Commit 11dabe3

Browse files
committed
remove verbose telemetry comments
1 parent 583133a commit 11dabe3

9 files changed

Lines changed: 0 additions & 75 deletions

File tree

apps/code/src/main/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ function isCrashLoop(): boolean {
7575
return recentCrashTimestamps.length >= CRASH_LOOP_THRESHOLD;
7676
}
7777

78-
// Shared diagnostics attached to every crash event: uptime, the native chromium
79-
// log tail, and flattened memory. A hard OOM kills the renderer before it can
80-
// log, so the memory snapshot is often the only signal of what happened.
8178
function crashDiagnostics() {
8279
return {
8380
appUptimeSeconds: Math.round(process.uptime()),
@@ -100,8 +97,6 @@ app.on("render-process-gone", (_event, webContents, details) => {
10097
log.error("Renderer process gone", props);
10198
captureException(new Error(`Renderer process gone: ${details.reason}`), {
10299
...props,
103-
// Stack is always this handler, so default grouping collapses every
104-
// renderer death into one issue. Split by reason instead.
105100
$exception_fingerprint: ["render-process-gone", details.reason],
106101
});
107102
getPostHogClient()

apps/code/src/main/services/posthog-analytics.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ export function initializePostHog() {
2323
enableExceptionAutocapture: true,
2424
});
2525

26-
// Mint the main-owned session id now, before the first window, so crash
27-
// handlers can stamp $session_id even when the renderer crashes during
28-
// startup (before it fetches the id to bootstrap posthog-js).
2926
getOrCreateSessionId();
3027

3128
return posthogClient;
@@ -39,18 +36,6 @@ export function getCurrentUserId() {
3936
return currentUserId;
4037
}
4138

42-
/**
43-
* The PostHog session id is OWNED BY MAIN. Main mints one UUIDv7 and every
44-
* renderer window bootstraps posthog-js with it (`bootstrap.sessionID`).
45-
* Because main outlives the renderer, the id stays stable across a renderer
46-
* crash + reload, so the replay is one continuous session spanning the crash
47-
* and main-captured crash events (the renderer can't report its own OOM)
48-
* always carry the right `$session_id` with no race or hand-off.
49-
*
50-
* Minted lazily on first request (a window asks at boot, before posthog-js
51-
* init) so its UUIDv7 timestamp precedes the session's first event, as
52-
* posthog-js requires.
53-
*/
5439
export function getOrCreateSessionId(): string {
5540
if (!sessionId) {
5641
sessionId = uuidv7();
@@ -123,8 +108,6 @@ export function captureException(
123108
posthogClient.captureException(error, distinctId, {
124109
team: "posthog-code",
125110
...additionalProperties,
126-
// System-owned fields last so callers can't overwrite them: main owns the
127-
// session id used for crash->replay linking.
128111
...(sessionId ? { $session_id: sessionId } : {}),
129112
app_version: getAppVersion(),
130113
});

apps/code/src/main/trpc/routers/analytics.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ export const analyticsRouter = router({
3030
}
3131
}),
3232

33-
/**
34-
* Return the main-owned session id for a window to bootstrap posthog-js with
35-
* (`bootstrap.sessionID`). Main owns it so crash events captured from main
36-
* link to the right replay, and the id survives renderer crash+reload.
37-
*/
3833
getSessionId: publicProcedure
3934
.output(z.object({ sessionId: z.string() }))
4035
.query(() => ({ sessionId: getOrCreateSessionId() })),

apps/code/src/main/utils/crash-diagnostics.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,6 @@ export interface MemorySnapshot {
55
byType: Record<string, number>;
66
}
77

8-
/**
9-
* Summarize per-process memory (from `app.getAppMetrics()`, passed in by the
10-
* caller so this stays free of a direct `electron` import) for crash
11-
* diagnostics. Working-set sizes are in KB. Attached to renderer/child crash
12-
* events so PostHog Error Tracking can show whether the app was under memory
13-
* pressure: a hard OOM kills the renderer before it can log anything, so the
14-
* chromium log usually goes silent and this is the only reliable signal.
15-
*
16-
* Defensive on purpose: a throw here would run before the crash handler's
17-
* auto-recovery reload, so failures return `undefined` instead.
18-
*
19-
* Caveat: at `render-process-gone` time the dead renderer is already gone from
20-
* the metrics, so the `Tab` total understates the renderer's real peak. The
21-
* `unresponsive` sample (renderer still alive) is the more telling one.
22-
*/
238
export function collectMemorySnapshot(
249
getMetrics: () => Electron.ProcessMetric[],
2510
): MemorySnapshot | undefined {
@@ -48,11 +33,6 @@ export function collectMemorySnapshot(
4833
}
4934
}
5035

51-
/**
52-
* Flatten a snapshot into scalar event properties for PostHog (which doesn't
53-
* accept nested objects, so `byType` is serialized). Returns `{}` when no
54-
* snapshot was collected, so it spreads cleanly into a crash event's props.
55-
*/
5636
export function flattenMemorySnapshot(
5737
memory: MemorySnapshot | undefined,
5838
): Record<string, number | string> {

apps/code/src/main/utils/uuidv7.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ describe("uuidv7", () => {
1616
const id = uuidv7();
1717
const after = Date.now();
1818

19-
// First 48 bits (first 12 hex chars, minus the dash) are the unix-ms stamp.
2019
const stampMs = Number.parseInt(id.slice(0, 8) + id.slice(9, 13), 16);
2120
expect(stampMs).toBeGreaterThanOrEqual(before);
2221
expect(stampMs).toBeLessThanOrEqual(after);
@@ -31,7 +30,6 @@ describe("uuidv7", () => {
3130
vi.spyOn(Date, "now").mockReturnValue(0x0123456789ab);
3231
try {
3332
const id = uuidv7();
34-
// bytes 0-5 of 0x0123456789ab -> "01234567" then "89ab"
3533
expect(id.slice(0, 8)).toBe("01234567");
3634
expect(id.slice(9, 13)).toBe("89ab");
3735
} finally {

apps/code/src/main/utils/uuidv7.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
import { randomBytes } from "node:crypto";
22

3-
/**
4-
* Generate a UUIDv7 (time-ordered, RFC 9562). posthog-js requires this exact
5-
* format for `bootstrap.sessionID`: a valid v7 whose 48-bit timestamp precedes
6-
* the session's first event. Main mints it before any window starts posthog-js,
7-
* so the ordering holds.
8-
*
9-
* Layout: 48-bit big-endian unix-ms timestamp, 4-bit version (7), 2-bit variant
10-
* (10), 74 random bits. Hand-rolled to avoid a phantom dependency on `uuid`
11-
* (transitive only, and several major versions resolve in the tree).
12-
*/
133
export function uuidv7(): string {
144
const bytes = randomBytes(16);
155
const timestamp = Date.now();

apps/code/src/main/window.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ function setupCrashLogging(window: BrowserWindow): void {
116116
});
117117
});
118118

119-
// Unresponsive often precedes an OOM kill, and here the renderer is still
120-
// alive, so this memory sample reflects its real (bloated) footprint.
121119
window.on("unresponsive", () => {
122120
log.warn("Window unresponsive", {
123121
url: window.webContents.getURL(),

apps/code/src/renderer/App.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ function App() {
5252

5353
// Initialize PostHog analytics and register the app version super property.
5454
useEffect(() => {
55-
// Fetch the main-owned session id BEFORE initializing posthog-js so the
56-
// recording shares the id main stamps on crash events. Init is gated on it
57-
// so the id is set before the first event (posthog-js requires the
58-
// bootstrap id's timestamp to precede the session's first event).
5955
void (async () => {
6056
let sessionId: string | undefined;
6157
try {

apps/code/src/renderer/utils/analytics.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,8 @@ type PendingFlagListener = {
3636
// Subscribers added before initializePostHog runs.
3737
const pendingFlagListeners = new Set<PendingFlagListener>();
3838

39-
// 10 h, the posthog-js maximum. The app sits idle for hours during background
40-
// tasks; a shorter timeout would rotate the session id and break the
41-
// main-owned crash->replay link.
4239
const SESSION_IDLE_TIMEOUT_SECONDS = 36_000;
4340

44-
/**
45-
* @param sessionId Main-owned session id (UUIDv7) to bootstrap posthog-js with,
46-
* so the recording shares the id main stamps on crash events. Main owns it so
47-
* it survives a renderer crash+reload as one continuous session.
48-
*/
4941
export function initializePostHog(sessionId?: string) {
5042
const apiKey = import.meta.env.VITE_POSTHOG_API_KEY;
5143
const apiHost =
@@ -61,8 +53,6 @@ export function initializePostHog(sessionId?: string) {
6153
api_host: apiHost,
6254
ui_host: uiHost,
6355
disable_session_recording: false,
64-
// Hold the session open through long idle so posthog-js's own rotation
65-
// doesn't replace main's bootstrapped id mid-run.
6656
session_idle_timeout_seconds: SESSION_IDLE_TIMEOUT_SECONDS,
6757
...(sessionId ? { bootstrap: { sessionID: sessionId } } : {}),
6858
capture_exceptions: import.meta.env.DEV

0 commit comments

Comments
 (0)