mirror of
https://github.com/go-vikunja/app
synced 2025-02-11 09:12:49 +00:00
Refactor DSN to constants Use correct import Add sentry Co-authored-by: Jonas Franz <info@jonasfranz.software> Reviewed-on: vikunja/app#43 Reviewed-by: konrad <konrad@kola-entertainments.de>
60 lines
1.6 KiB
Dart
60 lines
1.6 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:sentry/sentry.dart';
|
|
import 'package:vikunja_app/constants.dart';
|
|
import 'package:vikunja_app/global.dart';
|
|
import 'package:vikunja_app/pages/home.dart';
|
|
import 'package:vikunja_app/pages/user/login.dart';
|
|
import 'package:vikunja_app/theme/theme.dart';
|
|
|
|
void main() {
|
|
var sentry = new SentryClient(dsn: SENTRY_DSN);
|
|
|
|
FlutterError.onError = (details, {bool forceReport = false}) {
|
|
try {
|
|
sentry.captureException(
|
|
exception: details.exception,
|
|
stackTrace: details.stack,
|
|
);
|
|
} catch (e) {
|
|
print('Sending report to sentry.io failed: $e');
|
|
} finally {
|
|
// Also use Flutter's pretty error logging to the device's console.
|
|
FlutterError.dumpErrorToConsole(details, forceReport: forceReport);
|
|
}
|
|
};
|
|
|
|
runZoned(
|
|
() => runApp(VikunjaGlobal(
|
|
child: new VikunjaApp(home: HomePage()),
|
|
login: new VikunjaApp(home: LoginPage()))),
|
|
onError: (Object error, StackTrace stackTrace) {
|
|
try {
|
|
sentry.captureException(
|
|
exception: error,
|
|
stackTrace: stackTrace,
|
|
);
|
|
print('Error sent to sentry.io: $error');
|
|
} catch (e) {
|
|
print('Sending report to sentry.io failed: $e');
|
|
print('Original error: $error');
|
|
}
|
|
},
|
|
);
|
|
}
|
|
|
|
class VikunjaApp extends StatelessWidget {
|
|
final Widget home;
|
|
|
|
const VikunjaApp({Key key, this.home}) : super(key: key);
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return new MaterialApp(
|
|
title: 'Vikunja',
|
|
theme: buildVikunjaTheme(),
|
|
home: this.home,
|
|
);
|
|
}
|
|
}
|