Consider emulated devices to be debug devices

So do not run analytics on them.
This commit is contained in:
Vishesh Handa
2019-02-16 13:56:23 +01:00
parent 29c8da11fb
commit 40a12b8af1
3 changed files with 21 additions and 6 deletions

View File

@ -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

View File

@ -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:

View File

@ -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"