mirror of https://github.com/grafana/grafana.git
Crash detection: Track last user interaction to identify crashes happening after user interactions (#97914)
* Track last user interaction to identify crashes happening after user interactions * Add keypress event and use capture phase
This commit is contained in:
parent
51d9b577d5
commit
dc8e010cf3
|
|
@ -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<GrafanaCrashReport>({
|
||||
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)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue