Add telemetry for memory item load

This commit is contained in:
Eric Wong (PAX) 2019-05-16 14:05:56 -07:00
commit e2f347d555
3 changed files with 19 additions and 0 deletions

View file

@ -78,6 +78,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_MEMORY_ITEM_LOAD = L"MemoryItemLoad";
constexpr auto EVENT_NAME_EXCEPTION = L"Exception";
@ -556,6 +557,21 @@ namespace CalculatorApp
LogLevel2Event(EVENT_NAME_HISTORY_ITEM_LOAD, fields);
}
void TraceLogger::LogMemoryItemLoad(ViewMode mode, int maxMemoryIndex, int loadedIndex) const
{
if (!GetTraceLoggingProviderEnabled())
{
return;
}
LoggingFields fields{};
// cast mode to an int for telemetry
fields.AddInt32(L"CalcMode", NavCategory::Serialize(mode));
fields.AddInt32(L"maxIndex", maxMemoryIndex);
fields.AddInt32(L"loadedIndex", loadedIndex);
LogLevel2Event(EVENT_NAME_MEMORY_ITEM_LOAD, fields);
}
void TraceLogger::LogHistoryItemLoadBegin() const
{
if (!GetTraceLoggingProviderEnabled())

View file

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

View file

@ -1101,6 +1101,8 @@ void StandardCalculatorViewModel::OnMemoryItemPressed(Object ^ memoryItemPositio
HideMemoryClicked();
int windowId = Utils::GetWindowId();
TraceLogger::GetInstance().LogMemoryUsed(windowId, boxedPosition->Value, IsStandard, IsScientific, IsProgrammer, MemorizedNumbers->Size);
auto mode = IsStandard ? ViewMode::Standard : IsScientific ? ViewMode::Scientific : ViewMode::Programmer;
TraceLogger::GetInstance().LogMemoryItemLoad(mode, MemorizedNumbers->Size - 1, boxedPosition->Value);
}
}