File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -149,7 +149,13 @@ class AnalyticsTracker {
149149 // console.log('Fetched data: ', data);
150150 return data ;
151151 } catch ( error ) {
152- console . error ( 'Fetch error: ' , error ) ;
152+ // Suppress CORS errors in local development
153+ const isLocalhost = window . location . hostname === 'localhost' || window . location . hostname === '127.0.0.1' ;
154+ if ( isLocalhost ) {
155+ console . log ( '[Analytics] Skipping analytics in local development (CORS restriction)' ) ;
156+ } else {
157+ console . error ( '[Analytics] Fetch error: ' , error ) ;
158+ }
153159 }
154160 }
155161
@@ -401,6 +407,13 @@ class AnalyticsTracker {
401407 // Initialization
402408 // ========================
403409 static init ( ) {
410+ // Skip analytics in local development to avoid CORS errors
411+ const isLocalhost = window . location . hostname === 'localhost' || window . location . hostname === '127.0.0.1' ;
412+ if ( isLocalhost ) {
413+ console . log ( '[Analytics] Skipping analytics in local development environment.' ) ;
414+ return ;
415+ }
416+
404417 // Only initialize analytics if user has consented
405418 if ( ! this . hasConsent ( ) ) {
406419 console . log ( '[Analytics] User has not consented to tracking. Analytics disabled.' ) ;
You can’t perform that action at this time.
0 commit comments