From 959ee2fb2565cda941303ad6174a547eb04462ab Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Wed, 15 Jan 2025 13:31:15 +0100 Subject: [PATCH] fixup! feat(telemetry): capture client errors with Sentry --- client/src/telemetry/sentry.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/src/telemetry/sentry.ts b/client/src/telemetry/sentry.ts index c20b8635e9cc..14f7c2743630 100644 --- a/client/src/telemetry/sentry.ts +++ b/client/src/telemetry/sentry.ts @@ -31,14 +31,14 @@ export function initSentry() { return; } - let onNextError: (() => void) | null = null; + let onSentryLoad: (() => void) | null = null; const capturedMessages = new Set(); const handleError = (event: ErrorEvent) => { loadSentry().then((Sentry) => { - if (onNextError) { - onNextError(); - onNextError = null; + if (onSentryLoad) { + onSentryLoad(); + onSentryLoad = null; } if (!capturedMessages.has(event.message)) { // Capture every error only once. @@ -48,8 +48,8 @@ export function initSentry() { }); }; - // To avoid capturing too many events, we stop listening after the first error. - onNextError = () => window.removeEventListener("error", handleError); + // Avoid capturing too many events by stop listening when Sentry is loaded. + onSentryLoad = () => window.removeEventListener("error", handleError); window.addEventListener("error", handleError); }