From bf5d60ca635c0dc572ca02c05263a17e262cb33e Mon Sep 17 00:00:00 2001 From: Trey t Date: Tue, 3 Mar 2026 21:28:27 -0600 Subject: [PATCH] Fix iOS analytics by calling Swift AnalyticsManager instead of Kotlin no-op stub PostHogAnalytics.shared.initialize() was calling the Kotlin actual object which is a no-op on iOS. Replaced with AnalyticsManager.shared.configure() so the PostHog SDK actually initializes. Also switched to anonymous-only person profiles. Co-Authored-By: Claude Opus 4.6 --- iosApp/iosApp/Analytics/AnalyticsManager.swift | 5 ++--- iosApp/iosApp/Login/LoginViewModel.swift | 2 -- iosApp/iosApp/iOSApp.swift | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/iosApp/iosApp/Analytics/AnalyticsManager.swift b/iosApp/iosApp/Analytics/AnalyticsManager.swift index 1e86c43..89024b0 100644 --- a/iosApp/iosApp/Analytics/AnalyticsManager.swift +++ b/iosApp/iosApp/Analytics/AnalyticsManager.swift @@ -41,9 +41,8 @@ final class AnalyticsManager { let config = PostHogConfig(apiKey: Self.apiKey, host: Self.host) - // Person profiles — required so events create person records - // and appear in the PostHog Events Explorer / Activity view. - config.personProfiles = .always + // Anonymous-only — no user identification, events use anonymous IDs + config.personProfiles = .never // Auto-capture config.captureElementInteractions = true diff --git a/iosApp/iosApp/Login/LoginViewModel.swift b/iosApp/iosApp/Login/LoginViewModel.swift index dd93c7f..c2f77ef 100644 --- a/iosApp/iosApp/Login/LoginViewModel.swift +++ b/iosApp/iosApp/Login/LoginViewModel.swift @@ -146,8 +146,6 @@ class LoginViewModel: ObservableObject { // APILayer.logout clears DataManager try? await APILayer.shared.logout() - - SubscriptionCacheWrapper.shared.clear() PushNotificationManager.shared.clearRegistrationCache() diff --git a/iosApp/iosApp/iOSApp.swift b/iosApp/iosApp/iOSApp.swift index c0eef8c..a1862e3 100644 --- a/iosApp/iosApp/iOSApp.swift +++ b/iosApp/iosApp/iOSApp.swift @@ -45,8 +45,8 @@ struct iOSApp: App { TokenStorage.shared.initialize(manager: TokenManager.Companion.shared.getInstance()) if !UITestRuntime.isEnabled { - // Initialize PostHog Analytics - PostHogAnalytics.shared.initialize() + // Initialize PostHog Analytics (must use Swift AnalyticsManager, not the Kotlin stub) + AnalyticsManager.shared.configure() } // Initialize lookups at app start (public endpoints, no auth required)