Replace EventLogger with typed AnalyticsManager using PostHog

Complete analytics overhaul: delete EventLogger.swift, create Analytics.swift
with typed event enum (~45 events), screen tracking, super properties
(theme, icon pack, voting layout, etc.), session replay with kill switch,
autocapture, and network telemetry. Replace all 99 call sites across 38 files
with compiler-enforced typed events in object_action naming convention.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-02-10 15:12:33 -06:00
parent a08d0d33c0
commit e0330dbc8d
38 changed files with 1048 additions and 202 deletions

View File

@@ -26,7 +26,7 @@ extension DataController {
)
modelContext.insert(entry)
EventLogger.log(event: "add_entry", withData: ["entry_type": entryType.rawValue])
AnalyticsManager.shared.track(.moodLogged(mood: mood.rawValue, entryType: String(describing: entryType)))
saveAndRunDataListeners()
}
@@ -69,7 +69,7 @@ extension DataController {
// Single save and listener notification at the end
saveAndRunDataListeners()
EventLogger.log(event: "filled_in_missing_entries", withData: ["count": missing.count])
AnalyticsManager.shared.track(.missingEntriesFilled(count: missing.count))
}
func fixWrongWeekdays() {
@@ -83,6 +83,5 @@ extension DataController {
func removeNoForDates() {
// Note: With SwiftData's non-optional forDate, this is essentially a no-op
// Keeping for API compatibility
EventLogger.log(event: "removed_entry_no_for_date", withData: ["count": 0])
}
}

View File

@@ -18,7 +18,7 @@ extension DataController {
entry.moodValue = mood.rawValue
saveAndRunDataListeners()
EventLogger.log(event: "update_entry")
AnalyticsManager.shared.track(.moodUpdated(mood: mood.rawValue))
return true
}
@@ -33,7 +33,7 @@ extension DataController {
entry.notes = notes
saveAndRunDataListeners()
EventLogger.log(event: "update_notes")
AnalyticsManager.shared.track(.noteUpdated(characterCount: (notes ?? "").count))
return true
}
@@ -48,7 +48,11 @@ extension DataController {
entry.photoID = photoID
saveAndRunDataListeners()
EventLogger.log(event: "update_photo")
if photoID != nil {
AnalyticsManager.shared.track(.photoAdded)
} else {
AnalyticsManager.shared.track(.photoDeleted)
}
return true
}
}