/// <summary> /// Invoked when application execution is being suspended. Application state is saved /// without knowing whether the application will be terminated or resumed with the contents /// of memory still intact. /// </summary> /// <param name="sender">The source of the suspend request.</param> /// <param name="e">Details about the suspend request.</param> private async void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); await Countly.EndSession(); deferral.Complete(); }
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(); }
public async Task RecordEvent() { Countly.UserDetails.Name = UserName; await Countly.StartSession(Server, ApiKey); var segmentation = new Segmentation(); segmentation.Add("test", new Random().Next(10).ToString()); Countly.RecordEvent("unit-test", 1, 0, 123.5, segmentation); await Countly.EndSession(); }
public async Task SendAction() { Countly.UserDetails.Name = UserName; await Countly.StartSession(Server, ApiKey); Countly.RecordView("ScreenA", MakeSegment()); var segmentation = MakeSegment(); segmentation.Add("type", "click"); segmentation.Add("x", "0"); segmentation.Add("y", "0"); segmentation.Add("width", "0"); segmentation.Add("height", "0"); Countly.RecordEvent("[CLY]_action", segmentation: segmentation); await Countly.EndSession(); }
public async Task SendViews() { Countly.UserDetails.Name = UserName; Countly.UserDetails.Custom["Level"] = "1"; Countly.UserDetails.Custom["Team"] = "Warriors"; await Countly.StartSession(Server, ApiKey); Countly.RecordView("ScreenA", MakeSegment()); await Task.Delay(3500); Countly.RecordView("ScreenB", MakeSegment()); await Task.Delay(1242); Countly.RecordView("ScreenC", MakeSegment()); await Task.Delay(2322); Countly.RecordView("ScreenD", MakeSegment()); Countly.RecordView("ScreenE", MakeSegment()); await Countly.EndSession(); }
public async Task ChangeMyTeamAndLevel() { Countly.UserDetails.Name = UserName; await Countly.StartSession(Server, ApiKey); Countly.RecordView("ScreenA", MakeSegment()); await Task.Delay(1000); Countly.RecordView("ScreenB", MakeSegment()); await Task.Delay(1000); Countly.RecordView("ScreenC", MakeSegment()); await Task.Delay(1000); Countly.RecordView("ScreenD", MakeSegment()); Countly.RecordView("ScreenE", MakeSegment()); Countly.UserDetails.Custom["Level"] = "3"; Countly.UserDetails.Custom["Team"] = "Warriors"; await Countly.EndSession(); }
public async Task SendBunchOfEvents() { Countly.UserDetails.Name = UserName; await Countly.StartSession(Server, ApiKey); Countly.RecordEvent("ActionA", segmentation: MakeSegment()); await Task.Delay(25); Countly.RecordEvent("ActionB", segmentation: MakeSegment()); await Task.Delay(25); Countly.RecordEvent("ActionC", segmentation: MakeSegment()); await Task.Delay(2100); Countly.RecordEvent("ActionD", segmentation: MakeSegment()); await Task.Delay(25); Countly.RecordEvent("ActionE", segmentation: MakeSegment()); await Task.Delay(1000); await Countly.EndSession(); }
public async Task SendViewsWithStartEnd() { Countly.UserDetails.Name = UserName; await Countly.StartSession(Server, ApiKey); Countly.RecordView("ScreenA", MakeSegment()); await Task.Delay(3500); Countly.RecordView("ScreenB", MakeSegment()); await Countly.EndSession(); //Should still be on ScreenB await Countly.StartSession(Server, ApiKey); await Task.Delay(1242); Countly.RecordView("ScreenC", MakeSegment()); await Task.Delay(2322); Countly.RecordView("ScreenD", MakeSegment()); await Countly.EndSession(); }
public async Task LongTestForSessions() { var random = new Random(); Countly.UserDetails.Name = UserName; await Countly.StartSession(Server, ApiKey); for (int i = 0; i < 200; i++) { if (random.Next(2) == 0) { Countly.RecordEvent("Action" + i, segmentation: MakeSegment()); } else { Countly.RecordView("Screen" + i, MakeSegment()); } await Task.Delay(1000); } await Countly.EndSession(); }
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(); }
// Code to execute when the application is closing (eg, user hit Back) // This code will not execute when the application is deactivated private void Application_Closing(object sender, ClosingEventArgs e) { Countly.EndSession(); }
// Code to execute when the application is deactivated (sent to background) // This code will not execute when the application is closing private void Application_Deactivated(object sender, DeactivatedEventArgs e) { Countly.EndSession(); }
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(); }
/// <summary> /// Test cleanup /// </summary> public void Dispose() { TestHelper.ValidateDataPointUpload().Wait(); Countly.EndSession().Wait(); TestHelper.ValidateDataPointUpload().Wait(); }
private void btnEndSession_Click(object sender, EventArgs e) { Countly.EndSession(); }
private void End_Session_Button_Click(object sender, RoutedEventArgs e) { Countly.EndSession(); }
public async void LegacyInitSimple() { await CountlyImpl.StartLegacyCountlySession("123", "234", "345"); await Countly.EndSession(); }