mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 03:19:11 +08:00
Consider emulated devices to be debug devices
So do not run analytics on them.
This commit is contained in:
19
lib/app.dart
19
lib/app.dart
@ -1,3 +1,4 @@
|
||||
import 'package:device_info/device_info.dart';
|
||||
import 'package:firebase_analytics/firebase_analytics.dart';
|
||||
import 'package:firebase_analytics/observer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -25,6 +26,17 @@ class JournalApp extends StatelessWidget {
|
||||
var remoteGitRepoSubFolder = pref.getString("remoteGitRepoSubFolder") ?? "";
|
||||
var onBoardingCompleted = pref.getBool("onBoardingCompleted") ?? false;
|
||||
|
||||
//
|
||||
// Check if in debugMode or not a real device
|
||||
//
|
||||
assert(JournalApp.isInDebugMode = true);
|
||||
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
||||
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
|
||||
if (androidInfo.isPhysicalDevice == false) {
|
||||
print("Not running in a physcial device");
|
||||
JournalApp.isInDebugMode = true;
|
||||
}
|
||||
|
||||
if (JournalApp.isInDebugMode) {
|
||||
if (JournalApp.analytics.android != null) {
|
||||
JournalApp.analytics.android.setAnalyticsCollectionEnabled(false);
|
||||
@ -62,12 +74,7 @@ class JournalApp extends StatelessWidget {
|
||||
static FirebaseAnalyticsObserver observer =
|
||||
FirebaseAnalyticsObserver(analytics: analytics);
|
||||
|
||||
static bool get isInDebugMode {
|
||||
bool inDebugMode = false;
|
||||
assert(inDebugMode = true);
|
||||
return inDebugMode;
|
||||
}
|
||||
|
||||
static bool isInDebugMode = false;
|
||||
static SharedPreferences preferences;
|
||||
|
||||
@override
|
||||
|
@ -87,6 +87,13 @@ packages:
|
||||
url: "https://github.com/MarkOSullivan94/dart_config.git"
|
||||
source: git
|
||||
version: "0.5.0"
|
||||
device_info:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: device_info
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.0+1"
|
||||
dots_indicator:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -19,6 +19,7 @@ dependencies:
|
||||
badges: ^0.0.6
|
||||
share: ^0.6.0+1
|
||||
launch_review: ^1.0.1
|
||||
device_info: ^0.4.0+1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_launcher_icons: "^0.7.0"
|
||||
|
Reference in New Issue
Block a user