Skip to content

Commit

Permalink
published v0.7.0 for windows
Browse files Browse the repository at this point in the history
fixed cmd popup issue
added sentry crash reporting
  • Loading branch information
oliverbytes committed Aug 24, 2022
1 parent e0b91c0 commit af56c86
Show file tree
Hide file tree
Showing 15 changed files with 110 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
- New! Autofill service setting
- New! Contact Screen
- New! Update Shared Vault details
- New! Sentry crash reporting for Windows
- Improved! Category/Template picker for large screen devices
- Improved! Files Explorer UX
- Improved! Descriptive biometric prompts
- Fixed! Stuck syncing after restore / unlock
- Fixed! Send feedback feature
- Fixed! Protected toggle is covered by Save button
- Fixed! Random CMD window flashing on Windows

## 0.6.0

Expand Down
21 changes: 21 additions & 0 deletions lib/core/firebase/config/models/config_secrets.model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@ class ConfigSecrets {
this.s3 = const ConfigSecretsS3(),
this.revenuecat = const ConfigSecretsRevenuecat(),
this.alchemy = const ConfigSecretsAlchemy(),
this.sentry = const ConfigSecretsSentry(),
});

final ConfigSecretsS3 s3;
final ConfigSecretsRevenuecat revenuecat;
final ConfigSecretsAlchemy alchemy;
final ConfigSecretsSentry sentry;

factory ConfigSecrets.fromJson(Map<String, dynamic> json) => ConfigSecrets(
s3: ConfigSecretsS3.fromJson(json["s3"]),
revenuecat: ConfigSecretsRevenuecat.fromJson(json["revenuecat"]),
alchemy: ConfigSecretsAlchemy.fromJson(json["alchemy"]),
sentry: ConfigSecretsSentry.fromJson(json["sentry"]),
);

Map<String, dynamic> toJson() => {
"s3": s3.toJson(),
"revenuecat": revenuecat.toJson(),
"alchemy": alchemy.toJson(),
"sentry": sentry.toJson(),
};
}

Expand Down Expand Up @@ -112,3 +116,20 @@ class ConfigSecretsS3 {
}
}
}

class ConfigSecretsSentry {
const ConfigSecretsSentry({
this.dsn = '',
});

final String dsn;

factory ConfigSecretsSentry.fromJson(Map<String, dynamic> json) =>
ConfigSecretsSentry(
dsn: json["dsn"],
);

Map<String, dynamic> toJson() => {
"dsn": dsn,
};
}
14 changes: 12 additions & 2 deletions lib/core/firebase/crashlytics.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:console_mixin/console_mixin.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/foundation.dart';
import 'package:get/get.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

import '../persistence/persistence.dart';

Expand Down Expand Up @@ -43,7 +44,7 @@ class CrashlyticsService extends GetxService with ConsoleMixin {
));
}

static void recordStatic(FlutterErrorDetails details) {
static void recordStatic(FlutterErrorDetails details) async {
final console = Console(name: 'CrashlyticsService');
final errorString = details.summary.value.toString();

Expand All @@ -65,7 +66,16 @@ class CrashlyticsService extends GetxService with ConsoleMixin {
}
}

if (GetPlatform.isWindows) return console.warning('Not Supported');
// send to sentry
if (GetPlatform.isWindows) {
await Sentry.captureException(
details.exception,
stackTrace: details.stack,
);

return;
}

FirebaseCrashlytics.instance.recordFlutterError(details);
}
}
36 changes: 33 additions & 3 deletions lib/core/hive/models/metadata/device.hive.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import 'dart:convert';
import 'dart:io';

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:console_mixin/console_mixin.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:get/get_utils/src/platform/platform.dart';
import 'package:hive/hive.dart';
Expand Down Expand Up @@ -65,7 +69,13 @@ class HiveMetadataDevice extends HiveObject {
static Future<HiveMetadataDevice> get() async {
final device = HiveMetadataDevice(platform: Utils.platformName());
final deviceInfo = DeviceInfoPlugin();
device.id = (await PlatformDeviceId.getDeviceId)!;

if (!GetPlatform.isWindows) {
device.id = (await PlatformDeviceId.getDeviceId)!;
} else {
device.id = await getWindowsDeviceID();
Console(name: 'Windows Device ID').wtf(device.id);
}

if (GetPlatform.isIOS) {
final info = await deviceInfo.iosInfo;
Expand All @@ -78,7 +88,6 @@ class HiveMetadataDevice extends HiveObject {
device.osVersion = info.version.release ?? '';
device.name = info.device ?? '';
device.model = info.model ?? '';

// strip unecessary info
final infoMap = info.toMap();
infoMap.remove('supportedAbis');
Expand All @@ -94,7 +103,6 @@ class HiveMetadataDevice extends HiveObject {
device.info = info.toMap();
} else if (GetPlatform.isWindows) {
final info = await deviceInfo.windowsInfo;
// generate a usable id
device.name = info.computerName;
device.info = info.toMap();
} else if (GetPlatform.isLinux) {
Expand All @@ -106,5 +114,27 @@ class HiveMetadataDevice extends HiveObject {
return device;
}

// manually obtain device id via process to avoid flashing window bug
// https://github.com/BestBurning/platform_device_id/issues/15
static Future<String> getWindowsDeviceID() async {
final process = await Process.start(
'wmic',
['csproduct', 'get', 'UUID'],
mode: ProcessStartMode.detachedWithStdio,
);

final result = await process.stdout.transform(utf8.decoder).toList();
String deviceId = '';

for (var element in result) {
final item = element.replaceAll(RegExp('\r|\n|\\s|UUID|uuid'), '');
if (item.isNotEmpty) {
deviceId = item;
}
}

return deviceId;
}

static Future<Map<String, dynamic>> getJson() async => (await get()).toJson();
}
4 changes: 3 additions & 1 deletion lib/core/liso/liso.manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class LisoManager {
// reset variables
S3Service.to.backedUp = false;
// invalidate purchases
await Purchases.invalidateCustomerInfoCache();
if (!GetPlatform.isWindows) {
await Purchases.invalidateCustomerInfoCache();
}
// sign out
AuthenticationMiddleware.signedIn = false;
console.info('reset!');
Expand Down
5 changes: 5 additions & 0 deletions lib/core/notifications/notifications.manager.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:get/get_utils/src/platform/platform.dart';
import 'package:liso/core/persistence/persistence.dart';
import 'package:console_mixin/console_mixin.dart';

Expand All @@ -10,6 +11,8 @@ class NotificationsManager {
static void cancelAll() => plugin.cancelAll();

static void init() async {
if (GetPlatform.isWindows) return console.warning('not supported');

const iosSettings = IOSInitializationSettings(
onDidReceiveLocalNotification: onForegroundPayload,
);
Expand All @@ -35,6 +38,8 @@ class NotificationsManager {
required final String body,
String payload = '',
}) async {
if (GetPlatform.isWindows) return console.warning('not supported');

const iosDetails = IOSNotificationDetails();
const macosDetails = MacOSNotificationDetails();
const linuxDetails = LinuxNotificationDetails();
Expand Down
7 changes: 6 additions & 1 deletion lib/features/app/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:liso/core/translations/data.dart';
import 'package:liso/features/app/pages.dart';
import 'package:liso/features/app/routes.dart';
import 'package:liso/features/general/unknown.screen.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

import '../../core/firebase/analytics.service.dart';
import '../../core/utils/globals.dart';
Expand All @@ -31,7 +32,11 @@ class App extends StatelessWidget {
// MATERIAL APP
return GetMaterialApp(
navigatorObservers: [
if (!GetPlatform.isWindows) ...[AnalyticsService.to.observer]
if (!GetPlatform.isWindows) ...[
AnalyticsService.to.observer,
] else ...[
SentryNavigatorObserver(),
]
],
debugShowCheckedModeBanner: false,
// showPerformanceOverlay: true,
Expand Down
2 changes: 1 addition & 1 deletion lib/features/debug/debug.screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:get/get.dart';
import 'package:iconsax/iconsax.dart';
import 'package:liso/features/debug/debug_screen.controller.dart';
import 'package:liso/features/general/appbar_leading.widget.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

import '../../core/firebase/auth_desktop.service.dart';
import '../../core/middlewares/authentication.middleware.dart';
Expand Down Expand Up @@ -80,7 +81,6 @@ class DebugScreen extends StatelessWidget with ConsoleMixin {
title: const Text('Sign Out'),
trailing: const Icon(Iconsax.arrow_right_3),
onTap: () async {
// Get.toNamed(Routes.categoryPicker);
AuthenticationMiddleware.signedIn = false;
},
),
Expand Down
11 changes: 11 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'package:liso/features/pro/pro.controller.dart';
import 'package:liso/features/wallet/wallet.service.dart';
import 'package:secrets/firebase_options.dart';
import 'package:secrets/secrets.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:window_manager/window_manager.dart';
import 'package:worker_manager/worker_manager.dart';

Expand Down Expand Up @@ -61,6 +62,16 @@ void init(Flavor flavor, {bool autofill = false}) async {
WidgetsFlutterBinding.ensureInitialized();
// improve performance
GestureBinding.instance.resamplingEnabled = true;
// init sentry
if (GetPlatform.isWindows) {
await SentryFlutter.init(
(options) {
options.dsn =
'https://2e0eed62c73845d3ac78dd47d374568a@o219011.ingest.sentry.io/6683557';
},
);
}

// init firebase
await Firebase.initializeApp(options: Secrets.firebaseOptions);

Expand Down
4 changes: 4 additions & 0 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <desktop_webview_auth/desktop_webview_auth_plugin.h>
#include <platform_device_id_linux/platform_device_id_linux_plugin.h>
#include <screen_retriever/screen_retriever_plugin.h>
#include <sentry_flutter/sentry_flutter_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
#include <window_manager/window_manager_plugin.h>

Expand All @@ -22,6 +23,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);
g_autoptr(FlPluginRegistrar) sentry_flutter_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "SentryFlutterPlugin");
sentry_flutter_plugin_register_with_registrar(sentry_flutter_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
Expand Down
1 change: 1 addition & 0 deletions linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
desktop_webview_auth
platform_device_id_linux
screen_retriever
sentry_flutter
url_launcher_linux
window_manager
)
Expand Down
2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import platform_device_id
import platform_device_id_macos
import purchases_flutter
import screen_retriever
import sentry_flutter
import share_plus_macos
import sqflite
import url_launcher_macos
Expand All @@ -47,6 +48,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PlatformDeviceIdMacosPlugin.register(with: registry.registrar(forPlugin: "PlatformDeviceIdMacosPlugin"))
PurchasesFlutterPlugin.register(with: registry.registrar(forPlugin: "PurchasesFlutterPlugin"))
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
SentryFlutterPlugin.register(with: registry.registrar(forPlugin: "SentryFlutterPlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
Expand Down
10 changes: 5 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ dependencies:
console_mixin: ^0.0.1 # logger
random_string_generator: ^2.0.0
humanizer: ^2.0.0
worker_manager: ^4.4.6
flutter_autofill_service: ^0.14.0
app_review: ^2.1.2+1
csv: ^5.0.1
xml2json: ^5.3.4
worker_manager: ^4.4.6 # multi threading
flutter_autofill_service: ^0.14.0 # android autofill plugun
app_review: ^2.1.2+1 # request for review on the app store
csv: ^5.0.1 # csv parsing tool
sentry_flutter: ^6.9.1 # crash reporting tool for windows

# INFO
device_info_plus: 4.1.2
Expand Down
3 changes: 3 additions & 0 deletions windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <local_auth_windows/local_auth_plugin.h>
#include <platform_device_id_windows/platform_device_id_windows_plugin.h>
#include <screen_retriever/screen_retriever_plugin.h>
#include <sentry_flutter/sentry_flutter_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>
#include <window_manager/window_manager_plugin.h>

Expand All @@ -25,6 +26,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("PlatformDeviceIdWindowsPlugin"));
ScreenRetrieverPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));
SentryFlutterPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SentryFlutterPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
WindowManagerPluginRegisterWithRegistrar(
Expand Down
1 change: 1 addition & 0 deletions windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
local_auth_windows
platform_device_id_windows
screen_retriever
sentry_flutter
url_launcher_windows
window_manager
)
Expand Down

0 comments on commit af56c86

Please sign in to comment.