1- import * as Sentry from '@sentry/node' ;
21import { createRequire } from 'module' ;
32
3+ import * as Sentry from '@sentry/node' ;
4+
45/**
56 * Initialize Sentry for error tracking
67 * @param dsn Optional custom DSN to use instead of the default
@@ -10,35 +11,35 @@ export function initSentry(dsn?: string) {
1011 let packageVersion = 'unknown' ;
1112 try {
1213 const require = createRequire ( import . meta. url ) ;
13- packageVersion = process . env . npm_package_version || require ( '../../package.json' ) . version ;
14+ packageVersion =
15+ process . env . npm_package_version || require ( '../../package.json' ) . version ;
1416 } catch ( error ) {
1517 console . warn ( 'Could not determine package version for Sentry:' , error ) ;
1618 }
1719
1820 // Initialize Sentry
1921 Sentry . init ( {
2022 // Default DSN from Sentry.io integration instructions
21- dsn : dsn || 'https://2873d2518b60f645918b6a08ae5e69ae@o4508898407481344.ingest.us.sentry.io/4508898476687360' ,
22-
23+ dsn :
24+ dsn ||
25+ 'https://2873d2518b60f645918b6a08ae5e69ae@o4508898407481344.ingest.us.sentry.io/4508898476687360' ,
26+
2327 // No profiling integration as requested
24-
28+
2529 // Capture 100% of the transactions
2630 tracesSampleRate : 1.0 ,
27-
31+
2832 // Set environment based on NODE_ENV
2933 environment : process . env . NODE_ENV || 'development' ,
30-
34+
3135 // Add release version from package.json
3236 release : `mycoder@${ packageVersion } ` ,
33-
37+
3438 // Don't capture errors in development mode unless explicitly enabled
35- enabled : process . env . NODE_ENV !== 'development' || process . env . ENABLE_SENTRY === 'true' ,
39+ enabled :
40+ process . env . NODE_ENV !== 'development' ||
41+ process . env . ENABLE_SENTRY === 'true' ,
3642 } ) ;
37-
38- // Log confirmation that Sentry is initialized with version info
39- if ( process . env . NODE_ENV !== 'test' ) {
40- console . log ( `Sentry initialized for mycoder@${ packageVersion } ` ) ;
41- }
4243}
4344
4445/**
@@ -67,20 +68,27 @@ export function testSentryErrorReporting() {
6768 let packageVersion = 'unknown' ;
6869 try {
6970 const require = createRequire ( import . meta. url ) ;
70- packageVersion = process . env . npm_package_version || require ( '../../package.json' ) . version ;
71+ packageVersion =
72+ process . env . npm_package_version ||
73+ require ( '../../package.json' ) . version ;
7174 } catch ( error ) {
72- console . warn ( 'Could not determine package version for test error:' , error ) ;
75+ console . warn (
76+ 'Could not determine package version for test error:' ,
77+ error ,
78+ ) ;
7379 }
74-
80+
7581 // Throw a test error with version information
76- throw new Error ( `Test error for Sentry.io integration from mycoder@${ packageVersion } ` ) ;
82+ throw new Error (
83+ `Test error for Sentry.io integration from mycoder@${ packageVersion } ` ,
84+ ) ;
7785 } catch ( error ) {
7886 // Capture the error with Sentry
7987 Sentry . captureException ( error ) ;
80-
88+
8189 // Log a message about the test
8290 console . log ( 'Test error sent to Sentry.io' ) ;
83-
91+
8492 // Return the error for inspection
8593 return error ;
8694 }
0 commit comments