mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 12:46:47 +02:00
Add telemetry event for FZ editor (#1294)
* trace zones settings changes
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#include "JsonHelpers.h"
|
#include "JsonHelpers.h"
|
||||||
#include "RegistryHelpers.h"
|
#include "RegistryHelpers.h"
|
||||||
#include "ZoneSet.h"
|
#include "ZoneSet.h"
|
||||||
|
#include "trace.h"
|
||||||
|
|
||||||
#include <common/common.h>
|
#include <common/common.h>
|
||||||
|
|
||||||
@@ -498,6 +499,12 @@ namespace JSONHelpers
|
|||||||
root.SetNamedValue(L"devices", SerializeDeviceInfos());
|
root.SetNamedValue(L"devices", SerializeDeviceInfos());
|
||||||
root.SetNamedValue(L"custom-zone-sets", SerializeCustomZoneSets());
|
root.SetNamedValue(L"custom-zone-sets", SerializeCustomZoneSets());
|
||||||
|
|
||||||
|
auto before = json::from_file(jsonFilePath);
|
||||||
|
if (!before.has_value() || before.value().Stringify() != root.Stringify())
|
||||||
|
{
|
||||||
|
Trace::FancyZones::DataChanged();
|
||||||
|
}
|
||||||
|
|
||||||
json::to_file(jsonFilePath, root);
|
json::to_file(jsonFilePath, root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -181,22 +181,25 @@ namespace JSONHelpers
|
|||||||
return activeDeviceId;
|
return activeDeviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(UNIT_TESTS)
|
|
||||||
inline const std::unordered_map<std::wstring, DeviceInfoData>& GetDeviceInfoMap() const
|
inline const std::unordered_map<std::wstring, DeviceInfoData>& GetDeviceInfoMap() const
|
||||||
{
|
{
|
||||||
|
std::scoped_lock lock{ dataLock };
|
||||||
return deviceInfoMap;
|
return deviceInfoMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::unordered_map<std::wstring, CustomZoneSetData>& GetCustomZoneSetsMap() const
|
inline const std::unordered_map<std::wstring, CustomZoneSetData>& GetCustomZoneSetsMap() const
|
||||||
{
|
{
|
||||||
|
std::scoped_lock lock{ dataLock };
|
||||||
return customZoneSetsMap;
|
return customZoneSetsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::unordered_map<std::wstring, AppZoneHistoryData>& GetAppZoneHistoryMap() const
|
inline const std::unordered_map<std::wstring, AppZoneHistoryData>& GetAppZoneHistoryMap() const
|
||||||
{
|
{
|
||||||
|
std::scoped_lock lock{ dataLock };
|
||||||
return appZoneHistoryMap;
|
return appZoneHistoryMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(UNIT_TESTS)
|
||||||
inline void clear_data()
|
inline void clear_data()
|
||||||
{
|
{
|
||||||
appliedZoneSetsMap.clear();
|
appliedZoneSetsMap.clear();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "lib/ZoneSet.h"
|
#include "lib/ZoneSet.h"
|
||||||
#include "lib/Settings.h"
|
#include "lib/Settings.h"
|
||||||
|
#include "lib/JsonHelpers.h"
|
||||||
|
|
||||||
TRACELOGGING_DEFINE_PROVIDER(
|
TRACELOGGING_DEFINE_PROVIDER(
|
||||||
g_hProvider,
|
g_hProvider,
|
||||||
@@ -64,6 +65,88 @@ void Trace::FancyZones::OnKeyDown(DWORD vkCode, bool win, bool control, bool inM
|
|||||||
TraceLoggingBoolean(inMoveSize, "InMoveSize"));
|
TraceLoggingBoolean(inMoveSize, "InMoveSize"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Trace::FancyZones::DataChanged() noexcept
|
||||||
|
{
|
||||||
|
const JSONHelpers::FancyZonesData& data = JSONHelpers::FancyZonesDataInstance();
|
||||||
|
int appsHistorySize = static_cast<int>(data.GetAppZoneHistoryMap().size());
|
||||||
|
const auto& customZones = data.GetCustomZoneSetsMap();
|
||||||
|
const auto& devices = data.GetDeviceInfoMap();
|
||||||
|
|
||||||
|
std::unique_ptr<INT32[]> customZonesArray(new (std::nothrow) INT32[customZones.size()]);
|
||||||
|
if (!customZonesArray)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto getCustomZoneCount = [&data](const std::variant<JSONHelpers::CanvasLayoutInfo, JSONHelpers::GridLayoutInfo>& layoutInfo) -> int {
|
||||||
|
if (std::holds_alternative<JSONHelpers::GridLayoutInfo>(layoutInfo))
|
||||||
|
{
|
||||||
|
const auto& info = std::get<JSONHelpers::GridLayoutInfo>(layoutInfo);
|
||||||
|
return (info.rows() * info.columns());
|
||||||
|
}
|
||||||
|
else if (std::holds_alternative<JSONHelpers::CanvasLayoutInfo>(layoutInfo))
|
||||||
|
{
|
||||||
|
const auto& info = std::get<JSONHelpers::CanvasLayoutInfo>(layoutInfo);
|
||||||
|
return static_cast<int>(info.zones.size());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
//NumberOfZonesForEachCustomZoneSet
|
||||||
|
int i = 0;
|
||||||
|
for (const auto& [id, customZoneSetData] : customZones)
|
||||||
|
{
|
||||||
|
customZonesArray.get()[i] = getCustomZoneCount(customZoneSetData.info);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//ActiveZoneSetsList
|
||||||
|
std::wstring activeZoneSetInfo;
|
||||||
|
for (const auto& [id, device] : devices)
|
||||||
|
{
|
||||||
|
const JSONHelpers::ZoneSetLayoutType type = device.activeZoneSet.type;
|
||||||
|
if (!activeZoneSetInfo.empty())
|
||||||
|
{
|
||||||
|
activeZoneSetInfo += L"; ";
|
||||||
|
}
|
||||||
|
activeZoneSetInfo += L"type: " + JSONHelpers::TypeToString(type);
|
||||||
|
|
||||||
|
int zoneCount = -1;
|
||||||
|
if (type == JSONHelpers::ZoneSetLayoutType::Custom)
|
||||||
|
{
|
||||||
|
const auto& activeCustomZone = customZones.find(device.activeZoneSet.uuid);
|
||||||
|
if (activeCustomZone != customZones.end())
|
||||||
|
{
|
||||||
|
zoneCount = getCustomZoneCount(activeCustomZone->second.info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
zoneCount = device.zoneCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zoneCount != -1)
|
||||||
|
{
|
||||||
|
activeZoneSetInfo += L", zone count: " + std::to_wstring(zoneCount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
activeZoneSetInfo += L", custom zone data was deleted";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TraceLoggingWrite(
|
||||||
|
g_hProvider,
|
||||||
|
"FancyZones_ZoneSettingsChanged",
|
||||||
|
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||||
|
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
||||||
|
TraceLoggingInt32(appsHistorySize, "AppsInHistoryCount"),
|
||||||
|
TraceLoggingInt32(static_cast<int>(customZones.size()), "CustomZoneSetCount"),
|
||||||
|
TraceLoggingInt32Array(customZonesArray.get(), static_cast<int>(customZones.size()), "NumberOfZonesForEachCustomZoneSet"),
|
||||||
|
TraceLoggingInt32(static_cast<int>(devices.size()), "ActiveZoneSetsCount"),
|
||||||
|
TraceLoggingWideString(activeZoneSetInfo.c_str(), "ActiveZoneSetsList"));
|
||||||
|
}
|
||||||
|
|
||||||
void Trace::SettingsChanged(const Settings& settings) noexcept
|
void Trace::SettingsChanged(const Settings& settings) noexcept
|
||||||
{
|
{
|
||||||
const auto& editorHotkey = settings.editorHotkey;
|
const auto& editorHotkey = settings.editorHotkey;
|
||||||
@@ -90,8 +173,7 @@ void Trace::SettingsChanged(const Settings& settings) noexcept
|
|||||||
TraceLoggingWideString(settings.zoneHightlightColor.c_str(), "ZoneHighlightColor"),
|
TraceLoggingWideString(settings.zoneHightlightColor.c_str(), "ZoneHighlightColor"),
|
||||||
TraceLoggingInt32(settings.zoneHighlightOpacity, "ZoneHighlightOpacity"),
|
TraceLoggingInt32(settings.zoneHighlightOpacity, "ZoneHighlightOpacity"),
|
||||||
TraceLoggingWideString(hotkeyStr.c_str(), "Hotkey"),
|
TraceLoggingWideString(hotkeyStr.c_str(), "Hotkey"),
|
||||||
TraceLoggingInt32(static_cast<int>(settings.excludedAppsArray.size()), "ExcludedAppsCount")
|
TraceLoggingInt32(static_cast<int>(settings.excludedAppsArray.size()), "ExcludedAppsCount"));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trace::VirtualDesktopChanged() noexcept
|
void Trace::VirtualDesktopChanged() noexcept
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
static void EnableFancyZones(bool enabled) noexcept;
|
static void EnableFancyZones(bool enabled) noexcept;
|
||||||
static void OnKeyDown(DWORD vkCode, bool win, bool control, bool inMoveSize) noexcept;
|
static void OnKeyDown(DWORD vkCode, bool win, bool control, bool inMoveSize) noexcept;
|
||||||
|
static void DataChanged() noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void SettingsChanged(const Settings& settings) noexcept;
|
static void SettingsChanged(const Settings& settings) noexcept;
|
||||||
|
|||||||
Reference in New Issue
Block a user