Adding privacy event tags to each telemetry event. (#2879)

* Adding privacy event tags to each telemetry event.

* Moving Privacy events to Telemetry base, Removing tag values, and fixing namespaces.

* Adding documentation comments to fix style cop errors in release

* UTCReplace_AppSessionGuid boolean property to all C# telemetry events.

* Adding hardcoded version number to boot events.

* Adding reference to telemetry in settings unittest

* Adding Preview Pane events for loading w/ hardcoded version number

* Adding telemetry.h to msi for svg and markdown events

* removing unused explicit interface exception
This commit is contained in:
ryanbodrug-microsoft
2020-05-15 09:08:39 -07:00
committed by GitHub
parent d4b56f99ff
commit 34f814717b
34 changed files with 505 additions and 354 deletions

View File

@@ -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
{
/// <summary>
/// TODO: This should be replaced by a P/Invoke call to get_product_version
/// </summary>
public string Version => "v0.18.0";
public double BootTimeMs { get; set; }
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance;
}
}

View File

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

View File

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

View File

@@ -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
/// </summary>
[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;
}
}

View File

@@ -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.
/// </summary>
[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;
}
}

View File

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

View File

@@ -107,6 +107,10 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj">
<Project>{5d00d290-4016-4cfe-9e41-1e7c724509ba}</Project>
<Name>Telemetry</Name>
</ProjectReference>
<ProjectReference Include="..\PowerLauncher.Telemetry\PowerLauncher.Telemetry.csproj">
<Project>{08c8c05f-0362-41bc-818c-724572df8b06}</Project>
<Name>PowerLauncher.Telemetry</Name>

View File

@@ -101,7 +101,6 @@
<Compile Include="Generated Files\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="MarkdownTelemetry.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@@ -112,6 +111,9 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Telemetry\Events\MarkdownFileHandlerLoaded.cs" />
<Compile Include="Telemetry\Events\MarkdownFilePreviewed.cs" />
<Compile Include="Telemetry\Events\MarkdownFilePreviewError.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="HtmlAgilityPack">
@@ -132,6 +134,10 @@
</AdditionalFiles>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj">
<Project>{5D00D290-4016-4CFE-9E41-1E7C724509BA}</Project>
<Name>Telemetry</Name>
</ProjectReference>
<ProjectReference Include="..\common\PreviewHandlerCommon.csproj">
<Project>{af2349b8-e5b6-4004-9502-687c1c7730b1}</Project>
<Name>PreviewHandlerCommon</Name>

View File

@@ -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
{
/// <summary>
/// A telemetry event that is triggered when a markdown file is viewed in the preview pane.
/// </summary>
[EventData]
public class MarkdownFileHandlerLoaded : EventBase, IEvent
{
/// <summary>
/// Gets The version string. TODO: This should be replaced by a P/Invoke call to get_product_version.
/// </summary>
public string Version => "v0.18.0";
/// <inheritdoc/>
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
}
}

View File

@@ -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
{
/// <summary>
/// A telemetry event that is triggered when an error occurs while attempting to view a markdown file in the preview pane.
/// </summary>
public class MarkdownFilePreviewError : EventBase, IEvent
{
/// <summary>
/// Gets or sets the error message.
/// </summary>
public string Message { get; set; }
/// <inheritdoc/>
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance;
}
}

View File

@@ -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
{
/// <summary>
/// A telemetry event that is triggered when a markdown file is viewed in the preview pane.
/// </summary>
[EventData]
public class MarkdownFilePreviewed : EventBase, IEvent
{
/// <inheritdoc/>
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
}
}

View File

@@ -5,6 +5,7 @@
using System;
using System.Runtime.InteropServices;
using Common;
using Microsoft.PowerToys.Telemetry;
namespace MarkdownPreviewHandler
{
@@ -27,6 +28,7 @@ namespace MarkdownPreviewHandler
/// <inheritdoc />
protected override IPreviewHandlerControl CreatePreviewHandlerControl()
{
PowerToysTelemetry.Log.WriteEvent(new Telemetry.Events.MarkdownFileHandlerLoaded());
this.markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl();
return this.markdownPreviewHandlerControl;
}

View File

@@ -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(() =>
{

View File

@@ -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
{
/// <summary>
/// Telemetry helper class for markdown renderer.
/// </summary>
public class MarkdownTelemetry : TelemetryBase
{
/// <summary>
/// Name for ETW event.
/// </summary>
private const string EventSourceName = "Microsoft.PowerToys";
/// <summary>
/// ETW event name when markdown is previewed.
/// </summary>
private const string MarkdownFilePreviewedEventName = "PowerPreview_MDRenderer_Previewed";
/// <summary>
/// ETW event name when error is thrown during markdown preview.
/// </summary>
private const string MarkdownFilePreviewErrorEventName = "PowerPreview_MDRenderer_Error";
/// <summary>
/// Initializes a new instance of the <see cref="MarkdownTelemetry"/> class.
/// </summary>
public MarkdownTelemetry()
: base(EventSourceName)
{
return;
}
/// <summary>
/// Gets an instance of the <see cref="MarkdownTelemetry"/> class.
/// </summary>
public static MarkdownTelemetry Log { get; } = new MarkdownTelemetry();
/// <summary>
/// Publishes ETW event when markdown is previewed successfully.
/// </summary>
public void MarkdownFilePreviewed()
{
this.Write(MarkdownFilePreviewedEventName, new EventSourceOptions()
{
Keywords = ProjectKeywordMeasure,
Tags = ProjectTelemetryTagProductAndServicePerformance,
});
}
/// <summary>
/// Publishes ETW event when markdown could not be previewed.
/// </summary>
public void MarkdownFilePreviewError(string message)
{
this.Write(
MarkdownFilePreviewErrorEventName,
new EventSourceOptions()
{
Keywords = ProjectKeywordMeasure,
Tags = ProjectTelemetryTagProductAndServicePerformance,
},
new { Message = message, });
}
}
}

View File

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

View File

@@ -5,6 +5,7 @@
using System;
using System.Runtime.InteropServices;
using Common;
using Microsoft.PowerToys.Telemetry;
namespace SvgPreviewHandler
{
@@ -27,6 +28,7 @@ namespace SvgPreviewHandler
/// <inheritdoc/>
protected override IPreviewHandlerControl CreatePreviewHandlerControl()
{
PowerToysTelemetry.Log.WriteEvent(new Telemetry.Events.SvgFileHandlerLoaded());
this.svgPreviewControl = new SvgPreviewControl();
return this.svgPreviewControl;
}

View File

@@ -107,10 +107,16 @@
<SubType>Form</SubType>
</Compile>
<Compile Include="SvgPreviewHandler.cs" />
<Compile Include="SvgTelemetry.cs" />
<Compile Include="Telemetry\Events\SvgFileHandlerLoaded.cs" />
<Compile Include="Telemetry\Events\SvgFilePreviewed.cs" />
<Compile Include="Telemetry\Events\SvgFilePreviewError.cs" />
<Compile Include="Utilities\SvgPreviewHandlerHelper.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj">
<Project>{5D00D290-4016-4CFE-9E41-1E7C724509BA}</Project>
<Name>Telemetry</Name>
</ProjectReference>
<ProjectReference Include="..\common\PreviewHandlerCommon.csproj">
<Project>{af2349b8-e5b6-4004-9502-687c1c7730b1}</Project>
<Name>PreviewHandlerCommon</Name>

View File

@@ -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
{
/// <summary>
/// Telemetry helper class for Svg renderer.
/// </summary>
public class SvgTelemetry : TelemetryBase
{
/// <summary>
/// Name for ETW event.
/// </summary>
private const string EventSourceName = "Microsoft.PowerToys";
/// <summary>
/// ETW event name when Svg is previewed.
/// </summary>
private const string SvgFilePreviewedEventName = "PowerPreview_SVGRenderer_Previewed";
/// <summary>
/// ETW event name when error is thrown during Svg preview.
/// </summary>
private const string SvgFilePreviewErrorEventName = "PowerPreview_SVGRenderer_Error";
/// <summary>
/// Initializes a new instance of the <see cref="SvgTelemetry"/> class.
/// </summary>
public SvgTelemetry()
: base(EventSourceName)
{
}
/// <summary>
/// Gets an instance of the <see cref="SvgTelemetry"/> class.
/// </summary>
public static SvgTelemetry Log { get; } = new SvgTelemetry();
/// <summary>
/// Publishes ETW event when svg is previewed successfully.
/// </summary>
public void SvgFilePreviewed()
{
this.Write(SvgFilePreviewedEventName, new EventSourceOptions()
{
Keywords = ProjectKeywordMeasure,
Tags = ProjectTelemetryTagProductAndServicePerformance,
});
}
/// <summary>
/// Publishes ETW event when svg could not be previewed.
/// </summary>
public void SvgFilePreviewError(string message)
{
this.Write(
SvgFilePreviewErrorEventName,
new EventSourceOptions()
{
Keywords = ProjectKeywordMeasure,
Tags = ProjectTelemetryTagProductAndServicePerformance,
},
new { Message = message, });
}
}
}

View File

@@ -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
{
/// <summary>
/// A telemetry event to be raised when a svg file has been viewed in the preview pane.
/// </summary>
[EventData]
public class SvgFileHandlerLoaded : EventBase, IEvent
{
/// <summary>
/// Gets The version string. TODO: This should be replaced by a P/Invoke call to get_product_version.
/// </summary>
public string Version => "v0.18.0";
/// <inheritdoc/>
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
}
}

View File

@@ -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
{
/// <summary>
/// A telemetry event to be raised when an error has occured in the preview pane.
/// </summary>
[EventData]
public class SvgFilePreviewError : EventBase, IEvent
{
/// <summary>
/// Gets or sets the error messsage to log as part of the telemetry event.
/// </summary>
public string Message { get; set; }
/// <inheritdoc/>
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance;
}
}

View File

@@ -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
{
/// <summary>
/// A telemetry event to be raised when a svg file has been viewed in the preview pane.
/// </summary>
[EventData]
public class SvgFilePreviewed : EventBase, IEvent
{
/// <inheritdoc/>
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
}
}

View File

@@ -93,9 +93,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\common\Telemetry\TelemetryBase.cs">
<Link>Telemetry\TelemetryBase.cs</Link>
</Compile>
<Compile Include="cominterop\IInitializeWithFile.cs" />
<Compile Include="cominterop\COLORREF.cs" />
<Compile Include="cominterop\IInitializeWithStream.cs" />