From a5bd2fcfaa7e966052536b1c93edda52995c61cc Mon Sep 17 00:00:00 2001 From: Sujatha Anishetty Date: Tue, 30 Jul 2024 14:22:36 -0400 Subject: [PATCH] exception logging to cloudwatch --- src/App.vue | 17 ++++ src/constants/application-config.js | 3 +- .../axios-response-interceptor-messages.js | 11 +++ src/constants/logging-endpoint-methods.js | 8 ++ src/global-methods.js | 67 ++++++++++++-- src/global-methods.spec.js | 7 ++ src/helpers/logger.js | 92 +++++++++++++++++++ src/main.js | 15 +++ 8 files changed, 213 insertions(+), 7 deletions(-) create mode 100644 src/constants/axios-response-interceptor-messages.js create mode 100644 src/constants/logging-endpoint-methods.js create mode 100644 src/helpers/logger.js diff --git a/src/App.vue b/src/App.vue index eccea8c4..3f54962a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -39,6 +39,23 @@ export default { } } }; +// Add a global Javascript exception handler for logging exceptions, this handler will log when there is an uncaught exception +window.onerror = (msg, url, line, col, error) => { + // Log the windows error + // Note that col & error are new to the HTML 5 spec and may not be + // supported in every browser. It worked for me in Chrome. + global.$logger.logError(msg, { + url: url, + line: line, + column: col ?? "", + error: error ?? "", + }); + + // If you return true, then error alerts (like in older versions of + // Internet Explorer) will be suppressed. + var suppressErrorAlert = true; + return suppressErrorAlert; +};