From 148a301d6ca26cfed516a6185c127177248cf7d0 Mon Sep 17 00:00:00 2001 From: alexandrev-tibco Date: Tue, 21 Jul 2026 09:19:50 +0200 Subject: [PATCH] =?UTF-8?q?2.0:=20analytics=20=E2=80=94=20log=20onboarding?= =?UTF-8?q?=20step=20as=20String=20+=20step=5Fname=20for=20GA4=20drop-off?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GA4 text custom dimensions do not capture numeric params (step showed as "(not set)"). Log step as String and add a readable step_name so the onboarding drop-off is queryable. Registered source/environment/step_name custom dimensions in the GA4 property to match. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01Df9kZEUMXPLn4Kb9Zx1f5o --- MealMood/Services/AnalyticsService.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/MealMood/Services/AnalyticsService.swift b/MealMood/Services/AnalyticsService.swift index 5394799..df87efc 100644 --- a/MealMood/Services/AnalyticsService.swift +++ b/MealMood/Services/AnalyticsService.swift @@ -107,8 +107,21 @@ enum AnalyticsService { logEvent(AnalyticsEvent.onboardingCompleted, parameters: ["dish_count": dishCount]) } + // Human-readable names for each onboarding step, indexed by step number. + // Keep in sync with the OnboardingView step order. + private static let onboardingStepNames = [ + "0_welcome", "1_meal_windows", "2_weekends", + "3_calendar", "4_first_dishes", "5_paywall" + ] + static func logOnboardingStepViewed(step: Int) { - logEvent(AnalyticsEvent.onboardingStepViewed, parameters: ["step": step]) + // GA4 text custom dimensions do not capture numeric params (they show as + // "(not set)"). Log the step as a String so the drop-off is queryable. + let name = step >= 0 && step < onboardingStepNames.count ? onboardingStepNames[step] : "\(step)" + logEvent(AnalyticsEvent.onboardingStepViewed, parameters: [ + "step": "\(step)", + "step_name": name + ]) } static func logAutoAssignUsed(filledSlots: Int, unfilledSlots: Int) {