mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 13:08:42 +00:00
wrap whole main function into sentry
This commit is contained in:
parent
4ff42c93b7
commit
2a9414ae4f
5 changed files with 69 additions and 59 deletions
|
|
@ -4,6 +4,8 @@ import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:camera/camera.dart';
|
import 'package:camera/camera.dart';
|
||||||
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:path/path.dart';
|
import 'package:path/path.dart';
|
||||||
|
|
@ -27,29 +29,7 @@ import 'package:twonly/src/utils/log.dart';
|
||||||
import 'package:twonly/src/utils/storage.dart';
|
import 'package:twonly/src/utils/storage.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
SentryWidgetsFlutterBinding.ensureInitialized();
|
||||||
try {
|
|
||||||
await initFCMService();
|
|
||||||
} catch (e) {
|
|
||||||
Log.error('$e');
|
|
||||||
}
|
|
||||||
|
|
||||||
initLogger();
|
|
||||||
|
|
||||||
final user = await getUser();
|
|
||||||
if (user != null) {
|
|
||||||
gUser = user;
|
|
||||||
unawaited(performTwonlySafeBackup());
|
|
||||||
}
|
|
||||||
|
|
||||||
final settingsController = SettingsChangeProvider();
|
|
||||||
|
|
||||||
await settingsController.loadSettings();
|
|
||||||
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
|
||||||
|
|
||||||
unawaited(setupPushNotification());
|
|
||||||
|
|
||||||
gCameras = await availableCameras();
|
|
||||||
|
|
||||||
// try {
|
// try {
|
||||||
// File(join((await getApplicationSupportDirectory()).path, 'twonly.sqlite'))
|
// File(join((await getApplicationSupportDirectory()).path, 'twonly.sqlite'))
|
||||||
|
|
@ -60,44 +40,67 @@ void main() async {
|
||||||
// return u;
|
// return u;
|
||||||
// });
|
// });
|
||||||
|
|
||||||
apiService = ApiService();
|
final user = await getUser();
|
||||||
twonlyDB = TwonlyDB();
|
|
||||||
|
|
||||||
await initFileDownloader();
|
|
||||||
unawaited(finishStartedPreprocessing());
|
|
||||||
|
|
||||||
unawaited(MediaFileService.purgeTempFolder());
|
|
||||||
unawaited(createPushAvatars());
|
|
||||||
await twonlyDB.messagesDao.purgeMessageTable();
|
|
||||||
|
|
||||||
final providers = [
|
|
||||||
ChangeNotifierProvider(create: (_) => settingsController),
|
|
||||||
ChangeNotifierProvider(create: (_) => CustomChangeProvider()),
|
|
||||||
ChangeNotifierProvider(create: (_) => ImageEditorProvider()),
|
|
||||||
];
|
|
||||||
|
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
|
gUser = user;
|
||||||
|
|
||||||
if (user.allowErrorTrackingViaSentry) {
|
if (user.allowErrorTrackingViaSentry) {
|
||||||
globalAllowErrorTrackingViaSentry = true;
|
globalAllowErrorTrackingViaSentry = true;
|
||||||
return SentryFlutter.init(
|
await SentryFlutter.init(
|
||||||
(options) => options
|
(options) => options
|
||||||
..dsn =
|
..dsn =
|
||||||
'https://6b24a012c85144c9b522440a1d17d01c@glitchtip.twonly.eu/4'
|
'https://6b24a012c85144c9b522440a1d17d01c@glitchtip.twonly.eu/4'
|
||||||
..tracesSampleRate = 0.01
|
..tracesSampleRate = 0.1
|
||||||
..enableAutoSessionTracking = false,
|
..enableAutoSessionTracking = false,
|
||||||
appRunner: () => runApp(
|
|
||||||
MultiProvider(
|
|
||||||
providers: providers,
|
|
||||||
child: const App(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unawaited(performTwonlySafeBackup());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await initFCMService();
|
||||||
|
|
||||||
|
initLogger();
|
||||||
|
|
||||||
|
final settingsController = SettingsChangeProvider();
|
||||||
|
|
||||||
|
await settingsController.loadSettings();
|
||||||
|
await SystemChrome.setPreferredOrientations(
|
||||||
|
[DeviceOrientation.portraitUp],
|
||||||
|
);
|
||||||
|
|
||||||
|
unawaited(setupPushNotification());
|
||||||
|
|
||||||
|
gCameras = await availableCameras();
|
||||||
|
|
||||||
|
apiService = ApiService();
|
||||||
|
twonlyDB = TwonlyDB();
|
||||||
|
|
||||||
|
await twonlyDB.messagesDao.purgeMessageTable();
|
||||||
|
unawaited(MediaFileService.purgeTempFolder());
|
||||||
|
|
||||||
|
await initFileDownloader();
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
if ((await DeviceInfoPlugin().androidInfo).version.release == '9') {
|
||||||
|
Future.delayed(const Duration(seconds: 20), () {
|
||||||
|
unawaited(finishStartedPreprocessing());
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
unawaited(finishStartedPreprocessing());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unawaited(finishStartedPreprocessing());
|
||||||
|
}
|
||||||
|
|
||||||
|
unawaited(createPushAvatars());
|
||||||
|
|
||||||
runApp(
|
runApp(
|
||||||
MultiProvider(
|
MultiProvider(
|
||||||
providers: providers,
|
providers: [
|
||||||
|
ChangeNotifierProvider(create: (_) => settingsController),
|
||||||
|
ChangeNotifierProvider(create: (_) => CustomChangeProvider()),
|
||||||
|
ChangeNotifierProvider(create: (_) => ImageEditorProvider()),
|
||||||
|
],
|
||||||
child: const App(),
|
child: const App(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ Future<void> handleBackupStatusUpdate(TaskStatusUpdate update) async {
|
||||||
return user;
|
return user;
|
||||||
});
|
});
|
||||||
} else if (update.status == TaskStatus.complete) {
|
} else if (update.status == TaskStatus.complete) {
|
||||||
Log.error(
|
Log.info(
|
||||||
'twonly Backup uploaded with status code ${update.responseStatusCode}',
|
'twonly Backup uploaded with status code ${update.responseStatusCode}',
|
||||||
);
|
);
|
||||||
await updateUserdata((user) {
|
await updateUserdata((user) {
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,6 @@ bool isUUIDNewer(String uuid1, String uuid2) {
|
||||||
final timestamp2 = int.parse(uuid2.substring(0, 8), radix: 16);
|
final timestamp2 = int.parse(uuid2.substring(0, 8), radix: 16);
|
||||||
return timestamp1 > timestamp2;
|
return timestamp1 > timestamp2;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Log.error(e);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:camera/camera.dart';
|
import 'package:camera/camera.dart';
|
||||||
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_android_volume_keydown/flutter_android_volume_keydown.dart';
|
import 'package:flutter_android_volume_keydown/flutter_android_volume_keydown.dart';
|
||||||
|
|
@ -224,7 +225,13 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
androidVolumeDownSub = FlutterAndroidVolumeKeydown.stream.listen((event) {
|
if ((await DeviceInfoPlugin().androidInfo).version.release == '9') {
|
||||||
|
// MissingPluginException: MissingPluginException(No implementation found for method cancel on channel dart-tools.dev/flutter_…
|
||||||
|
// Maybe this is the reason?
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
androidVolumeDownSub =
|
||||||
|
FlutterAndroidVolumeKeydown.stream.listen((event) {
|
||||||
if (widget.isVisible) {
|
if (widget.isVisible) {
|
||||||
takePicture();
|
takePicture();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -234,6 +241,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> deInitVolumeControl() async {
|
Future<void> deInitVolumeControl() async {
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ description: "twonly, a privacy-friendly way to connect with friends through sec
|
||||||
|
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 0.0.67+67
|
version: 0.0.68+68
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.6.0
|
sdk: ^3.6.0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue