Telemetry for visual state

This commit is contained in:
Eric Wong (PAX) 2019-05-16 18:07:57 -07:00
commit 9d8a87bc4a
13 changed files with 61 additions and 24 deletions

View file

@ -79,6 +79,7 @@ namespace CalculatorApp
constexpr auto EVENT_NAME_DATE_CALCULATION_MODE_USED = L"DateCalculationModeUsed";
constexpr auto EVENT_NAME_HISTORY_ITEM_LOAD = L"HistoryItemLoad";
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";
@ -109,7 +110,7 @@ namespace CalculatorApp
m_appLaunchActivity{ nullptr }
{
// initialize the function array
// InitFunctionLogArray();
// InitFunctionLogArray();
}
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
void TraceLogger::LogCalculatorModeViewed(ViewMode mode, int windowId)
{
@ -767,9 +781,8 @@ namespace CalculatorApp
{
// Writer lock for the static resources
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 {
return f.functionId == functionId && f.mode == mode;
});
vector<FuncLog>::iterator it =
std::find_if(funcLog.begin(), funcLog.end(), [functionId, mode](const FuncLog& f) -> bool { return f.functionId == functionId && f.mode == mode; });
if (it != funcLog.end())
{
it->count++;
@ -781,7 +794,7 @@ namespace CalculatorApp
}
}
//void TraceLogger::InitFunctionLogArray()
// void TraceLogger::InitFunctionLogArray()
//{
// int i = -1;
// for (int funcIndex = 0; funcIndex != maxFunctionSize; funcIndex++)

View file

@ -87,6 +87,7 @@ namespace CalculatorApp
void LogAppPrelaunchedBySystem();
void UpdateWindowCount(size_t windowCount);
bool UpdateWindowIdLog(int windowId);
void LogVisualStateChanged(CalculatorApp::Common::ViewMode mode, std::wstring_view state) const;
void LogMaxWindowCount();
void LogWindowActivated() const;
void LogWindowLaunched() const;

View file

@ -353,8 +353,7 @@
<Setter Property="ZoomMode" Value="Disabled"/>
</Style>
<Style x:Key="CalculationResultStyle"
TargetType="Controls:CalculationResult">
<Style x:Key="CalculationResultStyle" TargetType="Controls:CalculationResult">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{ThemeResource SystemControlPageTextBaseHighBrush}"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>

View file

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//

View file

@ -319,7 +319,7 @@
</VisualState>
</VisualStateGroup>
<!-- Layout specific -->
<VisualStateGroup>
<VisualStateGroup CurrentStateChanged="OnVisualStateChanged">
<VisualState x:Name="Portrait768x1366">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowHeight="1366" MinWindowWidth="768"/>

View file

@ -713,3 +713,10 @@ void CalculatorApp::Calculator::DockPivot_SelectionChanged(Platform::Object ^ se
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);
}

View file

@ -139,5 +139,6 @@ public
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 DockPivot_SelectionChanged(Platform::Object ^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e);
void OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e);
};
}

View file

@ -358,7 +358,7 @@
</Grid.RowDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualStateGroup CurrentStateChanged="OnVisualStateChanged">
<VisualState x:Name="LeftAlignedLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="480"/>

View file

@ -240,3 +240,9 @@ void DateCalculator::AddSubtractOption_Checked(_In_ Object ^ sender, _In_ Routed
{
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);
}

View file

@ -50,5 +50,6 @@ namespace CalculatorApp
void RaiseLiveRegionChangedAutomationEvent(_In_ bool isDateDiffMode);
Windows::Foundation::EventRegistrationToken m_dateCalcOptionChangedEventToken;
void OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e);
};
}

View file

@ -343,7 +343,7 @@
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="Sizing">
<VisualStateGroup x:Name="Sizing" CurrentStateChanged="OnVisualStateChanged">
<VisualState x:Name="Wide">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowHeight="768" MinWindowWidth="1280"/>

View file

@ -6,6 +6,7 @@
#include "pch.h"
#include "UnitConverter.xaml.h"
#include "CalcViewModel/Common/TraceLogger.h"
#include "CalcViewModel/UnitConverterViewModel.h"
#include "Controls/CalculationResult.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
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);
}

View file

@ -89,5 +89,6 @@ namespace CalculatorApp
bool m_isAnimationEnabled;
void SupplementaryResultsPanelInGrid_SizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
void OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e);
};
}