Merge pull request #1239 from Safelite/feature/jzimmerman/INSR-9794
INSR-9794: Added additional Bailout and Error logging information.
This commit is contained in:
commit
375f24b6f3
3 changed files with 35 additions and 18 deletions
|
|
@ -33,30 +33,41 @@ export class Logger {
|
||||||
|
|
||||||
formatLogEntry(message, details) {
|
formatLogEntry(message, details) {
|
||||||
let json = '';
|
let json = '';
|
||||||
if (details) {
|
const store = useMainStore();
|
||||||
if (details instanceof Error) {
|
const sessionKey = getSessionKeyValue();
|
||||||
json = JSON.stringify(details, Object.getOwnPropertyNames(details), 2);
|
|
||||||
} else {
|
try
|
||||||
json = JSON.stringify(details, undefined, 2)
|
{
|
||||||
|
if (details) {
|
||||||
|
if (details instanceof Error) {
|
||||||
|
json = JSON.stringify(details, Object.getOwnPropertyNames(details), 2);
|
||||||
|
} else {
|
||||||
|
json = JSON.stringify(details, undefined, 2)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
json = `Failed to serialize log details: ${error}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `Application: ${applicationConfig.APPLICATION_NAME} \n${message} \n${json}`;
|
return [
|
||||||
|
`Application: ${applicationConfig.APPLICATION_NAME}`,
|
||||||
|
`ClientTag: ${store.issConfig?.clientTag}`,
|
||||||
|
`ParentAccountNumber: ${store.issConfig?.parentAccountNumber}`,
|
||||||
|
`ClientName: ${store.issConfig?.clientName}`,
|
||||||
|
`LastPageVisited: ${store.applicationUser?.lastPageVisited}`,
|
||||||
|
`SessionLogSequenceNumber: ${sessionKey}`,
|
||||||
|
`ReferralSequenceNumber: ${store.order?.referralSequenceNumber}`,
|
||||||
|
`ReferralNumber: ${store.order?.referralNumber}`,
|
||||||
|
`EON: ${store.order?.eon}`,
|
||||||
|
`Message: ${message}`,
|
||||||
|
`JSON: ${json}`
|
||||||
|
].join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
writeLogEntry(endpoint, logEntry) {
|
writeLogEntry(endpoint, logEntry) {
|
||||||
const store = useMainStore();
|
const store = useMainStore();
|
||||||
const sessionKey = getSessionKeyValue();
|
const sessionKey = getSessionKeyValue();
|
||||||
|
|
||||||
// TODO: Work in progress.
|
|
||||||
/*
|
|
||||||
if ( store.applicationUser.logErrorCalls> 10 ) {
|
|
||||||
console.error("Exceeded maximum log error calls for this session. Further logging will be suppressed to prevent potential infinite loops.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
store.applicationUser.logErrorCalls += 1;
|
|
||||||
*/
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// If running locally or in the Dev environment show the log entries in the console.
|
// If running locally or in the Dev environment show the log entries in the console.
|
||||||
if (
|
if (
|
||||||
|
|
|
||||||
|
|
@ -116,11 +116,18 @@ export default {
|
||||||
mixins: [BaseFormMixin, analyticsMixIn],
|
mixins: [BaseFormMixin, analyticsMixIn],
|
||||||
async beforeRouteEnter(to, from, next) {
|
async beforeRouteEnter(to, from, next) {
|
||||||
const fromPage = from?.query?.issPage || 'external';
|
const fromPage = from?.query?.issPage || 'external';
|
||||||
|
|
||||||
// Only log bailout event if user is coming from a different page.
|
// Only log bailout event if user is coming from a different page.
|
||||||
// This ensures that we cannot get stuck in a loop, if the bailout-page ever bails out.
|
// This ensures that we cannot get stuck in a loop, if the bailout-page ever bails out.
|
||||||
if (fromPage !== issPageValues.BAILOUT_PAGE) {
|
if (fromPage !== issPageValues.BAILOUT_PAGE) {
|
||||||
const bailoutCode = useMainStore().pageData(issPageValues.BAILOUT_PAGE).bailoutCode;
|
const bailoutPageData = useMainStore().pageData(issPageValues.BAILOUT_PAGE);
|
||||||
|
const bailoutCode = bailoutPageData.bailoutCode;
|
||||||
const bailoutString = Object.keys(BailoutCode).find(key => BailoutCode[key] === bailoutCode);
|
const bailoutString = Object.keys(BailoutCode).find(key => BailoutCode[key] === bailoutCode);
|
||||||
|
|
||||||
|
// Log Bailout info to the error log for quick searching.
|
||||||
|
global.$logger.logError(`Bailout - Page: ${fromPage} - BailoutCode: ${bailoutCode} - BailoutString: ${bailoutString}`, bailoutPageData);
|
||||||
|
|
||||||
|
// Log a couple main bailout items to GA and session log events.
|
||||||
analyticsMixIn.methods.pushEventToGA(GaCategories.BAILOUT, bailoutString, fromPage, true, null, null);
|
analyticsMixIn.methods.pushEventToGA(GaCategories.BAILOUT, bailoutString, fromPage, true, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,6 @@ export const getDefaultState = () => ({
|
||||||
duplicateOrders: [],
|
duplicateOrders: [],
|
||||||
hasSentSaveQuoteEmail: null,
|
hasSentSaveQuoteEmail: null,
|
||||||
coverageLookupAttempts: 0,
|
coverageLookupAttempts: 0,
|
||||||
//logErrorCalls: 0,
|
|
||||||
firstHit: true
|
firstHit: true
|
||||||
},
|
},
|
||||||
issConfig: {
|
issConfig: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue