mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
Telemetry for visual state
This commit is contained in:
parent
94af6fc0dc
commit
9d8a87bc4a
13 changed files with 61 additions and 24 deletions
|
@ -79,6 +79,7 @@ namespace CalculatorApp
|
||||||
constexpr auto EVENT_NAME_DATE_CALCULATION_MODE_USED = L"DateCalculationModeUsed";
|
constexpr auto EVENT_NAME_DATE_CALCULATION_MODE_USED = L"DateCalculationModeUsed";
|
||||||
constexpr auto EVENT_NAME_HISTORY_ITEM_LOAD = L"HistoryItemLoad";
|
constexpr auto EVENT_NAME_HISTORY_ITEM_LOAD = L"HistoryItemLoad";
|
||||||
constexpr auto EVENT_NAME_MEMORY_ITEM_LOAD = L"MemoryItemLoad";
|
constexpr auto EVENT_NAME_MEMORY_ITEM_LOAD = L"MemoryItemLoad";
|
||||||
|
constexpr auto EVENT_NAME_VISUAL_STATE_CHANGED = L"VisualStateChanged";
|
||||||
|
|
||||||
constexpr auto EVENT_NAME_EXCEPTION = L"Exception";
|
constexpr auto EVENT_NAME_EXCEPTION = L"Exception";
|
||||||
|
|
||||||
|
@ -102,14 +103,14 @@ namespace CalculatorApp
|
||||||
|
|
||||||
TraceLogger::TraceLogger()
|
TraceLogger::TraceLogger()
|
||||||
: g_calculatorProvider(
|
: g_calculatorProvider(
|
||||||
L"MicrosoftCalculator",
|
L"MicrosoftCalculator",
|
||||||
LoggingChannelOptions(GUID{ 0x4f50731a, 0x89cf, 0x4782, 0xb3, 0xe0, 0xdc, 0xe8, 0xc9, 0x4, 0x76, 0xba }), // Microsoft Telemetry group
|
LoggingChannelOptions(GUID{ 0x4f50731a, 0x89cf, 0x4782, 0xb3, 0xe0, 0xdc, 0xe8, 0xc9, 0x4, 0x76, 0xba }), // Microsoft Telemetry group
|
||||||
GUID{ 0x905ca09, 0x610e, 0x401e, 0xb6, 0x50, 0x2f, 0x21, 0x29, 0x80, 0xb9, 0xe0 })
|
GUID{ 0x905ca09, 0x610e, 0x401e, 0xb6, 0x50, 0x2f, 0x21, 0x29, 0x80, 0xb9, 0xe0 })
|
||||||
, // Unique providerID {0905CA09-610E-401E-B650-2F212980B9E0}
|
, // Unique providerID {0905CA09-610E-401E-B650-2F212980B9E0}
|
||||||
m_appLaunchActivity{ nullptr }
|
m_appLaunchActivity{ nullptr }
|
||||||
{
|
{
|
||||||
// initialize the function array
|
// initialize the function array
|
||||||
// InitFunctionLogArray();
|
// InitFunctionLogArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
TraceLogger::~TraceLogger()
|
TraceLogger::~TraceLogger()
|
||||||
|
@ -229,6 +230,19 @@ namespace CalculatorApp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TraceLogger::LogVisualStateChanged(ViewMode mode, wstring_view state) const
|
||||||
|
{
|
||||||
|
if (!GetTraceLoggingProviderEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LoggingFields fields{};
|
||||||
|
fields.AddString(L"CalculatorMode", NavCategory::GetFriendlyName(mode)->Data());
|
||||||
|
fields.AddString(L"VisualState", state);
|
||||||
|
LogLevel2Event(EVENT_NAME_VISUAL_STATE_CHANGED, fields);
|
||||||
|
}
|
||||||
|
|
||||||
// call comes here at the time of ApplicationViewModel initialisation
|
// call comes here at the time of ApplicationViewModel initialisation
|
||||||
void TraceLogger::LogCalculatorModeViewed(ViewMode mode, int windowId)
|
void TraceLogger::LogCalculatorModeViewed(ViewMode mode, int windowId)
|
||||||
{
|
{
|
||||||
|
@ -767,9 +781,8 @@ namespace CalculatorApp
|
||||||
{
|
{
|
||||||
// Writer lock for the static resources
|
// Writer lock for the static resources
|
||||||
reader_writer_lock::scoped_lock lock(s_traceLoggerLock);
|
reader_writer_lock::scoped_lock lock(s_traceLoggerLock);
|
||||||
vector<FuncLog>::iterator it = std::find_if(funcLog.begin(), funcLog.end(), [functionId, mode](const FuncLog& f) -> bool {
|
vector<FuncLog>::iterator it =
|
||||||
return f.functionId == functionId && f.mode == mode;
|
std::find_if(funcLog.begin(), funcLog.end(), [functionId, mode](const FuncLog& f) -> bool { return f.functionId == functionId && f.mode == mode; });
|
||||||
});
|
|
||||||
if (it != funcLog.end())
|
if (it != funcLog.end())
|
||||||
{
|
{
|
||||||
it->count++;
|
it->count++;
|
||||||
|
@ -781,7 +794,7 @@ namespace CalculatorApp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//void TraceLogger::InitFunctionLogArray()
|
// void TraceLogger::InitFunctionLogArray()
|
||||||
//{
|
//{
|
||||||
// int i = -1;
|
// int i = -1;
|
||||||
// for (int funcIndex = 0; funcIndex != maxFunctionSize; funcIndex++)
|
// for (int funcIndex = 0; funcIndex != maxFunctionSize; funcIndex++)
|
||||||
|
@ -808,15 +821,15 @@ namespace CalculatorApp
|
||||||
return s_programmerType[0];
|
return s_programmerType[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bool TraceLogger::GetIndex(int& index)
|
/* bool TraceLogger::GetIndex(int& index)
|
||||||
{
|
{
|
||||||
if (findIndex[index] > 0)
|
if (findIndex[index] > 0)
|
||||||
{
|
{
|
||||||
index = findIndex[index];
|
index = findIndex[index];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
void TraceLogger::UpdateWindowCount(size_t windowCount)
|
void TraceLogger::UpdateWindowCount(size_t windowCount)
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,6 +87,7 @@ namespace CalculatorApp
|
||||||
void LogAppPrelaunchedBySystem();
|
void LogAppPrelaunchedBySystem();
|
||||||
void UpdateWindowCount(size_t windowCount);
|
void UpdateWindowCount(size_t windowCount);
|
||||||
bool UpdateWindowIdLog(int windowId);
|
bool UpdateWindowIdLog(int windowId);
|
||||||
|
void LogVisualStateChanged(CalculatorApp::Common::ViewMode mode, std::wstring_view state) const;
|
||||||
void LogMaxWindowCount();
|
void LogMaxWindowCount();
|
||||||
void LogWindowActivated() const;
|
void LogWindowActivated() const;
|
||||||
void LogWindowLaunched() const;
|
void LogWindowLaunched() const;
|
||||||
|
|
|
@ -353,8 +353,7 @@
|
||||||
<Setter Property="ZoomMode" Value="Disabled"/>
|
<Setter Property="ZoomMode" Value="Disabled"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style x:Key="CalculationResultStyle"
|
<Style x:Key="CalculationResultStyle" TargetType="Controls:CalculationResult">
|
||||||
TargetType="Controls:CalculationResult">
|
|
||||||
<Setter Property="Background" Value="Transparent"/>
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
<Setter Property="Foreground" Value="{ThemeResource SystemControlPageTextBaseHighBrush}"/>
|
<Setter Property="Foreground" Value="{ThemeResource SystemControlPageTextBaseHighBrush}"/>
|
||||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -319,7 +319,7 @@
|
||||||
</VisualState>
|
</VisualState>
|
||||||
</VisualStateGroup>
|
</VisualStateGroup>
|
||||||
<!-- Layout specific -->
|
<!-- Layout specific -->
|
||||||
<VisualStateGroup>
|
<VisualStateGroup CurrentStateChanged="OnVisualStateChanged">
|
||||||
<VisualState x:Name="Portrait768x1366">
|
<VisualState x:Name="Portrait768x1366">
|
||||||
<VisualState.StateTriggers>
|
<VisualState.StateTriggers>
|
||||||
<AdaptiveTrigger MinWindowHeight="1366" MinWindowWidth="768"/>
|
<AdaptiveTrigger MinWindowHeight="1366" MinWindowWidth="768"/>
|
||||||
|
|
|
@ -713,3 +713,10 @@ void CalculatorApp::Calculator::DockPivot_SelectionChanged(Platform::Object ^ se
|
||||||
TraceLogger::GetInstance().LogMemoryBodyOpened();
|
TraceLogger::GetInstance().LogMemoryBodyOpened();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CalculatorApp::Calculator::OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e)
|
||||||
|
{
|
||||||
|
auto mode = IsStandard ? ViewMode::Standard : IsScientific ? ViewMode::Scientific : ViewMode::Programmer;
|
||||||
|
auto state = std::wstring(e->NewState->Name->Begin());
|
||||||
|
TraceLogger::GetInstance().LogVisualStateChanged(mode, state);
|
||||||
|
}
|
||||||
|
|
|
@ -139,5 +139,6 @@ public
|
||||||
void OnHistoryAccessKeyInvoked(_In_ Windows::UI::Xaml::UIElement ^ sender, _In_ Windows::UI::Xaml::Input::AccessKeyInvokedEventArgs ^ args);
|
void OnHistoryAccessKeyInvoked(_In_ Windows::UI::Xaml::UIElement ^ sender, _In_ Windows::UI::Xaml::Input::AccessKeyInvokedEventArgs ^ args);
|
||||||
void OnMemoryAccessKeyInvoked(_In_ Windows::UI::Xaml::UIElement ^ sender, _In_ Windows::UI::Xaml::Input::AccessKeyInvokedEventArgs ^ args);
|
void OnMemoryAccessKeyInvoked(_In_ Windows::UI::Xaml::UIElement ^ sender, _In_ Windows::UI::Xaml::Input::AccessKeyInvokedEventArgs ^ args);
|
||||||
void DockPivot_SelectionChanged(Platform::Object ^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e);
|
void DockPivot_SelectionChanged(Platform::Object ^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e);
|
||||||
|
void OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -358,7 +358,7 @@
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<VisualStateManager.VisualStateGroups>
|
<VisualStateManager.VisualStateGroups>
|
||||||
<VisualStateGroup>
|
<VisualStateGroup CurrentStateChanged="OnVisualStateChanged">
|
||||||
<VisualState x:Name="LeftAlignedLayout">
|
<VisualState x:Name="LeftAlignedLayout">
|
||||||
<VisualState.StateTriggers>
|
<VisualState.StateTriggers>
|
||||||
<AdaptiveTrigger MinWindowWidth="480"/>
|
<AdaptiveTrigger MinWindowWidth="480"/>
|
||||||
|
|
|
@ -240,3 +240,9 @@ void DateCalculator::AddSubtractOption_Checked(_In_ Object ^ sender, _In_ Routed
|
||||||
{
|
{
|
||||||
RaiseLiveRegionChangedAutomationEvent(/* DateDiff mode */ false);
|
RaiseLiveRegionChangedAutomationEvent(/* DateDiff mode */ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CalculatorApp::DateCalculator::OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e)
|
||||||
|
{
|
||||||
|
auto state = std::wstring(e->NewState->Name->Begin());
|
||||||
|
TraceLogger::GetInstance().LogVisualStateChanged(ViewMode::Date, state);
|
||||||
|
}
|
||||||
|
|
|
@ -50,5 +50,6 @@ namespace CalculatorApp
|
||||||
void RaiseLiveRegionChangedAutomationEvent(_In_ bool isDateDiffMode);
|
void RaiseLiveRegionChangedAutomationEvent(_In_ bool isDateDiffMode);
|
||||||
|
|
||||||
Windows::Foundation::EventRegistrationToken m_dateCalcOptionChangedEventToken;
|
Windows::Foundation::EventRegistrationToken m_dateCalcOptionChangedEventToken;
|
||||||
|
void OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,7 +343,7 @@
|
||||||
</VisualState.Setters>
|
</VisualState.Setters>
|
||||||
</VisualState>
|
</VisualState>
|
||||||
</VisualStateGroup>
|
</VisualStateGroup>
|
||||||
<VisualStateGroup x:Name="Sizing">
|
<VisualStateGroup x:Name="Sizing" CurrentStateChanged="OnVisualStateChanged">
|
||||||
<VisualState x:Name="Wide">
|
<VisualState x:Name="Wide">
|
||||||
<VisualState.StateTriggers>
|
<VisualState.StateTriggers>
|
||||||
<AdaptiveTrigger MinWindowHeight="768" MinWindowWidth="1280"/>
|
<AdaptiveTrigger MinWindowHeight="768" MinWindowWidth="1280"/>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "UnitConverter.xaml.h"
|
#include "UnitConverter.xaml.h"
|
||||||
|
#include "CalcViewModel/Common/TraceLogger.h"
|
||||||
#include "CalcViewModel/UnitConverterViewModel.h"
|
#include "CalcViewModel/UnitConverterViewModel.h"
|
||||||
#include "Controls/CalculationResult.h"
|
#include "Controls/CalculationResult.h"
|
||||||
#include "Controls/CalculatorButton.h"
|
#include "Controls/CalculatorButton.h"
|
||||||
|
@ -368,3 +369,10 @@ void CalculatorApp::UnitConverter::SupplementaryResultsPanelInGrid_SizeChanged(P
|
||||||
// We add 0.01 to be sure to not create an infinite loop with SizeChanged events cascading due to float approximation
|
// We add 0.01 to be sure to not create an infinite loop with SizeChanged events cascading due to float approximation
|
||||||
RowDltrUnits->MinHeight = max(48.0, e->NewSize.Height + 0.01);
|
RowDltrUnits->MinHeight = max(48.0, e->NewSize.Height + 0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CalculatorApp::UnitConverter::OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e)
|
||||||
|
{
|
||||||
|
auto mode = NavCategory::Deserialize(Model->CurrentCategory->GetModelCategory().id);
|
||||||
|
auto state = std::wstring(e->NewState->Name->Begin());
|
||||||
|
TraceLogger::GetInstance().LogVisualStateChanged(mode, state);
|
||||||
|
}
|
||||||
|
|
|
@ -89,5 +89,6 @@ namespace CalculatorApp
|
||||||
|
|
||||||
bool m_isAnimationEnabled;
|
bool m_isAnimationEnabled;
|
||||||
void SupplementaryResultsPanelInGrid_SizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
|
void SupplementaryResultsPanelInGrid_SizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
|
||||||
|
void OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue