private async void CrashButton_1000_Click(object sender, System.Windows.RoutedEventArgs e) { System.Diagnostics.Debug.WriteLine("Recording 1000 exceptions"); for (int a = 0; a < 1000; a++) { Countly.AddBreadCrumb("Recording exception x1000"); bool x = await Countly.RecordException("Some exception text"); } }
public async Task SendException() { Countly.UserDetails.Name = UserName; await Countly.StartSession(Server, ApiKey); await Countly.RecordException("Oh no!", "this is a trace\nmorelines\n"); await Countly.EndSession(); }
private async void Button_Click_0(object sender, RoutedEventArgs e) { //Record Handled Crash try { throw new DivideByZeroException(); } catch (Exception ex) { await Countly.RecordException(ex.Message, ex.StackTrace); } }
private void btnCrash_Click(object sender, EventArgs e) { try { throw new Exception("This is some bad exception 3"); } catch (Exception ex) { Dictionary <string, string> customInfo = new Dictionary <string, string>(); customInfo.Add("customData", "importantStuff"); Countly.RecordException(ex.Message, ex.StackTrace, customInfo); } }
void ThreadWorkExceptions() { Exception exToUse; try { throw new Exception("This is some bad exception 35454"); } catch (Exception ex) { exToUse = ex; } Random rnd = new Random(1); Dictionary <String, String> dict = new Dictionary <string, string>(); dict.Add("booh", "waah"); for (int a = 0; a < threadIterations; a++) { int choice = a % 4; bool res; switch (choice) { case 0: res = Countly.RecordException("Big error 1").Result; break; case 1: res = Countly.RecordException(exToUse.Message, exToUse.StackTrace).Result; break; case 2: res = Countly.RecordException(exToUse.Message, exToUse.StackTrace, dict).Result; break; case 3: default: res = Countly.RecordException(exToUse.Message, exToUse.StackTrace, dict, false).Result; break; } Assert.True(res); Thread.Sleep(rnd.Next(threadWaitStart, threadWaitEnd)); } }
public async void MultipleExceptions() { bool res; try { throw new Exception("This is some bad exception 3"); } catch (Exception ex) { Dictionary <string, string> customInfo = new Dictionary <string, string>(); customInfo.Add("customData", "importantStuff"); res = await Countly.RecordException(ex.Message, ex.StackTrace, customInfo); Assert.True(res); } Exception exToUse; try { throw new Exception("This is some bad exception 35454"); } catch (Exception ex) { exToUse = ex; } Dictionary <String, String> dict = new Dictionary <string, string>(); dict.Add("booh", "waah"); res = await Countly.RecordException("Big error 1"); Assert.True(res); res = await Countly.RecordException(exToUse.Message, exToUse.StackTrace); Assert.True(res); res = await Countly.RecordException(exToUse.Message, exToUse.StackTrace, dict); Assert.True(res); res = await Countly.RecordException(exToUse.Message, exToUse.StackTrace, dict, false); Assert.True(res); }
void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { Exception ex = e.Exception; logger.LogError("handled uncaught exception: {msg}", ex.Message); logger.LogError(ex.StackTrace); Dictionary <String, String> extraData = new Dictionary <string, string>(); Countly.RecordException(ex.Message, ex.StackTrace, extraData, true) .ContinueWith(RecordedException, TaskScheduler.FromCurrentSynchronizationContext()); MessageBox.Show("An unhandled exception just occurred: " + e.Exception.Message, "Exception Sample", MessageBoxButton.OK, MessageBoxImage.Warning); // This prevents the exception from crashing the application e.Handled = true; }
void ThreadWorkExceptions() { Exception exToUse; try { throw new Exception("This is some bad exception 35454"); } catch (Exception ex) { exToUse = ex; } Dictionary <String, String> dict = new Dictionary <string, string>(); dict.Add("booh", "waah"); for (int a = 0; a < threadIterations; a++) { int choice = a % 4; switch (choice) { case 0: Countly.RecordException("Big error 1"); break; case 1: Countly.RecordException(exToUse.Message, exToUse.StackTrace); break; case 2: Countly.RecordException(exToUse.Message, exToUse.StackTrace, dict); break; case 3: Countly.RecordException(exToUse.Message, exToUse.StackTrace, dict, false); break; default: break; } Thread.Sleep((new Random()).Next(threadWaitStart, threadWaitEnd)); } }
public async void VeryLargeException() { bool res; int steps = 10; String[] str = TestHelper.CreateLargeStrings(steps, 1000); for (int a = 0; a < steps; a++) { String pre = "" + (a + 1) + "/" + steps + " | "; String msg = pre + str[a]; res = await Countly.RecordException("" + (a + 1) + "SASAS", msg); Thread.Sleep(200); Assert.True(res); } }
public async Task Run() { Console.WriteLine("Hello to the Countly sample console program"); if (serverURL == null || appKey == null) { Console.WriteLine(""); Console.WriteLine("Problem encountered, you have not set up either the serverURL or the appKey"); Console.ReadKey(); return; } Countly.IsLoggingEnabled = true; //Countly.SetCustomDataPath(@"D:\123z\");//usable only when targeting .net3.5 //Countly.SetCustomDataPath(null); //Countly.deferUpload = true;//this call is only available by allowing access to internal members to this project, should not be used await Countly.StartSession(serverURL, appKey, "1.234", Countly.DeviceIdMethod.multipleFields); Console.WriteLine("DeviceID: " + await Countly.GetDeviceId()); System.Console.WriteLine("DeviceID: " + await Countly.GetDeviceId()); while (true) { Console.WriteLine(""); Console.WriteLine("Choose your option:"); Console.WriteLine("1) Sample event"); Console.WriteLine("2) Sample caught exception"); Console.WriteLine("3) Change deviceID to a random value (create new user)"); Console.WriteLine("4) Change the name of the current user"); Console.WriteLine("5) Exit"); Console.WriteLine("6) Another caught Exception"); Console.WriteLine("7) Test"); if (enableDebugOpptions) { Console.WriteLine("8) (debug) Threading test"); } ConsoleKeyInfo cki = System.Console.ReadKey(); Console.WriteLine(""); if (cki.Key == ConsoleKey.D1) { System.Console.WriteLine("1"); Countly.RecordEvent("Some event"); } else if (cki.Key == ConsoleKey.D2) { Console.WriteLine("2"); try { throw new Exception("This is some bad exception 3"); } catch (Exception ex) { Dictionary <string, string> customInfo = new Dictionary <string, string>(); customInfo.Add("customData", "importantStuff"); Countly.RecordException(ex.Message, ex.StackTrace, customInfo); } } else if (cki.Key == ConsoleKey.D3) { Console.WriteLine("3"); //await Device.SetDeviceId("ID-" + (new Random()).Next()); } else if (cki.Key == ConsoleKey.D4) { Console.WriteLine("4"); Countly.UserDetails.Name = "Some Username " + (new Random()).Next(); } else if (cki.Key == ConsoleKey.D5) { Console.WriteLine("5"); break; } else if (cki.Key == ConsoleKey.D6) { Console.WriteLine("6"); Countly.RecordException("What is here", ""); } else if (cki.Key == ConsoleKey.D7) { Console.WriteLine("7"); } else if (enableDebugOpptions && cki.Key == ConsoleKey.D8) { Console.WriteLine("8"); Console.WriteLine("Running threaded debug test"); ThreadTest(); } else { Console.WriteLine("Wrong input, please try again."); } } ; await Countly.EndSession(); }
public void Run() { Console.WriteLine("Hello to the Countly sample console program"); Console.WriteLine("DeviceID: " + Device.DeviceId); if (serverURL == null || appKey == null) { Console.WriteLine(""); Console.WriteLine("Problem encountered, you have not set up either the serverURL or the appKey"); Console.ReadKey(); return; } Countly.IsLoggingEnabled = true; //Countly.SetCustomDataPath(@"D:\123z\");//usable only when targeting .net3.5 //Countly.SetCustomDataPath(null); Countly.StartSession(serverURL, appKey, "1.234"); System.Console.WriteLine("DeviceID: " + Device.DeviceId); while (true) { Console.WriteLine(""); Console.WriteLine("Choose your option:"); Console.WriteLine("1) Sample event"); Console.WriteLine("2) Sample caught exception"); Console.WriteLine("3) Change deviceID to a random value (create new user)"); Console.WriteLine("4) Change the name of the current user"); Console.WriteLine("5) Exit"); if (enableDebugOpptions) { Console.WriteLine("8) (debug) Threading test"); } ConsoleKeyInfo cki = System.Console.ReadKey(); Console.WriteLine(""); if (cki.Key == ConsoleKey.D1) { System.Console.WriteLine("1"); Countly.RecordEvent("Some event"); } else if (cki.Key == ConsoleKey.D2) { Console.WriteLine("2"); try { throw new Exception("This is some bad exception 3"); } catch (Exception ex) { Countly.RecordException(ex.Message, ex.StackTrace); } } else if (cki.Key == ConsoleKey.D3) { Console.WriteLine("3"); Device.DeviceId = "ID-" + (new Random()).Next(); } else if (cki.Key == ConsoleKey.D4) { Console.WriteLine("4"); Countly.UserDetails.Name = "Some Username " + (new Random()).Next(); } else if (cki.Key == ConsoleKey.D5) { Console.WriteLine("5"); break; } else if (enableDebugOpptions && cki.Key == ConsoleKey.D8) { Console.WriteLine("8"); Console.WriteLine("Running threaded debug test"); ThreadTest(); } else { Console.WriteLine("Wrong input, please try again."); } } ; Countly.EndSession(); }
private async void CrashButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { await Countly.RecordException("exception info"); }
public async Task Run() { Console.WriteLine("Hello to the Countly sample console program"); Console.WriteLine("DeviceID: " + await Countly.GetDeviceId()); if (serverURL == null || appKey == null) { Console.WriteLine(""); Console.WriteLine("Problem encountered, you have not set up either the serverURL or the appKey"); Console.ReadKey(); return; } Countly.IsLoggingEnabled = true; //Countly.deferUpload = true; await Countly.StartSession(serverURL, appKey, "1.234", FileSystem.Current); System.Console.WriteLine("DeviceID: " + await Countly.GetDeviceId()); while (true) { Console.WriteLine(""); Console.WriteLine("Choose your option:"); Console.WriteLine("1) Sample event"); Console.WriteLine("2) Sample caught exception"); Console.WriteLine("3) Change deviceID to a random value (create new user)"); Console.WriteLine("4) Change the name of the current user"); Console.WriteLine("5) Exit"); Console.WriteLine("6) Another caught Exception"); Console.WriteLine("7) Sample event without await"); if (enableDebugOpptions) { Console.WriteLine("8) (debug) Threading test"); } ConsoleKeyInfo cki = System.Console.ReadKey(); Console.WriteLine(""); if (cki.Key == ConsoleKey.D1) { System.Console.WriteLine("1"); await Countly.RecordEvent("Some event"); } else if (cki.Key == ConsoleKey.D2) { Console.WriteLine("2"); try { throw new Exception("This is some bad exception 3"); } catch (Exception ex) { Dictionary <string, string> customInfo = new Dictionary <string, string>(); customInfo.Add("customData", "importantStuff"); await Countly.RecordException(ex.Message, ex.StackTrace, customInfo); } Exception exToUse; try { throw new Exception("This is some bad exception 35454"); } catch (Exception ex) { exToUse = ex; } Dictionary <String, String> dict = new Dictionary <string, string>(); dict.Add("booh", "waah"); await Countly.RecordException("Big error 1"); await Countly.RecordException(exToUse.Message, exToUse.StackTrace); await Countly.RecordException(exToUse.Message, exToUse.StackTrace, dict); await Countly.RecordException(exToUse.Message, exToUse.StackTrace, dict, false); } else if (cki.Key == ConsoleKey.D3) { Console.WriteLine("3"); //await Device.SetDeviceId("ID-" + (new Random()).Next()); } else if (cki.Key == ConsoleKey.D4) { Console.WriteLine("4"); Countly.UserDetails.Name = "Some Username " + (new Random()).Next(); } else if (cki.Key == ConsoleKey.D5) { Console.WriteLine("5"); break; } else if (cki.Key == ConsoleKey.D6) { Console.WriteLine("6"); await Countly.RecordException("What is here", ""); } else if (cki.Key == ConsoleKey.D7) { Console.WriteLine("7"); Countly.RecordEvent("Some event"); } else if (enableDebugOpptions && cki.Key == ConsoleKey.D8) { Console.WriteLine("8"); Console.WriteLine("Running threaded debug test"); ThreadTest(); } else { Console.WriteLine("Wrong input, please try again."); } } ; await Countly.EndSession(); }