1.1.5: add analytics for stats_viewed and week_rated events
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,12 @@ enum AnalyticsEvent {
|
|||||||
static let iCloudSyncToggled = "icloud_sync_toggled"
|
static let iCloudSyncToggled = "icloud_sync_toggled"
|
||||||
static let notificationsToggled = "notifications_toggled"
|
static let notificationsToggled = "notifications_toggled"
|
||||||
static let languageChanged = "language_changed"
|
static let languageChanged = "language_changed"
|
||||||
|
|
||||||
|
// Stats
|
||||||
|
static let statsViewed = "stats_viewed"
|
||||||
|
|
||||||
|
// Feedback loop
|
||||||
|
static let weekRated = "week_rated"
|
||||||
}
|
}
|
||||||
|
|
||||||
enum AnalyticsService {
|
enum AnalyticsService {
|
||||||
@@ -103,4 +109,13 @@ enum AnalyticsService {
|
|||||||
static func logNotificationsToggled(enabled: Bool) {
|
static func logNotificationsToggled(enabled: Bool) {
|
||||||
logEvent(AnalyticsEvent.notificationsToggled, parameters: ["enabled": enabled])
|
logEvent(AnalyticsEvent.notificationsToggled, parameters: ["enabled": enabled])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func logStatsViewed() {
|
||||||
|
logEvent(AnalyticsEvent.statsViewed)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func logWeekRated(rating: Int) {
|
||||||
|
let value = rating == 1 ? "liked" : rating == -1 ? "disliked" : "cleared"
|
||||||
|
logEvent(AnalyticsEvent.weekRated, parameters: ["rating": value])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ final class HomeViewModel: ObservableObject {
|
|||||||
func rateWeek(plan: WeekPlan, rating: Int) {
|
func rateWeek(plan: WeekPlan, rating: Int) {
|
||||||
plan.userRating = rating
|
plan.userRating = rating
|
||||||
plan.updatedAt = Date()
|
plan.updatedAt = Date()
|
||||||
|
AnalyticsService.logWeekRated(rating: rating)
|
||||||
HapticManager.shared.impact(style: .light)
|
HapticManager.shared.impact(style: .light)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ struct StatsView: View {
|
|||||||
.padding(.vertical, 20)
|
.padding(.vertical, 20)
|
||||||
}
|
}
|
||||||
.background(Color.mealMoodBackground.ignoresSafeArea())
|
.background(Color.mealMoodBackground.ignoresSafeArea())
|
||||||
|
.onAppear { AnalyticsService.logStatsViewed() }
|
||||||
.navigationTitle("stats_title")
|
.navigationTitle("stats_title")
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.toolbar {
|
.toolbar {
|
||||||
|
|||||||
Reference in New Issue
Block a user