mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 23:25:45 +03: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:
parent
915e8cf072
commit
4d3d8b643a
15 changed files with 138 additions and 142 deletions
|
@ -19,7 +19,7 @@
|
|||
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<AndroidLinkSkip>Xamarin.GooglePlayServices.Base;Xamarin.GooglePlayServices.Basement;Xamarin.GooglePlayServices.Measurement;Xamarin.GooglePlayServices.Gcm;BitwardenAndroid;BitwardenApp;BitwardenCore;Xamarin.Android.Net;Xamarin.Android.Net.OldAndroidSSLSocketFactory;LiteDB</AndroidLinkSkip>
|
||||
<AndroidLinkSkip>Xamarin.GooglePlayServices.Base;Xamarin.GooglePlayServices.Basement;Xamarin.GooglePlayServices.Measurement;Xamarin.GooglePlayServices.Gcm;BitwardenAndroid;BitwardenApp;BitwardenCore;Xamarin.Android.Net;Xamarin.Android.Net.OldAndroidSSLSocketFactory;LiteDB;Microsoft.AppCenter.Crashes</AndroidLinkSkip>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
@ -140,7 +140,7 @@
|
|||
<Compile Include="Tiles\GeneratorTileService.cs" />
|
||||
<Compile Include="Tiles\MyVaultTileService.cs" />
|
||||
<Compile Include="Utilities\AndroidHelpers.cs" />
|
||||
<Compile Include="Utilities\HockeyAppCrashManagerListener.cs" />
|
||||
<Compile Include="Utilities\AppCenterHelper.cs" />
|
||||
<Compile Include="Utilities\StaticStore.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -79,8 +79,8 @@ namespace Bit.Droid
|
|||
}
|
||||
|
||||
#if !FDROID
|
||||
var hockeyAppListener = new HockeyAppCrashManagerListener(_appIdService, _userService);
|
||||
var hockeyAppTask = hockeyAppListener.InitAsync(this);
|
||||
var appCenterHelper = new AppCenterHelper(_appIdService, _userService);
|
||||
var appCenterTask = appCenterHelper.InitAsync();
|
||||
#endif
|
||||
|
||||
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
|
||||
|
|
58
src/Android/Utilities/AppCenterHelper.cs
Normal file
58
src/Android/Utilities/AppCenterHelper.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
#if !FDROID
|
||||
using Bit.Core.Abstractions;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AppCenter;
|
||||
using Microsoft.AppCenter.Crashes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Droid.Utilities
|
||||
{
|
||||
public class AppCenterHelper
|
||||
{
|
||||
private const string AppSecret = "d3834185-b4a6-4347-9047-b86c65293d42";
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -1,69 +0,0 @@
|
|||
#if !FDROID
|
||||
using HockeyApp.Android;
|
||||
using Bit.App.Abstractions;
|
||||
using Newtonsoft.Json;
|
||||
using Android.Runtime;
|
||||
using Bit.Core.Abstractions;
|
||||
using System.Threading.Tasks;
|
||||
using Android.Content;
|
||||
|
||||
namespace Bit.Droid.Utilities
|
||||
{
|
||||
public class HockeyAppCrashManagerListener : CrashManagerListener
|
||||
{
|
||||
private const string HockeyAppId = "d3834185b4a643479047b86c65293d42";
|
||||
|
||||
private readonly IAppIdService _appIdService;
|
||||
private readonly IUserService _userService;
|
||||
|
||||
private string _userId;
|
||||
private string _appId;
|
||||
|
||||
public HockeyAppCrashManagerListener()
|
||||
{ }
|
||||
|
||||
public HockeyAppCrashManagerListener(System.IntPtr javaRef, JniHandleOwnership transfer)
|
||||
: base(javaRef, transfer)
|
||||
{ }
|
||||
|
||||
public HockeyAppCrashManagerListener(
|
||||
IAppIdService appIdService,
|
||||
IUserService userService)
|
||||
{
|
||||
_appIdService = appIdService;
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
public async Task InitAsync(Context context)
|
||||
{
|
||||
_userId = await _userService.GetUserIdAsync();
|
||||
_appId = await _appIdService.GetAppIdAsync();
|
||||
CrashManager.Register(context, HockeyAppId, this);
|
||||
}
|
||||
|
||||
public override string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_userId != null && _appId != null)
|
||||
{
|
||||
return JsonConvert.SerializeObject(new
|
||||
{
|
||||
AppId = _appId,
|
||||
UserId = _userId
|
||||
}, Formatting.Indented);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ShouldAutoUploadCrashes()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -108,8 +108,8 @@ echo "########################################"
|
|||
$xml=New-Object XML;
|
||||
$xml.Load($appPath);
|
||||
|
||||
$hockeyNode=$xml.SelectSingleNode("/Project/ItemGroup/PackageReference[@Include='HockeySDK.Xamarin']");
|
||||
$hockeyNode.ParentNode.RemoveChild($hockeyNode);
|
||||
$appCenterNode=$xml.SelectSingleNode("/Project/ItemGroup/PackageReference[@Include='Microsoft.AppCenter.Crashes']");
|
||||
$appCenterNode.ParentNode.RemoveChild($appCenterNode);
|
||||
|
||||
$xml.Save($appPath);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="HockeySDK.Xamarin" Version="5.2.0" />
|
||||
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="3.1.0" />
|
||||
<PackageReference Include="Plugin.Fingerprint" Version="2.1.1" />
|
||||
<PackageReference Include="Xamarin.Essentials" Version="1.5.1" />
|
||||
<PackageReference Include="Xamarin.FFImageLoading.Forms" Version="2.4.11.982" />
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Bit.iOS.Autofill
|
|||
public partial class CredentialProviderViewController : ASCredentialProviderViewController
|
||||
{
|
||||
private Context _context;
|
||||
private bool _initedHockeyApp;
|
||||
private bool _initedAppCenter;
|
||||
|
||||
public CredentialProviderViewController(IntPtr handle)
|
||||
: base(handle)
|
||||
|
@ -270,10 +270,10 @@ namespace Bit.iOS.Autofill
|
|||
iOSCoreHelpers.RegisterLocalServices();
|
||||
var deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||
ServiceContainer.Init(deviceActionService.DeviceUserAgent);
|
||||
if (!_initedHockeyApp)
|
||||
if (!_initedAppCenter)
|
||||
{
|
||||
iOSCoreHelpers.RegisterHockeyApp();
|
||||
_initedHockeyApp = true;
|
||||
iOSCoreHelpers.RegisterAppCenter();
|
||||
_initedAppCenter = true;
|
||||
}
|
||||
iOSCoreHelpers.Bootstrap();
|
||||
iOSCoreHelpers.AppearanceAdjustments(deviceActionService);
|
||||
|
|
|
@ -252,8 +252,8 @@
|
|||
<BundleResource Include="Resources\logo_white%403x.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="HockeySDK.Xamarin">
|
||||
<Version>5.2.0</Version>
|
||||
<PackageReference Include="Microsoft.AppCenter.Crashes">
|
||||
<Version>3.1.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.AppExtension.CSharp.targets" />
|
||||
|
|
56
src/iOS.Core/Utilities/AppCenterHelper.cs
Normal file
56
src/iOS.Core/Utilities/AppCenterHelper.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Bit.iOS.Extension
|
|||
public partial class LoadingViewController : ExtendedUIViewController
|
||||
{
|
||||
private Context _context = new Context();
|
||||
private bool _initedHockeyApp;
|
||||
private bool _initedAppCenter;
|
||||
|
||||
public LoadingViewController(IntPtr handle)
|
||||
: base(handle)
|
||||
|
@ -389,10 +389,10 @@ namespace Bit.iOS.Extension
|
|||
iOSCoreHelpers.RegisterLocalServices();
|
||||
var deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||
ServiceContainer.Init(deviceActionService.DeviceUserAgent);
|
||||
if (!_initedHockeyApp)
|
||||
if (!_initedAppCenter)
|
||||
{
|
||||
iOSCoreHelpers.RegisterHockeyApp();
|
||||
_initedHockeyApp = true;
|
||||
iOSCoreHelpers.RegisterAppCenter();
|
||||
_initedAppCenter = true;
|
||||
}
|
||||
iOSCoreHelpers.Bootstrap();
|
||||
iOSCoreHelpers.AppearanceAdjustments(deviceActionService);
|
||||
|
|
|
@ -227,8 +227,8 @@
|
|||
<BundleResource Include="Resources\logo_white%403x.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="HockeySDK.Xamarin">
|
||||
<Version>5.2.0</Version>
|
||||
<PackageReference Include="Microsoft.AppCenter.Crashes">
|
||||
<Version>3.1.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.AppExtension.CSharp.targets" />
|
||||
|
|
|
@ -276,7 +276,7 @@ namespace Bit.iOS
|
|||
RegisterPush();
|
||||
var deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||
ServiceContainer.Init(deviceActionService.DeviceUserAgent);
|
||||
iOSCoreHelpers.RegisterHockeyApp();
|
||||
iOSCoreHelpers.RegisterAppCenter();
|
||||
_pushHandler = new iOSPushNotificationHandler(
|
||||
ServiceContainer.Resolve<IPushNotificationListenerService>("pushNotificationListenerService"));
|
||||
_nfcDelegate = new NFCReaderDelegate((success, message) =>
|
||||
|
|
Loading…
Reference in a new issue