Skip to content

Commit 5d44cde

Browse files
committed
feat(telemetry): integrate Sentry error monitoring across main and renderer processes (#175)
- Add @sentry/electron dependency for comprehensive error tracking and performance monitoring - Create shared TypeScript definitions for main and renderer Sentry configurations - Implement SentryService for main process with native crash reporting and breadcrumb collection - Implement SentryService for renderer process with web-specific error handling - Initialize Sentry in both main index and renderer init files for full coverage - Configure error boundaries, performance monitoring, and user context tracking - Add support for release tracking, environment detection, and custom integrations - Enable automatic breadcrumb collection and unhandled rejection capture This implementation provides: - Centralized error monitoring and crash reporting - Performance tracking and bottleneck identification - User session tracking with privacy-conscious defaults - Development/production environment separation - Comprehensive error context for debugging production issues
1 parent 19ca2f5 commit 5d44cde

7 files changed

Lines changed: 1599 additions & 0 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"@electron-toolkit/preload": "^3.0.2",
6565
"@electron-toolkit/utils": "^4.0.0",
6666
"@remotion/media-parser": "^4.0.344",
67+
"@sentry/electron": "^5.12.0",
6768
"antd": "^5.27.3",
6869
"better-sqlite3": "^12.2.0",
6970
"dompurify": "^3.2.6",

packages/shared/types/sentry.d.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
export interface SentryMainOptions {
2+
dsn: string
3+
release?: string
4+
environment?: string
5+
sampleRate?: number
6+
enableNative?: boolean
7+
beforeSend?: (event: any, hint?: any) => any | null | Promise<any | null>
8+
beforeBreadcrumb?: (breadcrumb: any, hint?: any) => any | null
9+
initialScope?: {
10+
user?: any
11+
tags?: { [key: string]: string }
12+
contexts?: { [key: string]: any }
13+
}
14+
integrations?: any[]
15+
debug?: boolean
16+
maxBreadcrumbs?: number
17+
attachStacktrace?: boolean
18+
sendDefaultPii?: boolean
19+
serverName?: string
20+
captureUnhandledRejections?: boolean
21+
captureUncaughtException?: boolean
22+
}
23+
24+
export interface SentryRendererOptions {
25+
dsn: string
26+
release?: string
27+
environment?: string
28+
sampleRate?: number
29+
beforeSend?: (event: any, hint?: any) => any | null | Promise<any | null>
30+
beforeBreadcrumb?: (breadcrumb: any, hint?: any) => any | null
31+
initialScope?: {
32+
user?: any
33+
tags?: { [key: string]: string }
34+
contexts?: { [key: string]: any }
35+
}
36+
integrations?: any[]
37+
debug?: boolean
38+
maxBreadcrumbs?: number
39+
attachStacktrace?: boolean
40+
sendDefaultPii?: boolean
41+
captureUnhandledRejections?: boolean
42+
captureConsoleIntegration?: boolean
43+
captureGlobalErrorHandlers?: boolean
44+
}
45+
46+
declare module '@sentry/electron/main' {
47+
export function init(options: SentryMainOptions): void
48+
export function captureException(exception: any, hint?: any): string
49+
export function captureMessage(message: string, level?: string): string
50+
export function addBreadcrumb(breadcrumb: any): void
51+
export function configureScope(callback: (scope: any) => void): void
52+
}
53+
54+
declare module '@sentry/electron/renderer' {
55+
export function init(options: SentryRendererOptions): void
56+
export function captureException(exception: any, hint?: any): string
57+
export function captureMessage(message: string, level?: string): string
58+
export function addBreadcrumb(breadcrumb: any): void
59+
export function configureScope(callback: (scope: any) => void): void
60+
}

0 commit comments

Comments
 (0)