mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Report extra context info to sentry
This commit is contained in:
parent
fafaf8d036
commit
0afac83483
@ -4,10 +4,14 @@ import 'dart:io';
|
|||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
|
import 'package:InvenTree/api.dart';
|
||||||
import 'package:InvenTree/widget/home.dart';
|
import 'package:InvenTree/widget/home.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:device_info/device_info.dart';
|
||||||
|
import 'package:package_info/package_info.dart';
|
||||||
|
|
||||||
import 'dsn.dart';
|
import 'dsn.dart';
|
||||||
|
|
||||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||||
@ -35,13 +39,69 @@ Future<void> _reportError(dynamic error, dynamic stackTrace) async {
|
|||||||
|
|
||||||
print('Reporting to Sentry.io...');
|
print('Reporting to Sentry.io...');
|
||||||
|
|
||||||
|
// Extract device information
|
||||||
|
final DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
||||||
|
|
||||||
|
Map<String, dynamic> device_info = {};
|
||||||
|
|
||||||
// Extract some platform information
|
// Extract some platform information
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
|
final iosDeviceInfo = await deviceInfo.iosInfo;
|
||||||
|
|
||||||
|
device_info = {
|
||||||
|
'name': iosDeviceInfo.name,
|
||||||
|
'model': iosDeviceInfo.model,
|
||||||
|
'systemName': iosDeviceInfo.systemName,
|
||||||
|
'systemVersion': iosDeviceInfo.systemVersion,
|
||||||
|
'localizedModel': iosDeviceInfo.localizedModel,
|
||||||
|
'utsname': iosDeviceInfo.utsname.sysname,
|
||||||
|
'identifierForVendor': iosDeviceInfo.identifierForVendor,
|
||||||
|
'isPhysicalDevice': iosDeviceInfo.isPhysicalDevice,
|
||||||
|
};
|
||||||
|
|
||||||
} else if (Platform.isAndroid) {
|
} else if (Platform.isAndroid) {
|
||||||
|
final androidDeviceInfo = await deviceInfo.androidInfo;
|
||||||
|
|
||||||
|
device_info = {
|
||||||
|
'type': androidDeviceInfo.type,
|
||||||
|
'model': androidDeviceInfo.model,
|
||||||
|
'device': androidDeviceInfo.device,
|
||||||
|
'id': androidDeviceInfo.id,
|
||||||
|
'androidId': androidDeviceInfo.androidId,
|
||||||
|
'brand': androidDeviceInfo.brand,
|
||||||
|
'display': androidDeviceInfo.display,
|
||||||
|
'hardware': androidDeviceInfo.hardware,
|
||||||
|
'manufacturer': androidDeviceInfo.manufacturer,
|
||||||
|
'product': androidDeviceInfo.product,
|
||||||
|
'version': androidDeviceInfo.version.release,
|
||||||
|
'supported32BitAbis': androidDeviceInfo.supported32BitAbis,
|
||||||
|
'supported64BitAbis': androidDeviceInfo.supported64BitAbis,
|
||||||
|
'supportedAbis': androidDeviceInfo.supportedAbis,
|
||||||
|
'isPhysicalDevice': androidDeviceInfo.isPhysicalDevice,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add app info
|
||||||
|
final package_info = await PackageInfo.fromPlatform();
|
||||||
|
|
||||||
|
Map<String, dynamic> app_version_info = {
|
||||||
|
"name": package_info.appName,
|
||||||
|
"build": package_info.buildNumber,
|
||||||
|
"version": package_info.version,
|
||||||
|
"package": package_info.packageName,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add server info (anonymized)
|
||||||
|
Map<String, dynamic> server_info = {
|
||||||
|
"version": InvenTreeAPI().version,
|
||||||
|
};
|
||||||
|
|
||||||
|
Sentry.configureScope((scope) {
|
||||||
|
scope.setExtra("server", server_info);
|
||||||
|
scope.setExtra("app", app_version_info);
|
||||||
|
scope.setExtra("device", device_info);
|
||||||
|
});
|
||||||
|
|
||||||
Sentry.captureException(error, stackTrace: stackTrace).catchError((error) {
|
Sentry.captureException(error, stackTrace: stackTrace).catchError((error) {
|
||||||
print("Error uploading information to Sentry.io:");
|
print("Error uploading information to Sentry.io:");
|
||||||
print(error);
|
print(error);
|
||||||
|
@ -30,21 +30,21 @@ class InvenTreeAboutWidget extends StatelessWidget {
|
|||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(I18N.of(context).address),
|
title: Text(I18N.of(context).address),
|
||||||
subtitle: Text(InvenTreeAPI().baseUrl.isNotEmpty ? InvenTreeAPI().baseUrl : "Not connected"),
|
subtitle: Text(InvenTreeAPI().baseUrl.isNotEmpty ? InvenTreeAPI().baseUrl : I18N.of(context).notConnected),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(I18N.of(context).version),
|
title: Text(I18N.of(context).version),
|
||||||
subtitle: Text(InvenTreeAPI().version.isNotEmpty ? InvenTreeAPI().version : "Not connected"),
|
subtitle: Text(InvenTreeAPI().version.isNotEmpty ? InvenTreeAPI().version : I18N.of(context).notConnected),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(I18N.of(context).serverInstance),
|
title: Text(I18N.of(context).serverInstance),
|
||||||
subtitle: Text(InvenTreeAPI().instance.isNotEmpty ? InvenTreeAPI().instance : "Not connected"),
|
subtitle: Text(InvenTreeAPI().instance.isNotEmpty ? InvenTreeAPI().instance : I18N.of(context).notConnected),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user