()
| 44 | } |
| 45 | |
| 46 | async initialize(): Promise<void> { |
| 47 | if (this.initialized) return; |
| 48 | |
| 49 | try { |
| 50 | // Initialize consent manager |
| 51 | const settings = await this.consentManager.initialize(); |
| 52 | |
| 53 | // Only initialize PostHog if user has consented |
| 54 | if (settings.hasConsented && settings.enabled) { |
| 55 | this.initializePostHog(settings); |
| 56 | } |
| 57 | |
| 58 | // Start event queue flush interval |
| 59 | this.startFlushInterval(); |
| 60 | |
| 61 | this.initialized = true; |
| 62 | } catch (error) { |
| 63 | console.error('Failed to initialize analytics:', error); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | private initializePostHog(settings: AnalyticsSettings): void { |
| 68 | try { |
nothing calls this directly
no test coverage detected