Skip to content

Commit

Permalink
Merge pull request Azure-Samples#530 from alinapopa/hockeyApp
Browse files Browse the repository at this point in the history
Enable Hockey App logging for UWP
  • Loading branch information
Alina Popa committed May 12, 2016
2 parents f5cdbea + a9e784b commit 73654e9
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
using Android.Runtime;
using System;
using System.Threading.Tasks;
using HockeyApp;


namespace MyDriving.Droid
{
Expand Down Expand Up @@ -82,20 +84,39 @@ void InitializeHockeyApp()
return;

HockeyApp.CrashManager.Register(this, Logger.HockeyAppAndroid);
HockeyApp.UpdateManager.Register(this, Logger.HockeyAppAndroid);
HockeyApp.Metrics.MetricsManager.Register(this, Application, Logger.HockeyAppAndroid);
HockeyApp.TraceWriter.Initialize();
HockeyApp.Metrics.MetricsManager.EnableUserMetrics();

AndroidEnvironment.UnhandledExceptionRaiser += (sender, args) =>
{
HockeyApp.TraceWriter.WriteTrace(args.Exception);
args.Handled = true;
};
AppDomain.CurrentDomain.UnhandledException +=
(sender, args) => HockeyApp.TraceWriter.WriteTrace(args.ExceptionObject);
TaskScheduler.UnobservedTaskException += (sender, args) => HockeyApp.TraceWriter.WriteTrace(args.Exception);
CheckForUpdates();

}

void CheckForUpdates()
{
// Remove this for store builds!
UpdateManager.Register(this, Logger.HockeyAppAndroid);
}

void UnregisterManagers()
{
UpdateManager.Unregister();
}

protected override void OnPause()
{
base.OnPause();

UnregisterManagers();
}

protected override void OnDestroy()
{
base.OnDestroy();

UnregisterManagers();
}


