Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add telemetry event for PowerRename settings #1279

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/modules/powerrename/dll/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ class PowerRenameModule : public PowertoyModuleIface
CSettings::SetMaxMRUSize(values.get_int_value(L"int_max_mru_size").value());
CSettings::SetShowIconOnMenu(values.get_bool_value(L"bool_show_icon_on_menu").value());
CSettings::SetExtendedContextMenuOnly(values.get_bool_value(L"bool_show_extended_menu").value());

Trace::SettingsChanged();
}
catch (std::exception)
{
Expand Down
2 changes: 2 additions & 0 deletions src/modules/powerrename/lib/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class CSettings
{
public:
static const int MAX_INPUT_STRING_LEN = 1024;

static bool GetEnabled();
static bool SetEnabled(_In_ bool enabled);

Expand Down
16 changes: 16 additions & 0 deletions src/modules/powerrename/lib/trace.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "stdafx.h"
#include "trace.h"
#include "Settings.h"

TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
Expand Down Expand Up @@ -71,3 +72,18 @@ void Trace::RenameOperation(_In_ UINT totalItemCount, _In_ UINT selectedItemCoun
TraceLoggingWideString(extensionList, "ExtensionList"));
}

void Trace::SettingsChanged() noexcept
{
TraceLoggingWrite(
g_hProvider,
"PowerRename_SettingsChanged",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
TraceLoggingBoolean(CSettings::GetEnabled(), "IsEnabled"),
TraceLoggingBoolean(CSettings::GetShowIconOnMenu(), "ShowIconOnMenu"),
TraceLoggingBoolean(CSettings::GetExtendedContextMenuOnly(), "ExtendedContextMenuOnly"),
TraceLoggingBoolean(CSettings::GetPersistState(), "PersistState"),
TraceLoggingBoolean(CSettings::GetMRUEnabled(), "IsMRUEnabled"),
TraceLoggingUInt64(CSettings::GetMaxMRUSize(), "MaxMRUSize"),
TraceLoggingUInt64(CSettings::GetFlags(), "Flags"));
}
1 change: 1 addition & 0 deletions src/modules/powerrename/lib/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ class Trace {
_In_ UINT renameItemCount,
_In_ DWORD flags,
_In_ PCWSTR extensionList) noexcept;
static void SettingsChanged() noexcept;
};
11 changes: 6 additions & 5 deletions src/modules/powerrename/ui/PowerRenameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <helpers.h>
#include <settings.h>
#include <windowsx.h>
#include <trace.h>

extern HINSTANCE g_hInst;

Expand Down Expand Up @@ -77,8 +78,6 @@ inline int RECT_HEIGHT(RECT& r)
return r.bottom - r.top;
}

#define MAX_INPUT_STRING_LEN 1024

// IUnknown
IFACEMETHODIMP CPowerRenameUI::QueryInterface(__in REFIID riid, __deref_out void** ppv)
{
Expand Down Expand Up @@ -391,7 +390,7 @@ HRESULT CPowerRenameUI::_ReadSettings()
flags = CSettings::GetFlags();
m_spsrm->put_flags(flags);

wchar_t buffer[MAX_INPUT_STRING_LEN];
wchar_t buffer[CSettings::MAX_INPUT_STRING_LEN];
buffer[0] = L'\0';
CSettings::GetSearchText(buffer, ARRAYSIZE(buffer));
SetDlgItemText(m_hwnd, IDC_EDIT_SEARCHFOR, buffer);
Expand Down Expand Up @@ -419,7 +418,7 @@ HRESULT CPowerRenameUI::_WriteSettings()
m_spsrm->get_flags(&flags);
CSettings::SetFlags(flags);

wchar_t buffer[MAX_INPUT_STRING_LEN];
wchar_t buffer[CSettings::MAX_INPUT_STRING_LEN];
buffer[0] = L'\0';
GetDlgItemText(m_hwnd, IDC_EDIT_SEARCHFOR, buffer, ARRAYSIZE(buffer));
CSettings::SetSearchText(buffer);
Expand All @@ -445,6 +444,8 @@ HRESULT CPowerRenameUI::_WriteSettings()
spReplaceMRU->AddMRUString(buffer);
}
}

Trace::SettingsChanged();
}

return S_OK;
Expand Down Expand Up @@ -825,7 +826,7 @@ void CPowerRenameUI::_OnSearchReplaceChanged()
CComPtr<IPowerRenameRegEx> spRegEx;
if (m_spsrm && SUCCEEDED(m_spsrm->get_renameRegEx(&spRegEx)))
{
wchar_t buffer[MAX_INPUT_STRING_LEN];
wchar_t buffer[CSettings::MAX_INPUT_STRING_LEN];
buffer[0] = L'\0';
GetDlgItemText(m_hwnd, IDC_EDIT_SEARCHFOR, buffer, ARRAYSIZE(buffer));
spRegEx->put_searchTerm(buffer);
Expand Down