From bc0b2f6c6cfa968ad86b2ca7073c4d86640f686b Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Wed, 15 Oct 2025 14:10:29 -0400 Subject: [PATCH] Retain diagnostic info across refresh --- public/static/error/index.html | 133 +++++++++++++++++++-------------- 1 file changed, 75 insertions(+), 58 deletions(-) diff --git a/public/static/error/index.html b/public/static/error/index.html index 057d33f1e..8ea99c6ed 100644 --- a/public/static/error/index.html +++ b/public/static/error/index.html @@ -103,68 +103,87 @@ body { // =============== Check for session info: const existingVuexDataJSON = window.localStorage.getItem('vuex'); const existingVuexData = existingVuexDataJSON ? JSON.parse(existingVuexDataJSON) : null; + const existingBailoutInfoJSON = window.sessionStorage.getItem('bailoutInfo'); + const existingBailoutInfo = existingBailoutInfoJSON ? JSON.parse(existingBailoutInfoJSON) : null; console.log(`================ VUEX DATA`); console.log(existingVuexData); + console.log(`================ PRIOR BAILOUT DATA`); + console.log(existingBailoutInfo); - // If no info exists, exit. - if(!existingVuexData) { + let bailoutInfo = null; + + if(existingVuexData) { + try { + // =============== Collect diagnostic data: + bailoutInfo = []; + + // App & Site Name + bailoutInfo.push({ name: 'App Name', value: 'FixMyGlass' }); + bailoutInfo.push({ name: 'Site Name', value: 'SafeliteDotcom' }); + + // Not included (yet) from heritage: + // - Site ID + // - Code + // - Module + // - Page + + bailoutInfo.push({ name: 'Timestamp', value: `${new Date()}` }); + + // - URL + // - Server + + const sessionId = getCookieValueByName('sid'); + bailoutInfo.push({ name: 'Session Id', value: sessionId }); + + const userAgent = window.navigator.userAgent; + bailoutInfo.push({ name: 'User Agent', value: userAgent }); + + // - IP + // - Session Log Sequence Number + + bailoutInfo.push({ name: 'Referral Seq Number', value: existingVuexData.order?.referralSequenceNumber }); + bailoutInfo.push({ name: 'Referral Number', value: existingVuexData.order?.referralNumber }); + bailoutInfo.push({ name: 'Referral Date', value: existingVuexData.order?.referralDate }); + bailoutInfo.push({ name: 'Referral Provider Number', value: existingVuexData.order?.serviceLocation?.provider?.providerNumber }); + bailoutInfo.push({ name: 'Referral CTU', value: existingVuexData.order?.serviceLocation?.provider?.address?.zipCodeCtu }); + + // - Referral Insured Zip + // - Referral Insured Service Zip + + bailoutInfo.push({ name: 'Referral CarID', value: existingVuexData.order?.vehicle?.carId }); + + const vehicle = existingVuexData.order?.vehicle; + const vehicleString = vehicle?.year + ? `${vehicle.year} ${vehicle.make} ${vehicle.model} - ${vehicle.style}` + : null; + bailoutInfo.push({ name: 'Referral Vehicle', value: vehicleString }); + bailoutInfo.push({ name: 'Work Order Number', value: existingVuexData.order?.workOrderNumber }); + bailoutInfo.push({ name: 'Work Order ID', value: existingVuexData.order?.workOrderId }); + bailoutInfo.push({ name: 'Parent Account Number', value: existingVuexData.order?.payment?.parentAccountNumber }); + + // - Parent Account Name + // - Client GUID + } finally { + // If any information gathered, write to session storage. + if(bailoutInfo) { + window.sessionStorage.setItem('bailoutInfo', JSON.stringify(bailoutInfo)); + } + + // Then *always* clear vuex data. + window.localStorage.removeItem('vuex'); + } + } else if(existingBailoutInfo) { + // Proceed with prior data. + bailoutInfo = existingBailoutInfo; + } else { + // If neither fresh nor prior data exists, remove diagnostic section. const diagnosticContainer = document.getElementById('diagnostic-container'); diagnosticContainer.remove(); return; } try { - // =============== Collect diagnostic data: - const bailoutInfo = []; - - // App & Site Name - bailoutInfo.push({ name: 'App Name', value: 'FixMyGlass' }); - bailoutInfo.push({ name: 'Site Name', value: 'SafeliteDotcom' }); - - // Not included (yet) from heritage: - // - Site ID - // - Code - // - Module - // - Page - - bailoutInfo.push({ name: 'Timestamp', value: `${new Date()}` }); - - // - URL - // - Server - - const sessionId = getCookieValueByName('sid'); - bailoutInfo.push({ name: 'Session Id', value: sessionId }); - - const userAgent = window.navigator.userAgent; - bailoutInfo.push({ name: 'User Agent', value: userAgent }); - - // - IP - // - Session Log Sequence Number - - bailoutInfo.push({ name: 'Referral Seq Number', value: existingVuexData.order?.referralSequenceNumber }); - bailoutInfo.push({ name: 'Referral Number', value: existingVuexData.order?.referralNumber }); - bailoutInfo.push({ name: 'Referral Date', value: existingVuexData.order?.referralDate }); - bailoutInfo.push({ name: 'Referral Provider Number', value: existingVuexData.order?.serviceLocation?.provider?.providerNumber }); - bailoutInfo.push({ name: 'Referral CTU', value: existingVuexData.order?.serviceLocation?.provider?.address?.zipCodeCtu }); - - // - Referral Insured Zip - // - Referral Insured Service Zip - - bailoutInfo.push({ name: 'Referral CarID', value: existingVuexData.order?.vehicle?.carId }); - - const vehicle = existingVuexData.order?.vehicle; - const vehicleString = vehicle?.year - ? `${vehicle.year} ${vehicle.make} ${vehicle.model} - ${vehicle.style}` - : null; - bailoutInfo.push({ name: 'Referral Vehicle', value: vehicleString }); - bailoutInfo.push({ name: 'Work Order Number', value: existingVuexData.order?.workOrderNumber }); - bailoutInfo.push({ name: 'Work Order ID', value: existingVuexData.order?.workOrderId }); - bailoutInfo.push({ name: 'Parent Account Number', value: existingVuexData.order?.payment?.parentAccountNumber }); - - // - Parent Account Name - // - Client GUID - // =============== Display diagnostic data: // Create display nodes const elements = bailoutInfo.map( @@ -190,13 +209,11 @@ body { const ul = attachNode.appendChild(document.createElement('ul')); ul.append(fragment); } - } catch(e) { - + } finally { + // =============== Clear User Data + // ======== To avoid reproducing the same issue due to invalid states. + window.localStorage.removeItem('vuex'); } - - // =============== Clear User Data - // ======== To avoid reproducing the same issue due to invalid states. - window.localStorage.removeItem('vuex'); };