Remove background task logging and reporting

This commit is contained in:
Yegor Vialov 2019-12-10 21:19:29 +00:00
parent d1912a44c6
commit 3f1ece26ec
2 changed files with 8 additions and 11 deletions

View File

@ -104,6 +104,7 @@ class HomeAssistant {
Future _getLovelace() { Future _getLovelace() {
Completer completer = Completer(); Completer completer = Completer();
ConnectionManager().sendSocketMessage(type: "lovelace/config").then((data) { ConnectionManager().sendSocketMessage(type: "lovelace/config").then((data) {
_rawLovelaceData = data; _rawLovelaceData = data;
completer.complete(); completer.complete();

View File

@ -149,15 +149,14 @@ class LocationManager {
void updateDeviceLocationIsolate() { void updateDeviceLocationIsolate() {
workManager.Workmanager.executeTask((backgroundTask, data) { workManager.Workmanager.executeTask((backgroundTask, data) {
print("[Background $backgroundTask] Started"); //print("[Background $backgroundTask] Started");
final SentryClient sentryBackgroundClient = SentryClient(dsn: "https://5c868e5ef26947e2b61b189e391ec31b@sentry.io/1836366");
Geolocator geolocator = Geolocator(); Geolocator geolocator = Geolocator();
var battery = Battery(); var battery = Battery();
int batteryLevel = 100; int batteryLevel = 100;
String webhookId = data["webhookId"]; String webhookId = data["webhookId"];
String httpWebHost = data["httpWebHost"]; String httpWebHost = data["httpWebHost"];
if (webhookId != null && webhookId.isNotEmpty) { if (webhookId != null && webhookId.isNotEmpty) {
print("[Background $backgroundTask] hour=$battery"); //print("[Background $backgroundTask] hour=$battery");
String url = "$httpWebHost/api/webhook/$webhookId"; String url = "$httpWebHost/api/webhook/$webhookId";
Map<String, String> headers = {}; Map<String, String> headers = {};
headers["Content-Type"] = "application/json"; headers["Content-Type"] = "application/json";
@ -169,15 +168,15 @@ void updateDeviceLocationIsolate() {
"battery": batteryLevel "battery": batteryLevel
} }
}; };
print("[Background $backgroundTask] Getting battery level..."); //print("[Background $backgroundTask] Getting battery level...");
battery.batteryLevel.then((val) => data["data"]["battery"] = val).whenComplete((){ battery.batteryLevel.then((val) => data["data"]["battery"] = val).whenComplete((){
print("[Background $backgroundTask] Getting device location..."); //print("[Background $backgroundTask] Getting device location...");
geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high, locationPermissionLevel: GeolocationPermission.locationAlways).then((location) { geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high, locationPermissionLevel: GeolocationPermission.locationAlways).then((location) {
if (location != null) { if (location != null) {
print("[Background $backgroundTask] Got location: ${location.latitude} ${location.longitude}"); //print("[Background $backgroundTask] Got location: ${location.latitude} ${location.longitude}");
data["data"]["gps"] = [location.latitude, location.longitude]; data["data"]["gps"] = [location.latitude, location.longitude];
data["data"]["gps_accuracy"] = location.accuracy; data["data"]["gps_accuracy"] = location.accuracy;
print("[Background $backgroundTask] Sending data home."); //print("[Background $backgroundTask] Sending data home.");
http.post( http.post(
url, url,
headers: headers, headers: headers,
@ -187,10 +186,7 @@ void updateDeviceLocationIsolate() {
throw "Can't get device location. Location is null"; throw "Can't get device location. Location is null";
} }
}).catchError((e) { }).catchError((e) {
sentryBackgroundClient.captureException( //print("[Background $backgroundTask] Error getting current location: ${e.toString()}");
exception: "${e.toString()}"
);
print("[Background $backgroundTask] Error getting current location: ${e.toString()}");
}); });
}); });
} }