1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-22 19:23:58 +00:00

Conversion of HockeyApp to AppCenter for crash reporting (#810)

* Conversion of HockeyApp to AppCenter for crash reporting

* Corrected older-style nuget package definition
This commit is contained in:
Matt Portune
2020-04-02 09:02:38 -04:00
committed by GitHub
parent 915e8cf072
commit 4d3d8b643a
15 changed files with 138 additions and 142 deletions

View File

@@ -0,0 +1,56 @@
using Bit.Core.Abstractions;
using System.Threading.Tasks;
using Microsoft.AppCenter;
using Microsoft.AppCenter.Crashes;
using Newtonsoft.Json;
namespace Bit.iOS.Core.Utilities
{
public class AppCenterHelper
{
private const string AppSecret = "51f96ae5-68ba-45f6-99a1-8ad9f63046c3";
private readonly IAppIdService _appIdService;
private readonly IUserService _userService;
private string _userId;
private string _appId;
public AppCenterHelper(
IAppIdService appIdService,
IUserService userService)
{
_appIdService = appIdService;
_userService = userService;
}
public async Task InitAsync()
{
_userId = await _userService.GetUserIdAsync();
_appId = await _appIdService.GetAppIdAsync();
AppCenter.Start(AppSecret, typeof(Crashes));
AppCenter.SetUserId(_userId);
Crashes.GetErrorAttachments = (ErrorReport report) =>
{
return new ErrorAttachmentLog[]
{
ErrorAttachmentLog.AttachmentWithText(Description, "crshdesc.txt"),
};
};
}
public string Description
{
get
{
return JsonConvert.SerializeObject(new
{
AppId = _appId,
UserId = _userId
}, Formatting.Indented);
}
}
}
}

View File

@@ -1,48 +0,0 @@
using Bit.Core.Abstractions;
using HockeyApp.iOS;
using Newtonsoft.Json;
using System.Threading.Tasks;
namespace Bit.iOS.Core.Utilities
{
public class HockeyAppCrashManagerDelegate : BITCrashManagerDelegate
{
private const string HockeyAppId = "51f96ae568ba45f699a18ad9f63046c3";
private readonly IAppIdService _appIdService;
private readonly IUserService _userService;
private string _userId;
private string _appId;
public HockeyAppCrashManagerDelegate(
IAppIdService appIdService,
IUserService userService)
{
_appIdService = appIdService;
_userService = userService;
}
public async Task InitAsync()
{
_userId = await _userService.GetUserIdAsync();
_appId = await _appIdService.GetAppIdAsync();
var manager = BITHockeyManager.SharedHockeyManager;
manager.Configure(HockeyAppId, this);
manager.CrashManager.CrashManagerStatus = BITCrashManagerStatus.AutoSend;
manager.UserId = _userId;
manager.Authenticator.AuthenticateInstallation();
manager.DisableMetricsManager = manager.DisableFeedbackManager = manager.DisableUpdateManager = true;
manager.StartManager();
}
public override string ApplicationLogForCrashManager(BITCrashManager crashManager)
{
return JsonConvert.SerializeObject(new
{
AppId = _appId,
UserId = _userId
}, Formatting.Indented);
}
}
}

View File

@@ -9,7 +9,6 @@ using Bit.Core.Services;
using Bit.Core.Utilities;
using Bit.iOS.Core.Services;
using Foundation;
using HockeyApp.iOS;
using UIKit;
namespace Bit.iOS.Core.Utilities
@@ -22,12 +21,12 @@ namespace Bit.iOS.Core.Utilities
public static string AppGroupId = "group.com.8bit.bitwarden";
public static string AccessGroup = "LTZ2PFU5D6.com.8bit.bitwarden";
public static void RegisterHockeyApp()
public static void RegisterAppCenter()
{
var crashManagerDelegate = new HockeyAppCrashManagerDelegate(
var appCenterHelper = new AppCenterHelper(
ServiceContainer.Resolve<IAppIdService>("appIdService"),
ServiceContainer.Resolve<IUserService>("userService"));
var task = crashManagerDelegate.InitAsync();
var appCenterTask = appCenterHelper.InitAsync();
}
public static void RegisterLocalServices()

View File

@@ -91,7 +91,7 @@
<Compile Include="Services\DeviceActionService.cs" />
<Compile Include="Utilities\ASHelpers.cs" />
<Compile Include="Utilities\Dialogs.cs" />
<Compile Include="Utilities\HockeyAppCrashManagerDelegate.cs" />
<Compile Include="Utilities\AppCenterHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\CryptoPrimitiveService.cs" />
<Compile Include="Services\KeyChainStorageService.cs" />