Added telemetry for Color Picker module (#5259)

* Added telemetry for Color Picker module

* Closing color picker with Esc and added a telemetry for that

* Missed update of csproj

* updated installer to include telemetry.dll for color picker

* removed telemetry.dll it was alrady there

* after review changes
This commit is contained in:
martinchrzan
2020-07-29 09:01:04 +02:00
committed by GitHub
parent 704ca4eae2
commit 0b27fc39e6
7 changed files with 61 additions and 1 deletions

View File

@@ -62,6 +62,9 @@
<Compile Include="Settings\IUserSettings.cs" />
<Compile Include="Settings\SettingItem.cs" />
<Compile Include="Settings\UserSettings.cs" />
<Compile Include="Telemetry\ColorPickerCancelledEvent.cs" />
<Compile Include="Telemetry\ColorPickerShowEvent.cs" />
<Compile Include="Telemetry\ColorPickerZoomOpenedEvent.cs" />
<Compile Include="Win32Apis.cs" />
<Compile Include="ZoomWindow.xaml.cs">
<DependentUpon>ZoomWindow.xaml</DependentUpon>
@@ -177,6 +180,10 @@
<Project>{4AED67B6-55FD-486F-B917-E543DEE2CB3C}</Project>
<Name>ManagedCommon</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj">
<Project>{5d00d290-4016-4cfe-9e41-1e7c724509ba}</Project>
<Name>Telemetry</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\core\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>

View File

@@ -1,4 +1,6 @@
using ColorPicker.ViewModelContracts;
using ColorPicker.Telemetry;
using ColorPicker.ViewModelContracts;
using Microsoft.PowerToys.Telemetry;
using System;
using System.ComponentModel.Composition;
using System.Drawing;
@@ -163,6 +165,7 @@ namespace ColorPicker.Helpers
{
_zoomWindow.Left = _lastLeft + 1;
_zoomWindow.Top = _lastTop + 1;
PowerToysTelemetry.Log.WriteEvent(new ColorPickerZoomOpenedEvent());
}
_zoomWindow.DesiredLeft = _lastLeft;

View File

@@ -1,9 +1,12 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Windows.Input;
using ColorPicker.Helpers;
using ColorPicker.Settings;
using ColorPicker.Telemetry;
using Microsoft.PowerToys.Settings.UI.Lib.Utilities;
using Microsoft.PowerToys.Telemetry;
namespace ColorPicker.Keyboard
{
@@ -56,6 +59,14 @@ namespace ColorPicker.Keyboard
private void Hook_KeyboardPressed(object sender, GlobalKeyboardHookEventArgs e)
{
var virtualCode = e.KeyboardData.VirtualCode;
// ESC pressed
if(virtualCode == KeyInterop.VirtualKeyFromKey(Key.Escape))
{
_currentlyPressedKeys.Clear();
_appStateHandler.HideColorPicker();
PowerToysTelemetry.Log.WriteEvent(new ColorPickerCancelledEvent());
}
var name = Helper.GetKeyName((uint)virtualCode);
// we got modifier with additional info such as "Ctrl (left)" - get rid of parenthesess

View File

@@ -0,0 +1,12 @@
using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events;
using System.Diagnostics.Tracing;
namespace ColorPicker.Telemetry
{
[EventData]
public class ColorPickerCancelledEvent : EventBase, IEvent
{
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
}
}

View File

@@ -0,0 +1,12 @@
using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events;
using System.Diagnostics.Tracing;
namespace ColorPicker.Telemetry
{
[EventData]
public class ColorPickerShowEvent : EventBase, IEvent
{
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
}
}

View File

@@ -0,0 +1,12 @@
using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events;
using System.Diagnostics.Tracing;
namespace ColorPicker.Telemetry
{
[EventData]
public class ColorPickerZoomOpenedEvent : EventBase, IEvent
{
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
}
}

View File

@@ -10,7 +10,9 @@ using ColorPicker.Keyboard;
using ColorPicker.Mouse;
using ColorPicker.Settings;
using ColorPicker.ViewModelContracts;
using ColorPicker.Telemetry;
using Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Telemetry;
namespace ColorPicker.ViewModels
{
@@ -108,6 +110,7 @@ namespace ColorPicker.ViewModels
CopyToClipboard(colorRepresentationToCopy);
_appStateHandler.HideColorPicker();
PowerToysTelemetry.Log.WriteEvent(new ColorPickerShowEvent());
}
private static void CopyToClipboard(string colorRepresentationToCopy)