Skip to content

Commit

Permalink
Sentry SDK initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ioay committed Jan 25, 2024
1 parent 2b97f90 commit e68f4ca
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 99 deletions.
2 changes: 2 additions & 0 deletions dapp/.env.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_IS_SENTRY_ENABLED=true
REACT_APP_SENTRY_DSN = "https://3355df2870ed3e9d7eae3bba47350ed0@o4506633352577024.ingest.sentry.io/4506633358868480"
1 change: 1 addition & 0 deletions dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@emotion/styled": "^11.11.0",
"@ledgerhq/wallet-api-client": "^1.5.0",
"@ledgerhq/wallet-api-client-react": "^1.3.0",
"@sentry/react": "^7.98.0",
"@tanstack/react-table": "^8.11.3",
"formik": "^2.4.5",
"framer-motion": "^10.16.5",
Expand Down
2 changes: 2 additions & 0 deletions dapp/src/DApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import Overview from "./components/Overview"
import Sidebar from "./components/Sidebar"
import DocsDrawer from "./components/DocsDrawer"
import GlobalStyles from "./components/GlobalStyles"
import { useSentry } from "./hooks/useSentry"

function DApp() {
useDetectThemeMode()
useSentry()

return (
<>
Expand Down
10 changes: 10 additions & 0 deletions dapp/src/hooks/useSentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { initializeSentry } from "#/sdk/sentry"
import { useEffect } from "react"

export const useSentry = () => {
useEffect(() => {
if (process.env.REACT_APP_IS_SENTRY_ENABLED) {
initializeSentry()
}
}, [])
}
22 changes: 22 additions & 0 deletions dapp/src/sdk/sentry/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as Sentry from "@sentry/react"

export const initializeSentry = () => {
Sentry.init({
dsn: process.env.SENTRY_DSN,
integrations: [
new Sentry.BrowserTracing({
// Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
tracePropagationTargets: ["localhost"],
}),
new Sentry.Replay({
maskAllText: false,
blockAllMedia: false,
}),
],
// Performance Monitoring
tracesSampleRate: 1.0, // Capture 100% of the transactions
// Session Replay
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
})
}
196 changes: 97 additions & 99 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e68f4ca

Please sign in to comment.