Skip to content

Commit 3f2eb6f

Browse files
fixup! fix: ensure analytics are disabled development and CI environments
1 parent 01b221f commit 3f2eb6f

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/main.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ReactDOM from 'react-dom/client'
33
import * as Sentry from '@sentry/react'
44
import App from './App.tsx'
55
import './index.css'
6+
import { loadUmamiScript } from './utils/analytics'
67

78
// Initialize Sentry for error tracking
89
// Only initialize if DSN is provided (production environment) AND user hasn't explicitly declined
@@ -80,6 +81,14 @@ if (import.meta.env.VITE_SENTRY_DSN && errorReportingConsent !== 'declined') {
8081
});
8182
}
8283

84+
// Initialize analytics if user has consented
85+
const analyticsConsent = localStorage.getItem('lenr-analytics-consent')
86+
if (analyticsConsent === 'accepted') {
87+
loadUmamiScript().catch(error => {
88+
console.error('[Analytics] Failed to load on startup:', error)
89+
})
90+
}
91+
8392
ReactDOM.createRoot(document.getElementById('root')!).render(
8493
<React.StrictMode>
8594
<App />

0 commit comments

Comments
 (0)