Adding telemetry events for Settings Enabled or Disabled Modules

This commit is contained in:
ryanbodrug-microsoft 2020-05-05 11:44:54 -07:00
parent def0d7a519
commit b4d75e3240
4 changed files with 151 additions and 37 deletions

View File

@ -2,8 +2,11 @@
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Runtime.CompilerServices;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using Microsoft.PowerToys.Settings.Telemetry;
using Microsoft.PowerToys.Telemetry;
namespace Microsoft.PowerToys.Settings.UI.Lib namespace Microsoft.PowerToys.Settings.UI.Lib
{ {
@ -11,37 +14,131 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
{ {
public EnabledModules() public EnabledModules()
{ {
this.FancyZones = false;
this.ImageResizer = false;
this.FileExplorerPreview = false;
this.PowerRename = false;
this.ShortcutGuide = false;
this.PowerLauncher = true;
} }
private bool fancyZones = true;
[JsonPropertyName("FancyZones")] [JsonPropertyName("FancyZones")]
public bool FancyZones { get; set; } public bool FancyZones
{
get => this.fancyZones;
set
{
if (this.fancyZones != value)
{
LogTelemetryEvent(value);
this.fancyZones = value;
}
}
}
private bool imageResizer = true;
[JsonPropertyName("Image Resizer")] [JsonPropertyName("Image Resizer")]
public bool ImageResizer { get; set; } public bool ImageResizer
{
get => this.imageResizer;
set
{
if (this.imageResizer != value)
{
LogTelemetryEvent(value);
this.imageResizer = value;
}
}
}
private bool fileExplorerPreview = true;
[JsonPropertyName("File Explorer Preview")] [JsonPropertyName("File Explorer Preview")]
public bool FileExplorerPreview { get; set; } public bool FileExplorerPreview
{
get => this.fileExplorerPreview;
set
{
if (this.fileExplorerPreview != value)
{
LogTelemetryEvent(value);
this.fileExplorerPreview = value;
}
}
}
private bool shortcutGuide = true;
[JsonPropertyName("Shortcut Guide")] [JsonPropertyName("Shortcut Guide")]
public bool ShortcutGuide { get; set; } public bool ShortcutGuide
{
get => this.shortcutGuide;
set
{
if (this.shortcutGuide != value)
{
LogTelemetryEvent(value);
this.shortcutGuide = value;
}
}
}
public bool PowerRename { get; set; } private bool powerRename = true;
public bool PowerRename
{
get => this.powerRename;
set
{
if (this.powerRename != value)
{
LogTelemetryEvent(value);
this.powerRename = value;
}
}
}
private bool keyboardManager = true;
[JsonPropertyName("Keyboard Manager")] [JsonPropertyName("Keyboard Manager")]
public bool KeyboardManager { get; set; } public bool KeyboardManager
{
get => this.keyboardManager;
set
{
if (this.keyboardManager != value)
{
LogTelemetryEvent(value);
this.keyboardManager = value;
}
}
}
private bool powerLauncher = true;
[JsonPropertyName("Run")] [JsonPropertyName("Run")]
public bool PowerLauncher { get; set; } public bool PowerLauncher
{
get => this.powerLauncher;
set
{
if (this.powerLauncher != value)
{
LogTelemetryEvent(value);
this.powerLauncher = value;
}
}
}
public string ToJsonString() public string ToJsonString()
{ {
return JsonSerializer.Serialize(this); return JsonSerializer.Serialize(this);
} }
private void LogTelemetryEvent(bool value, [CallerMemberName] string moduleName = null )
{
var dataEvent = new EnabledModuleEvent()
{
Value = value,
ModuleName = moduleName,
};
PowerToysTelemetry.Log.WriteEvent(dataEvent);
}
} }
} }

View File

@ -33,6 +33,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\common\interop\interop.vcxproj" /> <ProjectReference Include="..\..\common\interop\interop.vcxproj" />
<ProjectReference Include="..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,15 @@
using System.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry;
namespace Microsoft.PowerToys.Settings.Telemetry
{
[EventData]
public class EnabledModuleEvent : IEvent
{
public string EventName { get; } = "Settings_EnableModule";
public string ModuleName { get; set; }
public bool Value { get; set; }
}
}

View File

@ -29,7 +29,8 @@ namespace Microsoft.PowerToys.Settings.UI.Runner
// send IPC Message // send IPC Message
shellPage.SetDefaultSndMessageCallback(msg => shellPage.SetDefaultSndMessageCallback(msg =>
{ {
Program.GetTwoWayIPCManager().Send(msg); //IPC Manager is null when launching runner directly
Program.GetTwoWayIPCManager()?.Send(msg);
}); });
// send IPC Message // send IPC Message