1- import { client } from '@common/api/generated/client.gen'
21import { StrictMode } from 'react'
32import ReactDOM from 'react-dom/client'
43import {
98import { routeTree } from './route-tree.gen'
109import { QueryClientProvider } from '@tanstack/react-query'
1110import { TooltipProvider } from '@radix-ui/react-tooltip'
12- import * as Sentry from '@sentry/electron/renderer'
1311import { ThemeProvider } from './common/components/theme/theme-provider'
1412import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
1513import log from 'electron-log/renderer'
@@ -18,79 +16,21 @@ import './index.css'
1816import { PromptProvider } from './common/contexts/prompt/provider'
1917import { trackPageView } from './common/lib/analytics'
2018import { queryClient } from './common/lib/query-client'
19+ import { initSentry } from './lib/sentry'
20+ import { configureClient } from './lib/client-config'
2121// Import feature flags to bind them to window for developer tools access
2222import './common/lib/feature-flags'
2323// Import OS design devtools to bind OsDesign.setMac/setWindows/reset to window
2424import './common/lib/os-design'
2525
26- // Sentry setup
27- Sentry . init ( {
28- // Adds request headers and IP for users, for more info visit:
29- // https://docs.sentry.io/platforms/javascript/guides/electron/configuration/options/#sendDefaultPii
30- sendDefaultPii : true ,
31- integrations : [
32- Sentry . browserTracingIntegration ( ) ,
33- Sentry . replayIntegration ( ) ,
34- ] ,
35- // Set tracesSampleRate to 1.0 to capture 100%
36- // of transactions for performance monitoring.
37- // We recommend adjusting this value in production
38- // Learn more at
39- // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
40- tracesSampleRate : 1.0 ,
41- // Capture Replay for 10% of all sessions,
42- // plus for 100% of sessions with an error
43- // Learn more at
44- // https://docs.sentry.io/platforms/javascript/session-replay/configuration/#general-integration-configuration
45- replaysSessionSampleRate : 0.1 ,
46- replaysOnErrorSampleRate : 1.0 ,
47- // It will send errors, exceptions and captured messages to Sentry only if the user has enabled telemetry
48- beforeSend : async ( event ) =>
49- ( await window . electronAPI . sentry . isEnabled ) ? event : null ,
50- // It will send transactions to Sentry only if the user has enabled telemetry
51- beforeSendTransaction : async ( transaction ) => {
52- if ( ! ( await window . electronAPI . sentry . isEnabled ) ) {
53- return null
54- }
55- if ( ! transaction ?. contexts ?. trace ) return null
56-
57- const instanceId = await window . electronAPI . getInstanceId ( )
58- const trace = transaction . contexts . trace
59-
60- return {
61- ...transaction ,
62- contexts : {
63- ...transaction . contexts ,
64- trace : {
65- ...trace ,
66- data : {
67- ...transaction . contexts . trace . data ,
68- 'custom.user_id' : instanceId ,
69- } ,
70- } ,
71- } ,
72- }
73- } ,
74- } )
26+ initSentry ( )
7527
7628if ( ! window . electronAPI || ! window . electronAPI . getToolhivePort ) {
7729 log . error ( 'ToolHive port API not available in renderer' )
7830}
7931
8032; ( async ( ) => {
81- try {
82- const port = await window . electronAPI . getToolhivePort ( )
83- const telemetryHeaders = await window . electronAPI . getTelemetryHeaders ( )
84- const baseUrl = `http://localhost:${ port } `
85-
86- client . setConfig ( {
87- baseUrl,
88- headers : telemetryHeaders ,
89- } )
90- } catch ( e ) {
91- log . error ( 'Failed to get ToolHive port from main process: ' , e )
92- throw e
93- }
33+ await configureClient ( )
9434
9535 // One-time migration: sync the old localStorage quit-confirmation
9636 // preference into the main-process electron-store so existing users
0 commit comments