Adding launcher telemetry for context buttons clicked.

This commit is contained in:
ryanbodrug-microsoft 2020-05-05 09:02:28 -07:00
parent e29e8ca0a3
commit a9cc4dabb7
11 changed files with 186 additions and 122 deletions

View File

@ -8,6 +8,7 @@ using Wox.Infrastructure.Logger;
using Wox.Infrastructure.Image;
using Wox.Plugin.SharedCommands;
using Wox.Plugin;
using System.Reflection;
namespace Microsoft.Plugin.Folder
{
@ -34,6 +35,7 @@ namespace Microsoft.Plugin.Folder
var fileOrFolder = (record.Type == ResultType.File) ? "file" : "folder";
contextMenus.Add(new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = "Copy path",
Glyph = "\xE8C8",
FontFamily = "Segoe MDL2 Assets",
@ -65,6 +67,7 @@ namespace Microsoft.Plugin.Folder
{
return new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = "Open containing folder",
Glyph = "\xE838",
FontFamily = "Segoe MDL2 Assets",

View File

@ -6,6 +6,7 @@ using System.Windows;
using Wox.Infrastructure.Logger;
using Wox.Plugin;
using Microsoft.Plugin.Indexer.SearchHelper;
using System.Reflection;
namespace Microsoft.Plugin.Indexer
{
@ -39,6 +40,7 @@ namespace Microsoft.Plugin.Indexer
var fileOrFolder = (type == ResultType.File) ? "file" : "folder";
contextMenus.Add(new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = "Copy path",
Glyph = "\xE8C8",
FontFamily = "Segoe MDL2 Assets",
@ -71,6 +73,7 @@ namespace Microsoft.Plugin.Indexer
{
return new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = "Open containing folder",
Glyph = "\xE838",
FontFamily = "Segoe MDL2 Assets",

View File

@ -20,6 +20,7 @@ using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Media;
using System.Windows.Controls;
using Wox.Plugin;
using System.Reflection;
namespace Microsoft.Plugin.Program.Programs
{
@ -314,6 +315,7 @@ namespace Microsoft.Plugin.Program.Programs
{
new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = api.GetTranslation("wox_plugin_program_open_containing_folder"),
Glyph = "\xE838",
FontFamily = "Segoe MDL2 Assets",

View File

@ -12,6 +12,7 @@ using Shell;
using Wox.Infrastructure;
using Microsoft.Plugin.Program.Logger;
using Wox.Plugin;
using System.Reflection;
namespace Microsoft.Plugin.Program.Programs
{
@ -95,6 +96,7 @@ namespace Microsoft.Plugin.Program.Programs
{
new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = api.GetTranslation("wox_plugin_program_run_as_administrator"),
Glyph = "\xE7EF",
FontFamily = "Segoe MDL2 Assets",
@ -117,6 +119,7 @@ namespace Microsoft.Plugin.Program.Programs
},
new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = api.GetTranslation("wox_plugin_program_open_containing_folder"),
Glyph = "\xE838",
FontFamily = "Segoe MDL2 Assets",

View File

@ -18,6 +18,7 @@ using Wox.Plugin;
using Application = System.Windows.Application;
using Control = System.Windows.Controls.Control;
using Keys = System.Windows.Forms.Keys;
using System.Reflection;
namespace Microsoft.Plugin.Shell
{
@ -341,6 +342,7 @@ namespace Microsoft.Plugin.Shell
{
new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = _context.API.GetTranslation("wox_plugin_cmd_run_as_administrator"),
Glyph = "\xE7EF",
FontFamily = "Segoe MDL2 Assets",

View File

@ -106,6 +106,12 @@
<Version>2.4.0-prerelease.200322001</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PowerLauncher.Telemetry\PowerLauncher.Telemetry.csproj">
<Project>{08c8c05f-0362-41bc-818c-724572df8b06}</Project>
<Name>PowerLauncher.Telemetry</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>

View File

@ -99,7 +99,7 @@
SelectedIndex="{Binding ContextMenuSelectedIndex}">
<GridView.ItemTemplate>
<DataTemplate>
<Button Command="{Binding Command}" VerticalAlignment="Center" CornerRadius="4" Height="42" Width="42" BorderThickness="1" Style="{ThemeResource IconOnlyButton}">
<Button Command="{Binding Command}" VerticalAlignment="Center" CornerRadius="4" Height="42" Width="42" BorderThickness="1" Style="{ThemeResource IconOnlyButton}" Click="ContextButton_OnClick">
<ToolTipService.ToolTip>
<TextBlock Text="{Binding Title}"/>
</ToolTipService.ToolTip>
@ -111,6 +111,7 @@
Key="{Binding AcceleratorKey}"
Modifiers="{Binding AcceleratorModifiers}"
IsEnabled="{Binding IsAcceleratorKeyEnabled}"
Invoked="ContextButton_OnAcceleratorInvoked"
/>
</Button.KeyboardAccelerators>
</Button>

View File

@ -1,4 +1,5 @@
using System;
using Microsoft.PowerLauncher.Telemetry;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -10,9 +11,35 @@ namespace PowerLauncher.UI
{
public sealed partial class ResultList : UserControl
{
private ResultActionEvent.TriggerType triggerType = ResultActionEvent.TriggerType.Click;
public ResultList()
{
InitializeComponent();
}
private void ContextButton_OnAcceleratorInvoked(Windows.UI.Xaml.Input.KeyboardAccelerator sender, Windows.UI.Xaml.Input.KeyboardAcceleratorInvokedEventArgs args)
{
this.triggerType = ResultActionEvent.TriggerType.KeyboardShortcut;
}
private void ContextButton_OnClick(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
var button = sender as Windows.UI.Xaml.Controls.Button;
if (button != null)
{
//We currently can't take a reference on the wox project from a UWP project. The dynamic method invoke should be replace
//by an call to the view model once we refactor the project.
var dataContext = ((dynamic)button.DataContext);
if(dataContext?.GetType().GetMethod("SendTelemetryEvent") != null)
{
dataContext.SendTelemetryEvent(triggerType);
}
}
//Restore the trigger type back to click
triggerType = ResultActionEvent.TriggerType.Click;
}
}
}

View File

@ -8,6 +8,7 @@ namespace Wox.Plugin
public class ContextMenuResult
{
public string PluginName { get; set; }
public string Title { get; set; }
public string SubTitle { get; set; }

View File

@ -1,4 +1,6 @@
using System.Drawing;
using Microsoft.PowerLauncher.Telemetry;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Input;
using Wox.Plugin;
@ -6,6 +8,7 @@ namespace Wox.ViewModel
{
public class ContextMenuItemViewModel : BaseModel
{
public string PluginName { get; set; }
public string Title { get; set; }
public string Glyph { get; set; }
public string FontFamily { get; set; }
@ -13,5 +16,17 @@ namespace Wox.ViewModel
public string AcceleratorKey { get; set; }
public string AcceleratorModifiers { get; set; }
public bool IsAcceleratorKeyEnabled { get; set; }
public void SendTelemetryEvent(ResultActionEvent.TriggerType triggerType)
{
var eventData = new ResultActionEvent()
{
PluginName = PluginName,
Trigger = triggerType,
ActionName = Title
};
PowerLauncherTelemetry.Log.WriteEvent(eventData);
}
}
}

View File

@ -119,6 +119,7 @@ namespace Wox.ViewModel
{
newItems.Add(new ContextMenuItemViewModel
{
PluginName = r.PluginName,
Title = r.Title,
Glyph = r.Glyph,
FontFamily = r.FontFamily,