mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-03 05:23:17 +00:00
Untangle Sentry initialization.
Thanks to upstream for the helpful advice at https://github.com/getsentry/sentry-electron/issues/427. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
import {Console} from "console"; // eslint-disable-line node/prefer-global/console
|
||||
import electron from "electron";
|
||||
import fs from "fs";
|
||||
import os from "os";
|
||||
|
||||
import {initSetUp} from "./default-util";
|
||||
import {app} from "./remote";
|
||||
import {captureException, sentryInit} from "./sentry-util";
|
||||
|
||||
interface LoggerOptions {
|
||||
file?: string;
|
||||
@@ -13,24 +11,6 @@ interface LoggerOptions {
|
||||
|
||||
initSetUp();
|
||||
|
||||
let reportErrors = true;
|
||||
if (process.type === "renderer") {
|
||||
// Report Errors to Sentry only if it is enabled in settings
|
||||
// Gets the value of reportErrors from config-util for renderer process
|
||||
// For main process, sentryInit() is handled in index.js
|
||||
const {ipcRenderer} = electron;
|
||||
ipcRenderer.send("error-reporting");
|
||||
ipcRenderer.on(
|
||||
"error-reporting-val",
|
||||
(_event: Event, errorReporting: boolean) => {
|
||||
reportErrors = errorReporting;
|
||||
if (reportErrors) {
|
||||
sentryInit();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
const logDir = `${app.getPath("userData")}/Logs`;
|
||||
|
||||
type Level = "log" | "debug" | "info" | "warn" | "error";
|
||||
@@ -91,12 +71,6 @@ export default class Logger {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
reportSentry(error: unknown): void {
|
||||
if (reportErrors) {
|
||||
captureException(error);
|
||||
}
|
||||
}
|
||||
|
||||
async trimLog(file: string): Promise<void> {
|
||||
const data = await fs.promises.readFile(file, "utf8");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user