Skip to content

Commit

Permalink
Add version number to telemetry event
Browse files Browse the repository at this point in the history
use defines from version.h in .rc files and other places.
  • Loading branch information
enricogior committed Oct 14, 2019
1 parent eb1ef65 commit f9be71e
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma comment(lib, "dwmapi.lib")
#include <strsafe.h>
#include <sddl.h>
#include "version.h"

std::optional<RECT> get_button_pos(HWND hwnd) {
RECT button;
Expand Down Expand Up @@ -290,3 +291,10 @@ std::wstring get_process_path(HWND window) noexcept {
}
return name;
}

std::wstring get_product_version() {
static std::wstring version = std::to_wstring(VERSION_MAJOR) +
L"." + std::to_wstring(VERSION_MINOR) +
L"." + std::to_wstring(VERSION_REVISION);
return version;
}
2 changes: 2 additions & 0 deletions src/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ bool drop_elevated_privileges();
std::wstring get_process_path(DWORD pid) noexcept;
// Get the executable path or module name for modern apps
std::wstring get_process_path(HWND hwnd) noexcept;

std::wstring get_product_version();
1 change: 1 addition & 0 deletions src/common/common.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<ClInclude Include="Telemetry\ProjectTelemetry.h" />
<ClInclude Include="Telemetry\TraceLoggingDefines.h" />
<ClInclude Include="two_way_pipe_message_ipc.h" />
<ClInclude Include="version.h" />
<ClInclude Include="windows_colors.h" />
</ItemGroup>
<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/common/common.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
<ClInclude Include="dpi_aware.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="version.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="d2d_svg.cpp">
Expand Down
19 changes: 19 additions & 0 deletions src/common/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#define STRINGIZE2(s) #s
#define STRINGIZE(s) STRINGIZE2(s)

#define VERSION_MAJOR 0
#define VERSION_MINOR 11
#define VERSION_REVISION 0
#define VERSION_BUILD 0

#define FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD
#define FILE_VERSION_STRING STRINGIZE(VERSION_MAJOR) "." STRINGIZE(VERSION_MINOR) "." STRINGIZE(VERSION_REVISION) "." STRINGIZE(VERSION_BUILD)

#define PRODUCT_VERSION FILE_VERSION
#define PRODUCT_VERSION_STRING FILE_VERSION_STRING

#define COMPANY_NAME "Microsoft Corporation"
#define COPYRIGHT_NOTE "Copyright (C) 2019 Microsoft Corporation"

Binary file modified src/modules/example_powertoy/example_powertoy.rc
Binary file not shown.
Binary file modified src/modules/fancyzones/lib/fancyzones.rc
Binary file not shown.
Binary file modified src/modules/shortcut_guide/shortcut_guide.rc
Binary file not shown.
2 changes: 1 addition & 1 deletion src/runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
// Start initial powertoys
start_initial_powertoys();

Trace::EventLaunch();
Trace::EventLaunch(get_product_version());

result = run_message_loop();
} catch (std::runtime_error& err) {
Expand Down
Binary file modified src/runner/runner.rc
Binary file not shown.
3 changes: 2 additions & 1 deletion src/runner/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ void Trace::UnregisterProvider() {
TraceLoggingUnregister(g_hProvider);
}

void Trace::EventLaunch() {
void Trace::EventLaunch(const std::wstring& versionNumber) {
TraceLoggingWrite(
g_hProvider,
"Runner::Event::Launch",
TraceLoggingWideString(versionNumber.c_str(), "version"),
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
Expand Down
2 changes: 1 addition & 1 deletion src/runner/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ class Trace {
public:
static void RegisterProvider();
static void UnregisterProvider();
static void EventLaunch();
static void EventLaunch(const std::wstring& versionNumber);
};
3 changes: 2 additions & 1 deletion src/runner/tray_icon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ LRESULT __stdcall tray_icon_window_proc(HWND window, UINT message, WPARAM wparam
case ID_ABOUT_MENU_COMMAND:
if (!about_box_shown) {
about_box_shown = true;
MessageBox(nullptr, L"PowerToys\nVersion 0.11.0\n\xa9 2019 Microsoft Corporation", L"About PowerToys", MB_OK);
std::wstring about_msg = L"PowerToys\nVersion " + get_product_version() + L"\n\xa9 2019 Microsoft Corporation";

This comment has been minimized.

Copy link
@FrankJWong

FrankJWong Oct 22, 2019

Nit: Not related to the version changes, but do we want to localize these strings?

This comment has been minimized.

Copy link
@enricogior

enricogior Oct 22, 2019

Author Contributor

Yes, eventually we will.

MessageBox(nullptr, about_msg.c_str(), L"About PowerToys", MB_OK);
about_box_shown = false;
}
break;
Expand Down
Binary file modified src/settings/settings.rc
Binary file not shown.

0 comments on commit f9be71e

Please sign in to comment.