* wip * wip * wip * format * wip(mobile): lint and format * cleanup * nits * nits * idiomatic react * nit * format all root files
31 lines
882 B
TypeScript
31 lines
882 B
TypeScript
import { app } from 'electron';
|
|
import * as Sentry from '@sentry/electron/main';
|
|
import { appConfig, appEnv } from '@/config/env';
|
|
import { installErrorSinks } from '@/lib/errors';
|
|
|
|
/**
|
|
* Initialise Sentry for the main process. Captures uncaught exceptions from
|
|
* the Node side and the crash reporter. Safe to call before `app.whenReady`.
|
|
*/
|
|
export function initSentryMain(): void {
|
|
if (!appConfig.sentryDsn) return;
|
|
|
|
Sentry.init({
|
|
dsn: appConfig.sentryDsn,
|
|
environment: appEnv,
|
|
tracesSampleRate: 0,
|
|
release: app.getVersion(),
|
|
});
|
|
|
|
installErrorSinks({
|
|
capture: (err, context) => Sentry.captureException(err, { extra: context }),
|
|
breadcrumb: (err, context) =>
|
|
Sentry.addBreadcrumb({
|
|
category: 'error',
|
|
level: 'error',
|
|
message: err instanceof Error ? err.message : String(err),
|
|
data: context,
|
|
}),
|
|
});
|
|
}
|