mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
Add telemetry event for FZ editor (#1294)
* trace zones settings changes
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "trace.h"
|
||||
#include "lib/ZoneSet.h"
|
||||
#include "lib/Settings.h"
|
||||
#include "lib/JsonHelpers.h"
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER(
|
||||
g_hProvider,
|
||||
@@ -64,6 +65,88 @@ void Trace::FancyZones::OnKeyDown(DWORD vkCode, bool win, bool control, bool inM
|
||||
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
|
||||
{
|
||||
const auto& editorHotkey = settings.editorHotkey;
|
||||
@@ -90,8 +173,7 @@ void Trace::SettingsChanged(const Settings& settings) noexcept
|
||||
TraceLoggingWideString(settings.zoneHightlightColor.c_str(), "ZoneHighlightColor"),
|
||||
TraceLoggingInt32(settings.zoneHighlightOpacity, "ZoneHighlightOpacity"),
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user