Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/utils/StorageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ limitations under the License.
*/

import Matrix from 'matrix-js-sdk';
import Analytics from '../Analytics';

const localStorage = window.localStorage;

Expand All @@ -37,6 +38,10 @@ function error(msg) {
console.error(`StorageManager: ${msg}`);
}

function track(action) {
Analytics.trackEvent("StorageManager", action);
}

export async function checkConsistency() {
log("Checking storage consistency");
log(`Local storage supported? ${!!localStorage}`);
Expand All @@ -52,6 +57,7 @@ export async function checkConsistency() {
} else {
healthy = false;
error("Local storage cannot be used on this browser");
track("Local storage disabled");
}

if (indexedDB && localStorage) {
Expand All @@ -62,6 +68,7 @@ export async function checkConsistency() {
} else {
healthy = false;
error("Sync store cannot be used on this browser");
track("Sync store disabled");
}

if (indexedDB) {
Expand All @@ -72,6 +79,7 @@ export async function checkConsistency() {
} else {
healthy = false;
error("Crypto store cannot be used on this browser");
track("Crypto store disabled");
}

if (dataInLocalStorage && !dataInCryptoStore) {
Expand All @@ -80,11 +88,14 @@ export async function checkConsistency() {
"Data exists in local storage but not in crypto store. " +
"IndexedDB storage has likely been evicted by the browser!",
);
track("Crypto store evicted");
}

if (healthy) {
log("Storage consistency checks passed");
track("Consistency checks passed");
} else {
error("Storage consistency checks failed");
track("Consistency checks failed");
}
}