@@ -77,51 +77,61 @@ function checkBinaryAvailability(binary: string): { available: boolean; version?
7777 return { available : true , version } ;
7878}
7979
80- Sentry . init ( {
81- dsn : 'https://798607831167c7b9fe2f2912f5d3c665@o4509258288332800.ingest.de.sentry.io/4509258293837904' ,
82-
83- // Setting this option to true will send default PII data to Sentry
84- // For example, automatic IP address collection on events
85- sendDefaultPii : true ,
86-
87- // Set release version to match application version
88- release : `xcodebuildmcp@${ version } ` ,
89-
90- // Set environment based on NODE_ENV
91- environment : process . env . NODE_ENV ?? 'development' ,
92-
93- // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring
94- // We recommend adjusting this value in production
95- tracesSampleRate : 1.0 ,
96- } ) ;
97-
98- // Add additional context that might be helpful for debugging
99- const tags : Record < string , string > = {
100- nodeVersion : process . version ,
101- platform : process . platform ,
102- arch : process . arch ,
103- } ;
104-
105- // Only add Xcode Info if it's available
106- const xcodeInfo = getXcodeInfo ( ) ;
107- if ( ! xcodeInfo . error ) {
108- tags . xcodeVersion = xcodeInfo . version ;
109- tags . xcodePath = xcodeInfo . path ;
110- } else {
111- tags . xcodeVersion = 'Unknown' ;
112- tags . xcodePath = 'Unknown' ;
80+ // Skip Sentry initialization during tests to prevent module loading conflicts
81+ const isTestEnvironment =
82+ process . env . NODE_ENV === 'test' ||
83+ process . env . VITEST === 'true' ||
84+ ( typeof global !== 'undefined' && 'vitest' in global ) ;
85+
86+ if ( ! isTestEnvironment ) {
87+ Sentry . init ( {
88+ dsn : 'https://798607831167c7b9fe2f2912f5d3c665@o4509258288332800.ingest.de.sentry.io/4509258293837904' ,
89+
90+ // Setting this option to true will send default PII data to Sentry
91+ // For example, automatic IP address collection on events
92+ sendDefaultPii : true ,
93+
94+ // Set release version to match application version
95+ release : `xcodebuildmcp@${ version } ` ,
96+
97+ // Set environment based on NODE_ENV
98+ environment : process . env . NODE_ENV ?? 'development' ,
99+
100+ // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring
101+ // We recommend adjusting this value in production
102+ tracesSampleRate : 1.0 ,
103+ } ) ;
113104}
114105
115- const envVars = getEnvironmentVariables ( ) ;
116- tags . env_XCODEBUILDMCP_DEBUG = envVars [ 'XCODEBUILDMCP_DEBUG' ] ?? 'false' ;
117- tags . env_XCODEMAKE_ENABLED = envVars [ 'INCREMENTAL_BUILDS_ENABLED' ] ?? 'false' ;
106+ // Add additional context that might be helpful for debugging (only in production)
107+ if ( ! isTestEnvironment ) {
108+ const tags : Record < string , string > = {
109+ nodeVersion : process . version ,
110+ platform : process . platform ,
111+ arch : process . arch ,
112+ } ;
113+
114+ // Only add Xcode Info if it's available
115+ const xcodeInfo = getXcodeInfo ( ) ;
116+ if ( ! xcodeInfo . error ) {
117+ tags . xcodeVersion = xcodeInfo . version ;
118+ tags . xcodePath = xcodeInfo . path ;
119+ } else {
120+ tags . xcodeVersion = 'Unknown' ;
121+ tags . xcodePath = 'Unknown' ;
122+ }
118123
119- const miseAvailable = checkBinaryAvailability ( 'mise' ) ;
120- tags . miseAvailable = miseAvailable . available ? 'true' : 'false' ;
121- tags . miseVersion = miseAvailable . version ?? 'Unknown ' ;
124+ const envVars = getEnvironmentVariables ( ) ;
125+ tags . env_XCODEBUILDMCP_DEBUG = envVars [ 'XCODEBUILDMCP_DEBUG' ] ?? 'false' ;
126+ tags . env_XCODEMAKE_ENABLED = envVars [ 'INCREMENTAL_BUILDS_ENABLED' ] ?? 'false ' ;
122127
123- const axeAvailable = checkBinaryAvailability ( 'axe ' ) ;
124- tags . axeAvailable = axeAvailable . available ? 'true' : 'false' ;
125- tags . axeVersion = axeAvailable . version ?? 'Unknown' ;
128+ const miseAvailable = checkBinaryAvailability ( 'mise ' ) ;
129+ tags . miseAvailable = miseAvailable . available ? 'true' : 'false' ;
130+ tags . miseVersion = miseAvailable . version ?? 'Unknown' ;
126131
127- Sentry . setTags ( tags ) ;
132+ const axeAvailable = checkBinaryAvailability ( 'axe' ) ;
133+ tags . axeAvailable = axeAvailable . available ? 'true' : 'false' ;
134+ tags . axeVersion = axeAvailable . version ?? 'Unknown' ;
135+
136+ Sentry . setTags ( tags ) ;
137+ }
0 commit comments