add user and os info to sentry.
This commit is contained in:
+2
-6
@@ -42,9 +42,7 @@ Future main() async {
|
|||||||
options.tracesSampleRate = 1.0;
|
options.tracesSampleRate = 1.0;
|
||||||
options.reportPackages = false;
|
options.reportPackages = false;
|
||||||
Sentry.configureScope(
|
Sentry.configureScope(
|
||||||
(scope) => scope.setUser(
|
setSentryScope,
|
||||||
SentryUser(username: Platform.environment['USER']),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
appRunner: () => runApp(const MyApp()),
|
appRunner: () => runApp(const MyApp()),
|
||||||
@@ -115,9 +113,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
}
|
}
|
||||||
Sentry.captureMessage(
|
Sentry.captureMessage(
|
||||||
'Found ${result.length} codes.',
|
'Found ${result.length} codes.',
|
||||||
withScope: (scope) {
|
withScope: setSentryScope,
|
||||||
SentryUser(username: Platform.environment['USER']);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
Future.delayed(const Duration(seconds: 3), () {
|
Future.delayed(const Duration(seconds: 3), () {
|
||||||
if (status == Status.notFound) {
|
if (status == Status.notFound) {
|
||||||
|
|||||||
+19
-1
@@ -1,4 +1,7 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||||
import 'package:zbar_scan_plugin/zbar_scan_plugin.dart';
|
import 'package:zbar_scan_plugin/zbar_scan_plugin.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
@@ -32,5 +35,20 @@ CenterAndSize getCenterAndSizeOfPoints(List<PointInfo> points) {
|
|||||||
center: center,
|
center: center,
|
||||||
size: size * 1.2,
|
size: size * 1.2,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
setSentryScope(Scope scope) {
|
||||||
|
var infoLines = File('/etc/os-release').readAsStringSync().split('\n').where((line) => line.contains('='));
|
||||||
|
Map<String, dynamic> data = {};
|
||||||
|
for (var info in infoLines) {
|
||||||
|
var parts = info.split('=');
|
||||||
|
data['OS_${parts.first}'] = parts.sublist(1).join('=');
|
||||||
|
}
|
||||||
|
return scope.setUser(
|
||||||
|
SentryUser(
|
||||||
|
id: File('/etc/machine-id').readAsStringSync(),
|
||||||
|
username: Platform.environment['USER'],
|
||||||
|
data: data,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user