Updated Calculator diagnostic data collection per the specification (#572)
- Removed unneeded diagnostic events and code - Added and consolidated events into the events defined in the spec
This commit is contained in:
committed by
Matt Cooley
parent
2ff7bb4089
commit
a6384269bc
@@ -161,55 +161,14 @@ public
|
||||
BINPOS62 = (int)CM::Command::CommandBINPOS62,
|
||||
BINPOS63 = (int)CM::Command::CommandBINPOS63,
|
||||
BINEND = (int)CM::Command::CommandBINEDITEND,
|
||||
Hyp = (int)CM::Command::CommandHYP
|
||||
};
|
||||
Hyp = (int)CM::Command::CommandHYP,
|
||||
|
||||
// This contains list of functions whose usage we are tracelogging
|
||||
public
|
||||
enum class FunctionLogEnum
|
||||
{
|
||||
Invert = (int)CM::Command::CommandREC,
|
||||
Sqrt = (int)CM::Command::CommandSQRT,
|
||||
Percent = (int)CM::Command::CommandPERCENT,
|
||||
Negate = (int)CM::Command::CommandSIGN,
|
||||
Degrees = (int)CM::Command::CommandDegrees,
|
||||
Pi = (int)CM::Command::CommandPI,
|
||||
Sin = (int)CM::Command::CommandSIN,
|
||||
Cos = (int)CM::Command::CommandCOS,
|
||||
Tan = (int)CM::Command::CommandTAN,
|
||||
Factorial = (int)CM::Command::CommandFAC,
|
||||
XPower2 = (int)CM::Command::CommandSQR,
|
||||
Mod = (int)CM::Command::CommandMOD,
|
||||
FToE = (int)CM::Command::CommandFE,
|
||||
LogBaseE = (int)CM::Command::CommandLN,
|
||||
InvSin = (int)CM::Command::CommandASIN,
|
||||
InvCos = (int)CM::Command::CommandACOS,
|
||||
InvTan = (int)CM::Command::CommandATAN,
|
||||
LogBase10 = (int)CM::Command::CommandLOG,
|
||||
XPowerY = (int)CM::Command::CommandPWR,
|
||||
YRootX = (int)CM::Command::CommandROOT,
|
||||
TenPowerX = (int)CM::Command::CommandPOW10,
|
||||
EPowerX = (int)CM::Command::CommandPOWE,
|
||||
Exp = (int)CM::Command::CommandEXP,
|
||||
DecButton = (int)CM::Command::CommandDec,
|
||||
OctButton = (int)CM::Command::CommandOct,
|
||||
HexButton = (int)CM::Command::CommandHex,
|
||||
BinButton = (int)CM::Command::CommandBin,
|
||||
And = (int)CM::Command::CommandAnd,
|
||||
Ror = (int)CM::Command::CommandROR,
|
||||
Rol = (int)CM::Command::CommandROL,
|
||||
Or = (int)CM::Command::CommandOR,
|
||||
Lsh = (int)CM::Command::CommandLSHF,
|
||||
Rsh = (int)CM::Command::CommandRSHF,
|
||||
Xor = (int)CM::Command::CommandXor,
|
||||
Not = (int)CM::Command::CommandNot,
|
||||
Sinh = (int)CM::Command::CommandSINH,
|
||||
Cosh = (int)CM::Command::CommandCOSH,
|
||||
Tanh = (int)CM::Command::CommandTANH,
|
||||
InvSinh = (int)CM::Command::CommandASINH,
|
||||
InvCosh = (int)CM::Command::CommandACOSH,
|
||||
InvTanh = (int)CM::Command::CommandATANH,
|
||||
Cube = (int)CM::Command::CommandCUB,
|
||||
DMS = (int)CM::Command::CommandDMS,
|
||||
// Enum values below are used for Tracelogging and do not map to the Calculator engine
|
||||
MemoryAdd = (int)CM::Command::CommandMPLUS,
|
||||
MemorySubtract = (int)CM::Command::CommandMMINUS,
|
||||
MemoryRecall = (int)CM::Command::CommandRECALL,
|
||||
MemoryClear = (int)CM::Command::CommandMCLEAR,
|
||||
BitflipButton = 1000,
|
||||
FullKeypadButton = 1001
|
||||
};
|
||||
}
|
||||
|
@@ -109,7 +109,7 @@ String ^ CopyPasteManager::ValidatePasteExpression(String ^ pastedText, ViewMode
|
||||
if (pastedText->Length() > MaxPasteableLength)
|
||||
{
|
||||
// return NoOp to indicate don't paste anything.
|
||||
TraceLogger::GetInstance().LogInvalidPastedInputOccurred(L"PastedExpressionSizeGreaterThanMaxAllowed", mode, programmerNumberBase, bitLengthType);
|
||||
TraceLogger::GetInstance().LogError(mode, L"CopyPasteManager::ValidatePasteExpression", L"PastedExpressionSizeGreaterThanMaxAllowed");
|
||||
return StringReference(PasteErrorString);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ String ^ CopyPasteManager::ValidatePasteExpression(String ^ pastedText, ViewMode
|
||||
|
||||
// Extract operands from the expression to make regex comparison easy and quick. For whole expression it was taking too much of time.
|
||||
// Operands vector will have the list of operands in the pasteExpression
|
||||
vector<wstring> operands = ExtractOperands(pasteExpression, mode, programmerNumberBase, bitLengthType);
|
||||
vector<wstring> operands = ExtractOperands(pasteExpression, mode);
|
||||
if (operands.empty())
|
||||
{
|
||||
// return NoOp to indicate don't paste anything.
|
||||
@@ -144,14 +144,14 @@ String ^ CopyPasteManager::ValidatePasteExpression(String ^ pastedText, ViewMode
|
||||
// validate each operand with patterns for different modes
|
||||
if (!ExpressionRegExMatch(operands, mode, modeType, programmerNumberBase, bitLengthType))
|
||||
{
|
||||
TraceLogger::GetInstance().LogInvalidPastedInputOccurred(L"InvalidExpressionForPresentMode", mode, programmerNumberBase, bitLengthType);
|
||||
TraceLogger::GetInstance().LogError(mode, L"CopyPasteManager::ValidatePasteExpression", L"InvalidExpressionForPresentMode");
|
||||
return StringReference(PasteErrorString);
|
||||
}
|
||||
|
||||
return ref new String(pastedText->Data());
|
||||
}
|
||||
|
||||
vector<wstring> CopyPasteManager::ExtractOperands(const wstring& pasteExpression, ViewMode mode, int programmerNumberBase, int bitLengthType)
|
||||
vector<wstring> CopyPasteManager::ExtractOperands(const wstring& pasteExpression, ViewMode mode)
|
||||
{
|
||||
vector<wstring> operands{};
|
||||
size_t lastIndex = 0;
|
||||
@@ -173,7 +173,7 @@ vector<wstring> CopyPasteManager::ExtractOperands(const wstring& pasteExpression
|
||||
|
||||
if (operands.size() >= MaxOperandCount)
|
||||
{
|
||||
TraceLogger::GetInstance().LogInvalidPastedInputOccurred(L"OperandCountGreaterThanMaxCount", mode, programmerNumberBase, bitLengthType);
|
||||
TraceLogger::GetInstance().LogError(mode, L"CopyPasteManager::ExtractOperands", L"OperandCountGreaterThanMaxCount");
|
||||
operands.clear();
|
||||
return operands;
|
||||
}
|
||||
@@ -187,7 +187,7 @@ vector<wstring> CopyPasteManager::ExtractOperands(const wstring& pasteExpression
|
||||
// to disallow pasting of 1e+12345 as 1e+1234, max exponent that can be pasted is 9999.
|
||||
if (expLength > MaxExponentLength)
|
||||
{
|
||||
TraceLogger::GetInstance().LogInvalidPastedInputOccurred(L"ExponentLengthGreaterThanMaxLength", mode, programmerNumberBase, bitLengthType);
|
||||
TraceLogger::GetInstance().LogError(mode, L"CopyPasteManager::ExtractOperands", L"ExponentLengthGreaterThanMaxLength");
|
||||
operands.clear();
|
||||
return operands;
|
||||
}
|
||||
|
@@ -51,7 +51,7 @@ namespace CalculatorApp
|
||||
int bitLengthType);
|
||||
|
||||
static std::vector<std::wstring>
|
||||
ExtractOperands(const std::wstring& pasteExpression, CalculatorApp::Common::ViewMode mode, int programmerNumberBase = -1, int bitLengthType = -1);
|
||||
ExtractOperands(const std::wstring& pasteExpression, CalculatorApp::Common::ViewMode mode);
|
||||
static bool ExpressionRegExMatch(
|
||||
std::vector<std::wstring> operands,
|
||||
CalculatorApp::Common::ViewMode mode,
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@
|
||||
#include "CalcManager/Command.h"
|
||||
#include "TraceActivity.h"
|
||||
#include "NavCategory.h"
|
||||
#include "CalculatorButtonUser.h"
|
||||
|
||||
static const int maxFunctionSize = (int)CalculationManager::Command::CommandBINEDITEND;
|
||||
|
||||
@@ -13,19 +14,17 @@ static const int maxFunctionSize = (int)CalculationManager::Command::CommandBINE
|
||||
// This class implements a singleton model ensure that only one instance is created.
|
||||
namespace CalculatorApp
|
||||
{
|
||||
struct FuncLog
|
||||
struct ButtonLog
|
||||
{
|
||||
public:
|
||||
int count;
|
||||
std::wstring funcName;
|
||||
FuncLog()
|
||||
CalculatorApp::NumbersAndOperatorsEnum button;
|
||||
CalculatorApp::Common::ViewMode mode;
|
||||
ButtonLog(CalculatorApp::NumbersAndOperatorsEnum btn, CalculatorApp::Common::ViewMode vMode)
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
FuncLog(std::wstring fName)
|
||||
{
|
||||
funcName = fName;
|
||||
count = 0;
|
||||
button = btn;
|
||||
mode = vMode;
|
||||
count = 1;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -38,123 +37,45 @@ namespace CalculatorApp
|
||||
static TraceLogger& GetInstance();
|
||||
bool GetTraceLoggingProviderEnabled() const;
|
||||
|
||||
void LogAppLaunchStart();
|
||||
void LogAppLaunchComplete();
|
||||
void LogAppResumeComplete();
|
||||
void LogOnAppLaunch(std::wstring_view previousExecutionState) const;
|
||||
void LogMemoryClearAll(int);
|
||||
void LogBitFlipPaneClicked() const;
|
||||
void LogBitFlipUsed() const;
|
||||
void LogHistoryBodyOpened() const;
|
||||
void LogHistoryItemLoadBegin() const;
|
||||
void LogHistoryItemLoadEnd(unsigned int) const;
|
||||
void LogHistoryFlyoutOpenBegin(unsigned int) const;
|
||||
void LogHistoryFlyoutOpenEnd(int) const;
|
||||
void LogCalculatorModeViewed(CalculatorApp::Common::ViewMode, int);
|
||||
void LogDateCalculatorModeViewed(CalculatorApp::Common::ViewMode, int);
|
||||
void LogConverterModeViewed(CalculatorApp::Common::ViewMode, int);
|
||||
void LogModeChangeBegin(CalculatorApp::Common::ViewMode, CalculatorApp::Common::ViewMode, int);
|
||||
void LogModeChangeEnd(CalculatorApp::Common::ViewMode, int) const;
|
||||
void LogClearHistory() const;
|
||||
void InsertIntoMemoryMap(int, bool, bool, bool);
|
||||
void UpdateMemoryMap(int, int, bool, bool, bool);
|
||||
void DeleteFromMemoryMap(int, int);
|
||||
void LogMemoryUsed(int, unsigned int, bool, bool, bool, unsigned int) const;
|
||||
void LogMultipleMemoryUsed(unsigned int, unsigned int) const;
|
||||
void LogSingleMemoryUsed(unsigned int) const;
|
||||
void LogSharedMemoryUsed(std::wstring_view, std::wstring_view, unsigned int) const;
|
||||
void LogMemoryBodyOpened() const;
|
||||
void LogMemoryFlyoutOpenBegin(unsigned int) const;
|
||||
void LogDebug(std::wstring_view debugData);
|
||||
void LogMemoryFlyoutOpenEnd(unsigned int) const;
|
||||
void LogInvalidPastedInputOccurred(std::wstring_view reason, CalculatorApp::Common::ViewMode mode, int ProgrammerNumberBase, int bitLengthType);
|
||||
void LogValidInputPasted(CalculatorApp::Common::ViewMode mode) const;
|
||||
void UpdateFunctionUsage(int func);
|
||||
void LogFunctionUsage(int);
|
||||
void InitFunctionLogArray();
|
||||
void LogBitLengthButtonUsed(int windowId);
|
||||
void LogRadixButtonUsed(int windowId);
|
||||
void LogAngleButtonUsed(int windowId);
|
||||
void LogHypButtonUsed(int windowId);
|
||||
void LogNewWindowCreationBegin(int windowId);
|
||||
void LogNewWindowCreationEnd(int windowId);
|
||||
void LogError(std::wstring_view errorString);
|
||||
void LogPrelaunchedAppActivatedByUser();
|
||||
void LogAppPrelaunchedBySystem();
|
||||
void UpdateWindowCount(size_t windowCount);
|
||||
void LogModeChange(CalculatorApp::Common::ViewMode mode) const;
|
||||
void LogHistoryItemLoad(CalculatorApp::Common::ViewMode mode, int historyListSize, int loadedIndex) const;
|
||||
void LogMemoryItemLoad(CalculatorApp::Common::ViewMode mode, int memoryListSize, int loadedIndex) const;
|
||||
void UpdateButtonUsage(CalculatorApp::NumbersAndOperatorsEnum button, CalculatorApp::Common::ViewMode mode);
|
||||
void LogButtonUsage();
|
||||
void LogDateCalculationModeUsed(bool AddSubtractMode);
|
||||
void UpdateWindowCount(size_t windowCount = 0);
|
||||
bool UpdateWindowIdLog(int windowId);
|
||||
void LogMaxWindowCount();
|
||||
void LogWindowActivated() const;
|
||||
void LogWindowLaunched() const;
|
||||
void LogUserRequestedRefreshFailed() const;
|
||||
void LogConversionResult(std::wstring_view fromValue, std::wstring_view fromUnit, std::wstring_view toValue, std::wstring_view toUnit) const;
|
||||
void LogAboutFlyoutOpened() const;
|
||||
void LogVisualStateChanged(CalculatorApp::Common::ViewMode mode, std::wstring_view state) const;
|
||||
void LogWindowCreated(CalculatorApp::Common::ViewMode mode) const;
|
||||
void LogConverterInputReceived(CalculatorApp::Common::ViewMode mode) const;
|
||||
void LogNavBarOpened() const;
|
||||
void LogViewClosingTelemetry(int);
|
||||
void LogCoreWindowWasNull() const;
|
||||
|
||||
// Trace methods for Date Calculator usage
|
||||
void LogDateDifferenceModeUsed(int windowId);
|
||||
void LogDateAddSubtractModeUsed(int windowId, bool isAddMode);
|
||||
void
|
||||
LogDateClippedTimeDifferenceFound(winrt::Windows::Globalization::Calendar const& today, winrt::Windows::Foundation::DateTime const& clippedTime) const;
|
||||
|
||||
void LogStandardException(std::wstring_view functionName, _In_ const std::exception& e) const;
|
||||
void LogWinRTException(std::wstring_view functionName, _In_ winrt::hresult_error const& e) const;
|
||||
void LogPlatformException(std::wstring_view functionName, _In_ Platform::Exception ^ e) const;
|
||||
void LogError(CalculatorApp::Common::ViewMode mode, std::wstring_view functionName, std::wstring_view errorString);
|
||||
void LogStandardException(CalculatorApp::Common::ViewMode mode, std::wstring_view functionName, _In_ const std::exception& e) const;
|
||||
void LogWinRTException(CalculatorApp::Common::ViewMode mode, std::wstring_view functionName, _In_ winrt::hresult_error const& e) const;
|
||||
void LogPlatformException(CalculatorApp::Common::ViewMode mode, std::wstring_view functionName, _In_ Platform::Exception ^ e) const;
|
||||
|
||||
private:
|
||||
// Create an instance of TraceLogger
|
||||
TraceLogger();
|
||||
|
||||
// Any new Log method should
|
||||
// a) decide the level of logging. This will help us in limiting recording of events only up to a certain level. See this link for guidance
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa363742(v=vs.85).aspx We're using Verbose level for events that are called frequently and
|
||||
// needed only for debugging or capturing perf for specific scenarios b) should decide whether or not to log to telemetry and pass
|
||||
// TraceLoggingKeyword(MICROSOFT_KEYWORD_TELEMETRY) accordingly c) Should accept a variable number of additional data arguments if needed
|
||||
void LogTelemetryEvent(std::wstring_view eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields) const;
|
||||
void LogMeasureEvent(std::wstring_view eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields) const;
|
||||
void LogCriticalDataEvent(std::wstring_view eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields) const;
|
||||
void LogPerformanceEvent(std::wstring_view eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields) const;
|
||||
void LogInfoEvent(std::wstring_view eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields) const;
|
||||
// As mentioned in Microsoft's Privacy Statement(https://privacy.microsoft.com/en-US/privacystatement#maindiagnosticsmodule),
|
||||
// sampling is involved in Microsoft's diagnostic data collection process.
|
||||
// These keywords provide additional input into how frequently an event might be sampled.
|
||||
// The lower the level of the keyword, the higher the possibility that the corresponding event may be sampled.
|
||||
void LogLevel1Event(std::wstring_view eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields) const;
|
||||
void LogLevel2Event(std::wstring_view eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields) const;
|
||||
void LogLevel3Event(std::wstring_view eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields) const;
|
||||
|
||||
std::unique_ptr<TraceActivity> CreateTraceActivity(std::wstring_view activityName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields) const;
|
||||
|
||||
winrt::Windows::Foundation::Diagnostics::LoggingChannel g_calculatorProvider;
|
||||
|
||||
bool isSizeChangeLogged = false;
|
||||
bool isHideIfShownLogged = false;
|
||||
bool isSizeChangedFirstTime = true; // to track the first size changed event which is fired on the launch of app
|
||||
bool isAutoConversionBeginLoggedInSession = false;
|
||||
bool isAutoConversionEndLoggedInSession = false;
|
||||
bool angleButtonLoggedInSession = false;
|
||||
bool radixButtonLoggedInSession = false;
|
||||
bool bitLengthButtonLoggedInSession = false;
|
||||
GUID sessionGuid;
|
||||
CalculatorApp::Common::ViewMode currentMode = CalculatorApp::Common::ViewMode::None;
|
||||
std::vector<FuncLog> funcLog;
|
||||
int functionCount = 0;
|
||||
bool isHypButtonLogged = false;
|
||||
bool isAngleButtonInitialized = false;
|
||||
unsigned int findIndex[maxFunctionSize] = { 0 };
|
||||
bool GetIndex(int& index);
|
||||
std::wstring GetProgrammerType(int index);
|
||||
size_t maxWindowCount = 0;
|
||||
bool isAppLaunchBeginLogged = false;
|
||||
bool isAppLaunchEndLogged = false;
|
||||
std::map<int, int> bitLengthButtonUsage;
|
||||
std::map<int, int> angleButtonUsage;
|
||||
std::map<int, int> radixButtonUsage;
|
||||
std::vector<ButtonLog> buttonLog;
|
||||
std::map<int, bool> windowIdLog;
|
||||
|
||||
// Private variables for Date Calculator usage
|
||||
bool m_dateDiffUsageLoggedInSession = false;
|
||||
bool m_dateAddUsageLoggedInSession = false;
|
||||
bool m_dateSubtractUsageLoggedInSession = false;
|
||||
std::map<int, int> m_dateAddModeUsage;
|
||||
std::map<int, int> m_dateSubtractModeUsage;
|
||||
|
||||
size_t windowLaunchCount = 0;
|
||||
GUID sessionGuid;
|
||||
size_t currentWindowCount = 0;
|
||||
|
||||
winrt::Windows::Foundation::Diagnostics::LoggingActivity m_appLaunchActivity;
|
||||
};
|
||||
|
Reference in New Issue
Block a user