mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-01 09:59:06 +08:00
[Telemetry][Hosts]Add telemetry to Hosts (#21486)
This commit is contained in:
parent
130561cfbb
commit
429569dcf3
@ -12,6 +12,7 @@ using Hosts.Views;
|
||||
using ManagedCommon;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.UI.Xaml;
|
||||
|
||||
@ -104,6 +105,8 @@ namespace Hosts
|
||||
Logger.LogInfo($"Hosts started detached from PowerToys Runner.");
|
||||
}
|
||||
|
||||
PowerToysTelemetry.Log.WriteEvent(new Hosts.Telemetry.HostsFileEditorOpenedEvent());
|
||||
|
||||
_window = new MainWindow();
|
||||
_window.Activate();
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
// 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 Hosts.Telemetry
|
||||
{
|
||||
[EventData]
|
||||
public class HostsFileEditorOpenedEvent : EventBase, IEvent
|
||||
{
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
|
||||
}
|
||||
}
|
Binary file not shown.
@ -165,6 +165,7 @@ public:
|
||||
{
|
||||
launch_process(true);
|
||||
}
|
||||
Trace::ActivateEditor();
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
@ -185,6 +186,7 @@ public:
|
||||
{
|
||||
Logger::trace("HostsModuleInterface::enable()");
|
||||
m_enabled = true;
|
||||
Trace::EnableHostsFileEditor(true);
|
||||
};
|
||||
|
||||
virtual void disable()
|
||||
@ -196,6 +198,7 @@ public:
|
||||
}
|
||||
|
||||
m_enabled = false;
|
||||
Trace::EnableHostsFileEditor(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -17,3 +17,24 @@ void Trace::UnregisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingUnregister(g_hProvider);
|
||||
}
|
||||
|
||||
// Log if the user has HostsFileEditor enabled or disabled
|
||||
void Trace::EnableHostsFileEditor(const bool enabled) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
g_hProvider,
|
||||
"HostsFileEditor_EnableHostsFileEditor",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
||||
TraceLoggingBoolean(enabled, "Enabled"));
|
||||
}
|
||||
|
||||
// Log that the user tried to activate the editor
|
||||
void Trace::ActivateEditor() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
g_hProvider,
|
||||
"HostsFileEditor_Activate",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
}
|
||||
|
@ -5,4 +5,10 @@ class Trace
|
||||
public:
|
||||
static void RegisterProvider() noexcept;
|
||||
static void UnregisterProvider() noexcept;
|
||||
|
||||
// Log if the user has HostsFileEditor enabled or disabled
|
||||
static void EnableHostsFileEditor(const bool enabled) noexcept;
|
||||
|
||||
// Log that the user tried to activate the editor
|
||||
static void ActivateEditor() noexcept;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user