feat: sentry proxy (#399)

* feat: sentry proxy

* refactor: extracting init
This commit is contained in:
Adam Uhlíř
2022-06-20 11:05:03 +02:00
committed by GitHub
parent f38e8e11d6
commit e9666639b2
2 changed files with 48 additions and 26 deletions
+3 -26
View File
@@ -4,7 +4,6 @@ import { SnackbarProvider } from 'notistack'
import React, { ReactElement } from 'react'
import { HashRouter as Router } from 'react-router-dom'
import * as Sentry from '@sentry/react'
import { BrowserTracing } from '@sentry/tracing'
import './App.css'
import Dashboard from './layout/Dashboard'
import { Provider as BeeProvider } from './providers/Bee'
@@ -17,9 +16,8 @@ import { Provider as TopUpProvider } from './providers/TopUp'
import BaseRouter from './routes'
import { theme } from './theme'
import { config } from './config'
import { getBeeDesktopLogs, getBeeLogs } from './utils/desktop'
import packageJson from '../package.json'
import ItsBroken from './layout/ItsBroken'
import { initSentry } from './utils/sentry'
interface Props {
beeApiUrl?: string
@@ -28,29 +26,8 @@ interface Props {
}
if (config.SENTRY_KEY) {
Sentry.init({
dsn: config.SENTRY_KEY,
release: packageJson.version,
integrations: [new BrowserTracing({ tracingOrigins: ['localhost'] })],
tracesSampleRate: 1.0,
beforeSend: async (event, hint) => {
hint.attachments = []
try {
// This will fail if we are not running in Bee Desktop, but that is alright
hint.attachments.push({ filename: 'bee-desktop.log', data: await getBeeDesktopLogs() })
// eslint-disable-next-line no-empty
} catch (e) {}
try {
// This will fail if we are not running in Bee Desktop, but that is alright
hint.attachments.push({ filename: 'bee.log', data: await getBeeLogs() })
// eslint-disable-next-line no-empty
} catch (e) {}
return event
},
})
// eslint-disable-next-line no-console
initSentry().catch(e => console.error(e))
}
const App = ({ beeApiUrl, beeDebugApiUrl, lockedApiSettings }: Props): ReactElement => {