chore: Let error reporter fill out bug report
This commit is contained in:
parent
600ab7581c
commit
86df13d6d8
1 changed files with 13 additions and 31 deletions
|
|
@ -1,6 +1,3 @@
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
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';
|
||||||
|
|
||||||
|
|
@ -11,7 +8,6 @@ import 'package:matrix/matrix.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/config/app_config.dart';
|
import 'package:fluffychat/config/app_config.dart';
|
||||||
import 'package:fluffychat/utils/platform_infos.dart';
|
|
||||||
|
|
||||||
class ErrorReporter {
|
class ErrorReporter {
|
||||||
final BuildContext context;
|
final BuildContext context;
|
||||||
|
|
@ -22,7 +18,7 @@ class ErrorReporter {
|
||||||
void onErrorCallback(Object error, [StackTrace? stackTrace]) async {
|
void onErrorCallback(Object error, [StackTrace? stackTrace]) async {
|
||||||
Logs().e(message ?? 'Error caught', error, stackTrace);
|
Logs().e(message ?? 'Error caught', error, stackTrace);
|
||||||
final text = '$error\n${stackTrace ?? ''}';
|
final text = '$error\n${stackTrace ?? ''}';
|
||||||
final consent = await showAdaptiveDialog<bool>(
|
await showAdaptiveDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => AlertDialog.adaptive(
|
builder: (context) => AlertDialog.adaptive(
|
||||||
title: Text(L10n.of(context)!.reportErrorDescription),
|
title: Text(L10n.of(context)!.reportErrorDescription),
|
||||||
|
|
@ -39,7 +35,7 @@ class ErrorReporter {
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(context).pop<bool>(false),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
child: Text(L10n.of(context)!.close),
|
child: Text(L10n.of(context)!.close),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
|
|
@ -49,35 +45,21 @@ class ErrorReporter {
|
||||||
child: Text(L10n.of(context)!.copy),
|
child: Text(L10n.of(context)!.copy),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(context).pop<bool>(true),
|
onPressed: () => launchUrl(
|
||||||
|
AppConfig.newIssueUrl.resolveUri(
|
||||||
|
Uri(
|
||||||
|
queryParameters: {
|
||||||
|
'template': 'bug_report.yaml',
|
||||||
|
'title': '[BUG]: ${message ?? error.toString()}',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
mode: LaunchMode.externalApplication,
|
||||||
|
),
|
||||||
child: Text(L10n.of(context)!.report),
|
child: Text(L10n.of(context)!.report),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (consent != true) return;
|
|
||||||
final os = kIsWeb ? 'web' : Platform.operatingSystem;
|
|
||||||
final version = await PlatformInfos.getVersion();
|
|
||||||
final description = '''
|
|
||||||
- Operating system: $os
|
|
||||||
- Version: $version
|
|
||||||
|
|
||||||
### Exception
|
|
||||||
$error
|
|
||||||
|
|
||||||
### StackTrace
|
|
||||||
${stackTrace?.toString().split('\n').take(10).join('\n')}
|
|
||||||
''';
|
|
||||||
launchUrl(
|
|
||||||
AppConfig.newIssueUrl.resolveUri(
|
|
||||||
Uri(
|
|
||||||
queryParameters: {
|
|
||||||
'title': '[BUG]: ${message ?? error.toString()}',
|
|
||||||
'body': description,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
mode: LaunchMode.externalApplication,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue