diff --git a/src/App/App.csproj b/src/App/App.csproj index 7cdef448b..dae8ee799 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -87,7 +87,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj index bfcd007b6..ecbd8c99a 100644 --- a/src/Core/Core.csproj +++ b/src/Core/Core.csproj @@ -53,7 +53,7 @@ - + diff --git a/src/Core/Lists/ItemViewModels/CustomFields/HiddenCustomFieldItemViewModel.cs b/src/Core/Lists/ItemViewModels/CustomFields/HiddenCustomFieldItemViewModel.cs index 526e0dc96..b4cbcce24 100644 --- a/src/Core/Lists/ItemViewModels/CustomFields/HiddenCustomFieldItemViewModel.cs +++ b/src/Core/Lists/ItemViewModels/CustomFields/HiddenCustomFieldItemViewModel.cs @@ -1,11 +1,7 @@ -using System; -using System.Threading.Tasks; -using System.Windows.Input; +using System.Windows.Input; using Bit.App.Utilities; using Bit.Core.Abstractions; using Bit.Core.Models.View; -using Microsoft.Maui.Controls; -using Microsoft.Maui; namespace Bit.App.Lists.ItemViewModels.CustomFields { @@ -32,9 +28,9 @@ namespace Bit.App.Lists.ItemViewModels.CustomFields CopyFieldCommand = new Command(() => copyFieldCommand?.Execute(Field)); ToggleHiddenValueCommand = CreateDefaultAsyncRelayCommand(ToggleHiddenValueAsync, null, ex => { -//#if !FDROID -// Microsoft.AppCenter.Crashes.Crashes.TrackError(ex); -//#endif +#if !FDROID + Microsoft.AppCenter.Crashes.Crashes.TrackError(ex); +#endif }); } diff --git a/src/Core/Services/Logging/Logger.cs b/src/Core/Services/Logging/Logger.cs index 7b9a7f5c8..e4f3d9381 100644 --- a/src/Core/Services/Logging/Logger.cs +++ b/src/Core/Services/Logging/Logger.cs @@ -1,23 +1,21 @@ #if !FDROID -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.IO; -using System.Linq; using System.Runtime.CompilerServices; -using System.Threading.Tasks; using Bit.Core.Abstractions; using Bit.Core.Utilities; -//using Microsoft.AppCenter; -//using Microsoft.AppCenter.Crashes; +using Microsoft.AppCenter; +using Microsoft.AppCenter.Crashes; using Newtonsoft.Json; namespace Bit.Core.Services { public class Logger : ILogger { - private const string iOSAppSecret = "51f96ae5-68ba-45f6-99a1-8ad9f63046c3"; - private const string DroidAppSecret = "d3834185-b4a6-4347-9047-b86c65293d42"; +#if IOS + private const string AppSecret = "51f96ae5-68ba-45f6-99a1-8ad9f63046c3"; +#else + private const string AppSecret = "d3834185-b4a6-4347-9047-b86c65293d42"; +#endif private string _userId; private string _appId; @@ -40,7 +38,6 @@ namespace Bit.Core.Services { } - public string Description { get @@ -60,40 +57,27 @@ namespace Bit.Core.Services return; } - var device = ServiceContainer.Resolve("platformUtilsService").GetDevice(); - _userId = await ServiceContainer.Resolve("stateService").GetActiveUserIdAsync(); - _appId = await ServiceContainer.Resolve("appIdService").GetAppIdAsync(); + _userId = await ServiceContainer.Resolve().GetActiveUserIdAsync(); + _appId = await ServiceContainer.Resolve().GetAppIdAsync(); - // TODO: [Error-Reporting] - //switch (device) - //{ - // case Enums.DeviceType.Android: - // AppCenter.Start(DroidAppSecret, typeof(Crashes)); - // break; - // case Enums.DeviceType.iOS: - // AppCenter.Start(iOSAppSecret, typeof(Crashes)); - // break; - // default: - // throw new AppCenterException("Cannot start AppCenter. Device type is not configured."); + AppCenter.Start(AppSecret, typeof(Crashes)); - //} + AppCenter.SetUserId(_userId); - //AppCenter.SetUserId(_userId); - - //Crashes.GetErrorAttachments = (ErrorReport report) => - //{ - // return new ErrorAttachmentLog[] - // { - // ErrorAttachmentLog.AttachmentWithText(Description, "crshdesc.txt"), - // }; - //}; + Crashes.GetErrorAttachments = (ErrorReport report) => + { + return new ErrorAttachmentLog[] + { + ErrorAttachmentLog.AttachmentWithText(Description, "crshdesc.txt"), + }; + }; _isInitialised = true; } - public async Task IsEnabled() => false;// await AppCenter.IsEnabledAsync(); + public async Task IsEnabled() => await AppCenter.IsEnabledAsync(); - public async Task SetEnabled(bool value) { }// await AppCenter.SetEnabledAsync(value); + public async Task SetEnabled(bool value) => await AppCenter.SetEnabledAsync(value); public void Error(string message, IDictionary extraData = null, @@ -109,28 +93,28 @@ namespace Bit.Core.Services ["Method"] = memberName }; - //var exception = new Exception(message ?? $"Error found in: {classAndMethod}"); - //if (extraData == null) - //{ - // Crashes.TrackError(exception, properties); - //} - //else - //{ - // var data = properties.Concat(extraData).ToDictionary(x => x.Key, x => x.Value); - // Crashes.TrackError(exception, data); - //} + var exception = new Exception(message ?? $"Error found in: {classAndMethod}"); + if (extraData == null) + { + Crashes.TrackError(exception, properties); + } + else + { + var data = properties.Concat(extraData).ToDictionary(x => x.Key, x => x.Value); + Crashes.TrackError(exception, data); + } } public void Exception(Exception exception) { - //try - //{ - // Crashes.TrackError(exception); - //} - //catch (Exception ex) - //{ - // Debug.WriteLine(ex.Message); - //} + try + { + Crashes.TrackError(exception); + } + catch (Exception ex) + { + Debug.WriteLine(ex.Message); + } } } } diff --git a/src/Core/Services/Logging/LoggerHelper.cs b/src/Core/Services/Logging/LoggerHelper.cs index c8dad80e8..9cdf225f6 100644 --- a/src/Core/Services/Logging/LoggerHelper.cs +++ b/src/Core/Services/Logging/LoggerHelper.cs @@ -22,8 +22,7 @@ namespace Bit.Core.Services #if !FDROID // just in case the caller throws the exception in a moment where the logger can't be resolved // we need to track the error as well - // TODO: [Error-Reporting] - //Microsoft.AppCenter.Crashes.Crashes.TrackError(ex); + Microsoft.AppCenter.Crashes.Crashes.TrackError(ex); #endif } diff --git a/src/Core/Services/Logging/StubLogger.cs b/src/Core/Services/Logging/StubLogger.cs index 2bb8bcd45..2d4161500 100644 --- a/src/Core/Services/Logging/StubLogger.cs +++ b/src/Core/Services/Logging/StubLogger.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using System.Threading.Tasks; +using System.Runtime.CompilerServices; using Bit.Core.Abstractions; namespace Bit.Core.Services diff --git a/src/iOS.Autofill/iOS.Autofill.csproj b/src/iOS.Autofill/iOS.Autofill.csproj index 47b72eded..d235b5418 100644 --- a/src/iOS.Autofill/iOS.Autofill.csproj +++ b/src/iOS.Autofill/iOS.Autofill.csproj @@ -129,7 +129,7 @@ - + diff --git a/src/iOS.Extension/iOS.Extension.csproj b/src/iOS.Extension/iOS.Extension.csproj index 69d29352e..a027cc52c 100644 --- a/src/iOS.Extension/iOS.Extension.csproj +++ b/src/iOS.Extension/iOS.Extension.csproj @@ -107,7 +107,7 @@ - + diff --git a/src/iOS.ShareExtension/iOS.ShareExtension.csproj b/src/iOS.ShareExtension/iOS.ShareExtension.csproj index 6acd7e412..0d9963351 100644 --- a/src/iOS.ShareExtension/iOS.ShareExtension.csproj +++ b/src/iOS.ShareExtension/iOS.ShareExtension.csproj @@ -101,7 +101,7 @@ - +