refact common layout (#490)
parent
da04ff040b
commit
39ea967b30
@ -0,0 +1,30 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { useEffect } from 'react'
|
||||||
|
import * as Sentry from '@sentry/react'
|
||||||
|
|
||||||
|
const isDevelopment = process.env.NODE_ENV === 'development'
|
||||||
|
|
||||||
|
const SentryInit = ({
|
||||||
|
children,
|
||||||
|
}: { children: React.ReactElement }) => {
|
||||||
|
useEffect(() => {
|
||||||
|
const SENTRY_DSN = document?.body?.getAttribute('data-public-sentry-dsn')
|
||||||
|
if (!isDevelopment && SENTRY_DSN) {
|
||||||
|
Sentry.init({
|
||||||
|
dsn: SENTRY_DSN,
|
||||||
|
integrations: [
|
||||||
|
new Sentry.BrowserTracing({
|
||||||
|
}),
|
||||||
|
new Sentry.Replay(),
|
||||||
|
],
|
||||||
|
tracesSampleRate: 0.1,
|
||||||
|
replaysSessionSampleRate: 0.1,
|
||||||
|
replaysOnErrorSampleRate: 1.0,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
return children
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SentryInit
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { SWRConfig } from 'swr'
|
||||||
|
import type { ReactNode } from 'react'
|
||||||
|
|
||||||
|
type SwrInitorProps = {
|
||||||
|
children: ReactNode
|
||||||
|
}
|
||||||
|
const SwrInitor = ({
|
||||||
|
children,
|
||||||
|
}: SwrInitorProps) => {
|
||||||
|
return (
|
||||||
|
<SWRConfig value={{
|
||||||
|
shouldRetryOnError: false,
|
||||||
|
}}>
|
||||||
|
{children}
|
||||||
|
</SWRConfig>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SwrInitor
|
||||||
Loading…
Reference in New Issue