Show warning before sending logs

This commit is contained in:
vishnukvmd 2021-08-09 19:42:42 +05:30
parent dd90b98ef0
commit f6322a9b28
4 changed files with 61 additions and 5 deletions

View file

@ -83,8 +83,9 @@ class SupportSectionWidget extends StatelessWidget {
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () async {
await sendLogs(context, "bug@ente.io");
showToast("thanks for reporting a bug!");
await sendLogs(context, "report bug", "bug@ente.io", postShare: () {
showToast("thanks for reporting a bug!");
});
},
child: SettingsTextItem(
text: "report bug 🐞", icon: Icons.navigate_next),

View file

@ -222,8 +222,9 @@ class _SyncIndicatorState extends State<SyncIndicator> {
onPressed: () {
sendLogs(
context,
"raise ticket",
"support@ente.io",
"Backup failed",
subject: "Backup failed",
);
},
),

View file

@ -2,6 +2,7 @@ import 'dart:io';
import 'package:archive/archive_io.dart';
import 'package:email_validator/email_validator.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_email_sender/flutter_email_sender.dart';
import 'package:path_provider/path_provider.dart';
@ -14,10 +15,62 @@ bool isValidEmail(String email) {
Future<void> sendLogs(
BuildContext context,
String toEmail, [
String title,
String toEmail, {
Function postShare,
String subject,
String body,
]) async {
}) async {
final confirmation = AlertDialog(
title: Text(
title,
style: TextStyle(
fontSize: 18,
),
),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: const [
Text(
"this will send across metrics and logs that will help us debug your issue better",
style: TextStyle(
height: 1.5,
fontFamily: 'Ubuntu',
fontSize: 16,
),
),
],
),
),
actions: [
TextButton(
child: Text(
title,
style: TextStyle(
color: Theme.of(context).buttonColor,
),
),
onPressed: () async {
Navigator.of(context).pop();
await _sendLogs(context, toEmail, subject, body);
if (postShare != null) {
postShare();
}
},
),
],
);
showDialog(
context: context,
builder: (_) {
return confirmation;
},
);
}
Future<void> _sendLogs(
BuildContext context, String toEmail, String subject, String body) async {
final dialog = createProgressDialog(context, "preparing logs...");
await dialog.show();
final tempPath = (await getTemporaryDirectory()).path;

View file

@ -184,6 +184,7 @@ class SuperLogging {
static void setUserID(String userID) {
Sentry.configureScope((scope) => scope.user = SentryUser(id: userID));
$.info("setting sentry user ID to: $userID");
}
static Future<void> _sendErrorToSentry(Object error, StackTrace stack) async {