PM-3350 Updated AppCenter package to latest version 5.0.3 and updated some things into MAUI style

This commit is contained in:
Federico Maccaroni 2023-11-20 17:29:16 -03:00
parent ce41eb0578
commit e6b1bab860
No known key found for this signature in database
GPG key ID: 5D233F8F2B034536
9 changed files with 49 additions and 73 deletions

View file

@ -87,7 +87,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<!-- <PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.2" /> --> <PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="zxcvbn-core" Version="7.0.92" /> <PackageReference Include="zxcvbn-core" Version="7.0.92" />
<PackageReference Include="CommunityToolkit.Maui" Version="5.2.0" /> <PackageReference Include="CommunityToolkit.Maui" Version="5.2.0" />

View file

@ -53,7 +53,7 @@
<PackageReference Include="MessagePack" Version="2.5.124" /> <PackageReference Include="MessagePack" Version="2.5.124" />
<PackageReference Include="CsvHelper" Version="30.0.1" /> <PackageReference Include="CsvHelper" Version="30.0.1" />
<PackageReference Include="LiteDB" Version="5.0.17" /> <PackageReference Include="LiteDB" Version="5.0.17" />
<!-- <PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.2" /> --> <PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.3" />
<PackageReference Include="PCLCrypto" Version="2.1.40-alpha" /> <PackageReference Include="PCLCrypto" Version="2.1.40-alpha" />
<PackageReference Include="zxcvbn-core" Version="7.0.92" /> <PackageReference Include="zxcvbn-core" Version="7.0.92" />
<PackageReference Include="MessagePack.MSBuild.Tasks" Version="2.5.124"> <PackageReference Include="MessagePack.MSBuild.Tasks" Version="2.5.124">

View file

@ -1,11 +1,7 @@
using System; using System.Windows.Input;
using System.Threading.Tasks;
using System.Windows.Input;
using Bit.App.Utilities; using Bit.App.Utilities;
using Bit.Core.Abstractions; using Bit.Core.Abstractions;
using Bit.Core.Models.View; using Bit.Core.Models.View;
using Microsoft.Maui.Controls;
using Microsoft.Maui;
namespace Bit.App.Lists.ItemViewModels.CustomFields namespace Bit.App.Lists.ItemViewModels.CustomFields
{ {
@ -32,9 +28,9 @@ namespace Bit.App.Lists.ItemViewModels.CustomFields
CopyFieldCommand = new Command(() => copyFieldCommand?.Execute(Field)); CopyFieldCommand = new Command(() => copyFieldCommand?.Execute(Field));
ToggleHiddenValueCommand = CreateDefaultAsyncRelayCommand(ToggleHiddenValueAsync, null, ex => ToggleHiddenValueCommand = CreateDefaultAsyncRelayCommand(ToggleHiddenValueAsync, null, ex =>
{ {
//#if !FDROID #if !FDROID
// Microsoft.AppCenter.Crashes.Crashes.TrackError(ex); Microsoft.AppCenter.Crashes.Crashes.TrackError(ex);
//#endif #endif
}); });
} }

View file