void ListItemClicked(int itemId)
{
//this way we don't load twice, but you might want to modify this a bit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
</PropertyGroup>
<ItemGroup>
<Reference Include="HockeySDK, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\HockeySDK.Xamarin.4.1.0-beta1\lib\MonoAndroid403\HockeySDK.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Devices.Client.PCL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Azure.Devices.Client.PCL.1.0.3\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Microsoft.Azure.Devices.Client.PCL.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -249,9 +253,6 @@
<Reference Include="MvvmHelpers">
<HintPath>..\..\packages\Refractored.MvvmHelpers.1.0.1\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\MvvmHelpers.dll</HintPath>
</Reference>
<Reference Include="HockeySDK">
<HintPath>..\..\packages\HockeySDK.Xamarin.4.1.0-alpha2\lib\MonoAndroid403\HockeySDK.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyDriving.DataStore.Abstractions\MyDriving.DataStore.Abstractions.csproj">
Expand Down Expand Up @@ -309,7 +310,9 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="Resources\AboutResources.txt" />
<None Include="Properties\AndroidManifest.xml" />
<None Include="Assets\AboutAssets.txt" />
Expand Down
2 changes: 1 addition & 1 deletion src/MobileApps/MyDriving/MyDriving.Android/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="Acr.Support" version="1.1.1" targetFramework="MonoAndroid60" />
<package id="Acr.UserDialogs.Android.AppCompat" version="4.3.2" targetFramework="MonoAndroid60" />
<package id="HockeySDK.Xamarin" version="4.1.0-alpha2" targetFramework="MonoAndroid60" />
<package id="HockeySDK.Xamarin" version="4.1.0-beta1" targetFramework="monoandroid60" />
<package id="Humanizer.Core" version="2.0.1" targetFramework="monoandroid60" />
<package id="Microsoft.Azure.Devices.Client.PCL" version="1.0.3" targetFramework="monoandroid60" />
<package id="Microsoft.Azure.Mobile.Client" version="2.0.1" targetFramework="monoandroid60" />
Expand Down
4 changes: 4 additions & 0 deletions src/MobileApps/MyDriving/MyDriving.Shared/PlatformLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public override void Track(string trackIdentifier, IDictionary<string, string> t
HockeyApp.Metrics.MetricsManager.TrackEvent(trackIdentifier);
#elif __IOS__
HockeyApp.BITHockeyManager.SharedHockeyManager?.MetricsManager?.TrackEvent(trackIdentifier);
#elif WINDOWS_UWP
Microsoft.HockeyApp.HockeyClient.Current.TrackEvent(trackIdentifier);
#endif
base.Track(trackIdentifier, table);
}
Expand All @@ -55,6 +57,8 @@ public override void Track(string trackIdentifier, string key, string value)
HockeyApp.Metrics.MetricsManager.TrackEvent(trackIdentifier);
#elif __IOS__
HockeyApp.BITHockeyManager.SharedHockeyManager?.MetricsManager?.TrackEvent(trackIdentifier);
#elif WINDOWS_UWP
Microsoft.HockeyApp.HockeyClient.Current.TrackEvent(trackIdentifier);
#endif
base.Track(trackIdentifier, key, value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/MobileApps/MyDriving/MyDriving.UWP/project.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"dependencies": {
"Acr.UserDialogs": "4.3.4",
"HockeySDK.UWP": "3.1.1-build59744",
"HockeySDK.UWP": "4.0.0",
"Humanizer.Core": "2.0.1",
"Microsoft.Azure.Devices.Client.PCL": "1.0.3",
"Microsoft.Azure.Mobile.Client.SQLiteStore": "2.0.1",
Expand Down
46 changes: 19 additions & 27 deletions src/MobileApps/MyDriving/MyDriving.iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,16 @@ public override bool FinishedLaunching(UIApplication application, NSDictionary l
ServiceLocator.Instance.Add<IAuthentication, Authentication>();
ServiceLocator.Instance.Add<ILogger, PlatformLogger>();
ServiceLocator.Instance.Add<IOBDDevice, OBDDevice>();

Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
SQLitePCL.CurrentPlatform.Init();

#if !XTC
if (!string.IsNullOrWhiteSpace(Logger.HockeyAppiOS))
{
Setup.EnableCustomCrashReporting(() =>
{
var manager = BITHockeyManager.SharedHockeyManager;
manager.Configure(Logger.HockeyAppiOS);
manager.StartManager();
manager.Authenticator.AuthenticateInstallation();
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
Setup.ThrowExceptionAsNative(e.ExceptionObject);
TaskScheduler.UnobservedTaskException += (sender, e) =>
Setup.ThrowExceptionAsNative(e.Exception);
});
var manager = BITHockeyManager.SharedHockeyManager;
manager.Configure(Logger.HockeyAppiOS);
manager.StartManager();
}
#endif

Expand All @@ -57,21 +49,21 @@ public override bool FinishedLaunching(UIApplication application, NSDictionary l
.InstantiateViewController("loginViewController");
Window.RootViewController = viewController;
#else
if (Settings.Current.FirstRun)
{
var viewController = UIStoryboard.FromName("Main", null)
.InstantiateViewController("gettingStartedViewController");
var navigationController = new UINavigationController(viewController);
Window.RootViewController = navigationController;

Settings.Current.FirstRun = false;
}
else
{
var viewController = UIStoryboard.FromName("Main", null)
.InstantiateViewController("loginViewController");
Window.RootViewController = viewController;
}
if (Settings.Current.FirstRun)
{
var viewController = UIStoryboard.FromName("Main", null)
.InstantiateViewController("gettingStartedViewController");
var navigationController = new UINavigationController(viewController);
Window.RootViewController = navigationController;

Settings.Current.FirstRun = false;
}
else
{
var viewController = UIStoryboard.FromName("Main", null)
.InstantiateViewController("loginViewController");
Window.RootViewController = viewController;
}
#endif
}
else
Expand Down
7 changes: 4 additions & 3 deletions src/MobileApps/MyDriving/MyDriving.iOS/MyDriving.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@
<HintPath>..\..\packages\Xamarin.TestCloud.Agent.0.18.2\lib\Xamarin.iOS10\Calabash.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="HockeySDK, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\HockeySDK.Xamarin.4.1.0-beta1\lib\Xamarin.iOS10\HockeySDK.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Devices.Client.PCL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Azure.Devices.Client.PCL.1.0.3\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Microsoft.Azure.Devices.Client.PCL.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -245,9 +249,6 @@
<Reference Include="BTProgressHUD">
<HintPath>..\..\..\Components\btprogresshud-1.20\lib\ios-unified\BTProgressHUD.dll</HintPath>
</Reference>
<Reference Include="HockeySDK">
<HintPath>..\..\packages\HockeySDK.Xamarin.4.1.0-alpha2\lib\Xamarin.iOS10\HockeySDK.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\OBDLibrary\ObdLibiOS\ObdLibiOS.csproj">
Expand Down
2 changes: 1 addition & 1 deletion src/MobileApps/MyDriving/MyDriving.iOS/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="Acr.Support" version="1.1.1" targetFramework="xamarinios10" />
<package id="Acr.UserDialogs" version="4.3.4" targetFramework="xamarinios10" />
<package id="HockeySDK.Xamarin" version="4.1.0-alpha2" targetFramework="xamarinios10" />
<package id="HockeySDK.Xamarin" version="4.1.0-beta1" targetFramework="xamarinios10" />
<package id="Humanizer" version="2.0.1" targetFramework="xamarinios10" />
<package id="Humanizer.Core" version="2.0.1" targetFramework="xamarinios10" />
<package id="Microsoft.Azure.Devices.Client.PCL" version="1.0.3" targetFramework="xamarinios10" />
Expand Down

0 comments on commit 73654e9

Please sign in to comment.