feat(client/analytics): GA4 funnel instrumentation + unified home CTA

Add Firebase Analytics (GA4) funnel tracking to client_app:
- AnalyticsService typed wrapper (enum-gated, no PII) + analyticsProvider
- FirebaseAnalyticsObserver on GoRouter (screen_name via nameExtractor)
- user_id = customer UUID, user_type property, set on auth resolve/upgrade
- funnel events: curhat_start, curhat_repeat_start, auth_*, onboarding_usp_view,
  payment_view, payment_method_select, payment_started, pairing_matched/no_bestie
- bottom-sheet events: verif_choice_view/select, bestie_choice_view/select,
  extension_offer_view, chat_extension_requested
- payment_started carries app_instance_id + ga_session_id in the
  /payment-requests body for future server-side stitching (backend ignores)
- curhat_mode_pick screen name disambiguates the chat/call mode picker
  (/payment/method-pick) from the payment-channel picker (/payment/method)
- unify both home CTAs to "Aku Mau Curhat"

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-02 21:57:26 +08:00
parent 76d74aa7b5
commit eeb4ea38fc
25 changed files with 594 additions and 23 deletions

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import '../../../core/analytics/analytics_service.dart';
import '../../../core/theme/halo_tokens.dart';
import '../../../core/theme/widgets/widgets.dart';
import '../usp_seen_provider.dart';
@@ -11,11 +12,30 @@ import '../usp_seen_provider.dart';
///
/// `verified` ➞ USP → OTP (`/auth/register`).
/// `anonymous` ➞ USP → `/payment/method-pick`.
class UspScreen extends ConsumerWidget {
class UspScreen extends ConsumerStatefulWidget {
final bool verified;
const UspScreen({super.key, required this.verified});
@override
ConsumerState<UspScreen> createState() => _UspScreenState();
}
class _UspScreenState extends ConsumerState<UspScreen> {
@override
void initState() {
super.initState();
// Activation funnel step 7 — fire on view (not teardown). One-shot:
// initState runs once per screen instance.
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted) return;
// ignore: discarded_futures
ref
.read(analyticsProvider)
.logOnboardingUspView(verified: widget.verified);
});
}
static const _cards = [
_UspCard(
icon: Icons.bolt_outlined,
@@ -40,7 +60,7 @@ class UspScreen extends ConsumerWidget {
];
@override
Widget build(BuildContext context, WidgetRef ref) {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Padding(
@@ -94,7 +114,7 @@ class UspScreen extends ConsumerWidget {
HaloButton(
label: 'aku ngerti, lanjut',
fullWidth: true,
onPressed: () => _onContinue(context, ref),
onPressed: () => _onContinue(context),
),
],
),
@@ -103,12 +123,12 @@ class UspScreen extends ConsumerWidget {
);
}
Future<void> _onContinue(BuildContext context, WidgetRef ref) async {
Future<void> _onContinue(BuildContext context) async {
// Persist the local + server flag before leaving — next time the user
// hits VerifChoice, this screen is skipped.
await ref.read(uspSeenProvider.notifier).markSeen();
if (!context.mounted) return;
if (verified) {
if (widget.verified) {
context.push('/auth/register');
} else {
context.push('/payment/method-pick');