From 155500710ae08bb29a57d41880d704b6d97a5ca9 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Wed, 20 May 2015 13:37:08 -0700 Subject: [PATCH] Add Raygun reporting --- MatterControl.csproj | 12 ++++++++++++ MatterControlApplication.cs | 24 ++++++++++++++++++++++-- packages.config | 2 ++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/MatterControl.csproj b/MatterControl.csproj index 1c4347e9d..f19adcdc3 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -340,6 +340,14 @@ + + packages\Mindscape.Raygun4Net.5.0.0\lib\net40\Mindscape.Raygun4Net.dll + True + + + packages\Mindscape.Raygun4Net.5.0.0\lib\net40\Mindscape.Raygun4Net4.dll + True + False packages\Newtonsoft.Json.6.0.6\lib\net45\Newtonsoft.Json.dll @@ -348,6 +356,10 @@ PdfSharp.dll + + packages\Raygun.Diagnostics.0.7.3\lib\net45\Raygun.Diagnostics.dll + True + diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs index 35448c81a..5f16640ac 100644 --- a/MatterControlApplication.cs +++ b/MatterControlApplication.cs @@ -40,6 +40,7 @@ using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.PolygonMesh.Processors; using MatterHackers.RenderOpenGl.OpenGl; using MatterHackers.VectorMath; +using Mindscape.Raygun4Net; using System; using System.Collections.Generic; using System.Diagnostics; @@ -70,6 +71,8 @@ namespace MatterHackers.MatterControl private string unableToExitTitle = "Unable to Exit".Localize(); + private static RaygunClient _raygunClient = new RaygunClient("hQIlyUUZRGPyXVXbI6l1dA=="); + static MatterControlApplication() { // Because fields on this class call localization methods and because those methods depend on the StaticData provider and because the field @@ -360,20 +363,37 @@ namespace MatterHackers.MatterControl // Make sure we have the right working directory as we assume everything relative to the executable. Directory.SetCurrentDirectory(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)); + System.Windows.Forms.Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); + AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); + + //throw new Exception("Forced exception thrown manually!"); + Datastore.Instance.Initialize(); #if !DEBUG // Conditionally spin up error reporting if not on the Stable channel string channel = UserSettings.Instance.get("UpdateFeedType"); - if (string.IsNullOrEmpty(channel) || channel != "release") + if (string.IsNullOrEmpty(channel) || channel != "release" || OemSettings.Instance.WindowTitleExtra == "Experimental") #endif { - + System.Windows.Forms.Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); + AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); } MatterControlApplication app = MatterControlApplication.Instance; } + private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) + { + _raygunClient.Send(e.Exception); + } + + private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + _raygunClient.Send(e.ExceptionObject as Exception); + } + + public static void WriteTestGCodeFile() { using (StreamWriter file = new StreamWriter("PerformanceTest.gcode")) diff --git a/packages.config b/packages.config index 5cb1720db..cee43fb0e 100644 --- a/packages.config +++ b/packages.config @@ -1,4 +1,6 @@  + + \ No newline at end of file