mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-01 20:43:20 +08:00
Disable analytics in debug mode
Sadly we can only do this in Android, there doesn't seem to be a way to disable it on iOS. https://github.com/flutter/flutter/issues/21063
This commit is contained in:
@ -11,6 +11,12 @@ class JournalApp extends StatelessWidget {
|
||||
static FirebaseAnalyticsObserver observer =
|
||||
FirebaseAnalyticsObserver(analytics: analytics);
|
||||
|
||||
static bool get isInDebugMode {
|
||||
bool inDebugMode = false;
|
||||
assert(inDebugMode = true);
|
||||
return inDebugMode;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final stateContainer = StateContainer.of(context);
|
||||
@ -30,7 +36,7 @@ class JournalApp extends StatelessWidget {
|
||||
primaryColorDark: Color(0xFF338a3e),
|
||||
accentColor: Color(0xff6d4c41),
|
||||
),
|
||||
navigatorObservers: <NavigatorObserver>[observer],
|
||||
navigatorObservers: <NavigatorObserver>[JournalApp.observer],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,12 @@ Future runJournalApp() async {
|
||||
var pref = await SharedPreferences.getInstance();
|
||||
var onBoardingCompleted = pref.getBool("onBoardingCompleted") ?? false;
|
||||
|
||||
if (JournalApp.isInDebugMode) {
|
||||
if (JournalApp.analytics.android != null) {
|
||||
JournalApp.analytics.android.setAnalyticsCollectionEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
runApp(new StateContainer(
|
||||
onBoardingCompleted: onBoardingCompleted,
|
||||
child: JournalApp(),
|
||||
|
Reference in New Issue
Block a user