Skip to content

Commit

Permalink
instabug extra set up
Browse files Browse the repository at this point in the history
  • Loading branch information
josancamon19 committed Jun 13, 2024
1 parent c49a676 commit 544a40f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
10 changes: 7 additions & 3 deletions apps/AppWithWearable/lib/backend/api_requests/api_calls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:friend_private/backend/storage/sample.dart';
import 'package:friend_private/backend/storage/segment.dart';
import 'package:friend_private/env/env.dart';
import 'package:http/http.dart' as http;
import 'package:instabug_flutter/instabug_flutter.dart';
import 'package:instabug_http_client/instabug_http_client.dart';
import 'package:intl/intl.dart';
import 'package:path/path.dart';
Expand Down Expand Up @@ -351,7 +352,8 @@ Future<List<Plugin>> retrievePlugins() async {
if (response?.statusCode == 200) {
try {
return Plugin.fromJsonList(jsonDecode(response!.body));
} catch (e) {
} catch (e, stackTrace) {
CrashReporting.reportHandledCrash(e, stackTrace);
return [];
}
}
Expand All @@ -361,6 +363,7 @@ Future<List<Plugin>> retrievePlugins() async {
// TODO: update vectors when fields updated

Future<List<TranscriptSegment>> transcribeAudioFile(File file, String uid) async {
final client = InstabugHttpClient();
var request = http.MultipartRequest(
'POST',
Uri.parse(
Expand All @@ -370,7 +373,7 @@ Future<List<TranscriptSegment>> transcribeAudioFile(File file, String uid) async

try {
var startTime = DateTime.now();
var streamedResponse = await request.send();
var streamedResponse = await client.send(request);
var response = await http.Response.fromStream(streamedResponse);
debugPrint('TranscribeAudioFile took: ${DateTime.now().difference(startTime).inSeconds} seconds');
if (response.statusCode == 200) {
Expand All @@ -380,7 +383,8 @@ Future<List<TranscriptSegment>> transcribeAudioFile(File file, String uid) async
} else {
throw Exception('Failed to upload file. Status code: ${response.statusCode} Body: ${response.body}');
}
} catch (e) {
} catch (e, stackTrace) {
CrashReporting.reportHandledCrash(e, stackTrace);
throw Exception('An error occurred transcribeAudioFile: $e');
}
}
Expand Down
5 changes: 3 additions & 2 deletions apps/AppWithWearable/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@ void main() async {
if (Env.instabugApiKey != null) {
runZonedGuarded(
() {
_initStuff();
Instabug.init(
token: Env.instabugApiKey!,
invocationEvents: [InvocationEvent.shake, InvocationEvent.screenshot],
);
FlutterError.onError = (FlutterErrorDetails details) {
Zone.current.handleUncaughtError(details.exception, details.stack!);
};
Instabug.setColorTheme(ColorTheme.dark);
_getRunApp();
},
CrashReporting.reportCrash,
);
} else {
_initStuff();
_getRunApp();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ class TranscriptWidgetState extends State<TranscriptWidget> {
}

void _cleanTranscript(List<TranscriptSegment> segments) {
var hallucinations = ['Thank you.', 'I don\'t know what to do,', 'I\'m', 'It was the worst case.'];
var hallucinations = ['Thank you.', 'I don\'t know what to do,', 'I\'m', 'It was the worst case.', 'and,'];
// TODO: do this with any words that gets repeated twice
// - Replicate apparently has much more hallucinations
for (var i = 0; i < segments.length; i++) {
for (var hallucination in hallucinations) {
segments[i].text = segments[i]
Expand Down

0 comments on commit 544a40f

Please sign in to comment.