From def0d7a519dc5d7a15d99b4a155dc25e7d67f0bd Mon Sep 17 00:00:00 2001
From: ryanbodrug-microsoft
<56318517+ryanbodrug-microsoft@users.noreply.github.com>
Date: Tue, 5 May 2020 09:23:31 -0700
Subject: [PATCH] Small refactor to use common powertoys telemetry event source
accross modules.
---
PowerToys.sln | 19 +++++++++++++++++++
.../Telemetry}/Events/IEvent.cs | 2 +-
.../Telemetry/PowerToysTelemetry.cs} | 12 ++++++------
.../Telemetry/Telemetry.csproj | 11 +++++++++++
.../Events/BootEvent.cs | 1 +
.../Events/FirstDeleteEvent.cs | 1 +
.../Events/HideEvent.cs | 1 +
.../Events/QueryEvent.cs | 1 +
.../Events/ResultActionEvent.cs | 1 +
.../Events/ShowEvent.cs | 1 +
.../PowerLauncher.Telemetry.csproj | 2 +-
.../launcher/PowerLauncher/App.xaml.cs | 3 ++-
.../launcher/PowerLauncher/MainWindow.xaml.cs | 3 ++-
.../Wox/ViewModel/ContextMenuItemViewModel.cs | 3 ++-
.../launcher/Wox/ViewModel/MainViewModel.cs | 9 +++++----
15 files changed, 55 insertions(+), 15 deletions(-)
rename src/{modules/launcher/PowerLauncher.Telemetry => common/ManagedTelemetry/Telemetry}/Events/IEvent.cs (73%)
rename src/{modules/launcher/PowerLauncher.Telemetry/PowerLauncherTelemetry.cs => common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs} (73%)
create mode 100644 src/common/ManagedTelemetry/Telemetry/Telemetry.csproj
diff --git a/PowerToys.sln b/PowerToys.sln
index 4153980331..7c6d765194 100644
--- a/PowerToys.sln
+++ b/PowerToys.sln
@@ -246,6 +246,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Plugin.Folder", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerLauncher.Telemetry", "src\modules\launcher\PowerLauncher.Telemetry\PowerLauncher.Telemetry.csproj", "{08C8C05F-0362-41BC-818C-724572DF8B06}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Telemetry", "src\common\ManagedTelemetry\Telemetry\Telemetry.csproj", "{5D00D290-4016-4CFE-9E41-1E7C724509BA}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
@@ -886,6 +888,22 @@ Global
{08C8C05F-0362-41BC-818C-724572DF8B06}.Release|x64.Build.0 = Release|Any CPU
{08C8C05F-0362-41BC-818C-724572DF8B06}.Release|x86.ActiveCfg = Release|Any CPU
{08C8C05F-0362-41BC-818C-724572DF8B06}.Release|x86.Build.0 = Release|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Debug|ARM.Build.0 = Debug|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Debug|ARM64.Build.0 = Debug|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Debug|x64.Build.0 = Debug|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Debug|x86.Build.0 = Debug|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Release|ARM.ActiveCfg = Release|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Release|ARM.Build.0 = Release|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Release|ARM64.Build.0 = Release|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Release|x64.ActiveCfg = Release|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Release|x64.Build.0 = Release|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Release|x86.ActiveCfg = Release|Any CPU
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -954,6 +972,7 @@ Global
{437AD818-3F1F-4CA5-A79B-25233A157026} = {1AFB6476-670D-4E80-A464-657E01DFF482}
{787B8AA6-CA93-4C84-96FE-DF31110AD1C4} = {4AFC9975-2456-4C70-94A4-84073C1CED93}
{08C8C05F-0362-41BC-818C-724572DF8B06} = {C140A3EF-6DBF-4084-9D4C-4EB5A99FEE68}
+ {5D00D290-4016-4CFE-9E41-1E7C724509BA} = {1AFB6476-670D-4E80-A464-657E01DFF482}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/IEvent.cs b/src/common/ManagedTelemetry/Telemetry/Events/IEvent.cs
similarity index 73%
rename from src/modules/launcher/PowerLauncher.Telemetry/Events/IEvent.cs
rename to src/common/ManagedTelemetry/Telemetry/Events/IEvent.cs
index 039f7b3592..0bdfb42099 100644
--- a/src/modules/launcher/PowerLauncher.Telemetry/Events/IEvent.cs
+++ b/src/common/ManagedTelemetry/Telemetry/Events/IEvent.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
-namespace Microsoft.PowerLauncher.Telemetry
+namespace Microsoft.PowerToys.Telemetry
{
public interface IEvent
{
diff --git a/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncherTelemetry.cs b/src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs
similarity index 73%
rename from src/modules/launcher/PowerLauncher.Telemetry/PowerLauncherTelemetry.cs
rename to src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs
index 3848e51633..5d3edfb2ad 100644
--- a/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncherTelemetry.cs
+++ b/src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs
@@ -5,12 +5,12 @@
using System.Diagnostics.Tracing;
using PreviewHandlerCommon.Telemetry;
-namespace Microsoft.PowerLauncher.Telemetry
+namespace Microsoft.PowerToys.Telemetry
{
///
- /// Telemetry helper class for Svg renderer.
+ /// Telemetry helper class for PowerToys.
///
- public class PowerLauncherTelemetry : TelemetryBase
+ public class PowerToysTelemetry : TelemetryBase
{
///
@@ -19,9 +19,9 @@ namespace Microsoft.PowerLauncher.Telemetry
private const string EventSourceName = "Microsoft.PowerToys";
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- public PowerLauncherTelemetry()
+ public PowerToysTelemetry()
: base(EventSourceName)
{
}
@@ -29,7 +29,7 @@ namespace Microsoft.PowerLauncher.Telemetry
///
/// Gets an instance of the class.
///
- public static PowerLauncherTelemetry Log = new PowerLauncherTelemetry();
+ public static PowerToysTelemetry Log = new PowerToysTelemetry();
///
/// Publishes ETW event when an action is triggered on
diff --git a/src/common/ManagedTelemetry/Telemetry/Telemetry.csproj b/src/common/ManagedTelemetry/Telemetry/Telemetry.csproj
new file mode 100644
index 0000000000..cca827fbf6
--- /dev/null
+++ b/src/common/ManagedTelemetry/Telemetry/Telemetry.csproj
@@ -0,0 +1,11 @@
+
+
+
+ netstandard2.0
+
+
+
+
+
+
+
diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/BootEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/BootEvent.cs
index 44577a513c..4351090652 100644
--- a/src/modules/launcher/PowerLauncher.Telemetry/Events/BootEvent.cs
+++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/BootEvent.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Text;
+using Microsoft.PowerToys.Telemetry;
namespace Microsoft.PowerLauncher.Telemetry
{
diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/FirstDeleteEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/FirstDeleteEvent.cs
index 22ded2d8d9..5585010717 100644
--- a/src/modules/launcher/PowerLauncher.Telemetry/Events/FirstDeleteEvent.cs
+++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/FirstDeleteEvent.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Text;
+using Microsoft.PowerToys.Telemetry;
namespace Microsoft.PowerLauncher.Telemetry
{
diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/HideEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/HideEvent.cs
index 8e2fc99045..3aab162662 100644
--- a/src/modules/launcher/PowerLauncher.Telemetry/Events/HideEvent.cs
+++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/HideEvent.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Text;
+using Microsoft.PowerToys.Telemetry;
namespace Microsoft.PowerLauncher.Telemetry
{
diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/QueryEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/QueryEvent.cs
index 0399fe14f3..ea986eccc6 100644
--- a/src/modules/launcher/PowerLauncher.Telemetry/Events/QueryEvent.cs
+++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/QueryEvent.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Text;
+using Microsoft.PowerToys.Telemetry;
namespace Microsoft.PowerLauncher.Telemetry
{
diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/ResultActionEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/ResultActionEvent.cs
index 3371d0d72d..a338ba26a9 100644
--- a/src/modules/launcher/PowerLauncher.Telemetry/Events/ResultActionEvent.cs
+++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/ResultActionEvent.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Text;
+using Microsoft.PowerToys.Telemetry;
namespace Microsoft.PowerLauncher.Telemetry
{
diff --git a/src/modules/launcher/PowerLauncher.Telemetry/Events/ShowEvent.cs b/src/modules/launcher/PowerLauncher.Telemetry/Events/ShowEvent.cs
index de27e42f5d..ec5afe34c4 100644
--- a/src/modules/launcher/PowerLauncher.Telemetry/Events/ShowEvent.cs
+++ b/src/modules/launcher/PowerLauncher.Telemetry/Events/ShowEvent.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Text;
+using Microsoft.PowerToys.Telemetry;
namespace Microsoft.PowerLauncher.Telemetry
{
diff --git a/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncher.Telemetry.csproj b/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncher.Telemetry.csproj
index 79047e06d2..d70903b0cb 100644
--- a/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncher.Telemetry.csproj
+++ b/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncher.Telemetry.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/src/modules/launcher/PowerLauncher/App.xaml.cs b/src/modules/launcher/PowerLauncher/App.xaml.cs
index 894af2fff5..d4b08fd256 100644
--- a/src/modules/launcher/PowerLauncher/App.xaml.cs
+++ b/src/modules/launcher/PowerLauncher/App.xaml.cs
@@ -1,4 +1,5 @@
using Microsoft.PowerLauncher.Telemetry;
+using Microsoft.PowerToys.Telemetry;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
@@ -98,7 +99,7 @@ namespace PowerLauncher
bootTime.Stop();
- PowerLauncherTelemetry.Log.WriteEvent(new BootEvent() { BootTimeMs = bootTime.ElapsedMilliseconds });
+ PowerToysTelemetry.Log.WriteEvent(new BootEvent() { BootTimeMs = bootTime.ElapsedMilliseconds });
//[Conditional("RELEASE")]
// check udpate every 5 hours
diff --git a/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs b/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs
index 89bb911eb7..1086b7620a 100644
--- a/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs
+++ b/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs
@@ -28,6 +28,7 @@ using Mages.Core.Runtime.Converters;
using System.Runtime.InteropServices;
using Microsoft.PowerLauncher.Telemetry;
using System.Timers;
+using Microsoft.PowerToys.Telemetry;
namespace PowerLauncher
{
@@ -66,7 +67,7 @@ namespace PowerLauncher
_firstDeleteTimer.Stop();
if (_deletePressed)
{
- PowerLauncherTelemetry.Log.WriteEvent(new FirstDeleteEvent());
+ PowerToysTelemetry.Log.WriteEvent(new FirstDeleteEvent());
}
}
diff --git a/src/modules/launcher/Wox/ViewModel/ContextMenuItemViewModel.cs b/src/modules/launcher/Wox/ViewModel/ContextMenuItemViewModel.cs
index d2509e5159..d09fa5d3c7 100644
--- a/src/modules/launcher/Wox/ViewModel/ContextMenuItemViewModel.cs
+++ b/src/modules/launcher/Wox/ViewModel/ContextMenuItemViewModel.cs
@@ -1,4 +1,5 @@
using Microsoft.PowerLauncher.Telemetry;
+using Microsoft.PowerToys.Telemetry;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Input;
@@ -26,7 +27,7 @@ namespace Wox.ViewModel
ActionName = Title
};
- PowerLauncherTelemetry.Log.WriteEvent(eventData);
+ PowerToysTelemetry.Log.WriteEvent(eventData);
}
}
}
\ No newline at end of file
diff --git a/src/modules/launcher/Wox/ViewModel/MainViewModel.cs b/src/modules/launcher/Wox/ViewModel/MainViewModel.cs
index 5483ddfb29..5005fc5fe2 100644
--- a/src/modules/launcher/Wox/ViewModel/MainViewModel.cs
+++ b/src/modules/launcher/Wox/ViewModel/MainViewModel.cs
@@ -19,7 +19,8 @@ using Wox.Infrastructure.UserSettings;
using Wox.Plugin;
using Microsoft.PowerLauncher.Telemetry;
using Wox.Storage;
-
+using Microsoft.PowerToys.Telemetry;
+
namespace Wox.ViewModel
{
public class MainViewModel : BaseModel, ISavable
@@ -311,11 +312,11 @@ namespace Wox.ViewModel
_visibility = value;
if(value == Visibility.Visible)
{
- PowerLauncherTelemetry.Log.WriteEvent(new ShowEvent());
+ PowerToysTelemetry.Log.WriteEvent(new ShowEvent());
}
else
{
- PowerLauncherTelemetry.Log.WriteEvent(new HideEvent());
+ PowerToysTelemetry.Log.WriteEvent(new HideEvent());
}
}
@@ -461,7 +462,7 @@ namespace Wox.ViewModel
NumResults = Results.Results.Count,
QueryLength = query.RawQuery.Length
};
- PowerLauncherTelemetry.Log.WriteEvent(queryEvent);
+ PowerToysTelemetry.Log.WriteEvent(queryEvent);
}, currentCancellationToken);
}