-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix Sentry init * Run linters
- Loading branch information
Showing
5 changed files
with
43 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,2 @@ | ||
import * as Sentry from '@sentry/nextjs'; | ||
import { Integrations as TracingIntegrations } from '@sentry/tracing'; | ||
import { publicRuntimeConfig } from './src/runtimeConfig'; | ||
|
||
const { APP_ENVIRONMENT, APP_FRONTEND_RELEASE, PUBLIC_SENTRY_DSN } = publicRuntimeConfig; | ||
|
||
if (publicRuntimeConfig.PUBLIC_SENTRY_DSN) { | ||
Sentry.init({ | ||
dsn: PUBLIC_SENTRY_DSN, | ||
release: APP_FRONTEND_RELEASE, | ||
environment: APP_ENVIRONMENT, | ||
integrations: [new TracingIntegrations.BrowserTracing()], | ||
tracesSampleRate: 1.0, | ||
}); | ||
} | ||
// We initialize Sentry in SentryClientSideInitializer to use environment variables. | ||
// Empty file so that Sentry wouldn't complain about missing config. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/app/[projectID]/_components/SentryClientSideInitializer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use client'; | ||
|
||
import useSentryInit from '../../../hooks/useSentryInit'; | ||
|
||
const SentryClientSideInitializer = () => { | ||
useSentryInit(); | ||
return null; | ||
}; | ||
|
||
export default SentryClientSideInitializer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use client'; | ||
|
||
import * as Sentry from '@sentry/nextjs'; | ||
import { Integrations as TracingIntegrations } from '@sentry/tracing'; | ||
import { useEnvironment } from '../environment/environmentContext'; | ||
import { useEffect } from 'react'; | ||
|
||
const useSentryInit = () => { | ||
const { | ||
publicEnvironment: { APP_ENVIRONMENT, APP_FRONTEND_RELEASE, PUBLIC_SENTRY_DSN }, | ||
} = useEnvironment(); | ||
useEffect(() => { | ||
if (PUBLIC_SENTRY_DSN) { | ||
Sentry.init({ | ||
dsn: PUBLIC_SENTRY_DSN, | ||
release: APP_FRONTEND_RELEASE, | ||
environment: APP_ENVIRONMENT, | ||
integrations: [new TracingIntegrations.BrowserTracing()], | ||
tracesSampleRate: 1.0, | ||
}); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
}; | ||
|
||
export default useSentryInit; |