mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +08:00
Replace FirebaseAnalyticsObserver with our own
This way we have the screen names in the debug log and diagnosing issues becomes easier. Also, this brings me closer to being able to drop Firebase Analytics.
This commit is contained in:
@ -151,10 +151,17 @@ void logEvent(Event event, {Map<String, String> parameters}) {
|
|||||||
Log.d("Event $event");
|
Log.d("Event $event");
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomRouteObserver extends RouteObserver<PageRoute<dynamic>> {
|
class AnalyticsRouteObserver extends RouteObserver<PageRoute<dynamic>> {
|
||||||
void _sendScreenView(PageRoute<dynamic> route) {
|
void _sendScreenView(PageRoute<dynamic> route) async {
|
||||||
final String screenName = route.settings.name;
|
final String screenName = route.settings.name;
|
||||||
assert(screenName != null, "Screen name is null $route");
|
assert(screenName != null, "Screen name is null $route");
|
||||||
|
|
||||||
|
Log.i("Screen: $screenName");
|
||||||
|
try {
|
||||||
|
await getAnalytics().firebase.setCurrentScreen(screenName: screenName);
|
||||||
|
} catch (e, stackTrace) {
|
||||||
|
Log.e("AnalyticsRouteObserver", ex: e, stacktrace: stackTrace);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -9,7 +9,6 @@ import 'package:device_info/device_info.dart';
|
|||||||
import 'package:dynamic_theme/dynamic_theme.dart';
|
import 'package:dynamic_theme/dynamic_theme.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:easy_localization_loader/easy_localization_loader.dart';
|
import 'package:easy_localization_loader/easy_localization_loader.dart';
|
||||||
import 'package:firebase_analytics/observer.dart';
|
|
||||||
import 'package:flutter_sentry/flutter_sentry.dart';
|
import 'package:flutter_sentry/flutter_sentry.dart';
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
@ -144,9 +143,6 @@ class JournalApp extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final analytics = Analytics();
|
static final analytics = Analytics();
|
||||||
static FirebaseAnalyticsObserver observer =
|
|
||||||
FirebaseAnalyticsObserver(analytics: analytics.firebase);
|
|
||||||
|
|
||||||
static bool isInDebugMode = false;
|
static bool isInDebugMode = false;
|
||||||
|
|
||||||
JournalApp(this.appState);
|
JournalApp(this.appState);
|
||||||
@ -305,8 +301,7 @@ class _JournalAppState extends State<JournalApp> {
|
|||||||
|
|
||||||
theme: themeData,
|
theme: themeData,
|
||||||
navigatorObservers: <NavigatorObserver>[
|
navigatorObservers: <NavigatorObserver>[
|
||||||
JournalApp.observer,
|
AnalyticsRouteObserver(),
|
||||||
CustomRouteObserver(),
|
|
||||||
],
|
],
|
||||||
initialRoute: initialRoute,
|
initialRoute: initialRoute,
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
|
Reference in New Issue
Block a user