Skip to content

Commit

Permalink
update for sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
3003h committed Nov 3, 2023
1 parent 6458ff1 commit ad0f2a1
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 64 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ app.*.map.json
/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
/ios/build/
/ios/Runner/GoogleService-Info.plist
/ios/firebase_app_id_file.json
/android/app/google-services.json
/android/app/asd.json

Expand Down
128 changes: 64 additions & 64 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:fehviewer/common/controller/tag_trans_controller.dart';
import 'package:fehviewer/common/service/ehsetting_service.dart';
import 'package:fehviewer/common/service/locale_service.dart';
import 'package:fehviewer/common/service/theme_service.dart';
import 'package:fehviewer/component/exception/error.dart';
import 'package:fehviewer/fehviewer.dart';
import 'package:fehviewer/store/get_store.dart';
import 'package:fehviewer/widget/system_ui_overlay.dart';
Expand All @@ -21,75 +20,76 @@ import 'package:oktoast/oktoast.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

import 'get_init.dart';
import 'network/app_dio/pdio.dart';
import 'widget/desktop.dart';

Future<void> main() async {
// BindingBase.debugZoneErrorsAreFatal = true;
runZonedGuarded<Future<void>>(() async {
WidgetsFlutterBinding.ensureInitialized();
final dsn = await getSentryDsn();
if (dsn != null && dsn.isNotEmpty) {
await SentryFlutter.init(
(SentryFlutterOptions options) {
options
..dsn = dsn
..debug = false
..diagnosticLevel = SentryLevel.warning;
},
);
}

Get.lazyPut(() => LogService(), fenix: true);
Get.lazyPut(() => GStore());
await Global.init();
getinit();
Global.proxyInit();

if (Get.find<EhSettingService>().debugMode || kDebugMode) {
Logger.level = Level.debug;
logger.t('Level.debug');
} else {
Logger.level = Level.error;
}
resetLogLevel();
updateTagTranslate();

// runZonedGuarded<Future<void>>(() async {
WidgetsFlutterBinding.ensureInitialized();
final dsn = await getSentryDsn();

Get.lazyPut(() => LogService(), fenix: true);
Get.lazyPut(() => GStore());
await Global.init();
getinit();
Global.proxyInit();

if (Get.find<EhSettingService>().debugMode || kDebugMode) {
Logger.level = Level.debug;
logger.t('Level.debug');
} else {
Logger.level = Level.error;
}
resetLogLevel();
updateTagTranslate();

if (dsn != null && dsn.isNotEmpty) {
await SentryFlutter.init(
(SentryFlutterOptions options) {
options
..dsn = dsn
// ..debug = kDebugMode
..diagnosticLevel = SentryLevel.warning;
},
appRunner: () => runApp(MyApp()),
);
} else {
runApp(MyApp());
}

if (GetPlatform.isDesktop) {
doWhenWindowReady(() {
const minSize = Size(400, 400);
appWindow.minSize = minSize;
// appWindow.size = initialSize;
appWindow.alignment = Alignment.center;
appWindow.title = L10n.current.app_title;
appWindow.show();
});

// setWindowTitle(L10n.of(Get.context!).app_title);
}
}, (Object error, StackTrace stackTrace) async {
if (error is EhError && error.type == EhErrorType.image509) {
debugPrint('EhErrorType.image509');
return;
}
if (error is NetworkException) {
debugPrint('NetworkException');
return;
}
if (error is CancelException) {
debugPrint('CancelException');
return;
}

debugPrint(
'runZonedGuarded: Caught error in my root zone.\n$error\n$stackTrace');

if (!kDebugMode) {
await Sentry.captureException(error, stackTrace: stackTrace);
}
});
if (GetPlatform.isDesktop) {
doWhenWindowReady(() {
const minSize = Size(400, 400);
appWindow.minSize = minSize;
// appWindow.size = initialSize;
appWindow.alignment = Alignment.center;
appWindow.title = L10n.current.app_title;
appWindow.show();
});

// setWindowTitle(L10n.of(Get.context!).app_title);
}
// }, (Object error, StackTrace stackTrace) async {
// if (error is EhError && error.type == EhErrorType.image509) {
// debugPrint('EhErrorType.image509');
// return;
// }
// if (error is NetworkException) {
// debugPrint('NetworkException');
// return;
// }
// if (error is CancelException) {
// debugPrint('CancelException');
// return;
// }
//
// debugPrint(
// 'runZonedGuarded: Caught error in my root zone.\n$error\n$stackTrace');
//
// if (!kDebugMode) {
// await Sentry.captureException(error, stackTrace: stackTrace);
// }
// });
}

class MyApp extends StatefulWidget {
Expand Down

0 comments on commit ad0f2a1

Please sign in to comment.