feat: add PostHog analytics with full event tracking across app
Integrate self-hosted PostHog (SPM) with AnalyticsManager singleton wrapping all SDK calls. Adds ~40 type-safe events covering trip planning, schedule, progress, IAP, settings, polls, export, and share flows. Includes session replay, autocapture, network telemetry, privacy opt-out toggle in Settings, and super properties (app version, device, pro status, selected sports). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,9 @@ final class SettingsViewModel {
|
||||
|
||||
var selectedTheme: AppTheme {
|
||||
didSet {
|
||||
let oldName = oldValue.displayName
|
||||
ThemeManager.shared.currentTheme = selectedTheme
|
||||
AnalyticsManager.shared.track(.themeChanged(from: oldName, to: selectedTheme.displayName))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +25,10 @@ final class SettingsViewModel {
|
||||
}
|
||||
|
||||
var maxDrivingHoursPerDay: Int {
|
||||
didSet { savePreferences() }
|
||||
didSet {
|
||||
savePreferences()
|
||||
AnalyticsManager.shared.track(.drivingHoursChanged(hours: maxDrivingHoursPerDay))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - App Info
|
||||
@@ -63,8 +68,10 @@ final class SettingsViewModel {
|
||||
// Don't allow removing all sports
|
||||
guard selectedSports.count > 1 else { return }
|
||||
selectedSports.remove(sport)
|
||||
AnalyticsManager.shared.track(.sportToggled(sport: sport.rawValue, enabled: false))
|
||||
} else {
|
||||
selectedSports.insert(sport)
|
||||
AnalyticsManager.shared.track(.sportToggled(sport: sport.rawValue, enabled: true))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +80,7 @@ final class SettingsViewModel {
|
||||
selectedSports = Set(Sport.supported)
|
||||
maxDrivingHoursPerDay = 8
|
||||
AppearanceManager.shared.currentMode = .system
|
||||
AnalyticsManager.shared.track(.settingsReset)
|
||||
}
|
||||
|
||||
// MARK: - Persistence
|
||||
|
||||
Reference in New Issue
Block a user