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>
89 lines
3.2 KiB
Dart
89 lines
3.2 KiB
Dart
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/pairing/pairing_notifier.dart';
|
|
import '../../payment/state/payment_draft_provider.dart';
|
|
|
|
/// Terminal failed-pairing screen.
|
|
///
|
|
/// Reached when the pairing notifier transitions to [PairingFailedData]
|
|
/// (terminal — payment session is `failed_delivery` server-side, audit row
|
|
/// recorded). Copy is intentionally identical regardless of `cause_tag` for
|
|
/// now (the design pass will revise this later).
|
|
///
|
|
/// Single CTA "Kembali ke beranda" resets the pairing notifier and routes
|
|
/// home. PopScope falls back to home for deep-link entry per project memory
|
|
/// rule "Deep-link pop fallback".
|
|
class NoBestieScreen extends ConsumerStatefulWidget {
|
|
const NoBestieScreen({super.key});
|
|
|
|
@override
|
|
ConsumerState<NoBestieScreen> createState() => _NoBestieScreenState();
|
|
}
|
|
|
|
class _NoBestieScreenState extends ConsumerState<NoBestieScreen> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
// Funnel drop-off marker — pairing failed. A targeted-mitra draft means
|
|
// the repeat funnel; otherwise activation. Fire once on view.
|
|
final isRepeat =
|
|
ref.read(paymentDraftNotifierProvider).targetedMitraId != null;
|
|
// ignore: discarded_futures
|
|
ref.read(analyticsProvider).logPairingNoBestie(
|
|
funnel:
|
|
isRepeat ? AnalyticsFunnel.repeat : AnalyticsFunnel.activation,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return PopScope(
|
|
canPop: true,
|
|
onPopInvokedWithResult: (didPop, _) {
|
|
if (!didPop) return;
|
|
ref.read(pairingProvider.notifier).reset();
|
|
},
|
|
child: Scaffold(
|
|
body: SafeArea(
|
|
child: Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(32),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const Icon(Icons.sentiment_dissatisfied, size: 80, color: Colors.orange),
|
|
const SizedBox(height: 24),
|
|
const Text(
|
|
'Belum berhasil terhubung',
|
|
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
|
|
),
|
|
const SizedBox(height: 12),
|
|
const Text(
|
|
'Maaf, kami tidak bisa menemukan bestie untuk sesimu. '
|
|
'Tim kami akan menghubungimu segera.',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(fontSize: 16, color: Colors.grey),
|
|
),
|
|
const SizedBox(height: 48),
|
|
ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 14),
|
|
),
|
|
onPressed: () {
|
|
ref.read(pairingProvider.notifier).reset();
|
|
context.go('/home');
|
|
},
|
|
child: const Text('Kembali ke beranda'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|