feat(analytics): port SessionJourney tracking from GardenBuddy (v1.12.0+16)
Rolls the session/journey/friction tracking module out to M8Chat app2, per plan ancient-petting-hejlsberg.md §5 step 4. Same pattern as GardenBuddy's same-day port: SessionJourney.init() wired after WidgetsFlutterBinding. ensureInitialized() and after the existing FlutterError.onError / PlatformDispatcher.instance.onError handlers, which it chains rather than replaces. SessionJourneyNavigatorObserver registered on the GoRouter instance; SessionJourneyGestureLayer wraps MaterialApp.router for rage-tap detection. This repo has no shared offline-cache module like GardenBuddy's core/offline/, so persistence is a small scoped sj_local_store.dart using the package:web dependency already present in the repo (localStorage on web, in-memory fallback for the test VM), rather than adding a new package. app_key m8chat.au-app was reserved today in track.php v2.0.1's allowed_sites/allowed_origins for https://app2.m8chat.au, confirmed by grep before use. Verified live: build deployed to app2.m8chat.au (md5-matched), Playwright navigation produced real session/visitor/screen_view rows in admin_flutterstats with app_key=m8chat.au-app, nginx logs show no 5xx and no real visitor served a broken build during the test window.
This commit is contained in:
+16
-2
@@ -1,5 +1,11 @@
|
||||
// Version: 1.2.0 | Created: 2026-04-01 | Updated: 2026-04-27
|
||||
// Version: 1.3.0 | Created: 2026-04-01 | Updated: 2026-09-25
|
||||
// Application entry point.
|
||||
// v1.3.0: wires SessionJourney (session/journey/friction tracking, ported
|
||||
// from the WordPress sites per plan ancient-petting-hejlsberg.md §3/§5).
|
||||
// WidgetsFlutterBinding.ensureInitialized() stays the literal first line —
|
||||
// calling SessionJourney.init() before it crashes the release web build
|
||||
// with a null-check error (found and fixed on GardenBuddy the same day,
|
||||
// 2026-09-25 — not repeating that mistake here).
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
@@ -9,6 +15,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
|
||||
import 'app/app.dart';
|
||||
import 'core/analytics/session_journey.dart';
|
||||
import 'core/push/web_push_service.dart';
|
||||
|
||||
void main() async {
|
||||
@@ -17,7 +24,9 @@ void main() async {
|
||||
// Check Olm availability — this prints to the browser console.
|
||||
try {
|
||||
await olm.init();
|
||||
debugPrint('[M8Chat] Olm initialized successfully: ${olm.get_library_version()}');
|
||||
debugPrint(
|
||||
'[M8Chat] Olm initialized successfully: ${olm.get_library_version()}',
|
||||
);
|
||||
} catch (e) {
|
||||
debugPrint('[M8Chat] Olm NOT available: $e');
|
||||
}
|
||||
@@ -41,5 +50,10 @@ void main() async {
|
||||
return true; // returning true marks the error as handled
|
||||
};
|
||||
|
||||
// SessionJourney.init() runs AFTER the two handlers above so it CHAINS to
|
||||
// them (captures them as "previous", calls them after its own reporting)
|
||||
// rather than replacing them. See session_journey.dart's header.
|
||||
SessionJourney.init(appVersion: '1.12.0');
|
||||
|
||||
runApp(const ProviderScope(child: M8ChatApp()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user