Last active
December 24, 2015 23:29
-
-
Save jbristowe/6880046 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using EQATEC.Analytics.Monitor; | |
sealed partial class App : Application | |
{ | |
public static IAnalyticsMonitor Monitor; | |
public App() | |
{ | |
this.Suspending += OnSuspending; | |
this.Resuming += OnResuming; | |
this.UnhandledException += OnUnhandledException; | |
Version version = GetType().GetTypeInfo().Assembly.GetName().Version; | |
Monitor = AnalyticsMonitorFactory.CreateMonitor("PRODUCT KEY", version); | |
Monitor.Start(); | |
// ... | |
} | |
void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) | |
{ | |
if (Monitor != null) | |
{ | |
Monitor.TrackException(e.Exception); | |
Monitor.Stop(); | |
Monitor.Dispose(); | |
} | |
} | |
void OnResuming(object sender, object e) | |
{ | |
if (Monitor != null) | |
{ | |
Monitor.Start(); | |
} | |
} | |
async void OnSuspending(object sender, SuspendingEventArgs e) | |
{ | |
if (Monitor != null) | |
{ | |
Monitor.Stop(); | |
} | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment