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>
59 lines
1.3 KiB
Swift
59 lines
1.3 KiB
Swift
//
|
|
// DataControllerUPDATE.swift
|
|
// Feels
|
|
//
|
|
// SwiftData UPDATE operations.
|
|
//
|
|
|
|
import SwiftData
|
|
import Foundation
|
|
|
|
extension DataController {
|
|
@discardableResult
|
|
func update(entryDate: Date, withMood mood: Mood) -> Bool {
|
|
guard let entry = getEntry(byDate: entryDate) else {
|
|
return false
|
|
}
|
|
|
|
entry.moodValue = mood.rawValue
|
|
saveAndRunDataListeners()
|
|
|
|
AnalyticsManager.shared.track(.moodUpdated(mood: mood.rawValue))
|
|
return true
|
|
}
|
|
|
|
// MARK: - Notes
|
|
|
|
@discardableResult
|
|
func updateNotes(forDate date: Date, notes: String?) -> Bool {
|
|
guard let entry = getEntry(byDate: date) else {
|
|
return false
|
|
}
|
|
|
|
entry.notes = notes
|
|
saveAndRunDataListeners()
|
|
|
|
AnalyticsManager.shared.track(.noteUpdated(characterCount: (notes ?? "").count))
|
|
return true
|
|
}
|
|
|
|
// MARK: - Photo
|
|
|
|
@discardableResult
|
|
func updatePhoto(forDate date: Date, photoID: UUID?) -> Bool {
|
|
guard let entry = getEntry(byDate: date) else {
|
|
return false
|
|
}
|
|
|
|
entry.photoID = photoID
|
|
saveAndRunDataListeners()
|
|
|
|
if photoID != nil {
|
|
AnalyticsManager.shared.track(.photoAdded)
|
|
} else {
|
|
AnalyticsManager.shared.track(.photoDeleted)
|
|
}
|
|
return true
|
|
}
|
|
}
|