mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 11:33:34 +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/firebase_analytics.dart';
|
||||||
import 'package:firebase_analytics/observer.dart';
|
import 'package:firebase_analytics/observer.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -25,6 +26,17 @@ class JournalApp extends StatelessWidget {
|
|||||||
var remoteGitRepoSubFolder = pref.getString("remoteGitRepoSubFolder") ?? "";
|
var remoteGitRepoSubFolder = pref.getString("remoteGitRepoSubFolder") ?? "";
|
||||||
var onBoardingCompleted = pref.getBool("onBoardingCompleted") ?? false;
|
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.isInDebugMode) {
|
||||||
if (JournalApp.analytics.android != null) {
|
if (JournalApp.analytics.android != null) {
|
||||||
JournalApp.analytics.android.setAnalyticsCollectionEnabled(false);
|
JournalApp.analytics.android.setAnalyticsCollectionEnabled(false);
|
||||||
@ -62,12 +74,7 @@ class JournalApp extends StatelessWidget {
|
|||||||
static FirebaseAnalyticsObserver observer =
|
static FirebaseAnalyticsObserver observer =
|
||||||
FirebaseAnalyticsObserver(analytics: analytics);
|
FirebaseAnalyticsObserver(analytics: analytics);
|
||||||
|
|
||||||
static bool get isInDebugMode {
|
static bool isInDebugMode = false;
|
||||||
bool inDebugMode = false;
|
|
||||||
assert(inDebugMode = true);
|
|
||||||
return inDebugMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SharedPreferences preferences;
|
static SharedPreferences preferences;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -87,6 +87,13 @@ packages:
|
|||||||
url: "https://github.com/MarkOSullivan94/dart_config.git"
|
url: "https://github.com/MarkOSullivan94/dart_config.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.5.0"
|
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:
|
dots_indicator:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -19,6 +19,7 @@ dependencies:
|
|||||||
badges: ^0.0.6
|
badges: ^0.0.6
|
||||||
share: ^0.6.0+1
|
share: ^0.6.0+1
|
||||||
launch_review: ^1.0.1
|
launch_review: ^1.0.1
|
||||||
|
device_info: ^0.4.0+1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_launcher_icons: "^0.7.0"
|
flutter_launcher_icons: "^0.7.0"
|
||||||
|
Reference in New Issue
Block a user