MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / initErrorReporting

Function initErrorReporting

apps/desktop/src/main/diagnostics.ts:80–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78 * every child process Electron spawns.
79 */
80export const initErrorReporting = () => {
81 if (errorReportingEnabled) {
82 Sentry.init(
83 mainCrashReportingOptions({
84 dsn: sentryDsn,
85 release: releaseTag(),
86 environment: environmentTag(),
87 runId,
88 }),
89 );
90 } else {
91 // No DSN baked in — keep native crash dumps local so a user-reported
92 // crash still leaves minidumps for the diagnostics zip to collect.
93 crashReporter.start({ uploadToServer: false, compress: true });
94 }
95
96 // Persist process-death signals to main.log regardless of Sentry — these
97 // are the events a "the app just disappeared" report hinges on. Sentry's
98 // ChildProcess integration reports them upstream; this keeps a local copy.
99 app.on("child-process-gone", (_event, details) => {
100 log.error("[crash] child process gone", details);
101 });
102 app.on("render-process-gone", (_event, webContents, details) => {
103 log.error("[crash] render process gone", { url: webContents.getURL(), ...details });
104 });
105
106 // Main-process uncaught errors: electron-log writes them to main.log and
107 // keeps the process alive (matching its default), Sentry (when enabled)
108 // captures them via its own integrations.
109 log.errorHandler.startCatching({ showDialog: false });
110
111 // Every log line becomes a Sentry breadcrumb, so an error event arrives
112 // with the recent log context (sidecar restarts, update checks, …) instead
113 // of a bare stack. Hooked on the file transport only so each line is
114 // recorded once. No-ops when Sentry is disabled.
115 log.hooks.push((message, transport) => {
116 if (transport !== log.transports.file) return message;
117 Sentry.addBreadcrumb({
118 category: message.scope ?? "main",
119 level: message.level === "warn" ? "warning" : message.level === "error" ? "error" : "info",
120 message: message.data
121 .map((part) => (typeof part === "string" ? part : JSON.stringify(part)))
122 .join(" ")
123 .slice(0, 1024),
124 });
125 return message;
126 });
127};
128
129/**
130 * Report a sidecar crash that happened after a successful boot. The startup

Callers 1

index.tsFile · 0.90

Calls 7

releaseTagFunction · 0.85
environmentTagFunction · 0.85
errorMethod · 0.80
pushMethod · 0.80
startMethod · 0.65
initMethod · 0.45

Tested by

no test coverage detected