Merge pull request #2832 from jryans/storage-telemetry
Send telemetry about storage consistency
This commit is contained in:
commit
a1e5fecb67
1 changed files with 11 additions and 0 deletions
|
@ -15,6 +15,7 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Matrix from 'matrix-js-sdk';
|
import Matrix from 'matrix-js-sdk';
|
||||||
|
import Analytics from '../Analytics';
|
||||||
|
|
||||||
const localStorage = window.localStorage;
|
const localStorage = window.localStorage;
|
||||||
|
|
||||||
|
@ -37,6 +38,10 @@ function error(msg) {
|
||||||
console.error(`StorageManager: ${msg}`);
|
console.error(`StorageManager: ${msg}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function track(action) {
|
||||||
|
Analytics.trackEvent("StorageManager", action);
|
||||||
|
}
|
||||||
|
|
||||||
export async function checkConsistency() {
|
export async function checkConsistency() {
|
||||||
log("Checking storage consistency");
|
log("Checking storage consistency");
|
||||||
log(`Local storage supported? ${!!localStorage}`);
|
log(`Local storage supported? ${!!localStorage}`);
|
||||||
|
@ -52,6 +57,7 @@ export async function checkConsistency() {
|
||||||
} else {
|
} else {
|
||||||
healthy = false;
|
healthy = false;
|
||||||
error("Local storage cannot be used on this browser");
|
error("Local storage cannot be used on this browser");
|
||||||
|
track("Local storage disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indexedDB && localStorage) {
|
if (indexedDB && localStorage) {
|
||||||
|
@ -62,6 +68,7 @@ export async function checkConsistency() {
|
||||||
} else {
|
} else {
|
||||||
healthy = false;
|
healthy = false;
|
||||||
error("Sync store cannot be used on this browser");
|
error("Sync store cannot be used on this browser");
|
||||||
|
track("Sync store disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indexedDB) {
|
if (indexedDB) {
|
||||||
|
@ -72,6 +79,7 @@ export async function checkConsistency() {
|
||||||
} else {
|
} else {
|
||||||
healthy = false;
|
healthy = false;
|
||||||
error("Crypto store cannot be used on this browser");
|
error("Crypto store cannot be used on this browser");
|
||||||
|
track("Crypto store disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataInLocalStorage && !dataInCryptoStore) {
|
if (dataInLocalStorage && !dataInCryptoStore) {
|
||||||
|
@ -80,11 +88,14 @@ export async function checkConsistency() {
|
||||||
"Data exists in local storage but not in crypto store. " +
|
"Data exists in local storage but not in crypto store. " +
|
||||||
"IndexedDB storage has likely been evicted by the browser!",
|
"IndexedDB storage has likely been evicted by the browser!",
|
||||||
);
|
);
|
||||||
|
track("Crypto store evicted");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (healthy) {
|
if (healthy) {
|
||||||
log("Storage consistency checks passed");
|
log("Storage consistency checks passed");
|
||||||
|
track("Consistency checks passed");
|
||||||
} else {
|
} else {
|
||||||
error("Storage consistency checks failed");
|
error("Storage consistency checks failed");
|
||||||
|
track("Consistency checks failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue