From 4377de260f0640e5ada8c9b18e3fa19a4698ebaa Mon Sep 17 00:00:00 2001 From: dreamstart <33367956+wang563681252@users.noreply.github.com> Date: Tue, 18 Mar 2025 21:52:24 +0800 Subject: [PATCH] [AOT] add some mudole editor open time, timestamp telemetry code (#38008) * add some mudole editor open time, timestamp telemetry code * fix spelling error * fix namespace warrning --------- Co-authored-by: Zhaopeng Wang (from Dev Box) --- src/modules/Hosts/Hosts/HostsXAML/App.xaml.cs | 3 +++ .../Hosts/Hosts/HostsXAML/MainWindow.xaml.cs | 5 +++++ .../Hosts/Telemetry/HostEditorStartEvent.cs | 18 ++++++++++++++++++ .../Telemetry/HostEditorStartFinishEvent.cs | 18 ++++++++++++++++++ .../Workspaces/WorkspacesEditor/App.xaml.cs | 4 +++- .../WorkspacesEditor/MainWindow.xaml.cs | 3 +++ .../Telemetry/WorkspacesEditorStartEvent.cs | 18 ++++++++++++++++++ .../WorkspacesEditorStartFinishEvent.cs | 18 ++++++++++++++++++ .../editor/FancyZonesEditor/App.xaml.cs | 6 +++++- .../editor/FancyZonesEditor/MainWindow.xaml.cs | 5 ++++- .../Telemetry/FancyZonesEditorStartEvent.cs | 18 ++++++++++++++++++ .../FancyZonesEditorStartFinishEvent.cs | 18 ++++++++++++++++++ .../RegistryPreviewXAML/App.xaml.cs | 4 +++- .../RegistryPreviewXAML/MainWindow.xaml.cs | 5 ++++- .../RegistryPreviewEditorStartEvent.cs | 18 ++++++++++++++++++ .../RegistryPreviewEditorStartFinishEvent.cs | 18 ++++++++++++++++++ 16 files changed, 174 insertions(+), 5 deletions(-) create mode 100644 src/modules/Hosts/Hosts/Telemetry/HostEditorStartEvent.cs create mode 100644 src/modules/Hosts/Hosts/Telemetry/HostEditorStartFinishEvent.cs create mode 100644 src/modules/Workspaces/WorkspacesEditor/Telemetry/WorkspacesEditorStartEvent.cs create mode 100644 src/modules/Workspaces/WorkspacesEditor/Telemetry/WorkspacesEditorStartFinishEvent.cs create mode 100644 src/modules/fancyzones/editor/FancyZonesEditor/Telemetry/FancyZonesEditorStartEvent.cs create mode 100644 src/modules/fancyzones/editor/FancyZonesEditor/Telemetry/FancyZonesEditorStartFinishEvent.cs create mode 100644 src/modules/registrypreview/RegistryPreview/Telemetry/RegistryPreviewEditorStartEvent.cs create mode 100644 src/modules/registrypreview/RegistryPreview/Telemetry/RegistryPreviewEditorStartFinishEvent.cs diff --git a/src/modules/Hosts/Hosts/HostsXAML/App.xaml.cs b/src/modules/Hosts/Hosts/HostsXAML/App.xaml.cs index 7c4d6c389e..fbe5d3662d 100644 --- a/src/modules/Hosts/Hosts/HostsXAML/App.xaml.cs +++ b/src/modules/Hosts/Hosts/HostsXAML/App.xaml.cs @@ -7,6 +7,7 @@ using System.IO.Abstractions; using System.Threading; using Common.UI; +using HostsEditor.Telemetry; using HostsUILib.Helpers; using HostsUILib.Settings; using HostsUILib.ViewModels; @@ -38,6 +39,8 @@ namespace Hosts /// public App() { + PowerToysTelemetry.Log.WriteEvent(new HostEditorStartEvent() { TimeStamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }); + string appLanguage = LanguageHelper.LoadLanguage(); if (!string.IsNullOrEmpty(appLanguage)) { diff --git a/src/modules/Hosts/Hosts/HostsXAML/MainWindow.xaml.cs b/src/modules/Hosts/Hosts/HostsXAML/MainWindow.xaml.cs index bab06fcfbb..85df8e7313 100644 --- a/src/modules/Hosts/Hosts/HostsXAML/MainWindow.xaml.cs +++ b/src/modules/Hosts/Hosts/HostsXAML/MainWindow.xaml.cs @@ -2,10 +2,13 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; using Hosts.Helpers; +using HostsEditor.Telemetry; using HostsUILib.Helpers; using HostsUILib.Views; using ManagedCommon; +using Microsoft.PowerToys.Telemetry; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media; @@ -44,6 +47,8 @@ namespace Hosts Activated += MainWindow_Activated; MainPage = Host.GetService(); + + PowerToysTelemetry.Log.WriteEvent(new HostEditorStartFinishEvent() { TimeStamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }); } private void MainWindow_Activated(object sender, WindowActivatedEventArgs args) diff --git a/src/modules/Hosts/Hosts/Telemetry/HostEditorStartEvent.cs b/src/modules/Hosts/Hosts/Telemetry/HostEditorStartEvent.cs new file mode 100644 index 0000000000..02c3c57e49 --- /dev/null +++ b/src/modules/Hosts/Hosts/Telemetry/HostEditorStartEvent.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics.Tracing; + +using Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; + +namespace HostsEditor.Telemetry; + +[EventData] +public class HostEditorStartEvent() : EventBase, IEvent +{ + public long TimeStamp { get; set; } + + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; +} diff --git a/src/modules/Hosts/Hosts/Telemetry/HostEditorStartFinishEvent.cs b/src/modules/Hosts/Hosts/Telemetry/HostEditorStartFinishEvent.cs new file mode 100644 index 0000000000..ff055417cd --- /dev/null +++ b/src/modules/Hosts/Hosts/Telemetry/HostEditorStartFinishEvent.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics.Tracing; + +using Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; + +namespace HostsEditor.Telemetry; + +[EventData] +public class HostEditorStartFinishEvent() : EventBase, IEvent +{ + public long TimeStamp { get; set; } + + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; +} diff --git a/src/modules/Workspaces/WorkspacesEditor/App.xaml.cs b/src/modules/Workspaces/WorkspacesEditor/App.xaml.cs index 669230b744..34097cb7f4 100644 --- a/src/modules/Workspaces/WorkspacesEditor/App.xaml.cs +++ b/src/modules/Workspaces/WorkspacesEditor/App.xaml.cs @@ -6,10 +6,10 @@ using System; using System.Globalization; using System.Threading; using System.Windows; - using Common.UI; using ManagedCommon; using Microsoft.PowerToys.Telemetry; +using WorkspacesEditor.Telemetry; using WorkspacesEditor.Utils; using WorkspacesEditor.ViewModels; @@ -36,6 +36,8 @@ namespace WorkspacesEditor public App() { + PowerToysTelemetry.Log.WriteEvent(new WorkspacesEditorStartEvent() { TimeStamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }); + WorkspacesEditorIO = new WorkspacesEditorIO(); } diff --git a/src/modules/Workspaces/WorkspacesEditor/MainWindow.xaml.cs b/src/modules/Workspaces/WorkspacesEditor/MainWindow.xaml.cs index f5fc7bcac6..d99f8771ed 100644 --- a/src/modules/Workspaces/WorkspacesEditor/MainWindow.xaml.cs +++ b/src/modules/Workspaces/WorkspacesEditor/MainWindow.xaml.cs @@ -10,6 +10,7 @@ using System.Windows; using System.Windows.Interop; using ManagedCommon; using Microsoft.PowerToys.Telemetry; +using WorkspacesEditor.Telemetry; using WorkspacesEditor.Utils; using WorkspacesEditor.ViewModels; @@ -87,6 +88,8 @@ namespace WorkspacesEditor }, Application.Current.Dispatcher, cancellationToken.Token); + + PowerToysTelemetry.Log.WriteEvent(new WorkspacesEditorStartFinishEvent() { TimeStamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }); } private bool IsEditorInsideVisibleArea() diff --git a/src/modules/Workspaces/WorkspacesEditor/Telemetry/WorkspacesEditorStartEvent.cs b/src/modules/Workspaces/WorkspacesEditor/Telemetry/WorkspacesEditorStartEvent.cs new file mode 100644 index 0000000000..e1cd8864bd --- /dev/null +++ b/src/modules/Workspaces/WorkspacesEditor/Telemetry/WorkspacesEditorStartEvent.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics.Tracing; + +using Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; + +namespace WorkspacesEditor.Telemetry; + +[EventData] +public class WorkspacesEditorStartEvent() : EventBase, IEvent +{ + public long TimeStamp { get; set; } + + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; +} diff --git a/src/modules/Workspaces/WorkspacesEditor/Telemetry/WorkspacesEditorStartFinishEvent.cs b/src/modules/Workspaces/WorkspacesEditor/Telemetry/WorkspacesEditorStartFinishEvent.cs new file mode 100644 index 0000000000..006280bad8 --- /dev/null +++ b/src/modules/Workspaces/WorkspacesEditor/Telemetry/WorkspacesEditorStartFinishEvent.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics.Tracing; + +using Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; + +namespace WorkspacesEditor.Telemetry; + +[EventData] +public class WorkspacesEditorStartFinishEvent() : EventBase, IEvent +{ + public long TimeStamp { get; set; } + + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; +} diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs index 9de3baeeba..3520602c02 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs @@ -5,13 +5,15 @@ using System; using System.Diagnostics; using System.Globalization; +using System.IO; using System.Threading; using System.Windows; using System.Windows.Input; - using Common.UI; +using FancyZoneEditor.Telemetry; using FancyZonesEditor.Utils; using ManagedCommon; +using Microsoft.PowerToys.Telemetry; namespace FancyZonesEditor { @@ -56,6 +58,8 @@ namespace FancyZonesEditor public App() { + PowerToysTelemetry.Log.WriteEvent(new FancyZonesEditorStartEvent() { TimeStamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }); + var languageTag = LanguageHelper.LoadLanguage(); if (!string.IsNullOrEmpty(languageTag)) diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml.cs index f8400a713f..3562175bca 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml.cs @@ -13,11 +13,12 @@ using System.Windows.Automation.Peers; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Interop; - using Common.UI; +using FancyZoneEditor.Telemetry; using FancyZonesEditor.Models; using FancyZonesEditor.Utils; using ManagedCommon; +using Microsoft.PowerToys.Telemetry; using ModernWpf.Controls; namespace FancyZonesEditor @@ -69,6 +70,8 @@ namespace FancyZonesEditor // reinit considering work area rect _settings.InitModels(); + + PowerToysTelemetry.Log.WriteEvent(new FancyZonesEditorStartFinishEvent() { TimeStamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }); } private void BringToFront() diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Telemetry/FancyZonesEditorStartEvent.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Telemetry/FancyZonesEditorStartEvent.cs new file mode 100644 index 0000000000..8abf27f8e6 --- /dev/null +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Telemetry/FancyZonesEditorStartEvent.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics.Tracing; + +using Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; + +namespace FancyZoneEditor.Telemetry; + +[EventData] +public class FancyZonesEditorStartEvent() : EventBase, IEvent +{ + public long TimeStamp { get; set; } + + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; +} diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Telemetry/FancyZonesEditorStartFinishEvent.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Telemetry/FancyZonesEditorStartFinishEvent.cs new file mode 100644 index 0000000000..f3d7ae19c2 --- /dev/null +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Telemetry/FancyZonesEditorStartFinishEvent.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics.Tracing; + +using Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; + +namespace FancyZoneEditor.Telemetry; + +[EventData] +public class FancyZonesEditorStartFinishEvent() : EventBase, IEvent +{ + public long TimeStamp { get; set; } + + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; +} diff --git a/src/modules/registrypreview/RegistryPreview/RegistryPreviewXAML/App.xaml.cs b/src/modules/registrypreview/RegistryPreview/RegistryPreviewXAML/App.xaml.cs index 6930d8bc98..f41f2cfca1 100644 --- a/src/modules/registrypreview/RegistryPreview/RegistryPreviewXAML/App.xaml.cs +++ b/src/modules/registrypreview/RegistryPreview/RegistryPreviewXAML/App.xaml.cs @@ -4,11 +4,11 @@ using System; using System.Web; - using ManagedCommon; using Microsoft.PowerToys.Telemetry; using Microsoft.UI.Xaml; using Microsoft.Windows.AppLifecycle; +using RegistryPreview.Telemetry; using Windows.ApplicationModel.Activation; // To learn more about WinUI, the WinUI project structure, @@ -27,6 +27,8 @@ namespace RegistryPreview /// public App() { + PowerToysTelemetry.Log.WriteEvent(new RegistryPreviewEditorStartEvent() { TimeStamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }); + string appLanguage = LanguageHelper.LoadLanguage(); if (!string.IsNullOrEmpty(appLanguage)) diff --git a/src/modules/registrypreview/RegistryPreview/RegistryPreviewXAML/MainWindow.xaml.cs b/src/modules/registrypreview/RegistryPreview/RegistryPreviewXAML/MainWindow.xaml.cs index 673e47590d..0a1083d00d 100644 --- a/src/modules/registrypreview/RegistryPreview/RegistryPreviewXAML/MainWindow.xaml.cs +++ b/src/modules/registrypreview/RegistryPreview/RegistryPreviewXAML/MainWindow.xaml.cs @@ -3,12 +3,13 @@ // See the LICENSE file in the project root for more information. using System; - using ManagedCommon; +using Microsoft.PowerToys.Telemetry; using Microsoft.UI; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media; +using RegistryPreview.Telemetry; using RegistryPreviewUILib; using Windows.Data.Json; using Windows.Graphics; @@ -87,6 +88,8 @@ namespace RegistryPreview MainPage = new RegistryPreviewMainPage(this, this.UpdateWindowTitle, App.AppFilename); WindowHelpers.BringToForeground(windowHandle); + + PowerToysTelemetry.Log.WriteEvent(new RegistryPreviewEditorStartFinishEvent() { TimeStamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }); } private void MainWindow_Activated(object sender, WindowActivatedEventArgs args) diff --git a/src/modules/registrypreview/RegistryPreview/Telemetry/RegistryPreviewEditorStartEvent.cs b/src/modules/registrypreview/RegistryPreview/Telemetry/RegistryPreviewEditorStartEvent.cs new file mode 100644 index 0000000000..6ac5fb51a8 --- /dev/null +++ b/src/modules/registrypreview/RegistryPreview/Telemetry/RegistryPreviewEditorStartEvent.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics.Tracing; + +using Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; + +namespace RegistryPreview.Telemetry; + +[EventData] +public class RegistryPreviewEditorStartEvent() : EventBase, IEvent +{ + public long TimeStamp { get; set; } + + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; +} diff --git a/src/modules/registrypreview/RegistryPreview/Telemetry/RegistryPreviewEditorStartFinishEvent.cs b/src/modules/registrypreview/RegistryPreview/Telemetry/RegistryPreviewEditorStartFinishEvent.cs new file mode 100644 index 0000000000..98067f26ce --- /dev/null +++ b/src/modules/registrypreview/RegistryPreview/Telemetry/RegistryPreviewEditorStartFinishEvent.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics.Tracing; + +using Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; + +namespace RegistryPreview.Telemetry; + +[EventData] +public class RegistryPreviewEditorStartFinishEvent() : EventBase, IEvent +{ + public long TimeStamp { get; set; } + + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; +}