From 3a24e4703d432d54c618c90eec8ee5d77a094698 Mon Sep 17 00:00:00 2001 From: ryanbodrug-microsoft <56318517+ryanbodrug-microsoft@users.noreply.github.com> Date: Tue, 5 May 2020 08:53:07 -0700 Subject: [PATCH] Adding PowerLauncherTelemetry events --- PowerToys.sln | 19 ++++++++ .../Events/BootEvent.cs | 15 ++++++ .../Events/FirstDeleteEvent.cs | 13 +++++ .../Events/HideEvent.cs | 13 +++++ .../PowerLauncher.Telemetry/Events/IEvent.cs | 11 +++++ .../Events/QueryEvent.cs | 20 ++++++++ .../Events/ResultActionEvent.cs | 26 ++++++++++ .../Events/ShowEvent.cs | 13 +++++ .../PowerLauncher.Telemetry.csproj | 11 +++++ .../PowerLauncherTelemetry.cs | 48 +++++++++++++++++++ 10 files changed, 189 insertions(+) create mode 100644 src/modules/launcher/PowerLauncher.Telemetry/Events/BootEvent.cs create mode 100644 src/modules/launcher/PowerLauncher.Telemetry/Events/FirstDeleteEvent.cs create mode 100644 src/modules/launcher/PowerLauncher.Telemetry/Events/HideEvent.cs create mode 100644 src/modules/launcher/PowerLauncher.Telemetry/Events/IEvent.cs create mode 100644 src/modules/launcher/PowerLauncher.Telemetry/Events/QueryEvent.cs create mode 100644 src/modules/launcher/PowerLauncher.Telemetry/Events/ResultActionEvent.cs create mode 100644 src/modules/launcher/PowerLauncher.Telemetry/Events/ShowEvent.cs create mode 100644 src/modules/launcher/PowerLauncher.Telemetry/PowerLauncher.Telemetry.csproj create mode 100644 src/modules/launcher/PowerLauncher.Telemetry/PowerLauncherTelemetry.cs diff --git a/PowerToys.sln b/PowerToys.sln index ad2e5ddc68..4153980331 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -244,6 +244,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "interop-tests", "src\common EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Plugin.Folder", "src\modules\launcher\Plugins\Microsoft.Plugin.Folder\Microsoft.Plugin.Folder.csproj", "{787B8AA6-CA93-4C84-96FE-DF31110AD1C4}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerLauncher.Telemetry", "src\modules\launcher\PowerLauncher.Telemetry\PowerLauncher.Telemetry.csproj", "{08C8C05F-0362-41BC-818C-724572DF8B06}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -868,6 +870,22 @@ Global {787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Release|x64.ActiveCfg = Release|x64 {787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Release|x64.Build.0 = Release|x64 {787B8AA6-CA93-4C84-96FE-DF31110AD1C4}.Release|x86.ActiveCfg = Release|x64 + {08C8C05F-0362-41BC-818C-724572DF8B06}.Debug|ARM.ActiveCfg = Debug|Any CPU + {08C8C05F-0362-41BC-818C-724572DF8B06}.Debug|ARM.Build.0 = Debug|Any CPU + {08C8C05F-0362-41BC-818C-724572DF8B06}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {08C8C05F-0362-41BC-818C-724572DF8B06}.Debug|ARM64.Build.0 = Debug|Any CPU + {08C8C05F-0362-41BC-818C-724572DF8B06}.Debug|x64.ActiveCfg = Debug|Any CPU + {08C8C05F-0362-41BC-818C-724572DF8B06}.Debug|x64.Build.0 = Debug|Any CPU + {08C8C05F-0362-41BC-818C-724572DF8B06}.Debug|x86.ActiveCfg = Debug|Any CPU + {08C8C05F-0362-41BC-818C-724572DF8B06}.Debug|x86.Build.0 = Debug|Any CPU + {08C8C05F-0362-41BC-818C-724572DF8B06}.Release|ARM.ActiveCfg = Release|Any CPU + {08C8C05F-0362-41BC-818C-724572DF8B06}.Release|ARM.Build.0 = Release|Any CPU + {08C8C05F-0362-41BC-818C-724572DF8B06}.Release|ARM64.ActiveCfg = Release|Any CPU + {08C8C05F-0362-41BC-818C-724572DF8B06}.Release|ARM64.Build.0 = Release|Any CPU + {08C8C05F-0362-41BC-818C-724572DF8B06}.Release|x64.ActiveCfg = Release|Any CPU + {08C8C05F-0362-41BC-818C-724572DF8B06}.Release|x64.Build.0 = Release|Any CPU + {08C8C05F-0362-41BC-818C-724572DF8B06}.Release|x86.ActiveCfg = Release|Any CPU + {08C8C05F-0362-41BC-818C-724572DF8B06}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -935,6 +953,7 @@ Global {985B3F2F-CEED-4C0A-A249-69257E719145} = {1AFB6476-670D-4E80-A464-657E01DFF482} {437AD818-3F1F-4CA5-A79B-25233A157026} = {1AFB6476-670D-4E80-A464-657E01DFF482} {787B8AA6-CA93-4C84-96FE-DF31110AD1C4} = {4AFC9975-2456-4C70-94A4-84073C1CED93} + {08C8C05F-0362-41BC-818C-724572DF8B06} = {C140A3EF-6DBF-4084-9D4C-4EB5A99FEE68} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0} diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/BootEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/BootEvent.cs new file mode 100644 index 0000000000..44577a513c --- /dev/null +++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/BootEvent.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.Tracing; +using System.Text; + +namespace Microsoft.PowerLauncher.Telemetry +{ + [EventData] + public class BootEvent : IEvent + { + public string EventName { get; } = "PowerLauncher_Boot_Event"; + + public double BootTimeMs { get; set; } + } +} diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/FirstDeleteEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/FirstDeleteEvent.cs new file mode 100644 index 0000000000..22ded2d8d9 --- /dev/null +++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/FirstDeleteEvent.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.Tracing; +using System.Text; + +namespace Microsoft.PowerLauncher.Telemetry +{ + [EventData] + public class FirstDeleteEvent : IEvent + { + public string EventName { get; } = "PowerLauncher_FirstDelete_Event"; + } +} diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/HideEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/HideEvent.cs new file mode 100644 index 0000000000..8e2fc99045 --- /dev/null +++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/HideEvent.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.Tracing; +using System.Text; + +namespace Microsoft.PowerLauncher.Telemetry +{ + [EventData] + public class HideEvent : IEvent + { + public string EventName { get; } = "PowerLauncher_Hide_Event"; + } +} diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/IEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/IEvent.cs new file mode 100644 index 0000000000..039f7b3592 --- /dev/null +++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/IEvent.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.PowerLauncher.Telemetry +{ + public interface IEvent + { + string EventName { get; } + } +} diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/QueryEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/QueryEvent.cs new file mode 100644 index 0000000000..0399fe14f3 --- /dev/null +++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/QueryEvent.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.Tracing; +using System.Text; + +namespace Microsoft.PowerLauncher.Telemetry +{ + /// + /// ETW Event for when the user initiates a query + /// + [EventData] + public class QueryEvent : IEvent + { + public string EventName { get; } = "PowerLauncher_Query_Event"; + public double QueryTimeMs { get; set; } + public int QueryLength { get; set; } + public int NumResults { get; set; } + } + +} diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/ResultActionEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/ResultActionEvent.cs new file mode 100644 index 0000000000..3371d0d72d --- /dev/null +++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/ResultActionEvent.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.Tracing; +using System.Text; + +namespace Microsoft.PowerLauncher.Telemetry +{ + /// + /// ETW event for when a result is actioned. + /// + [EventData] + public class ResultActionEvent : IEvent + { + public string EventName { get; } = "PowerLauncher_Result_ActionEvent"; + + public enum TriggerType + { + Click, + KeyboardShortcut + } + + public TriggerType Trigger { get; set; } + public string PluginName { get; set; } + public string ActionName { get; set; } + } +} diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/ShowEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/ShowEvent.cs new file mode 100644 index 0000000000..de27e42f5d --- /dev/null +++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/ShowEvent.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.Tracing; +using System.Text; + +namespace Microsoft.PowerLauncher.Telemetry +{ + [EventData] + public class ShowEvent : IEvent + { + public string EventName { get; } = "PowerLauncher_Show_Event"; + } +} diff --git a/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncher.Telemetry.csproj b/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncher.Telemetry.csproj new file mode 100644 index 0000000000..79047e06d2 --- /dev/null +++ b/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncher.Telemetry.csproj @@ -0,0 +1,11 @@ + + + + netstandard2.0 + + + + + + + diff --git a/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncherTelemetry.cs b/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncherTelemetry.cs new file mode 100644 index 0000000000..3848e51633 --- /dev/null +++ b/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncherTelemetry.cs @@ -0,0 +1,48 @@ +// 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 Microsoft.PowerLauncher.Telemetry +{ + /// + /// Telemetry helper class for Svg renderer. + /// + public class PowerLauncherTelemetry : TelemetryBase + { + + /// + /// Name for ETW event. + /// + private const string EventSourceName = "Microsoft.PowerToys"; + + /// + /// Initializes a new instance of the class. + /// + public PowerLauncherTelemetry() + : base(EventSourceName) + { + } + + /// + /// Gets an instance of the class. + /// + public static PowerLauncherTelemetry Log = new PowerLauncherTelemetry(); + + /// + /// Publishes ETW event when an action is triggered on + /// + public void WriteEvent(T telemetryEvent) + where T : IEvent + { + this.Write(telemetryEvent.EventName, new EventSourceOptions() + { + Keywords = ProjectKeywordMeasure, + Tags = ProjectTelemetryTagProductAndServicePerformance, + }, + telemetryEvent); + } + } +}