Commit 89c2fcf0 authored by Wilko Manger's avatar Wilko Manger

Integrate Sentry

parent abd3681a
Pipeline #329 canceled with stages
in 1 minute and 46 seconds
SENTRY_DSN=https://<key>@sentry.io/<project>
......@@ -8,6 +8,7 @@
.buildlog/
.history
.svn/
.env
# IntelliJ related
*.iml
......
......@@ -17,6 +17,7 @@ build:
- tags
script:
- 'echo "version: ${CI_COMMIT_REF_NAME:1}+$((123 + $CI_PIPELINE_IID))" >> pubspec.yaml'
- 'echo "SENTRY_DSN=$SENTRY_DSN" > .env'
- echo "$STORE" | base64 -d > android/app/pattle.keystore
- flutter build apk
- mv build/app/outputs/apk/release/app-release.apk pattle.apk
......
......@@ -15,7 +15,13 @@
// You should have received a copy of the GNU Affero General Public License
// along with Pattle. If not, see <https://www.gnu.org/licenses/>.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:pattle/src/app.dart';
import 'package:pattle/src/sentry.dart' as sentry;
void main() => runApp(App());
Future<void> main() async {
await sentry.init();
sentry.wrap(() => runApp(App()));
}
// Copyright (C) 2019 wilko
//
// This file is part of Pattle.
//
// Pattle is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Pattle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Pattle. If not, see <https://www.gnu.org/licenses/>.
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:pattle/src/app.dart';
import 'package:sentry/sentry.dart';
import 'package:package_info/package_info.dart';
import 'package:device_info/device_info.dart';
import 'dart:io' show Platform;
SentryClient _sentry;
Future<void> _reportError(dynamic error, dynamic stackTrace) async {
print('Caught error: $error');
if (_isInDebugMode) {
print(stackTrace);
} else {
_sentry.captureException(
exception: error,
stackTrace: stackTrace,
);
}
}
bool get _isInDebugMode {
bool inDebugMode = false;
// Set to true if running debug mode (where asserts are evaluated)
assert(inDebugMode = true);
return inDebugMode;
}
Future<String> get _environment async {
final deviceInfo = DeviceInfoPlugin();
if (Platform.isAndroid) {
final ai = await deviceInfo.androidInfo;
return 'Android ${ai.version.release}: ${ai.model}';
} else {
final ii = await deviceInfo.iosInfo;
return 'iOS ${ii.systemName} ${ii.systemVersion}: ${ii.model}';
}
}
Future<void> init() async {
await DotEnv().load();
final packageInfo = await PackageInfo.fromPlatform();
_sentry = SentryClient(
dsn: DotEnv().env['SENTRY_DSN'],
environmentAttributes: Event(
release: packageInfo.version,
environment: await _environment
)
);
FlutterError.onError = (FlutterErrorDetails details) {
if (_isInDebugMode) {
FlutterError.dumpErrorToConsole(details);
} else {
// Report to zone
Zone.current.handleUncaughtError(details.exception, details.stack);
}
};
}
void wrap(Function run) {
runZoned<Future<void>>(() async {
run();
}, onError: (error, stackTrace) {
_reportError(error, stackTrace);
});
}
\ No newline at end of file
......@@ -80,11 +80,25 @@ packages:
url: "https://github.com/MarkOSullivan94/dart_config.git"
source: git
version: "0.5.0"
device_info:
dependency: "direct main"
description:
name: device_info
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.0+1"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_dotenv:
dependency: "direct main"
description:
name: flutter_dotenv
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
flutter_launcher_icons:
dependency: "direct dev"
description:
......@@ -172,6 +186,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
package_info:
dependency: "direct main"
description:
name: package_info
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.0+3"
path:
dependency: transitive
description:
......@@ -214,6 +235,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.21.0"
sentry:
dependency: "direct main"
description:
name: sentry
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
sky_engine:
dependency: transitive
description: flutter
......@@ -289,6 +317,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
usage:
dependency: transitive
description:
name: usage
url: "https://pub.dartlang.org"
source: hosted
version: "3.4.1"
validators:
dependency: transitive
description:
......
......@@ -17,6 +17,13 @@ dependencies:
rxdart: ^0.21.0
sentry: ^2.2.0
device_info: ^0.4.0+1
package_info: ^0.4.0+3
flutter_dotenv: ^2.0.1
respect_24_hour: ^0.0.2
transparent_image: ^1.0.0
......@@ -49,33 +56,5 @@ flutter:
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.io/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.io/custom-fonts/#from-packages
assets:
- .env
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment