Adding PowerLauncherTelemetry events

This commit is contained in:
ryanbodrug-microsoft 2020-05-05 08:53:07 -07:00
parent 2b158c2b4e
commit 3a24e4703d
10 changed files with 189 additions and 0 deletions

View File

@ -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}

View File

@ -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; }
}
}

View File

@ -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";
}
}

View File

@ -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";
}
}

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.PowerLauncher.Telemetry
{
public interface IEvent
{
string EventName { get; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Text;
namespace Microsoft.PowerLauncher.Telemetry
{
/// <summary>
/// ETW Event for when the user initiates a query
/// </summary>
[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; }
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Text;
namespace Microsoft.PowerLauncher.Telemetry
{
/// <summary>
/// ETW event for when a result is actioned.
/// </summary>
[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; }
}
}

View File

@ -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";
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\..\common\Telemetry\TelemetryBase.cs" Link="TelemetryBase.cs" />
</ItemGroup>
</Project>

View File

@ -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
{
/// <summary>
/// Telemetry helper class for Svg renderer.
/// </summary>
public class PowerLauncherTelemetry : TelemetryBase
{
/// <summary>
/// Name for ETW event.
/// </summary>
private const string EventSourceName = "Microsoft.PowerToys";
/// <summary>
/// Initializes a new instance of the <see cref="PowerLauncherTelemetry"/> class.
/// </summary>
public PowerLauncherTelemetry()
: base(EventSourceName)
{
}
/// <summary>
/// Gets an instance of the <see cref="PowerLauncherTelemetry"/> class.
/// </summary>
public static PowerLauncherTelemetry Log = new PowerLauncherTelemetry();
/// <summary>
/// Publishes ETW event when an action is triggered on
/// </summary>
public void WriteEvent<T>(T telemetryEvent)
where T : IEvent
{
this.Write<T>(telemetryEvent.EventName, new EventSourceOptions()
{
Keywords = ProjectKeywordMeasure,
Tags = ProjectTelemetryTagProductAndServicePerformance,
},
telemetryEvent);
}
}
}