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 28, 2024
1 parent 2b97f90 commit 55b1147
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 99 deletions.
4 changes: 4 additions & 0 deletions dapp/.env
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
VITE_USE_TESTNET=true

# Configuration of sentry.io
VITE_SENTRY_SUPPORT=true
VITE_SENTRY_DSN=https://4c1f78c9a9f5e2b556d94abd754ccf20@o4506637342539776.ingest.sentry.io/4506637357416448
5 changes: 5 additions & 0 deletions dapp/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
VITE_USE_TESTNET=false

# Configuration of sentry.io
VITE_SENTRY_SUPPORT=false
VITE_SENTRY_DSN=""
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
12 changes: 12 additions & 0 deletions dapp/src/hooks/useSentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { initializeSentry } from "#/sdk/sentry"
import { useEffect } from "react"

export const useSentry = () => {
useEffect(() => {
const { VITE_SENTRY_SUPPORT, VITE_SENTRY_DSN } = import.meta.env

if (VITE_SENTRY_SUPPORT) {
initializeSentry(`${VITE_SENTRY_DSN}`)
}
}, [])
}
16 changes: 16 additions & 0 deletions dapp/src/sdk/sentry/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as Sentry from "@sentry/react"

export const initializeSentry = (dsn: string) => {
Sentry.init({
dsn,
integrations: [
new Sentry.BrowserTracing({
// Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
tracePropagationTargets: ["localhost"],
}),
],
// Performance Monitoring
// Capture 100% of the transactions
tracesSampleRate: 1.0,
})
}
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 55b1147

Please sign in to comment.