|
@@ -16,6 +16,7 @@ import 'package:path_provider/path_provider.dart';
|
|
import 'package:photos/core/error-reporting/tunneled_transport.dart';
|
|
import 'package:photos/core/error-reporting/tunneled_transport.dart';
|
|
import 'package:photos/models/typedefs.dart';
|
|
import 'package:photos/models/typedefs.dart';
|
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
|
|
|
+import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
|
extension SuperString on String {
|
|
extension SuperString on String {
|
|
Iterable<String> chunked(int chunkSize) sync* {
|
|
Iterable<String> chunked(int chunkSize) sync* {
|
|
@@ -141,11 +142,16 @@ class SuperLogging {
|
|
/// The current super logging configuration
|
|
/// The current super logging configuration
|
|
static late LogConfig config;
|
|
static late LogConfig config;
|
|
|
|
|
|
|
|
+ static late SharedPreferences _preferences;
|
|
|
|
+
|
|
|
|
+ static const keyShouldReportCrashes = "should_report_crashes";
|
|
|
|
+
|
|
static Future<void> main([LogConfig? appConfig]) async {
|
|
static Future<void> main([LogConfig? appConfig]) async {
|
|
appConfig ??= LogConfig();
|
|
appConfig ??= LogConfig();
|
|
SuperLogging.config = appConfig;
|
|
SuperLogging.config = appConfig;
|
|
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
+ _preferences = await SharedPreferences.getInstance();
|
|
|
|
|
|
appVersion ??= await getAppVersion();
|
|
appVersion ??= await getAppVersion();
|
|
final isFDroidClient = await isFDroidBuild();
|
|
final isFDroidClient = await isFDroidBuild();
|
|
@@ -155,7 +161,10 @@ class SuperLogging {
|
|
}
|
|
}
|
|
|
|
|
|
final enable = appConfig.enableInDebugMode || kReleaseMode;
|
|
final enable = appConfig.enableInDebugMode || kReleaseMode;
|
|
- sentryIsEnabled = enable && appConfig.sentryDsn != null && !isFDroidClient;
|
|
|
|
|
|
+ sentryIsEnabled = enable &&
|
|
|
|
+ appConfig.sentryDsn != null &&
|
|
|
|
+ !isFDroidClient &&
|
|
|
|
+ shouldReportCrashes();
|
|
fileIsEnabled = enable && appConfig.logDirPath != null;
|
|
fileIsEnabled = enable && appConfig.logDirPath != null;
|
|
|
|
|
|
if (fileIsEnabled) {
|
|
if (fileIsEnabled) {
|
|
@@ -307,6 +316,18 @@ class SuperLogging {
|
|
sentryQueueControl.add(error);
|
|
sentryQueueControl.add(error);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ static bool shouldReportCrashes() {
|
|
|
|
+ if (_preferences.containsKey(keyShouldReportCrashes)) {
|
|
|
|
+ return _preferences.getBool(keyShouldReportCrashes)!;
|
|
|
|
+ } else {
|
|
|
|
+ return true; // Report crashes by default
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static Future<void> setShouldReportCrashes(bool value) {
|
|
|
|
+ return _preferences.setBool(keyShouldReportCrashes, value);
|
|
|
|
+ }
|
|
|
|
+
|
|
/// The log file currently in use.
|
|
/// The log file currently in use.
|
|
static File? logFile;
|
|
static File? logFile;
|
|
|
|
|