Disable crash reporting in production
This commit is contained in:
parent
1e8047cf73
commit
80bc63bb90
2 changed files with 25 additions and 4 deletions
|
@ -9,6 +9,7 @@ import z from 'zod';
|
||||||
|
|
||||||
import type { LoggerType } from '../ts/types/Logging';
|
import type { LoggerType } from '../ts/types/Logging';
|
||||||
import * as Errors from '../ts/types/errors';
|
import * as Errors from '../ts/types/errors';
|
||||||
|
import { isProduction } from '../ts/util/version';
|
||||||
import OS from '../ts/util/os/osMain';
|
import OS from '../ts/util/os/osMain';
|
||||||
|
|
||||||
const dumpSchema = z
|
const dumpSchema = z
|
||||||
|
@ -64,12 +65,21 @@ async function eraseDumps(
|
||||||
|
|
||||||
export function setup(
|
export function setup(
|
||||||
getLogger: () => LoggerType,
|
getLogger: () => LoggerType,
|
||||||
showDebugLogWindow: () => Promise<void>
|
showDebugLogWindow: () => Promise<void>,
|
||||||
|
forceEnable = false
|
||||||
): void {
|
): void {
|
||||||
getLogger().info('crashReporter: enabled');
|
const isEnabled = !isProduction(app.getVersion()) || forceEnable;
|
||||||
crashReporter.start({ uploadToServer: false });
|
|
||||||
|
if (isEnabled) {
|
||||||
|
getLogger().info(`crashReporter: ${forceEnable ? 'force ' : ''}enabled`);
|
||||||
|
crashReporter.start({ uploadToServer: false });
|
||||||
|
}
|
||||||
|
|
||||||
ipc.handle('crash-reports:get-count', async () => {
|
ipc.handle('crash-reports:get-count', async () => {
|
||||||
|
if (!isEnabled) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const pendingDumps = await getPendingDumps();
|
const pendingDumps = await getPendingDumps();
|
||||||
if (pendingDumps.length !== 0) {
|
if (pendingDumps.length !== 0) {
|
||||||
getLogger().warn(
|
getLogger().warn(
|
||||||
|
@ -80,6 +90,10 @@ export function setup(
|
||||||
});
|
});
|
||||||
|
|
||||||
ipc.handle('crash-reports:write-to-log', async () => {
|
ipc.handle('crash-reports:write-to-log', async () => {
|
||||||
|
if (!isEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const pendingDumps = await getPendingDumps();
|
const pendingDumps = await getPendingDumps();
|
||||||
if (pendingDumps.length === 0) {
|
if (pendingDumps.length === 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -119,6 +133,10 @@ export function setup(
|
||||||
});
|
});
|
||||||
|
|
||||||
ipc.handle('crash-reports:erase', async () => {
|
ipc.handle('crash-reports:erase', async () => {
|
||||||
|
if (!isEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const pendingDumps = await getPendingDumps();
|
const pendingDumps = await getPendingDumps();
|
||||||
|
|
||||||
await eraseDumps(getLogger(), pendingDumps);
|
await eraseDumps(getLogger(), pendingDumps);
|
||||||
|
|
|
@ -208,10 +208,13 @@ const DISABLE_GPU =
|
||||||
OS.isLinux() && !process.argv.some(arg => arg === '--enable-gpu');
|
OS.isLinux() && !process.argv.some(arg => arg === '--enable-gpu');
|
||||||
|
|
||||||
const DISABLE_IPV6 = process.argv.some(arg => arg === '--disable-ipv6');
|
const DISABLE_IPV6 = process.argv.some(arg => arg === '--disable-ipv6');
|
||||||
|
const FORCE_ENABLE_CRASH_REPORTS = process.argv.some(
|
||||||
|
arg => arg === '--enable-crash-reports'
|
||||||
|
);
|
||||||
|
|
||||||
const CLI_LANG = cliOptions.lang as string | undefined;
|
const CLI_LANG = cliOptions.lang as string | undefined;
|
||||||
|
|
||||||
setupCrashReports(getLogger, showDebugLogWindow);
|
setupCrashReports(getLogger, showDebugLogWindow, FORCE_ENABLE_CRASH_REPORTS);
|
||||||
|
|
||||||
let sendDummyKeystroke: undefined | (() => void);
|
let sendDummyKeystroke: undefined | (() => void);
|
||||||
if (OS.isWindows()) {
|
if (OS.isWindows()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue