diff --git a/public/app/core/crash/index.ts b/public/app/core/crash/index.ts index e3ef01ed25d..68022a81aea 100644 --- a/public/app/core/crash/index.ts +++ b/public/app/core/crash/index.ts @@ -21,6 +21,7 @@ interface GrafanaCrashReport extends BaseStateReport { email: string; login: string; name: string; + lastInteraction: number; }; memory?: { heapUtilization: number; @@ -36,6 +37,11 @@ export function initializeCrashDetection() { return; } + let lastInteraction = Date.now(); + // Add last interaction listeners to capture phase to reduce skipped events when stopPropagation() is called + document.body.addEventListener('click', () => (lastInteraction = Date.now()), true); + document.body.addEventListener('keypress', () => (lastInteraction = Date.now()), true); + initCrashDetection({ id: nanoid(5), @@ -81,6 +87,7 @@ export function initializeCrashDetection() { email: contextSrv.user.email, login: contextSrv.user.login, name: contextSrv.user.name, + lastInteraction, }; if (isChromePerformance(performance)) {