大幅変更&環境バージョンアップ

This commit is contained in:
2024-08-22 14:35:09 +09:00
parent 56e9861c7a
commit dc58dc0584
446 changed files with 29645 additions and 8315 deletions

View File

@ -0,0 +1,63 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;
class ErrorService {
static Future<void> reportError(dynamic error, StackTrace stackTrace, Map<String, dynamic> deviceInfo, List<String> operationLogs) async {
try {
final String errorMessage = error.toString();
final String stackTraceString = stackTrace.toString();
final String estimatedCause = _estimateErrorCause(errorMessage);
//final String deviceInfo = await _getDeviceInfo();
final Uri url = Uri.parse('https://rogaining.sumasen.net/report-error');
final response = await http.post(
url,
body: {
'error_message': errorMessage,
'stack_trace': stackTraceString,
'estimated_cause': estimatedCause,
'device_info': deviceInfo,
'operation_logs': operationLogs.join('\n'), // オペレーションログを改行で結合して送信
},
);
if (response.statusCode == 200) {
// エラー報告が成功した場合の処理(必要に応じて)
debugPrint("===== エラーログ送信成功しました。 ====");
} else {
// エラー報告が失敗した場合の処理(必要に応じて)
debugPrint("===== エラーログ送信失敗しました。 ====");
}
} catch (e) {
// エラー報告中にエラーが発生した場合の処理(必要に応じて)
debugPrint("===== エラーログ送信中にエラーになりました。 ====");
}
}
static String _estimateErrorCause(String errorMessage) {
// エラーメッセージに基づいてエラーの原因を推定するロジックを追加する
if (errorMessage.contains('NetworkException')) {
return 'ネットワーク接続エラー';
} else if (errorMessage.contains('DatabaseException')) {
return 'データベースエラー';
} else if (errorMessage.contains('AuthenticationException')) {
return '認証エラー';
} else {
return '不明なエラー';
}
}
/*
// 2024-4-8 Akira: メモリ使用量のチェックのため追加 See #2810
//
static void reportMemoryError(String message, StackTrace stackTrace) async {
final errorDetails = FlutterErrorDetails(
exception: Exception(message),
stack: stackTrace,
);
await reportError(errorDetails.exception, errorDetails.stack ?? StackTrace.current, deviceInfo);
}
*/
}