mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-09-19 02:01:07 +08:00
Disable analytics in firebase test lab
I'm also keeping analytics disabled by default.
This commit is contained in:
@ -49,5 +49,6 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<meta-data android:name="google_analytics_adid_collection_enabled" android:value="false" />
|
<meta-data android:name="google_analytics_adid_collection_enabled" android:value="false" />
|
||||||
|
<meta-data android:name="firebase_analytics_collection_enabled" android:value="false" />
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package io.gitjournal.gitjournal;
|
package io.gitjournal.gitjournal;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
@ -38,7 +40,8 @@ public class MainActivity extends FlutterActivity implements MethodCallHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMethodCall(MethodCall call, Result result) {
|
public void onMethodCall(MethodCall call, Result result) {
|
||||||
final String filesDir = PathUtils.getFilesDir(getApplicationContext());
|
Context context = getApplicationContext();
|
||||||
|
final String filesDir = PathUtils.getFilesDir(context);
|
||||||
final String sshKeysLocation = filesDir + "/ssh";
|
final String sshKeysLocation = filesDir + "/ssh";
|
||||||
final String privateKeyPath = sshKeysLocation + "/id_rsa";
|
final String privateKeyPath = sshKeysLocation + "/id_rsa";
|
||||||
final String publicKeyPath = sshKeysLocation + "/id_rsa.pub";
|
final String publicKeyPath = sshKeysLocation + "/id_rsa.pub";
|
||||||
@ -242,6 +245,20 @@ public class MainActivity extends FlutterActivity implements MethodCallHandler {
|
|||||||
|
|
||||||
result.success(filePath);
|
result.success(filePath);
|
||||||
return;
|
return;
|
||||||
|
} else if (call.method.equals("shouldEnableAnalytics")) {
|
||||||
|
boolean shouldBe = true;
|
||||||
|
String testLabSetting =
|
||||||
|
Settings.System.getString(context.getContentResolver(), "firebase.test.lab");
|
||||||
|
if ("true".equals(testLabSetting)) {
|
||||||
|
shouldBe = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BuildConfig.DEBUG) {
|
||||||
|
shouldBe = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.success(shouldBe);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.notImplemented();
|
result.notImplemented();
|
||||||
|
43
lib/app.dart
43
lib/app.dart
@ -7,6 +7,7 @@ import 'package:journal/screens/home_screen.dart';
|
|||||||
import 'package:journal/screens/settings_screen.dart';
|
import 'package:journal/screens/settings_screen.dart';
|
||||||
import 'package:journal/settings.dart';
|
import 'package:journal/settings.dart';
|
||||||
import 'package:journal/state_container.dart';
|
import 'package:journal/state_container.dart';
|
||||||
|
import 'package:journal/utils.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
import 'screens/githostsetup_screens.dart';
|
import 'screens/githostsetup_screens.dart';
|
||||||
@ -35,24 +36,7 @@ class JournalApp extends StatelessWidget {
|
|||||||
print("onBoardingCompleted: $onBoardingCompleted");
|
print("onBoardingCompleted: $onBoardingCompleted");
|
||||||
print(" ------------------ ");
|
print(" ------------------ ");
|
||||||
|
|
||||||
//
|
_enableAnalyticsIfPossible();
|
||||||
// Check if in debugMode or not a real device
|
|
||||||
//
|
|
||||||
assert(JournalApp.isInDebugMode = true);
|
|
||||||
try {
|
|
||||||
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
|
||||||
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
|
|
||||||
if (androidInfo.isPhysicalDevice == false) {
|
|
||||||
print("Not running in a physcial device");
|
|
||||||
JournalApp.isInDebugMode = true;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
print(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (JournalApp.isInDebugMode) {
|
|
||||||
JournalApp.analytics.setAnalyticsCollectionEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (localGitRepoConfigured == false) {
|
if (localGitRepoConfigured == false) {
|
||||||
// FIXME: What about exceptions!
|
// FIXME: What about exceptions!
|
||||||
@ -81,6 +65,29 @@ class JournalApp extends StatelessWidget {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _enableAnalyticsIfPossible() async {
|
||||||
|
//
|
||||||
|
// Check if in debugMode or not a real device
|
||||||
|
//
|
||||||
|
assert(JournalApp.isInDebugMode = true);
|
||||||
|
try {
|
||||||
|
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
||||||
|
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
|
||||||
|
if (androidInfo.isPhysicalDevice == false) {
|
||||||
|
print("Not running in a physcial device");
|
||||||
|
JournalApp.isInDebugMode = true;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool should = (JournalApp.isInDebugMode == false);
|
||||||
|
should = should && (await shouldEnableAnalytics());
|
||||||
|
|
||||||
|
print("Analytics Collection: $should");
|
||||||
|
JournalApp.analytics.setAnalyticsCollectionEnabled(should);
|
||||||
|
}
|
||||||
|
|
||||||
static FirebaseAnalytics analytics = FirebaseAnalytics();
|
static FirebaseAnalytics analytics = FirebaseAnalytics();
|
||||||
static FirebaseAnalyticsObserver observer =
|
static FirebaseAnalyticsObserver observer =
|
||||||
FirebaseAnalyticsObserver(analytics: analytics);
|
FirebaseAnalyticsObserver(analytics: analytics);
|
||||||
|
@ -20,6 +20,12 @@ Future<String> getVersionString() async {
|
|||||||
return versionText;
|
return versionText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> shouldEnableAnalytics() async {
|
||||||
|
const _platform = const MethodChannel('gitjournal.io/git');
|
||||||
|
final bool result = await _platform.invokeMethod('shouldEnableAnalytics');
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// adb logcat
|
/// adb logcat
|
||||||
/// Returns the file path where the logs were dumped
|
/// Returns the file path where the logs were dumped
|
||||||
Future<String> dumpAppLogs() async {
|
Future<String> dumpAppLogs() async {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: journal
|
name: journal
|
||||||
description: A Journaling App Built on top of Git
|
description: A Journaling App Built on top of Git
|
||||||
version: 1.1.5+10
|
version: 1.1.6+10
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
Reference in New Issue
Block a user