public async void MultipleEvents() { bool res; res = await Countly.RecordEvent("Some event0"); Assert.True(res); res = await Countly.RecordEvent("Some event1", 123); Assert.True(res); res = await Countly.RecordEvent("Some event2", 123, 456); Assert.True(res); res = await Countly.RecordEvent("Some event3", 4234, 1236.12, 234.5, null); Assert.True(res); Segmentation segm = new Segmentation(); segm.Add("oneKey", "SomeValue"); segm.Add("anotherKey", "SomeOtherValue"); res = await Countly.RecordEvent("Some event4", 123, 456, segm); res = await Countly.RecordEvent("Some event5", 123, 456, 42.54, segm); Assert.True(res); }
public static Segmentation CreateSegmentation(int index) { Segmentation se = new Segmentation(); se.Add(v[index], v[index + 1]); se.Add(v[index + 2], v[index + 3]); return(se); }
private Segmentation MakeSegment() { var segment = new Segmentation(); segment.Add("Level", "1"); segment.Add("Team", "Warriors"); return(segment); }
private void RecordEventSegmentation_Click(object sender, System.Windows.RoutedEventArgs e) { Segmentation segmentation = new Segmentation(); segmentation.Add("country", "Ukraine"); segmentation.Add("app_version", "1.2"); Countly.RecordEvent("seconds", DateTime.Now.Second, segmentation); }
private static Segmentation GetSegmentation(string clientType = "undefined") { Initialize(); var segmentation = new Segmentation(); segmentation.Add("machineId", DeviceId); segmentation.Add("clientType", clientType); segmentation.Add("coreVersion", GetAssemblyVersion()); return(segmentation); }
private void RecordEventSegmentation_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { Segmentation segmentation = new Segmentation(); segmentation.Add("country", "Ukraine"); segmentation.Add("app_version", "1.2"); Countly.RecordEvent("seconds", DateTime.Now.Second + 1, segmentation); Countly.AddBreadCrumb("segmentation event"); }
void ThreadWorkEvents() { String[] eventKeys = new string[] { "key_1", "key_2", "key_3", "key_4", "key_5", "key_6" }; Random rnd = new Random(0); for (int a = 0; a < threadIterations; a++) { int choice = a % 6; switch (choice) { case 0: Countly.RecordEvent(eventKeys[0]); break; case 1: Countly.RecordEvent(eventKeys[1], 3); break; case 2: Countly.RecordEvent(eventKeys[2], 3, 4); break; case 3: Segmentation segm = new Segmentation(); segm.Add("foo", "bar"); segm.Add("anti", "dote"); Countly.RecordEvent(eventKeys[3], 3, segm); break; case 4: Segmentation segm2 = new Segmentation(); segm2.Add("what", "is"); segm2.Add("world", "ending"); Countly.RecordEvent(eventKeys[4], 3, 4.3, segm2); break; default: case 5: Segmentation segm3 = new Segmentation(); segm3.Add("what3", "is"); segm3.Add("world2", "ending"); Countly.RecordEvent(eventKeys[4], 3, 4.3, 6.7, segm3); break; } Thread.Sleep(rnd.Next(threadWaitStart, threadWaitEnd)); } }
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 <bool> SetZoom(Setting setting, object?newValue) { if (newValue is int index) { // method 1: get/set zoom level based on resolution //Size[] all = this.GetResolutions(); //if (index >= 0 && index < all.Length) //{ // this.display.SetResolution(all[index]); //} // method 2: get/set zoom level based on scale percentage var all = Display.GetDPIScales(); double?newDpiScale = null; if (all is not null && index >= 0 && index < all.Count) { newDpiScale = all[index]; } // // NOTE: due to current architectural limitations, Morphic v1.x uses the mouse cursor to determine which display to zoom (instead of finding the display the MorphicBar is on) var getCurrentPositionResult = Morphic.WindowsNative.Mouse.Mouse.GetCurrentPosition(); if (getCurrentPositionResult.IsError == true) { return(false); } var currentMousePosition = getCurrentPositionResult.Value !; // var getDisplayForPointResult = Morphic.WindowsNative.Display.Display.GetDisplayForPoint(currentMousePosition); if (getDisplayForPointResult.IsError == true) { return(false); } var targetDisplay = getDisplayForPointResult.Value !; // if (newDpiScale is not null) { // capture the current scale var oldDpiScale = targetDisplay.GetMonitorScalePercentage(); // // capture the recommended scale Display.GetDpiOffsetResult?currentDpiOffsetAndRange; double?recommendedDpiScale; var getCurrentDpiOffsetAndRangeResult = targetDisplay.GetCurrentDpiOffsetAndRange(); if (getCurrentDpiOffsetAndRangeResult.IsSuccess == true) { currentDpiOffsetAndRange = getCurrentDpiOffsetAndRangeResult.Value !; var translateDpiOffsetToScalePercentageResult = Display.TranslateDpiOffsetToScalePercentage(0, currentDpiOffsetAndRange.Value.MinimumDpiOffset, currentDpiOffsetAndRange.Value.MaximumDpiOffset); if (translateDpiOffsetToScalePercentageResult.IsError == true) { recommendedDpiScale = null; } else { recommendedDpiScale = translateDpiOffsetToScalePercentageResult.Value !; } } else { currentDpiOffsetAndRange = null; recommendedDpiScale = null; } // // set the new percentage _ = await targetDisplay.SetDpiScaleAsync(newDpiScale.Value); // report the display scale (percentage) change if (oldDpiScale is not null) { var segmentation = new Segmentation(); if (recommendedDpiScale is not null) { var relativePercent = newDpiScale / recommendedDpiScale; segmentation.Add("scalePercent", ((int)(relativePercent * 100)).ToString()); var recommendedDpiIndex = -currentDpiOffsetAndRange !.Value.MinimumDpiOffset; var relativeDotOffset = index - recommendedDpiIndex; segmentation.Add("dotOffset", relativeDotOffset.ToString()); } // if (newDpiScale > oldDpiScale) { // NOTE: we can't call our main Countly logic from here (which skips Countly event recording if it's not enabled), so we just swallow any "not init'd" errors here try { await Countly.RecordEvent("textSizeIncrease", 1, segmentation); } catch (InvalidOperationException) { } } else { // NOTE: we can't call our main Countly logic from here (which skips Countly event recording if it's not enabled), so we just swallow any "not init'd" errors here try { await Countly.RecordEvent("textSizeDecrease", 1, segmentation); } catch (InvalidOperationException) { } } } } } return(true); }
internal static async Task RecordMenuItemTelemetryAsync(string?openPath, MorphicMenuItem.MenuType parentMenuType, MorphicMenuItemTelemetryType?telemetryType, string?telemetryCategory) { string?eventSource = null; switch (parentMenuType) { case MenuType.mainMenu: eventSource = "iconMenu"; break; case MenuType.contextMenu: eventSource = "contextMenu"; break; } switch (telemetryType) { case MorphicMenuItemTelemetryType.Settings: { var segmentation = new Segmentation(); var settingCategoryName = telemetryCategory; if (settingCategoryName is not null) { segmentation.Add("category", settingCategoryName); } // segmentation.Add("eventSource", eventSource); // await App.Current.Countly_RecordEventAsync("systemSettings", 1, segmentation); //await App.Current.Countly_RecordEventAsync("systemSettings" + settingCategoryName); } break; case MorphicMenuItemTelemetryType.LearnMore: { var segmentation = new Segmentation(); var settingCategoryName = telemetryCategory; if (settingCategoryName is not null) { segmentation.Add("category", settingCategoryName); } // segmentation.Add("eventSource", eventSource); // await App.Current.Countly_RecordEventAsync("learnMore", 1, segmentation); } break; case MorphicMenuItemTelemetryType.QuickDemoVideo: { var segmentation = new Segmentation(); var settingCategoryName = telemetryCategory; if (settingCategoryName is not null) { segmentation.Add("category", settingCategoryName); } // segmentation.Add("eventSource", eventSource); // await App.Current.Countly_RecordEventAsync("quickDemoVideo", 1, segmentation); } break; default: // handle menu "open settings" items // NOTE: we may want to create a separate "telemetry type" and embed it in the menu xaml itself (so that we don't have to compare against open paths here) { string?settingCategoryName = null; switch (openPath) { case "ms-settings:colors": settingCategoryName = "darkMode"; break; case "ms-settings:display": settingCategoryName = "textSize"; break; case "ms-settings:easeofaccess": case "ms-settings:easeofaccess-display": settingCategoryName = "allAccessibility"; break; case "ms-settings:easeofaccess-colorfilter": settingCategoryName = "colorFilter"; break; case "ms-settings:easeofaccess-cursorandpointersize": case "ms-settings:easeofaccess-MousePointer": settingCategoryName = "pointerSize"; break; case "ms-settings:easeofaccess-highcontrast": settingCategoryName = "highContrast"; break; case "ms-settings:easeofaccess-keyboard": settingCategoryName = "keyboard"; break; case "ms-settings:easeofaccess-magnifier": settingCategoryName = "magnifier"; break; case "ms-settings:mousetouchpad": settingCategoryName = "mouse"; break; case "ms-settings:nightlight": settingCategoryName = "nightMode"; break; case "ms-settings:regionlanguage": settingCategoryName = "language"; break; case "ms-settings:speech": settingCategoryName = "readAloud"; break; case null: // unknown (i.e. no data) break; default: Debug.Assert(false, "Unknown menu item (i.e. no telemetry)"); break; } if (settingCategoryName is not null) { var segmentation = new Segmentation(); segmentation.Add("category", settingCategoryName); segmentation.Add("eventSource", eventSource); // await App.Current.Countly_RecordEventAsync("systemSettings", 1, segmentation); //await App.Current.Countly_RecordEventAsync("systemSettings" + settingCategoryName); } } break; } }