Add Telemetry for History Item

This commit is contained in:
Eric Wong (PAX) 2019-05-16 11:03:41 -07:00
commit 4790946061
3 changed files with 20 additions and 2 deletions

View file

@ -77,6 +77,7 @@ namespace CalculatorApp
constexpr auto EVENT_NAME_MODE_CHANGED = L"ModeChanged";
constexpr auto EVENT_NAME_DATE_CALCULATION_MODE_USED = L"DateCalculationModeUsed";
constexpr auto EVENT_NAME_HISTORY_ITEM_LOAD = L"HistoryItemLoad";
constexpr auto EVENT_NAME_EXCEPTION = L"Exception";
@ -541,6 +542,20 @@ namespace CalculatorApp
}
}
void TraceLogger::LogHistoryItemLoad(ViewMode mode, int historyListSize) const
{
if (!GetTraceLoggingProviderEnabled())
{
return;
}
LoggingFields fields{};
// cast mode to an int for telemetry
fields.AddInt32(L"CalcMode", NavCategory::Serialize(mode));
fields.AddInt32(L"HistoryListSize", historyListSize);
LogLevel2Event(EVENT_NAME_HISTORY_ITEM_LOAD, fields);
}
void TraceLogger::LogHistoryItemLoadBegin() const
{
if (!GetTraceLoggingProviderEnabled())

View file

@ -65,6 +65,7 @@ namespace CalculatorApp
void LogSharedMemoryUsed(std::wstring_view, std::wstring_view, unsigned int) const;
void LogMemoryBodyOpened() const;
void LogModeChange(CalculatorApp::Common::ViewMode mode) const;
void LogHistoryItemLoad(CalculatorApp::Common::ViewMode mode, int historyListSize) const;
void LogMemoryFlyoutOpenBegin(unsigned int) const;
void LogDebug(std::wstring_view debugData);
void LogMemoryFlyoutOpenEnd(unsigned int) const;

View file

@ -457,6 +457,8 @@ void Calculator::OnHistoryItemClicked(_In_ HistoryItemViewModel ^ e)
Model->IsFToEEnabled = false;
TraceLogger::GetInstance().LogHistoryItemLoadEnd(tokenSize);
auto mode = IsScientific ? ViewMode::Scientific : ViewMode::Standard;
TraceLogger::GetInstance().LogHistoryItemLoad(mode, tokenSize);
CloseHistoryFlyout();
this->Focus(::FocusState::Programmatic);
}