mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 17:42:45 +08:00
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:
parent
d4b56f99ff
commit
34f814717b
@ -576,6 +576,7 @@
|
||||
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\powerpreview.dll" KeyPath="yes" />
|
||||
<!-- File to include common library used by preview handlers -->
|
||||
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\PreviewHandlerCommon.dll" />
|
||||
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\Telemetry.dll" />
|
||||
<!-- File to include dll for Svg Preview Handler -->
|
||||
<File Source="$(var.BinX64Dir)modules\FileExplorerPreview\SvgPreviewHandler.dll" />
|
||||
<!-- Files to include dll's for Markdown Preview Handler and it's dependencies -->
|
||||
|
16
src/common/ManagedTelemetry/Telemetry/Events/EventBase.cs
Normal file
16
src/common/ManagedTelemetry/Telemetry/Events/EventBase.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Tracing;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.PowerToys.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A base class to implement properties that are common to all telemetry events.
|
||||
/// </summary>
|
||||
[EventData]
|
||||
public class EventBase
|
||||
{
|
||||
public bool UTCReplace_AppSessionGuid => true;
|
||||
}
|
||||
}
|
11
src/common/ManagedTelemetry/Telemetry/Events/IEvent.cs
Normal file
11
src/common/ManagedTelemetry/Telemetry/Events/IEvent.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
@ -35,6 +36,7 @@ namespace Microsoft.PowerToys.Telemetry
|
||||
/// Publishes ETW event when an action is triggered on
|
||||
/// </summary>
|
||||
public void WriteEvent<T>(T telemetryEvent)
|
||||
where T : EventBase, IEvent
|
||||
{
|
||||
this.Write<T>(null, new EventSourceOptions()
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Platforms>x64</Platforms>
|
||||
|
@ -4,8 +4,24 @@
|
||||
|
||||
using System.Diagnostics.Tracing;
|
||||
|
||||
namespace PreviewHandlerCommon.Telemetry
|
||||
namespace Microsoft.PowerToys.Telemetry
|
||||
{
|
||||
/// <summary>
|
||||
/// Privacy Tag values
|
||||
/// </summary>
|
||||
public enum PartA_PrivTags
|
||||
: ulong
|
||||
{
|
||||
/// <nodoc/>
|
||||
None = 0,
|
||||
|
||||
/// <nodoc/>
|
||||
ProductAndServicePerformance = 0x0u,
|
||||
|
||||
/// <nodoc/>
|
||||
ProductAndServiceUsage = 0x0u,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Base class for telemetry events.
|
||||
/// </summary>
|
||||
|
@ -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
|
||||
{
|
||||
/// <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";
|
||||
|
||||
public double BootTimeMs { get; set; }
|
||||
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
@ -15,7 +17,13 @@ namespace Microsoft.PowerToys.Settings.UI.Runner
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
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);
|
||||
});
|
||||
|
||||
|
@ -68,6 +68,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\common\interop\interop.vcxproj" />
|
||||
<ProjectReference Include="..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.PowerToys.Settings.UI.Lib\Microsoft.PowerToys.Settings.UI.Lib.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.PowerToys.Settings.UI\Microsoft.PowerToys.Settings.UI.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -231,6 +231,10 @@
|
||||
</AdditionalFiles>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj">
|
||||
<Project>{5d00d290-4016-4cfe-9e41-1e7c724509ba}</Project>
|
||||
<Name>Telemetry</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Microsoft.PowerToys.Settings.UI.Lib\Microsoft.PowerToys.Settings.UI.Lib.csproj">
|
||||
<Project>{b1bcc8c6-46b5-4bfa-8f22-20f32d99ec6a}</Project>
|
||||
<Name>Microsoft.PowerToys.Settings.UI.Lib</Name>
|
||||
|
@ -167,6 +167,10 @@
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj">
|
||||
<Project>{5d00d290-4016-4cfe-9e41-1e7c724509ba}</Project>
|
||||
<Name>Telemetry</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Microsoft.PowerToys.Settings.UI.Lib\Microsoft.PowerToys.Settings.UI.Lib.csproj">
|
||||
<Project>{b1bcc8c6-46b5-4bfa-8f22-20f32d99ec6a}</Project>
|
||||
<Name>Microsoft.PowerToys.Settings.UI.Lib</Name>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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(() =>
|
||||
{
|
||||
|
@ -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, });
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -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, });
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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" />
|
||||
|
Loading…
Reference in New Issue
Block a user