Retain diagnostic info across refresh
This commit is contained in:
parent
7a960cd8d6
commit
bc0b2f6c6c
1 changed files with 75 additions and 58 deletions
|
|
@ -103,20 +103,20 @@ body {
|
||||||
// =============== Check for session info:
|
// =============== Check for session info:
|
||||||
const existingVuexDataJSON = window.localStorage.getItem('vuex');
|
const existingVuexDataJSON = window.localStorage.getItem('vuex');
|
||||||
const existingVuexData = existingVuexDataJSON ? JSON.parse(existingVuexDataJSON) : null;
|
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(`================ VUEX DATA`);
|
||||||
console.log(existingVuexData);
|
console.log(existingVuexData);
|
||||||
|
console.log(`================ PRIOR BAILOUT DATA`);
|
||||||
|
console.log(existingBailoutInfo);
|
||||||
|
|
||||||
// If no info exists, exit.
|
let bailoutInfo = null;
|
||||||
if(!existingVuexData) {
|
|
||||||
const diagnosticContainer = document.getElementById('diagnostic-container');
|
|
||||||
diagnosticContainer.remove();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(existingVuexData) {
|
||||||
try {
|
try {
|
||||||
// =============== Collect diagnostic data:
|
// =============== Collect diagnostic data:
|
||||||
const bailoutInfo = [];
|
bailoutInfo = [];
|
||||||
|
|
||||||
// App & Site Name
|
// App & Site Name
|
||||||
bailoutInfo.push({ name: 'App Name', value: 'FixMyGlass' });
|
bailoutInfo.push({ name: 'App Name', value: 'FixMyGlass' });
|
||||||
|
|
@ -164,7 +164,26 @@ body {
|
||||||
|
|
||||||
// - Parent Account Name
|
// - Parent Account Name
|
||||||
// - Client GUID
|
// - 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 {
|
||||||
// =============== Display diagnostic data:
|
// =============== Display diagnostic data:
|
||||||
// Create display nodes
|
// Create display nodes
|
||||||
const elements = bailoutInfo.map(
|
const elements = bailoutInfo.map(
|
||||||
|
|
@ -190,13 +209,11 @@ body {
|
||||||
const ul = attachNode.appendChild(document.createElement('ul'));
|
const ul = attachNode.appendChild(document.createElement('ul'));
|
||||||
ul.append(fragment);
|
ul.append(fragment);
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} finally {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// =============== Clear User Data
|
// =============== Clear User Data
|
||||||
// ======== To avoid reproducing the same issue due to invalid states.
|
// ======== To avoid reproducing the same issue due to invalid states.
|
||||||
window.localStorage.removeItem('vuex');
|
window.localStorage.removeItem('vuex');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue