diff --git a/installer/PowerToysSetup/Product.wxs b/installer/PowerToysSetup/Product.wxs index 2ff4c033f0..b9352bda34 100644 --- a/installer/PowerToysSetup/Product.wxs +++ b/installer/PowerToysSetup/Product.wxs @@ -576,6 +576,7 @@ + diff --git a/src/common/ManagedTelemetry/Telemetry/Events/EventBase.cs b/src/common/ManagedTelemetry/Telemetry/Events/EventBase.cs new file mode 100644 index 0000000000..ec0ad494ac --- /dev/null +++ b/src/common/ManagedTelemetry/Telemetry/Events/EventBase.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.Tracing; +using System.Text; + +namespace Microsoft.PowerToys.Telemetry.Events +{ + /// + /// A base class to implement properties that are common to all telemetry events. + /// + [EventData] + public class EventBase + { + public bool UTCReplace_AppSessionGuid => true; + } +} diff --git a/src/common/ManagedTelemetry/Telemetry/Events/IEvent.cs b/src/common/ManagedTelemetry/Telemetry/Events/IEvent.cs new file mode 100644 index 0000000000..d4494c8f66 --- /dev/null +++ b/src/common/ManagedTelemetry/Telemetry/Events/IEvent.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.PowerToys.Telemetry.Events +{ + public interface IEvent + { + PartA_PrivTags PartA_PrivTags { get; } + } +} diff --git a/src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs b/src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs index 9159e837e4..30982a2526 100644 --- a/src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs +++ b/src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs @@ -2,8 +2,9 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.PowerToys.Telemetry.Events; using System.Diagnostics.Tracing; -using PreviewHandlerCommon.Telemetry; + namespace Microsoft.PowerToys.Telemetry { @@ -12,7 +13,7 @@ namespace Microsoft.PowerToys.Telemetry /// public class PowerToysTelemetry : TelemetryBase { - + /// /// Name for ETW event. /// @@ -34,7 +35,8 @@ namespace Microsoft.PowerToys.Telemetry /// /// Publishes ETW event when an action is triggered on /// - public void WriteEvent(T telemetryEvent) + public void WriteEvent(T telemetryEvent) + where T : EventBase, IEvent { this.Write(null, new EventSourceOptions() { diff --git a/src/common/ManagedTelemetry/Telemetry/Telemetry.csproj b/src/common/ManagedTelemetry/Telemetry/Telemetry.csproj index 49f78f102e..4483870d2f 100644 --- a/src/common/ManagedTelemetry/Telemetry/Telemetry.csproj +++ b/src/common/ManagedTelemetry/Telemetry/Telemetry.csproj @@ -1,4 +1,4 @@ - + x64 diff --git a/src/common/Telemetry/TelemetryBase.cs b/src/common/Telemetry/TelemetryBase.cs index 28eec72559..c25be44b02 100644 --- a/src/common/Telemetry/TelemetryBase.cs +++ b/src/common/Telemetry/TelemetryBase.cs @@ -4,8 +4,24 @@ using System.Diagnostics.Tracing; -namespace PreviewHandlerCommon.Telemetry +namespace Microsoft.PowerToys.Telemetry { + /// + /// Privacy Tag values + /// + public enum PartA_PrivTags + : ulong + { + /// + None = 0, + + /// + ProductAndServicePerformance = 0x0u, + + /// + ProductAndServiceUsage = 0x0u, + } + /// /// Base class for telemetry events. /// diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/Telemetry/Events/SettingsBootEvent.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/Telemetry/Events/SettingsBootEvent.cs new file mode 100644 index 0000000000..b2945bf434 --- /dev/null +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/Telemetry/Events/SettingsBootEvent.cs @@ -0,0 +1,23 @@ +// 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 Microsoft.PowerLauncher.Telemetry +{ + [EventData] + public class SettingsBootEvent : EventBase, IEvent + { + /// + /// Gets The version string. TODO: This should be replaced by a P/Invoke call to get_product_version + /// + public string Version => "v0.18.0"; + + public double BootTimeMs { get; set; } + + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance; + } +} diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/Telemetry/Events/SettingsEnabledEvent.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/Telemetry/Events/SettingsEnabledEvent.cs index 59f3158ae7..77f179200e 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/Telemetry/Events/SettingsEnabledEvent.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/Telemetry/Events/SettingsEnabledEvent.cs @@ -1,12 +1,16 @@ using System.Diagnostics.Tracing; +using Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; namespace Microsoft.PowerToys.Settings.Telemetry { [EventData] - public class SettingsEnabledEvent + public class SettingsEnabledEvent : EventBase, IEvent { public string Name { get; set; } public bool Value { get; set; } + + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; } } diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Runner/MainWindow.xaml.cs b/src/core/Microsoft.PowerToys.Settings.UI.Runner/MainWindow.xaml.cs index c2dcd664d4..48f455c228 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Runner/MainWindow.xaml.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Runner/MainWindow.xaml.cs @@ -4,7 +4,9 @@ using System; using System.Windows; +using Microsoft.PowerLauncher.Telemetry; using Microsoft.PowerToys.Settings.UI.Views; +using Microsoft.PowerToys.Telemetry; using Microsoft.Toolkit.Wpf.UI.XamlHost; using Windows.UI.Popups; @@ -14,8 +16,14 @@ namespace Microsoft.PowerToys.Settings.UI.Runner public partial class MainWindow : Window { public MainWindow() - { - this.InitializeComponent(); + { + var bootTime = new System.Diagnostics.Stopwatch(); + bootTime.Start(); + + this.InitializeComponent(); + bootTime.Stop(); + + PowerToysTelemetry.Log.WriteEvent(new SettingsBootEvent() { BootTimeMs = bootTime.ElapsedMilliseconds }); } private void WindowsXamlHost_ChildChanged(object sender, EventArgs e) @@ -29,7 +37,7 @@ namespace Microsoft.PowerToys.Settings.UI.Runner // send IPC Message shellPage.SetDefaultSndMessageCallback(msg => { - //IPC Manager is null when launching runner directly + // IPC Manager is null when launching runner directly Program.GetTwoWayIPCManager()?.Send(msg); }); diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Runner/Microsoft.PowerToys.Settings.UI.Runner.csproj b/src/core/Microsoft.PowerToys.Settings.UI.Runner/Microsoft.PowerToys.Settings.UI.Runner.csproj index 4741890862..e22e80839b 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Runner/Microsoft.PowerToys.Settings.UI.Runner.csproj +++ b/src/core/Microsoft.PowerToys.Settings.UI.Runner/Microsoft.PowerToys.Settings.UI.Runner.csproj @@ -68,6 +68,8 @@ + + diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj b/src/core/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj index 72dc626798..186e67943e 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj +++ b/src/core/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj @@ -231,6 +231,10 @@ + + {5d00d290-4016-4cfe-9e41-1e7c724509ba} + Telemetry + {b1bcc8c6-46b5-4bfa-8f22-20f32d99ec6a} Microsoft.PowerToys.Settings.UI.Lib diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/Microsoft.PowerToys.Settings.UnitTest.csproj b/src/core/Microsoft.PowerToys.Settings.UnitTest/Microsoft.PowerToys.Settings.UnitTest.csproj index 1b8f79345c..a6df41db57 100644 --- a/src/core/Microsoft.PowerToys.Settings.UnitTest/Microsoft.PowerToys.Settings.UnitTest.csproj +++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/Microsoft.PowerToys.Settings.UnitTest.csproj @@ -1,191 +1,195 @@ - - - - - Debug - x86 - {A80355C2-780D-4245-BD80-25B8DE698EE3} - AppContainerExe - Properties - Microsoft.PowerToys.Settings.UnitTest - Microsoft.PowerToys.Settings.UnitTest - en-US - UAP - 10.0.18362.0 - 10.0.18362.0 - 14 - 512 - {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - $(VisualStudioVersion) - false - - - true - bin\x86\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 - full - x86 - false - prompt - true - - - bin\x86\Release\ - TRACE;NETFX_CORE;WINDOWS_UWP - true - ;2008 - pdbonly - x86 - false - prompt - true - true - - - true - bin\ARM\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 - full - ARM - false - prompt - true - - - bin\ARM\Release\ - TRACE;NETFX_CORE;WINDOWS_UWP - true - ;2008 - pdbonly - ARM - false - prompt - true - true - - - true - bin\ARM64\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 - full - ARM64 - false - prompt - true - true - - - bin\ARM64\Release\ - TRACE;NETFX_CORE;WINDOWS_UWP - true - ;2008 - pdbonly - ARM64 - false - prompt - true - true - - - true - bin\x64\Debug\Test\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 - full - x64 - false - prompt - true - - - bin\x64\Release\ - TRACE;NETFX_CORE;WINDOWS_UWP - true - ;2008 - pdbonly - x64 - false - prompt - true - false - - - PackageReference - - - - - - - - - - - - - - - UnitTestApp.xaml - - - - - - - - - MSBuild:Compile - Designer - - - - - Designer - - - - - - - - - - - - - - 6.2.9 - - - 2.1.1 - - - 2.1.1 - - - - - {b1bcc8c6-46b5-4bfa-8f22-20f32d99ec6a} - Microsoft.PowerToys.Settings.UI.Lib - - - {a7d5099e-f0fd-4bf3-8522-5a682759f915} - Microsoft.PowerToys.Settings.UI - - - - - 14.0 - - + + + + + Debug + x86 + {A80355C2-780D-4245-BD80-25B8DE698EE3} + AppContainerExe + Properties + Microsoft.PowerToys.Settings.UnitTest + Microsoft.PowerToys.Settings.UnitTest + en-US + UAP + 10.0.18362.0 + 10.0.18362.0 + 14 + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + $(VisualStudioVersion) + false + + + true + bin\x86\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x86 + false + prompt + true + + + bin\x86\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x86 + false + prompt + true + true + + + true + bin\ARM\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + ARM + false + prompt + true + + + bin\ARM\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + ARM + false + prompt + true + true + + + true + bin\ARM64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + ARM64 + false + prompt + true + true + + + bin\ARM64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + ARM64 + false + prompt + true + true + + + true + bin\x64\Debug\Test\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x64 + false + prompt + true + + + bin\x64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x64 + false + prompt + true + false + + + PackageReference + + + + + + + + + + + + + + + UnitTestApp.xaml + + + + + + + + + MSBuild:Compile + Designer + + + + + Designer + + + + + + + + + + + + + + 6.2.9 + + + 2.1.1 + + + 2.1.1 + + + + + {5d00d290-4016-4cfe-9e41-1e7c724509ba} + Telemetry + + + {b1bcc8c6-46b5-4bfa-8f22-20f32d99ec6a} + Microsoft.PowerToys.Settings.UI.Lib + + + {a7d5099e-f0fd-4bf3-8522-5a682759f915} + Microsoft.PowerToys.Settings.UI + + + + + 14.0 + + + --> \ No newline at end of file diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherBootEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherBootEvent.cs index 5e245c655e..42f8b5c659 100644 --- a/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherBootEvent.cs +++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherBootEvent.cs @@ -1,10 +1,19 @@ -using System.Diagnostics.Tracing; +using Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; +using System.Diagnostics.Tracing; namespace Microsoft.PowerLauncher.Telemetry { [EventData] - public class LauncherBootEvent + public class LauncherBootEvent : EventBase, IEvent { + /// + /// TODO: This should be replaced by a P/Invoke call to get_product_version + /// + public string Version => "v0.18.0"; + public double BootTimeMs { get; set; } + + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance; } } diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherFirstDeleteEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherFirstDeleteEvent.cs index 3c4ff30af2..189a4248bd 100644 --- a/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherFirstDeleteEvent.cs +++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherFirstDeleteEvent.cs @@ -1,9 +1,16 @@ -using System.Diagnostics.Tracing; +// 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 Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; +using System.Diagnostics.Tracing; namespace Microsoft.PowerLauncher.Telemetry { [EventData] - public class LauncherFirstDeleteEvent + public class LauncherFirstDeleteEvent : EventBase, IEvent { + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; } } diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherHideEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherHideEvent.cs index 7ce8c92ccd..48da76254f 100644 --- a/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherHideEvent.cs +++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherHideEvent.cs @@ -1,9 +1,12 @@ using System.Diagnostics.Tracing; +using Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; namespace Microsoft.PowerLauncher.Telemetry { [EventData] - public class LauncherHideEvent + public class LauncherHideEvent : EventBase, IEvent { + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; } } diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherQueryEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherQueryEvent.cs index 8e1cc73c5c..b179a982a3 100644 --- a/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherQueryEvent.cs +++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherQueryEvent.cs @@ -1,4 +1,10 @@ -using System.Diagnostics.Tracing; +// 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 Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; +using System.Diagnostics.Tracing; namespace Microsoft.PowerLauncher.Telemetry { @@ -6,11 +12,13 @@ namespace Microsoft.PowerLauncher.Telemetry /// ETW Event for when the user initiates a query /// [EventData] - public class LauncherQueryEvent + public class LauncherQueryEvent : EventBase, IEvent { public double QueryTimeMs { get; set; } public int QueryLength { get; set; } public int NumResults { get; set; } + + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance; } } diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherResultActionEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherResultActionEvent.cs index be28d20906..a27e4cc049 100644 --- a/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherResultActionEvent.cs +++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherResultActionEvent.cs @@ -1,4 +1,10 @@ -using System.Diagnostics.Tracing; +// 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 Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; +using System.Diagnostics.Tracing; namespace Microsoft.PowerLauncher.Telemetry { @@ -6,7 +12,7 @@ namespace Microsoft.PowerLauncher.Telemetry /// ETW event for when a result is actioned. /// [EventData] - public class LauncherResultActionEvent + public class LauncherResultActionEvent : EventBase, IEvent { public enum TriggerType @@ -18,5 +24,7 @@ namespace Microsoft.PowerLauncher.Telemetry public string Trigger { get; set; } public string PluginName { get; set; } public string ActionName { get; set; } + + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; } } diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherShowEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherShowEvent.cs index d785bef5c8..32277de448 100644 --- a/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherShowEvent.cs +++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/LauncherShowEvent.cs @@ -1,9 +1,16 @@ -using System.Diagnostics.Tracing; +// 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 Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; +using System.Diagnostics.Tracing; namespace Microsoft.PowerLauncher.Telemetry { [EventData] - public class LauncherShowEvent + public class LauncherShowEvent : EventBase, IEvent { + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; } } diff --git a/src/modules/launcher/PowerLauncher.UI/PowerLauncher.UI.csproj b/src/modules/launcher/PowerLauncher.UI/PowerLauncher.UI.csproj index 2a008006d1..495b595c7e 100644 --- a/src/modules/launcher/PowerLauncher.UI/PowerLauncher.UI.csproj +++ b/src/modules/launcher/PowerLauncher.UI/PowerLauncher.UI.csproj @@ -107,6 +107,10 @@ + + {5d00d290-4016-4cfe-9e41-1e7c724509ba} + Telemetry + {08c8c05f-0362-41bc-818c-724572df8b06} PowerLauncher.Telemetry diff --git a/src/modules/previewpane/MarkDownPreviewHandler/MarkDownPreviewHandler.csproj b/src/modules/previewpane/MarkDownPreviewHandler/MarkDownPreviewHandler.csproj index 1c5fcbb182..517f456434 100644 --- a/src/modules/previewpane/MarkDownPreviewHandler/MarkDownPreviewHandler.csproj +++ b/src/modules/previewpane/MarkDownPreviewHandler/MarkDownPreviewHandler.csproj @@ -101,7 +101,6 @@ Code - True True @@ -112,6 +111,9 @@ True Settings.settings + + + @@ -132,6 +134,10 @@ + + {5D00D290-4016-4CFE-9E41-1E7C724509BA} + Telemetry + {af2349b8-e5b6-4004-9502-687c1c7730b1} PreviewHandlerCommon diff --git a/src/modules/previewpane/MarkDownPreviewHandler/Telemetry/Events/MarkdownFileHandlerLoaded.cs b/src/modules/previewpane/MarkDownPreviewHandler/Telemetry/Events/MarkdownFileHandlerLoaded.cs new file mode 100644 index 0000000000..7c2eded0e8 --- /dev/null +++ b/src/modules/previewpane/MarkDownPreviewHandler/Telemetry/Events/MarkdownFileHandlerLoaded.cs @@ -0,0 +1,25 @@ +// 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 MarkdownPreviewHandler.Telemetry.Events +{ + /// + /// A telemetry event that is triggered when a markdown file is viewed in the preview pane. + /// + [EventData] + public class MarkdownFileHandlerLoaded : EventBase, IEvent + { + /// + /// Gets The version string. TODO: This should be replaced by a P/Invoke call to get_product_version. + /// + public string Version => "v0.18.0"; + + /// + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; + } +} diff --git a/src/modules/previewpane/MarkDownPreviewHandler/Telemetry/Events/MarkdownFilePreviewError.cs b/src/modules/previewpane/MarkDownPreviewHandler/Telemetry/Events/MarkdownFilePreviewError.cs new file mode 100644 index 0000000000..95b10a90d9 --- /dev/null +++ b/src/modules/previewpane/MarkDownPreviewHandler/Telemetry/Events/MarkdownFilePreviewError.cs @@ -0,0 +1,23 @@ +// 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 Microsoft.PowerToys.Telemetry; +using Microsoft.PowerToys.Telemetry.Events; + +namespace MarkdownPreviewHandler.Telemetry.Events +{ + /// + /// A telemetry event that is triggered when an error occurs while attempting to view a markdown file in the preview pane. + /// + public class MarkdownFilePreviewError : EventBase, IEvent + { + /// + /// Gets or sets the error message. + /// + public string Message { get; set; } + + /// + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance; + } +} diff --git a/src/modules/previewpane/MarkDownPreviewHandler/Telemetry/Events/MarkdownFilePreviewed.cs b/src/modules/previewpane/MarkDownPreviewHandler/Telemetry/Events/MarkdownFilePreviewed.cs new file mode 100644 index 0000000000..f3334c0f6e --- /dev/null +++ b/src/modules/previewpane/MarkDownPreviewHandler/Telemetry/Events/MarkdownFilePreviewed.cs @@ -0,0 +1,20 @@ +// 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 MarkdownPreviewHandler.Telemetry.Events +{ + /// + /// A telemetry event that is triggered when a markdown file is viewed in the preview pane. + /// + [EventData] + public class MarkdownFilePreviewed : EventBase, IEvent + { + /// + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; + } +} diff --git a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandler.cs b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandler.cs index be0b9ac731..053c41845b 100644 --- a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandler.cs +++ b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandler.cs @@ -5,6 +5,7 @@ using System; using System.Runtime.InteropServices; using Common; +using Microsoft.PowerToys.Telemetry; namespace MarkdownPreviewHandler { @@ -27,6 +28,7 @@ namespace MarkdownPreviewHandler /// protected override IPreviewHandlerControl CreatePreviewHandlerControl() { + PowerToysTelemetry.Log.WriteEvent(new Telemetry.Events.MarkdownFileHandlerLoaded()); this.markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl(); return this.markdownPreviewHandlerControl; } diff --git a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandlerControl.cs b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandlerControl.cs index b28c8526f1..cd6581cd60 100644 --- a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandlerControl.cs +++ b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandlerControl.cs @@ -10,6 +10,8 @@ using System.Windows.Forms; using Common; using Markdig; using MarkdownPreviewHandler.Properties; +using MarkdownPreviewHandler.Telemetry.Events; +using Microsoft.PowerToys.Telemetry; using PreviewHandlerCommon; namespace MarkdownPreviewHandler @@ -112,11 +114,11 @@ namespace MarkdownPreviewHandler } }); - MarkdownTelemetry.Log.MarkdownFilePreviewed(); + PowerToysTelemetry.Log.WriteEvent(new MarkdownFilePreviewed()); } catch (Exception e) { - MarkdownTelemetry.Log.MarkdownFilePreviewError(e.Message); + PowerToysTelemetry.Log.WriteEvent(new MarkdownFilePreviewError { Message = e.Message }); this.InvokeOnControlThread(() => { diff --git a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs deleted file mode 100644 index 07bf17cd24..0000000000 --- a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs +++ /dev/null @@ -1,71 +0,0 @@ -// 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 PreviewHandlerCommon.Telemetry; - -namespace MarkdownPreviewHandler -{ - /// - /// Telemetry helper class for markdown renderer. - /// - public class MarkdownTelemetry : TelemetryBase - { - /// - /// Name for ETW event. - /// - private const string EventSourceName = "Microsoft.PowerToys"; - - /// - /// ETW event name when markdown is previewed. - /// - private const string MarkdownFilePreviewedEventName = "PowerPreview_MDRenderer_Previewed"; - - /// - /// ETW event name when error is thrown during markdown preview. - /// - private const string MarkdownFilePreviewErrorEventName = "PowerPreview_MDRenderer_Error"; - - /// - /// Initializes a new instance of the class. - /// - public MarkdownTelemetry() - : base(EventSourceName) - { - return; - } - - /// - /// Gets an instance of the class. - /// - public static MarkdownTelemetry Log { get; } = new MarkdownTelemetry(); - - /// - /// Publishes ETW event when markdown is previewed successfully. - /// - public void MarkdownFilePreviewed() - { - this.Write(MarkdownFilePreviewedEventName, new EventSourceOptions() - { - Keywords = ProjectKeywordMeasure, - Tags = ProjectTelemetryTagProductAndServicePerformance, - }); - } - - /// - /// Publishes ETW event when markdown could not be previewed. - /// - public void MarkdownFilePreviewError(string message) - { - this.Write( - MarkdownFilePreviewErrorEventName, - new EventSourceOptions() - { - Keywords = ProjectKeywordMeasure, - Tags = ProjectTelemetryTagProductAndServicePerformance, - }, - new { Message = message, }); - } - } -} diff --git a/src/modules/previewpane/SvgPreviewHandler/SvgPreviewControl.cs b/src/modules/previewpane/SvgPreviewHandler/SvgPreviewControl.cs index d6591ab347..e09fe9fa1d 100644 --- a/src/modules/previewpane/SvgPreviewHandler/SvgPreviewControl.cs +++ b/src/modules/previewpane/SvgPreviewHandler/SvgPreviewControl.cs @@ -14,7 +14,9 @@ using System.Xml; using System.Xml.Linq; using Common; using Common.Utilities; +using Microsoft.PowerToys.Telemetry; using PreviewHandlerCommon; +using SvgPreviewHandler.Telemetry.Events; using SvgPreviewHandler.Utilities; namespace SvgPreviewHandler @@ -69,11 +71,11 @@ namespace SvgPreviewHandler this.AddBrowserControl(svgData); this.Resize += this.FormResized; base.DoPreview(dataSource); - SvgTelemetry.Log.SvgFilePreviewed(); + PowerToysTelemetry.Log.WriteEvent(new SvgFilePreviewed()); } catch (Exception ex) { - SvgTelemetry.Log.SvgFilePreviewError(ex.Message); + PowerToysTelemetry.Log.WriteEvent(new SvgFilePreviewError { Message = ex.Message }); this.Controls.Clear(); this.infoBarAdded = true; this.AddTextBoxControl(Resource.SvgNotPreviewedError); diff --git a/src/modules/previewpane/SvgPreviewHandler/SvgPreviewHandler.cs b/src/modules/previewpane/SvgPreviewHandler/SvgPreviewHandler.cs index 9e3b09046f..d5aa8f6ad6 100644 --- a/src/modules/previewpane/SvgPreviewHandler/SvgPreviewHandler.cs +++ b/src/modules/previewpane/SvgPreviewHandler/SvgPreviewHandler.cs @@ -5,6 +5,7 @@ using System; using System.Runtime.InteropServices; using Common; +using Microsoft.PowerToys.Telemetry; namespace SvgPreviewHandler { @@ -27,6 +28,7 @@ namespace SvgPreviewHandler /// protected override IPreviewHandlerControl CreatePreviewHandlerControl() { + PowerToysTelemetry.Log.WriteEvent(new Telemetry.Events.SvgFileHandlerLoaded()); this.svgPreviewControl = new SvgPreviewControl(); return this.svgPreviewControl; } diff --git a/src/modules/previewpane/SvgPreviewHandler/SvgPreviewHandler.csproj b/src/modules/previewpane/SvgPreviewHandler/SvgPreviewHandler.csproj index f1c516dec9..b63ca02e9f 100644 --- a/src/modules/previewpane/SvgPreviewHandler/SvgPreviewHandler.csproj +++ b/src/modules/previewpane/SvgPreviewHandler/SvgPreviewHandler.csproj @@ -107,10 +107,16 @@ Form - + + + + + {5D00D290-4016-4CFE-9E41-1E7C724509BA} + Telemetry + {af2349b8-e5b6-4004-9502-687c1c7730b1} PreviewHandlerCommon diff --git a/src/modules/previewpane/SvgPreviewHandler/SvgTelemetry.cs b/src/modules/previewpane/SvgPreviewHandler/SvgTelemetry.cs deleted file mode 100644 index 044077babd..0000000000 --- a/src/modules/previewpane/SvgPreviewHandler/SvgTelemetry.cs +++ /dev/null @@ -1,70 +0,0 @@ -// 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 PreviewHandlerCommon.Telemetry; - -namespace SvgPreviewHandler -{ - /// - /// Telemetry helper class for Svg renderer. - /// - public class SvgTelemetry : TelemetryBase - { - /// - /// Name for ETW event. - /// - private const string EventSourceName = "Microsoft.PowerToys"; - - /// - /// ETW event name when Svg is previewed. - /// - private const string SvgFilePreviewedEventName = "PowerPreview_SVGRenderer_Previewed"; - - /// - /// ETW event name when error is thrown during Svg preview. - /// - private const string SvgFilePreviewErrorEventName = "PowerPreview_SVGRenderer_Error"; - - /// - /// Initializes a new instance of the class. - /// - public SvgTelemetry() - : base(EventSourceName) - { - } - - /// - /// Gets an instance of the class. - /// - public static SvgTelemetry Log { get; } = new SvgTelemetry(); - - /// - /// Publishes ETW event when svg is previewed successfully. - /// - public void SvgFilePreviewed() - { - this.Write(SvgFilePreviewedEventName, new EventSourceOptions() - { - Keywords = ProjectKeywordMeasure, - Tags = ProjectTelemetryTagProductAndServicePerformance, - }); - } - - /// - /// Publishes ETW event when svg could not be previewed. - /// - public void SvgFilePreviewError(string message) - { - this.Write( - SvgFilePreviewErrorEventName, - new EventSourceOptions() - { - Keywords = ProjectKeywordMeasure, - Tags = ProjectTelemetryTagProductAndServicePerformance, - }, - new { Message = message, }); - } - } -} diff --git a/src/modules/previewpane/SvgPreviewHandler/Telemetry/Events/SvgFileHandlerLoaded.cs b/src/modules/previewpane/SvgPreviewHandler/Telemetry/Events/SvgFileHandlerLoaded.cs new file mode 100644 index 0000000000..b8bb48adcc --- /dev/null +++ b/src/modules/previewpane/SvgPreviewHandler/Telemetry/Events/SvgFileHandlerLoaded.cs @@ -0,0 +1,25 @@ +// 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 SvgPreviewHandler.Telemetry.Events +{ + /// + /// A telemetry event to be raised when a svg file has been viewed in the preview pane. + /// + [EventData] + public class SvgFileHandlerLoaded : EventBase, IEvent + { + /// + /// Gets The version string. TODO: This should be replaced by a P/Invoke call to get_product_version. + /// + public string Version => "v0.18.0"; + + /// + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; + } +} diff --git a/src/modules/previewpane/SvgPreviewHandler/Telemetry/Events/SvgFilePreviewError.cs b/src/modules/previewpane/SvgPreviewHandler/Telemetry/Events/SvgFilePreviewError.cs new file mode 100644 index 0000000000..0f76d84e93 --- /dev/null +++ b/src/modules/previewpane/SvgPreviewHandler/Telemetry/Events/SvgFilePreviewError.cs @@ -0,0 +1,25 @@ +// 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 SvgPreviewHandler.Telemetry.Events +{ + /// + /// A telemetry event to be raised when an error has occured in the preview pane. + /// + [EventData] + public class SvgFilePreviewError : EventBase, IEvent + { + /// + /// Gets or sets the error messsage to log as part of the telemetry event. + /// + public string Message { get; set; } + + /// + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance; + } +} diff --git a/src/modules/previewpane/SvgPreviewHandler/Telemetry/Events/SvgFilePreviewed.cs b/src/modules/previewpane/SvgPreviewHandler/Telemetry/Events/SvgFilePreviewed.cs new file mode 100644 index 0000000000..2ce7bf5332 --- /dev/null +++ b/src/modules/previewpane/SvgPreviewHandler/Telemetry/Events/SvgFilePreviewed.cs @@ -0,0 +1,20 @@ +// 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 SvgPreviewHandler.Telemetry.Events +{ + /// + /// A telemetry event to be raised when a svg file has been viewed in the preview pane. + /// + [EventData] + public class SvgFilePreviewed : EventBase, IEvent + { + /// + public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; + } +} diff --git a/src/modules/previewpane/common/PreviewHandlerCommon.csproj b/src/modules/previewpane/common/PreviewHandlerCommon.csproj index 2c118c4181..4c237c672b 100644 --- a/src/modules/previewpane/common/PreviewHandlerCommon.csproj +++ b/src/modules/previewpane/common/PreviewHandlerCommon.csproj @@ -93,9 +93,6 @@ - - Telemetry\TelemetryBase.cs -