6ba71e6341
The exact-copy-from-previous-week action already existed but was buried in the magic-wand long-press context menu. Expose it as a visible secondary button on the auto-assign banner (shown only when the previous week actually has a menu), so users landing on a fresh week can one-tap copy last week's plan and then tweak it. Confirms before overwriting a week that already has dishes. - Extract requestCopyPreviousWeek() shared by the menu and the banner. - Add week_copied_previous analytics (copied_slots + source: empty_banner|menu). - Reuses the existing localized home_copy_previous_week string (all 6 languages). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BkanrydYtrme8wipTzWssG
164 lines
5.0 KiB
Swift
164 lines
5.0 KiB
Swift
import FirebaseAnalytics
|
|
|
|
enum AnalyticsEvent {
|
|
// Onboarding
|
|
static let onboardingCompleted = "onboarding_completed"
|
|
|
|
// Dishes
|
|
static let dishAdded = "dish_added"
|
|
static let dishDeleted = "dish_deleted"
|
|
|
|
// Planner
|
|
static let mealAssigned = "meal_assigned"
|
|
static let mealCleared = "meal_cleared"
|
|
static let weekReset = "week_reset"
|
|
static let weekPlanShared = "week_plan_shared"
|
|
|
|
// Premium
|
|
static let premiumUpgradeTapped = "premium_upgrade_tapped"
|
|
static let premiumPurchased = "premium_purchased"
|
|
static let premiumRestored = "premium_restored"
|
|
|
|
// Planner
|
|
static let autoAssignUsed = "auto_assign_used"
|
|
static let weekCopiedPrevious = "week_copied_previous"
|
|
|
|
// Onboarding
|
|
static let onboardingStepViewed = "onboarding_step_viewed"
|
|
|
|
// Settings
|
|
static let iCloudSyncToggled = "icloud_sync_toggled"
|
|
static let notificationsToggled = "notifications_toggled"
|
|
static let languageChanged = "language_changed"
|
|
|
|
// Stats
|
|
static let statsViewed = "stats_viewed"
|
|
|
|
// Feedback loop
|
|
static let weekRated = "week_rated"
|
|
|
|
// Conversion funnel (1.1.5)
|
|
static let paywallViewed = "paywall_viewed"
|
|
static let paywallDismissed = "paywall_dismissed"
|
|
static let dishLimitHit = "dish_limit_hit"
|
|
static let weekLimitHit = "week_limit_hit"
|
|
static let freeTrialStarted = "free_trial_started"
|
|
}
|
|
|
|
enum AnalyticsService {
|
|
static func logEvent(_ name: String, parameters: [String: Any]? = nil) {
|
|
Analytics.logEvent(name, parameters: parameters)
|
|
}
|
|
|
|
static func logScreenView(_ screenName: String) {
|
|
Analytics.logEvent(AnalyticsEventScreenView, parameters: [
|
|
AnalyticsParameterScreenName: screenName,
|
|
AnalyticsParameterScreenClass: screenName
|
|
])
|
|
}
|
|
|
|
// MARK: - Convenience methods
|
|
|
|
static func logDishAdded(tagCount: Int, source: String = "editor") {
|
|
logEvent(AnalyticsEvent.dishAdded, parameters: [
|
|
"tag_count": tagCount,
|
|
"source": source
|
|
])
|
|
}
|
|
|
|
static func logDishDeleted() {
|
|
logEvent(AnalyticsEvent.dishDeleted)
|
|
}
|
|
|
|
static func logMealAssigned() {
|
|
logEvent(AnalyticsEvent.mealAssigned)
|
|
}
|
|
|
|
static func logMealCleared() {
|
|
logEvent(AnalyticsEvent.mealCleared)
|
|
}
|
|
|
|
static func logWeekReset() {
|
|
logEvent(AnalyticsEvent.weekReset)
|
|
}
|
|
|
|
static func logWeekPlanShared(format: String) {
|
|
logEvent(AnalyticsEvent.weekPlanShared, parameters: ["format": format])
|
|
}
|
|
|
|
static func logPremiumUpgradeTapped(source: String) {
|
|
logEvent(AnalyticsEvent.premiumUpgradeTapped, parameters: ["source": source])
|
|
}
|
|
|
|
static func logPremiumPurchased(environment: String = "unknown") {
|
|
logEvent(AnalyticsEvent.premiumPurchased, parameters: ["environment": environment])
|
|
}
|
|
|
|
static func logPremiumRestored() {
|
|
logEvent(AnalyticsEvent.premiumRestored)
|
|
}
|
|
|
|
static func logOnboardingCompleted(dishCount: Int) {
|
|
logEvent(AnalyticsEvent.onboardingCompleted, parameters: ["dish_count": dishCount])
|
|
}
|
|
|
|
static func logOnboardingStepViewed(step: Int) {
|
|
logEvent(AnalyticsEvent.onboardingStepViewed, parameters: ["step": step])
|
|
}
|
|
|
|
static func logAutoAssignUsed(filledSlots: Int, unfilledSlots: Int) {
|
|
logEvent(AnalyticsEvent.autoAssignUsed, parameters: [
|
|
"filled_slots": filledSlots,
|
|
"unfilled_slots": unfilledSlots
|
|
])
|
|
}
|
|
|
|
static func logWeekCopiedPrevious(copiedSlots: Int, source: String) {
|
|
logEvent(AnalyticsEvent.weekCopiedPrevious, parameters: [
|
|
"copied_slots": copiedSlots,
|
|
"source": source
|
|
])
|
|
}
|
|
|
|
static func logICloudSyncToggled(enabled: Bool) {
|
|
logEvent(AnalyticsEvent.iCloudSyncToggled, parameters: ["enabled": enabled])
|
|
}
|
|
|
|
static func logNotificationsToggled(enabled: Bool) {
|
|
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])
|
|
}
|
|
|
|
static func logPaywallViewed(source: String) {
|
|
logEvent(AnalyticsEvent.paywallViewed, parameters: ["source": source])
|
|
}
|
|
|
|
static func logPaywallDismissed(source: String, secondsOnScreen: Int, didConvert: Bool) {
|
|
logEvent(AnalyticsEvent.paywallDismissed, parameters: [
|
|
"source": source,
|
|
"seconds_on_screen": secondsOnScreen,
|
|
"did_convert": didConvert
|
|
])
|
|
}
|
|
|
|
static func logDishLimitHit() {
|
|
logEvent(AnalyticsEvent.dishLimitHit)
|
|
}
|
|
|
|
static func logWeekLimitHit() {
|
|
logEvent(AnalyticsEvent.weekLimitHit)
|
|
}
|
|
|
|
static func logFreeTrialStarted(plan: String) {
|
|
logEvent(AnalyticsEvent.freeTrialStarted, parameters: ["plan": plan])
|
|
}
|
|
}
|