@ -1,23 +1,21 @@
#if !FDROID #if !FDROID
using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Bit.Core.Abstractions; using Bit.Core.Abstractions;
using Bit.Core.Utilities; using Bit.Core.Utilities;
//using Microsoft.AppCenter; using Microsoft.AppCenter;
//using Microsoft.AppCenter.Crashes; using Microsoft.AppCenter.Crashes;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Bit.Core.Services namespace Bit.Core.Services
{ {
public class Logger : ILogger public class Logger : ILogger
{ {
private const string iOSAppSecret = "51f96ae5-68ba-45f6-99a1-8ad9f63046c3"; #if IOS
private const string DroidAppSecret = "d3834185-b4a6-4347-9047-b86c65293d42"; 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 _userId;
private string _appId; private string _appId;
@ -40,7 +38,6 @@ namespace Bit.Core.Services
{ {
} }
public string Description public string Description
{ {
get get
@ -60,40 +57,27 @@ namespace Bit.Core.Services
return; return;
} }
var device = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService").GetDevice(); _userId = await ServiceContainer.Resolve<IStateService>().GetActiveUserIdAsync();
_userId = await ServiceContainer.Resolve<IStateService>("stateService").GetActiveUserIdAsync(); _appId = await ServiceContainer.Resolve<IAppIdService>().GetAppIdAsync();
_appId = await ServiceContainer.Resolve<IAppIdService>("appIdService").GetAppIdAsync();
// TODO: [Error-Reporting] AppCenter.Start(AppSecret, typeof(Crashes));
//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.SetUserId(_userId);
//AppCenter.SetUserId(_userId); Crashes.GetErrorAttachments = (ErrorReport report) =>
{
//Crashes.GetErrorAttachments = (ErrorReport report) => return new ErrorAttachmentLog[]
//{ {
// return new ErrorAttachmentLog[] ErrorAttachmentLog.AttachmentWithText(Description, "crshdesc.txt"),
// { };
// ErrorAttachmentLog.AttachmentWithText(Description, "crshdesc.txt"), };
// };
//};
_isInitialised = true; _isInitialised = true;
} }
public async Task<bool> IsEnabled() => false;// await AppCenter.IsEnabledAsync(); public async Task<bool> 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, public void Error(string message,
IDictionary<string, string> extraData = null, IDictionary<string, string> extraData = null,
@ -109,28 +93,28 @@ namespace Bit.Core.Services
["Method"] = memberName ["Method"] = memberName
}; };
//var exception = new Exception(message ?? $"Error found in: {classAndMethod}"); var exception = new Exception(message ?? $"Error found in: {classAndMethod}");
//if (extraData == null) if (extraData == null)
//{ {
// Crashes.TrackError(exception, properties); Crashes.TrackError(exception, properties);
//} }
//else else
//{ {
// var data = properties.Concat(extraData).ToDictionary(x => x.Key, x => x.Value); var data = properties.Concat(extraData).ToDictionary(x => x.Key, x => x.Value);
// Crashes.TrackError(exception, data); Crashes.TrackError(exception, data);
//} }
} }
public void Exception(Exception exception) public void Exception(Exception exception)
{ {
//try try
//{ {
// Crashes.TrackError(exception); Crashes.TrackError(exception);
//} }
//catch (Exception ex) catch (Exception ex)
//{ {
// Debug.WriteLine(ex.Message); Debug.WriteLine(ex.Message);
//} }
} }
} }
} }

View file

@ -22,8 +22,7 @@ namespace Bit.Core.Services
#if !FDROID #if !FDROID
// just in case the caller throws the exception in a moment where the logger can't be resolved // 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 // we need to track the error as well
// TODO: [Error-Reporting] Microsoft.AppCenter.Crashes.Crashes.TrackError(ex);
//Microsoft.AppCenter.Crashes.Crashes.TrackError(ex);
#endif #endif
} }

View file

@ -1,7 +1,4 @@
using System; using System.Runtime.CompilerServices;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Bit.Core.Abstractions; using Bit.Core.Abstractions;
namespace Bit.Core.Services namespace Bit.Core.Services

View file

@ -129,7 +129,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" /> <PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" /> <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<!-- <PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.2" /> --> <PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<BundleResource Include="Resources\yubikey.png" /> <BundleResource Include="Resources\yubikey.png" />

View file

@ -107,7 +107,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" /> <PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" /> <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<!-- <PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.2" /> --> <PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<BundleResource Update="Resources\yubikey%403x.png"> <BundleResource Update="Resources\yubikey%403x.png">

View file

@ -101,7 +101,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" /> <PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" /> <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<!-- <PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.2" /> --> <PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Core\Core.csproj" /> <ProjectReference Include="..\Core\Core.csproj" />