diff --git a/apps/client/src/common/components/error-boundary/ErrorBoundary.jsx b/apps/client/src/common/components/error-boundary/ErrorBoundary.jsx index 5cbb1e595..dcd522a08 100644 --- a/apps/client/src/common/components/error-boundary/ErrorBoundary.jsx +++ b/apps/client/src/common/components/error-boundary/ErrorBoundary.jsx @@ -3,6 +3,9 @@ import React from 'react'; // skipcq: JS-C1003 - sentry does not expose itself as an ES Module. import * as Sentry from '@sentry/react'; +import { runtime } from '@/common/stores/runtime'; +import { hasConnected, reconnectAttempts, shouldReconnect } from '@/common/utils/socket'; + import style from './ErrorBoundary.module.scss'; class ErrorBoundary extends React.Component { @@ -25,7 +28,9 @@ class ErrorBoundary extends React.Component { }); Sentry.withScope((scope) => { - scope.setExtras(error); + scope.setExtras('error', error); + scope.setExtras('store', runtime.getState()); + scope.setExtras('hasSocket', { hasConnected, shouldReconnect, reconnectAttempts }); const eventId = Sentry.captureException(error); this.setState({ eventId, info }); }); diff --git a/apps/client/src/common/utils/socket.ts b/apps/client/src/common/utils/socket.ts index c0c899819..ddeeb21cf 100644 --- a/apps/client/src/common/utils/socket.ts +++ b/apps/client/src/common/utils/socket.ts @@ -8,13 +8,16 @@ import { runtime } from '../stores/runtime'; export let websocket: WebSocket | null = null; let reconnectTimeout: NodeJS.Timeout | null = null; const reconnectInterval = 1000; -let shouldReconnect = true; - +export let shouldReconnect = true; +export let hasConnected = false; +export let reconnectAttempts = 0; export const connectSocket = () => { websocket = new WebSocket(websocketUrl); websocket.onopen = () => { clearTimeout(reconnectTimeout as NodeJS.Timeout); + hasConnected = true; + reconnectAttempts = 0; }; websocket.onclose = () => { @@ -23,6 +26,7 @@ export const connectSocket = () => { reconnectTimeout = setTimeout(() => { console.warn('WebSocket: attempting reconnect'); if (websocket && websocket.readyState === WebSocket.CLOSED) { + reconnectAttempts += 1; connectSocket(); } }, reconnectInterval); diff --git a/apps/client/src/index.tsx b/apps/client/src/index.tsx index 8a8271d53..a203885e2 100644 --- a/apps/client/src/index.tsx +++ b/apps/client/src/index.tsx @@ -18,6 +18,8 @@ Sentry.init({ tracesSampleRate: 1.0, release: ONTIME_VERSION, enabled: import.meta.env.PROD, + ignoreErrors: ['top.GLOBALS', 'Unable to preload CSS'], + denyUrls: [/extensions\//i, /^chrome:\/\//i, /^chrome-extension:\/\//i], }); root.render(