1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-05 18:13:36 +00:00

PM-3349 PM-3350 MAUI Migration Initial

This commit is contained in:
Federico Maccaroni
2023-09-29 11:02:19 -03:00
parent bbef0f8c93
commit 8ef9443b1e
717 changed files with 5367 additions and 4702 deletions

View File

@@ -8,8 +8,8 @@ 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
@@ -64,35 +64,36 @@ namespace Bit.Core.Services
_userId = await ServiceContainer.Resolve<IStateService>("stateService").GetActiveUserIdAsync();
_appId = await ServiceContainer.Resolve<IAppIdService>("appIdService").GetAppIdAsync();
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.");
// TODO: [MAUI-Migration] [Critical]
//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) =>
{
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() => await AppCenter.IsEnabledAsync();
public async Task<bool> IsEnabled() => false;// 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,
@@ -108,28 +109,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,7 +22,8 @@ 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
Microsoft.AppCenter.Crashes.Crashes.TrackError(ex);
// [MAUI-Migration] [Critical]
//Microsoft.AppCenter.Crashes.Crashes.TrackError(ex);
#endif
}