-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Context
I am using go_router and go_router_builder to use typed GoRoutes as described in the docs.
dependencies:
...
go_router: ^6.0.1
...
dev_dependencies:
...
build_runner: ^2.3.3
go_router_builder: ^1.0.16
...
I have set up Firebase/Google Analytics with the package firebase_analytics as described in their docs and have configured an observer as an FirebaseAnalyticsObserver:
@riverpod
GoRouter router(RouterRef ref) {
final notifier = ref.watch(stateAwareRouterNotifierProvider.notifier);
return GoRouter(
navigatorKey: _rootNavigatorKey,
refreshListenable: notifier,
debugLogDiagnostics: kDebugMode,
errorBuilder: (BuildContext context, GoRouterState state) => ErrorRoute(
error: state.error,
).build(context, state),
initialLocation: HomeScreen.routeName,
redirect: notifier.redirect,
routes: [
ShellRoute(
navigatorKey: _shellNavigatorKey,
builder: (BuildContext context, GoRouterState state, Widget child) {
return AppScaffold(child: child);
},
routes: notifier.routes,
),
],
observers: [_firebaseAnalyticsObserver()],
);
}
_firebaseAnalyticsObserver() =>
FirebaseAnalyticsObserver(analytics: FirebaseAnalytics.instance);
Problem
As noted in Firebase Analytics docs, this is working and producing analytics events. However, I see that screen_names are blank. Previously, when I have used Firebase Analytics with Flutter apps, not using typed GoRoutes, the screen names were captured correctly too.
It looks like FirebaseAnalyticsObserver tries to parse the screen name from the RouteSettings.name:
- https://github.com/firebase/flutterfire/blob/master/packages/firebase_analytics/firebase_analytics/lib/observer.dart#L15
- https://github.com/firebase/flutterfire/blob/master/packages/firebase_analytics/firebase_analytics/lib/observer.dart#L84
On debugging I see that the RouteSettings object has name="" when using typed GoRoutes.
Is there something I can do to populate the names?