From 5315b314df7f49bea165c098aa5ae14c54150f25 Mon Sep 17 00:00:00 2001 From: Piotr Czeglik Date: Tue, 11 Feb 2025 09:38:53 +0100 Subject: [PATCH] chore: add logging for fatal errors --- apps/browser-extension-wallet/sentry.js | 7 ++++++- apps/browser-extension-wallet/src/hooks/useFatalError.ts | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/browser-extension-wallet/sentry.js b/apps/browser-extension-wallet/sentry.js index cb8c8288df..9bf818ff33 100644 --- a/apps/browser-extension-wallet/sentry.js +++ b/apps/browser-extension-wallet/sentry.js @@ -4,7 +4,12 @@ import { storage } from 'webextension-polyfill'; Sentry.init({ environment: process.env.SENTRY_ENVIRONMENT, dsn: process.env.SENTRY_DSN, - integrations: [Sentry.browserTracingIntegration(), Sentry.browserProfilingIntegration(), Sentry.replayIntegration()], + integrations: [ + Sentry.browserTracingIntegration(), + Sentry.browserProfilingIntegration(), + Sentry.replayIntegration(), + Sentry.captureConsoleIntegration({ levels: ['error'] }) + ], // Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled tracePropagationTargets: ['localhost', 'chrome-extension://gafhhkghbfjjkeiendhlofajokpaflmk'], // .5% diff --git a/apps/browser-extension-wallet/src/hooks/useFatalError.ts b/apps/browser-extension-wallet/src/hooks/useFatalError.ts index bbebedac04..0c2fe93a3a 100644 --- a/apps/browser-extension-wallet/src/hooks/useFatalError.ts +++ b/apps/browser-extension-wallet/src/hooks/useFatalError.ts @@ -55,5 +55,14 @@ export const useFatalError = (): FatalError | undefined => { const { cardanoWallet } = useWalletStore(); const walletError$ = useMemo(() => anyError(cardanoWallet?.wallet), [cardanoWallet?.wallet]); const walletError = useObservable(walletError$); + + if (unhandledServiceWorkerError) { + console.error('useFatalError (service worker):', unhandledServiceWorkerError); + } + + if (walletError) { + console.error('useFatalError (wallet):', walletError); + } + return unhandledServiceWorkerError || walletError; };