Update libraries/react-shared-libraries/src/sentry/sentry.user.context.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Enno Gelhaus 2025-07-31 22:10:40 +02:00 committed by GitHub
parent cf03b9d0d6
commit a997bec147
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -60,14 +60,8 @@ export const setSentryUserContext = (user: UserInfo | null) => {
* Only executes if Sentry DSN is configured.
*/
export const clearSentryUserContext = () => {
// Only clear context if Sentry is configured (check at runtime for frontend)
if (typeof window !== 'undefined' && !window.location.origin.includes('localhost')) {
// For production, check if Sentry DSN exists in environment or is initialized
if (!process.env.NEXT_PUBLIC_SENTRY_DSN) {
return;
}
} else if (typeof process !== 'undefined' && !process.env.NEXT_PUBLIC_SENTRY_DSN) {
// For server-side or development
// Only clear context if Sentry is configured
if (!process.env.NEXT_PUBLIC_SENTRY_DSN) {
return;
}