2
0

build: 👷 Add Sentry context

This commit is contained in:
Baptiste Arnaud
2022-04-08 18:14:00 -05:00
parent 5aac8229d2
commit fb3bba897f
2 changed files with 14 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import { updateUser as updateUserInDb } from 'services/user/user'
import { useToast } from '@chakra-ui/react'
import { dequal } from 'dequal'
import { User } from 'db'
import { setUser as setSentryUser } from '@sentry/nextjs'
const userContext = createContext<{
user?: User
@ -48,7 +49,9 @@ export const UserContext = ({ children }: { children: ReactNode }) => {
useEffect(() => {
if (isDefined(user) || isNotDefined(session)) return
setUser(session.user as User)
const parsedUser = session.user as User
setUser(parsedUser)
setSentryUser({ id: parsedUser.id })
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [session])

View File

@ -7,4 +7,14 @@ import * as Sentry from '@sentry/nextjs'
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
ignoreErrors: ['ResizeObserver loop limit exceeded'],
beforeBreadcrumb(breadcrumb, hint) {
try {
if (breadcrumb.category?.startsWith('ui')) {
breadcrumb.message = `${hint?.event.target.tagName.toLowerCase()}: ${
hint?.event.target.innerText
}`
}
} catch (e) {}
return breadcrumb
},
})