2.0: mostrar los dos ultimos pasos del onboarding (aha moment + paywall)

completeOnboarding escribia settings.onboardingCompleted al terminar el paso
de platos. Ese flag es el que ContentView observa para cambiar de OnboardingView
a HomeView, asi que el save destruia el flujo antes de que nextStep() pudiera
pintar el paso 5. WeekReadyStepView (el aha moment de la 1.2.0) y PaywallStepView
no se han visto nunca. GA4 lo confirma: 3 onboarding_completed en 28 dias y cero
eventos con step 5 o 6.

Se separa persistir los datos de marcar el onboarding como terminado:
completeOnboarding(markFinished:) commitea platos y plan sin tocar el flag, y el
nuevo finishOnboarding() lo escribe al salir del paywall. HomeView ya difiere su
prompt premium a la segunda sesion, asi que no hay paywall duplicado.

De paso, los nombres de paso en AnalyticsService estaban desalineados: el indice
5 decia "5_paywall" cuando el paso 5 es WeekReady, y el 6 no tenia nombre.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Ks8uUcMA9mjypVK7F2Pkt
This commit is contained in:
alexandrev-tibco
2026-08-05 20:53:10 +02:00
parent 10a3d8bf32
commit 3694297d4f
4 changed files with 97 additions and 6 deletions
+10 -3
View File
@@ -63,7 +63,9 @@ struct OnboardingView: View {
viewModel: viewModel,
tags: tags,
onFinish: {
_ = viewModel.completeOnboarding(context: context)
// Commit the data but leave onboarding on screen: the flag
// that dismisses it is written when the paywall step exits.
_ = viewModel.completeOnboarding(context: context, markFinished: false)
viewModel.autoFillFirstWeek(context: context)
viewModel.nextStep()
}
@@ -79,8 +81,8 @@ struct OnboardingView: View {
.tag(5)
PaywallStepView(
onSkip: { onComplete() },
onConverted: { onComplete() }
onSkip: { finishOnboarding() },
onConverted: { finishOnboarding() }
)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.tag(6)
@@ -100,6 +102,11 @@ struct OnboardingView: View {
}
}
private func finishOnboarding() {
viewModel.finishOnboarding(context: context)
onComplete()
}
private func ensureDefaultTagsIfNeeded() {
let descriptor = FetchDescriptor<Tag>()
if (try? context.fetch(descriptor))?.isEmpty ?? true {