diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index fdb1828df..72c332fda 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -19,7 +19,7 @@ Xamarin.Android.Net.AndroidClientHandler - Xamarin.GooglePlayServices.Base;Xamarin.GooglePlayServices.Basement;Xamarin.GooglePlayServices.Measurement;Xamarin.GooglePlayServices.Gcm;BitwardenAndroid;BitwardenApp;BitwardenCore;Xamarin.Android.Net;Xamarin.Android.Net.OldAndroidSSLSocketFactory;LiteDB + 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 true @@ -140,7 +140,7 @@ - + diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index 0553443b4..427d18128 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -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); diff --git a/src/Android/Utilities/AppCenterHelper.cs b/src/Android/Utilities/AppCenterHelper.cs new file mode 100644 index 000000000..d580fbbc6 --- /dev/null +++ b/src/Android/Utilities/AppCenterHelper.cs @@ -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 diff --git a/src/Android/Utilities/HockeyAppCrashManagerListener.cs b/src/Android/Utilities/HockeyAppCrashManagerListener.cs deleted file mode 100644 index b039839ef..000000000 --- a/src/Android/Utilities/HockeyAppCrashManagerListener.cs +++ /dev/null @@ -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 diff --git a/src/Android/ci-build-apks.ps1 b/src/Android/ci-build-apks.ps1 index c20e702c8..dbf191f0a 100644 --- a/src/Android/ci-build-apks.ps1 +++ b/src/Android/ci-build-apks.ps1 @@ -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); diff --git a/src/App/App.csproj b/src/App/App.csproj index 1aac8c3b0..dac0cba56 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/iOS.Autofill/CredentialProviderViewController.cs b/src/iOS.Autofill/CredentialProviderViewController.cs index 064ef5417..dbbf1d644 100644 --- a/src/iOS.Autofill/CredentialProviderViewController.cs +++ b/src/iOS.Autofill/CredentialProviderViewController.cs @@ -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("deviceActionService"); ServiceContainer.Init(deviceActionService.DeviceUserAgent); - if (!_initedHockeyApp) + if (!_initedAppCenter) { - iOSCoreHelpers.RegisterHockeyApp(); - _initedHockeyApp = true; + iOSCoreHelpers.RegisterAppCenter(); + _initedAppCenter = true; } iOSCoreHelpers.Bootstrap(); iOSCoreHelpers.AppearanceAdjustments(deviceActionService); diff --git a/src/iOS.Autofill/iOS.Autofill.csproj b/src/iOS.Autofill/iOS.Autofill.csproj index 2ddbb7039..15f2878a1 100644 --- a/src/iOS.Autofill/iOS.Autofill.csproj +++ b/src/iOS.Autofill/iOS.Autofill.csproj @@ -252,8 +252,8 @@ - - 5.2.0 + + 3.1.0 diff --git a/src/iOS.Core/Utilities/AppCenterHelper.cs b/src/iOS.Core/Utilities/AppCenterHelper.cs new file mode 100644 index 000000000..50b64d154 --- /dev/null +++ b/src/iOS.Core/Utilities/AppCenterHelper.cs @@ -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); + } + } + } +} diff --git a/src/iOS.Core/Utilities/HockeyAppCrashManagerDelegate.cs b/src/iOS.Core/Utilities/HockeyAppCrashManagerDelegate.cs deleted file mode 100644 index e700ea5cd..000000000 --- a/src/iOS.Core/Utilities/HockeyAppCrashManagerDelegate.cs +++ /dev/null @@ -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); - } - } -} diff --git a/src/iOS.Core/Utilities/iOSCoreHelpers.cs b/src/iOS.Core/Utilities/iOSCoreHelpers.cs index fc657ff0d..57cdd9943 100644 --- a/src/iOS.Core/Utilities/iOSCoreHelpers.cs +++ b/src/iOS.Core/Utilities/iOSCoreHelpers.cs @@ -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("appIdService"), ServiceContainer.Resolve("userService")); - var task = crashManagerDelegate.InitAsync(); + var appCenterTask = appCenterHelper.InitAsync(); } public static void RegisterLocalServices() diff --git a/src/iOS.Core/iOS.Core.csproj b/src/iOS.Core/iOS.Core.csproj index 1f5418dd7..5e07acb54 100644 --- a/src/iOS.Core/iOS.Core.csproj +++ b/src/iOS.Core/iOS.Core.csproj @@ -91,7 +91,7 @@ - + diff --git a/src/iOS.Extension/LoadingViewController.cs b/src/iOS.Extension/LoadingViewController.cs index 1a7c748de..12d3f612d 100644 --- a/src/iOS.Extension/LoadingViewController.cs +++ b/src/iOS.Extension/LoadingViewController.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("deviceActionService"); ServiceContainer.Init(deviceActionService.DeviceUserAgent); - if (!_initedHockeyApp) + if (!_initedAppCenter) { - iOSCoreHelpers.RegisterHockeyApp(); - _initedHockeyApp = true; + iOSCoreHelpers.RegisterAppCenter(); + _initedAppCenter = true; } iOSCoreHelpers.Bootstrap(); iOSCoreHelpers.AppearanceAdjustments(deviceActionService); diff --git a/src/iOS.Extension/iOS.Extension.csproj b/src/iOS.Extension/iOS.Extension.csproj index 3aadcfa94..9f9b017ef 100644 --- a/src/iOS.Extension/iOS.Extension.csproj +++ b/src/iOS.Extension/iOS.Extension.csproj @@ -227,8 +227,8 @@ - - 5.2.0 + + 3.1.0 diff --git a/src/iOS/AppDelegate.cs b/src/iOS/AppDelegate.cs index 558eebd01..98d09b15d 100644 --- a/src/iOS/AppDelegate.cs +++ b/src/iOS/AppDelegate.cs @@ -276,7 +276,7 @@ namespace Bit.iOS RegisterPush(); var deviceActionService = ServiceContainer.Resolve("deviceActionService"); ServiceContainer.Init(deviceActionService.DeviceUserAgent); - iOSCoreHelpers.RegisterHockeyApp(); + iOSCoreHelpers.RegisterAppCenter(); _pushHandler = new iOSPushNotificationHandler( ServiceContainer.Resolve("pushNotificationListenerService")); _nfcDelegate = new NFCReaderDelegate((success, message) =>