mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 17:56:44 +02:00
[General]Add an option for telemetry opt-in and visualization(#34078)
* Data diagnostics opt-in
* [c++] Drop DROP_PII flag
* Bump telemtry package to 2.0.2
* Drop DropPii from custom actions
* Cleanup
* Do not start manually C# EtwTrace. FZ engine exit event.
* ImageResizer, PowerRename, FileLocksmith prev handlers
* Revert C# handlers exe logging
* Revert "Revert C# handlers exe logging"
This reverts commit 4c75a3953b.
* Do not recreate EtwTrace
* consume package
* xaml formatting
* Fix deps.json audit
* Update telem package paths
* Address PR comments
* Fix AdvancedPaste close on PT close
* Override etl file name for explorer loaded dlls
Start/stop tracer when needed for explorer loaded dlls to prevent explorer overload
* Fix setting desc
* Fix missing events
* Add infobar to restart when enable data viewing
* Flush on timer every 30s
* [Settings] Update View Data diagnostic description text
[New+] Add tracer
* Show Restart info bar for both enable/disable data viewer
* Fix newplus
* Fix stuck on restart and terminate AdvPaste exe on destroy()
* [Installer] Add tracer
* Address PR comment
* Add missing tracers
* Exclude etw dir from BugReport
* Fix bad merge
* [Hosts] Proper exit on initial dialog
* [OOBE] Make Data diagnostic setting visible without scroll
* [OOBE] Add hiperlynk to open general settings
* Disable data view on disabling data diagnostics
* Don't disable View data button
* Fix disabling data viewing
* Add missing dot
* Revert formatting
This commit is contained in:
@@ -26,6 +26,8 @@ namespace Peek.UI
|
||||
{
|
||||
public static int PowerToysPID { get; set; }
|
||||
|
||||
public ETWTrace EtwTrace { get; private set; } = new ETWTrace();
|
||||
|
||||
public IHost Host
|
||||
{
|
||||
get;
|
||||
@@ -100,12 +102,18 @@ namespace Peek.UI
|
||||
{
|
||||
RunnerHelper.WaitForPowerToysRunner(powerToysRunnerPid, () =>
|
||||
{
|
||||
EtwTrace?.Dispose();
|
||||
Environment.Exit(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
NativeEventWaiter.WaitForEventLoop(Constants.ShowPeekEvent(), OnPeekHotkey);
|
||||
NativeEventWaiter.WaitForEventLoop(Constants.TerminatePeekEvent(), () =>
|
||||
{
|
||||
EtwTrace?.Dispose();
|
||||
Environment.Exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE /*hModule*/,
|
||||
DWORD ul_reason_for_call,
|
||||
BOOL APIENTRY DllMain(HMODULE /*hModule*/,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID /*lpReserved*/)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
@@ -65,6 +65,7 @@ private:
|
||||
DWORD m_processPid = 0;
|
||||
|
||||
HANDLE m_hInvokeEvent;
|
||||
HANDLE m_hTerminateEvent;
|
||||
|
||||
// Load the settings file.
|
||||
void init_settings()
|
||||
@@ -163,7 +164,7 @@ private:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (wcsncmp(className, L"Progman", MAX_PATH) !=0 && wcsncmp(className, L"WorkerW", MAX_PATH) != 0)
|
||||
if (wcsncmp(className, L"Progman", MAX_PATH) != 0 && wcsncmp(className, L"WorkerW", MAX_PATH) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -239,7 +240,7 @@ private:
|
||||
}
|
||||
|
||||
DWORD pid{};
|
||||
if (GetWindowThreadProcessId(foregroundWindowHandle, &pid)!=0)
|
||||
if (GetWindowThreadProcessId(foregroundWindowHandle, &pid) != 0)
|
||||
{
|
||||
// If the foreground window is the Peek window, send activation signal.
|
||||
if (m_processPid != 0 && pid == m_processPid)
|
||||
@@ -321,6 +322,7 @@ public:
|
||||
init_settings();
|
||||
|
||||
m_hInvokeEvent = CreateDefaultEvent(CommonSharedConstants::SHOW_PEEK_SHARED_EVENT);
|
||||
m_hTerminateEvent = CreateDefaultEvent(CommonSharedConstants::TERMINATE_PEEK_SHARED_EVENT);
|
||||
};
|
||||
|
||||
~Peek()
|
||||
@@ -402,6 +404,8 @@ public:
|
||||
if (m_enabled)
|
||||
{
|
||||
ResetEvent(m_hInvokeEvent);
|
||||
SetEvent(m_hTerminateEvent);
|
||||
WaitForSingleObject(m_hProcess, 1500);
|
||||
auto result = TerminateProcess(m_hProcess, 1);
|
||||
if (result == 0)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,5 @@
|
||||
#include <windows.h>
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#include <ProjectTelemetry.h>
|
||||
#include <shellapi.h>
|
||||
#include <Shlwapi.h>
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "pch.h"
|
||||
#include "trace.h"
|
||||
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER(
|
||||
g_hProvider,
|
||||
"Microsoft.PowerToys",
|
||||
@@ -8,20 +10,10 @@ TRACELOGGING_DEFINE_PROVIDER(
|
||||
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
|
||||
TraceLoggingOptionProjectTelemetry());
|
||||
|
||||
void Trace::RegisterProvider()
|
||||
{
|
||||
TraceLoggingRegister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::UnregisterProvider()
|
||||
{
|
||||
TraceLoggingUnregister(g_hProvider);
|
||||
}
|
||||
|
||||
// Log if the user has Peek enabled or disabled
|
||||
void Trace::EnablePeek(const bool enabled) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"Peek_EnablePeek",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@@ -32,7 +24,7 @@ void Trace::EnablePeek(const bool enabled) noexcept
|
||||
// Log if the user has invoked Peek
|
||||
void Trace::PeekInvoked() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"Peek_InvokePeek",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@@ -49,7 +41,7 @@ void Trace::SettingsTelemetry(PowertoyModuleIface::Hotkey& hotkey) noexcept
|
||||
std::wstring(hotkey.alt ? L"Alt + " : L"") +
|
||||
std::wstring(L"VK ") + std::to_wstring(hotkey.key);
|
||||
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"Peek_Settings",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#pragma once
|
||||
#include <interface/powertoy_module_interface.h>
|
||||
|
||||
class Trace
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
class Trace : public telemetry::TraceBase
|
||||
{
|
||||
public:
|
||||
static void RegisterProvider();
|
||||
static void UnregisterProvider();
|
||||
|
||||
// Log if the user has Peek enabled or disabled
|
||||
static void EnablePeek(const bool enabled) noexcept;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user