Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry SDK initialization #195

Merged
merged 9 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dapp/.env
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
VITE_USE_TESTNET=true

# Configuration of sentry.io
VITE_SENTRY_SUPPORT=false
# TODO: Sentry DSN will be added during the application building process when it is ready
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
3 changes: 2 additions & 1 deletion dapp/src/DApp.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react"
import { Box, ChakraProvider } from "@chakra-ui/react"
import { useDetectThemeMode } from "./hooks"
import { useDetectThemeMode, useSentry } from "./hooks"
import theme from "./theme"
import {
DocsDrawerContextProvider,
Expand All @@ -16,6 +16,7 @@ import GlobalStyles from "./components/GlobalStyles"

function DApp() {
useDetectThemeMode()
useSentry()

return (
<>
Expand Down
1 change: 1 addition & 0 deletions dapp/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from "./useTransactionDetails"
export * from "./useSignMessage"
export * from "./useDepositBTCTransaction"
export * from "./useTransactionHistoryTable"
export * from "./useSentry"
12 changes: 12 additions & 0 deletions dapp/src/hooks/useSentry.ts
r-czajkowski marked this conversation as resolved.
Show resolved Hide resolved
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)
}
}, [])
}
11 changes: 11 additions & 0 deletions dapp/src/sdk/sentry/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as Sentry from "@sentry/react"

export const initializeSentry = (dsn: string) => {
Sentry.init({
dsn,
integrations: [new Sentry.BrowserTracing()],
// Performance Monitoring
// TODO: Now, it's capturing 100% of the transactions. It should be changed when prod mode is enabled
tracesSampleRate: 1.0,
})
}
9 changes: 9 additions & 0 deletions dapp/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly VITE_SENTRY_SUPPORT: boolean
readonly VITE_SENTRY_DSN: string
}

interface ImportMeta {
readonly env: ImportMetaEnv
}
88 changes: 88 additions & 0 deletions pnpm-lock.yaml

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

Loading