Screen-view analytics
Goal: send a screen-view event whenever the active screen changes — without
digging through raw Route<dynamic> objects.
Pass onNavigation: to raku_router. It reports the active leaf as a typed
RakuRoute after every change that moves it (push, pop, tab switch, browser
back/forward), once per change, and not for the initial route.
raku( initial: const Feed(), routes: [...], onNavigation: (route) { analytics.logScreenView(screenName: route.name);
// Or switch on the typed route for richer events: switch (route) { case Note(:final id): analytics.log('note_opened', {'id': id}); case _: break; } },);Notes
route.namedefaults to the type name (Note,Feed); overridenameon the route for a custom label.- The initial route isn’t reported (you already have
initial— log it once at startup if you need it). - Need the raw framework
Routeobjects (durations, modal barriers) or a drop-in likeFirebaseAnalyticsObserver? Passobservers:toraku(...)— a factory that attaches freshNavigatorObservers to the root and each tab branch. See Observability.