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>
<PrivateAssets>all</PrivateAssets>
</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="zxcvbn-core" Version="7.0.92" />
<PackageReference Include="CommunityToolkit.Maui" Version="5.2.0" />

View file

@ -53,7 +53,7 @@
<PackageReference Include="MessagePack" Version="2.5.124" />
<PackageReference Include="CsvHelper" Version="30.0.1" />
<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="zxcvbn-core" Version="7.0.92" />
<PackageReference Include="MessagePack.MSBuild.Tasks" Version="2.5.124">

View file

@ -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
});
}

View file

@ -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<IPlatformUtilsService>("platformUtilsService").GetDevice();
_userId = await ServiceContainer.Resolve<IStateService>("stateService").GetActiveUserIdAsync();
_appId = await ServiceContainer.Resolve<IAppIdService>("appIdService").GetAppIdAsync();
_userId = await ServiceContainer.Resolve<IStateService>().GetActiveUserIdAsync();
_appId = await ServiceContainer.Resolve<IAppIdService>().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<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,
IDictionary<string, string> 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);
}
}
}
}

View file

@ -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
}

View file

@ -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

View file

@ -129,7 +129,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" 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>
<BundleResource Include="Resources\yubikey.png" />

View file

@ -107,7 +107,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" 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>
<BundleResource Update="Resources\yubikey%403x.png">

View file

@ -101,7 +101,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" 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>
<ProjectReference Include="..\Core\Core.csproj" />