@@ -16,14 +16,17 @@ component {
1616 public function init ( required struct config ) {
1717 variables .config = arguments .config ;
1818
19- // Validate required config keys
20- if ( ! structKeyExists ( variables .config , " dsn" ) || isEmpty ( variables .config .dsn ) ) {
21- throw ( type = " Sentry.ConfigurationException" , message = " Missing required configuration key: dsn" );
19+ // DSN is optional - if not provided or empty, logger will exercise all code paths but not send to Sentry
20+ // Strip quotes in case DSN comes through as literal '""' string from environment variables
21+ var cleanDsn = trim ( replace ( variables .config .dsn ?: " " , ' ""' , ' ' , ' all' ) );
22+ if ( len ( cleanDsn ) && cleanDsn neq ' ""' ) {
23+ // Parse the DSN
24+ variables .sentryInfo = _parseDsn ( cleanDsn );
25+ variables .hasDsn = true ;
26+ } else {
27+ variables .hasDsn = false ;
2228 }
2329
24- // Parse the DSN
25- variables .sentryInfo = _parseDsn ( variables .config .dsn );
26-
2730 // Set defaults
2831 if ( ! structKeyExists ( variables .config , " environment" ) || isEmpty ( variables .config .environment ) ) {
2932 variables .config .environment = " production" ;
@@ -179,6 +182,17 @@ component {
179182 * Sends an event to Sentry via HTTP.
180183 */
181184 private struct function _sendEvent ( required struct event ) {
185+ // If no DSN configured, skip the HTTP call but return success
186+ // This allows full code path testing in dev without sending to Sentry
187+ if ( ! variables .hasDsn ) {
188+ return {
189+ " success" = true ,
190+ " eventId" = arguments .event .event_id ,
191+ " statusCode" = " 200" ,
192+ " note" = " No DSN configured - event not sent to Sentry"
193+ };
194+ }
195+
182196 var fullUrl = variables .sentryInfo .apiUrl ;
183197 var timestamp = _getTimestamp ();
184198
0 commit comments