Commit 301cf0cf authored by Wilko Manger's avatar Wilko Manger

Add more info to Sentry reports

parent 82af9ae8
SENTRY_DSN=https://<key>@sentry.io/<project>
BUILD_TYPE=debug
......@@ -21,6 +21,7 @@ build:
script:
- 'echo "version: ${CI_COMMIT_REF_NAME:1}+$((123 + $CI_PIPELINE_IID))" >> pubspec.yaml'
- 'echo "SENTRY_DSN=$SENTRY_DSN" > .env'
- 'echo "BUILD_TYPE=fdroid" >> .env'
- echo "$STORE" | base64 -d > android/app/pattle.keystore
- flutter build apk
- mv build/app/outputs/apk/release/app-release.apk pattle.apk
......
......@@ -34,7 +34,6 @@ Future<void> _reportError(dynamic error, dynamic stackTrace) async {
if (_isInDebugMode) {
print(stackTrace);
} else {
if (error is Response) {
var body;
try {
......@@ -77,33 +76,79 @@ bool get _isInDebugMode {
bool inDebugMode = false;
// Set to true if running debug mode (where asserts are evaluated)
assert(inDebugMode = true);
//assert(inDebugMode = false);
return inDebugMode;
}
Future<String> get _environment async {
Future<Event> get _environment async {
final deviceInfo = DeviceInfoPlugin();
User user;
Os os;
Device device;
if (Platform.isAndroid) {
final ai = await deviceInfo.androidInfo;
return 'Android ${ai.version.release}: ${ai.model}';
final info = await deviceInfo.androidInfo;
user = User(
id: info.androidId
);
os = Os(
name: 'Android',
version: info.version.release,
build: info.version.sdkInt.toString(),
);
device = Device(
model: info.model,
manufacturer: info.manufacturer,
brand: info.brand,
simulator: !info.isPhysicalDevice
);
} else {
final ii = await deviceInfo.iosInfo;
return 'iOS ${ii.systemName} ${ii.systemVersion}: ${ii.model}';
final info = await deviceInfo.iosInfo;
user = User(
id: info.identifierForVendor
);
os = Os(
name: 'iOS',
version: '${info.systemName} ${info.systemVersion}',
);
device = Device(
name: info.name,
family: info.model,
simulator: !info.isPhysicalDevice
);
}
final packageInfo = await PackageInfo.fromPlatform();
return Event(
release: packageInfo.version,
userContext: user,
contexts: Contexts(
device: device,
os: os,
app: App(
build: packageInfo.buildNumber,
buildType: DotEnv().env['BUILD_TYPE'],
)
)
);
}
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
)
environmentAttributes: await _environment
);
FlutterError.onError = (FlutterErrorDetails details) {
......
......@@ -296,9 +296,11 @@ packages:
sentry:
dependency: "direct main"
description:
name: sentry
url: "https://pub.dartlang.org"
source: hosted
path: "."
ref: HEAD
resolved-ref: f08ef8185c2fd27e2eae1a880927add08d2fc119
url: "https://git.pattle.im/forks/sentry.git"
source: git
version: "2.2.0"
sky_engine:
dependency: transitive
......
......@@ -17,7 +17,9 @@ dependencies:
rxdart: ^0.21.0
sentry: ^2.2.0
# TODO: Use official package when PR is merged
sentry:
git: https://git.pattle.im/forks/sentry.git
flutter_cache_manager: ^0.3.2
......
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