Log device info

This way it's easier to debug user's issues
This commit is contained in:
Vishesh Handa
2021-02-04 10:51:29 +01:00
parent 05aca7a013
commit e3e513ef65
3 changed files with 58 additions and 0 deletions

View File

@ -1,6 +1,7 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:device_info/device_info.dart';
import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:gitjournal/app.dart';
@ -220,3 +221,53 @@ class AnalyticsRouteObserver extends RouteObserver<PageRoute<dynamic>> {
}
}
}
// This should be provided by device_info
Map<String, dynamic> readAndroidBuildData(AndroidDeviceInfo build) {
return <String, dynamic>{
'version.securityPatch': build.version.securityPatch,
'version.sdkInt': build.version.sdkInt,
'version.release': build.version.release,
'version.previewSdkInt': build.version.previewSdkInt,
'version.incremental': build.version.incremental,
'version.codename': build.version.codename,
'version.baseOS': build.version.baseOS,
'board': build.board,
'bootloader': build.bootloader,
'brand': build.brand,
'device': build.device,
'display': build.display,
'fingerprint': build.fingerprint,
'hardware': build.hardware,
'host': build.host,
'id': build.id,
'manufacturer': build.manufacturer,
'model': build.model,
'product': build.product,
'supported32BitAbis': build.supported32BitAbis,
'supported64BitAbis': build.supported64BitAbis,
'supportedAbis': build.supportedAbis,
'tags': build.tags,
'type': build.type,
'isPhysicalDevice': build.isPhysicalDevice,
'androidId': build.androidId,
'systemFeatures': build.systemFeatures,
};
}
Map<String, dynamic> readIosDeviceInfo(IosDeviceInfo data) {
return <String, dynamic>{
'name': data.name,
'systemName': data.systemName,
'systemVersion': data.systemVersion,
'model': data.model,
'localizedModel': data.localizedModel,
'identifierForVendor': data.identifierForVendor,
'isPhysicalDevice': data.isPhysicalDevice,
'utsname.sysname:': data.utsname.sysname,
'utsname.nodename:': data.utsname.nodename,
'utsname.release:': data.utsname.release,
'utsname.version:': data.utsname.version,
'utsname.machine:': data.utsname.machine,
};
}

View File

@ -96,9 +96,13 @@ class JournalApp extends StatefulWidget {
if (Platform.isAndroid) {
var info = await deviceInfo.androidInfo;
isPhysicalDevice = info.isPhysicalDevice;
Log.i("Running on Android", props: readAndroidBuildData(info));
} else if (Platform.isIOS) {
var info = await deviceInfo.iosInfo;
isPhysicalDevice = info.isPhysicalDevice;
Log.i("Running on ios", props: readIosDeviceInfo(info));
}
} catch (e) {
Log.d(e);

View File

@ -57,6 +57,9 @@ class Log {
stacktrace = Trace.from(stacktrace).terse;
if (foundation.kDebugMode) {
if (props != null && props.isNotEmpty) {
msg += " $props";
}
Fimber.log("I", msg,
ex: ex, stacktrace: stacktrace, tag: LogTree.getTag(stackIndex: 2));
}