Add ModeChange Telemetry

This commit is contained in:
Eric Wong (PAX) 2019-05-15 14:44:28 -07:00
commit dc863785be
3 changed files with 26 additions and 2 deletions

View file

@ -155,13 +155,19 @@ void ApplicationViewModel::OnModeChanged()
auto resProvider = AppResourceProvider::GetInstance(); auto resProvider = AppResourceProvider::GetInstance();
CategoryName = resProvider.GetResourceString(NavCategory::GetNameResourceKey(m_mode)); CategoryName = resProvider.GetResourceString(NavCategory::GetNameResourceKey(m_mode));
// This is the only place where a ViewMode enum should be cast to an int. // Cast mode to an int in order to save it to app data.
//
// Save the changed mode, so that the new window launches in this mode. // Save the changed mode, so that the new window launches in this mode.
// Don't save until after we have adjusted to the new mode, so we don't save a mode that fails to load. // Don't save until after we have adjusted to the new mode, so we don't save a mode that fails to load.
ApplicationData::Current->LocalSettings->Values->Insert(ModePropertyName, NavCategory::Serialize(m_mode)); ApplicationData::Current->LocalSettings->Values->Insert(ModePropertyName, NavCategory::Serialize(m_mode));
TraceLogger::GetInstance().LogModeChangeEnd(m_mode, ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread())); TraceLogger::GetInstance().LogModeChangeEnd(m_mode, ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
// Do not log mode change on first launch
if (NavCategory::IsValidViewMode(m_PreviousMode))
{
TraceLogger::GetInstance().LogModeChange(m_mode);
}
RaisePropertyChanged(ClearMemoryVisibilityPropertyName); RaisePropertyChanged(ClearMemoryVisibilityPropertyName);
} }

View file

@ -75,6 +75,8 @@ namespace CalculatorApp
constexpr auto EVENT_NAME_NAV_BAR_OPENED = L"NavBarOpened"; constexpr auto EVENT_NAME_NAV_BAR_OPENED = L"NavBarOpened";
constexpr auto EVENT_NAME_CORE_WINDOW_WAS_NULL = L"CoreWindowWasNull"; constexpr auto EVENT_NAME_CORE_WINDOW_WAS_NULL = L"CoreWindowWasNull";
constexpr auto EVENT_NAME_MODE_CHANGED = L"ModeChanged";
constexpr auto EVENT_NAME_EXCEPTION = L"Exception"; constexpr auto EVENT_NAME_EXCEPTION = L"Exception";
constexpr auto PDT_PRIVACY_DATA_TAG = L"PartA_PrivTags"; constexpr auto PDT_PRIVACY_DATA_TAG = L"PartA_PrivTags";
@ -254,6 +256,7 @@ namespace CalculatorApp
fields.AddString(L"CalculatorMode", NavCategory::GetFriendlyName(mode)->Data()); fields.AddString(L"CalculatorMode", NavCategory::GetFriendlyName(mode)->Data());
fields.AddUInt32(L"WindowId", windowId); fields.AddUInt32(L"WindowId", windowId);
LogLevel3Event(EVENT_NAME_CALCULATOR_VIEWED_IN_SESSION, fields); LogLevel3Event(EVENT_NAME_CALCULATOR_VIEWED_IN_SESSION, fields);
LogLevel2Event(EVENT_NAME_MODE_CHANGED, fields);
} }
} }
@ -523,6 +526,20 @@ namespace CalculatorApp
} }
} }
void TraceLogger::LogModeChange(ViewMode mode) const
{
if (!GetTraceLoggingProviderEnabled())
return;
if (NavCategory::IsValidViewMode(mode))
{
LoggingFields fields{};
// cast mode to an int for telemetry
fields.AddInt32(L"CalcMode", NavCategory::Serialize(mode));
LogLevel2Event(EVENT_NAME_MODE_CHANGE_BEGIN, fields);
}
}
void TraceLogger::LogHistoryItemLoadBegin() const void TraceLogger::LogHistoryItemLoadBegin() const
{ {
if (!GetTraceLoggingProviderEnabled()) if (!GetTraceLoggingProviderEnabled())

View file

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