diff --git a/www/js/plugin/clientStats.ts b/www/js/plugin/clientStats.ts index e106dd7cf..7c512f2c2 100644 --- a/www/js/plugin/clientStats.ts +++ b/www/js/plugin/clientStats.ts @@ -12,7 +12,8 @@ type StatKey = | 'set_reminder_prefs' | 'force_sync' | 'open_notification' - | 'missing_keys'; + | 'missing_keys' + | 'ui_error'; let appVersion; export function getAppVersion() { @@ -39,9 +40,9 @@ export async function addStatReading(name: StatKey, reading?: any) { displayErrorMsg('addStatReading: db is not defined'); } -export async function addStatError(name: StatKey, errorStr: string) { +export async function addStatError(errorMsg: string) { const db = window['cordova']?.plugins?.BEMUserCache; - const event = await getStatsEvent(name, errorStr); + const event = await getStatsEvent('ui_error', errorMsg); logDebug('addStatError: adding CLIENT_ERROR event: ' + JSON.stringify(event)); if (db) return db.putMessage(CLIENT_ERROR, event); displayErrorMsg('addStatError: db is not defined'); diff --git a/www/js/plugin/logger.ts b/www/js/plugin/logger.ts index 98e852978..12664bbed 100644 --- a/www/js/plugin/logger.ts +++ b/www/js/plugin/logger.ts @@ -1,3 +1,5 @@ +import { addStatError } from './clientStats'; + export const logDebug = (message: string) => window['Logger']?.log(window['Logger'].LEVEL_DEBUG, message); @@ -19,6 +21,7 @@ export function displayErrorMsg(errorMsg: string, title?: string) { } const displayMsg = `━━━━\n${title}\n━━━━\n` + errorMsg; window.alert(displayMsg); + addStatError(title ? `${title}: ${errorMsg}` : errorMsg); console.error(displayMsg); window['Logger']?.log(window['Logger'].LEVEL_ERROR, displayMsg); }