From 16573a63818f8d42cfe770d66c88fb074794bfec Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Thu, 4 Apr 2019 11:59:53 +0100 Subject: [PATCH] Track store failures after startup This watches the `IndexedDBStore` in case it degrades. If it does, we track this in analytics so we can observe how often it happens in the field. Should help track errors like https://github.com/vector-im/riot-web/issues/7769 --- src/MatrixClientPeg.js | 3 +++ src/utils/StorageManager.js | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index 94a016d207..ccdd48f41b 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -31,6 +31,7 @@ import {phasedRollOutExpiredForUser} from "./PhasedRollOut"; import Modal from './Modal'; import {verificationMethods} from 'matrix-js-sdk/lib/crypto'; import MatrixClientBackedSettingsHandler from "./settings/handlers/MatrixClientBackedSettingsHandler"; +import * as StorageManager from './utils/StorageManager'; interface MatrixClientCreds { homeserverUrl: string, @@ -94,6 +95,8 @@ class MatrixClientPeg { } async start() { + StorageManager.trackStores(this.matrixClient); + for (const dbType of ['indexeddb', 'memory']) { try { const promise = this.matrixClient.store.startup(); diff --git a/src/utils/StorageManager.js b/src/utils/StorageManager.js index ad75c0391e..1c0931273b 100644 --- a/src/utils/StorageManager.js +++ b/src/utils/StorageManager.js @@ -147,3 +147,11 @@ async function checkCryptoStore() { log("Crypto store using memory only"); return { exists, healthy: false }; } + +export function trackStores(client) { + if (client.store && client.store.on) { + client.store.on("degraded", () => { + track("Sync store using IndexedDB degraded to memory"); + }); + } +}