diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx index 8b4e5c42..ce7dd2f6 100644 --- a/src/components/ErrorBoundary.tsx +++ b/src/components/ErrorBoundary.tsx @@ -5,6 +5,7 @@ import type { ErrorBoundaryProps } from '@sentry/react/types/errorboundary'; import { ErrorContext } from '../contexts'; import { SentryError } from '../types'; import { getTypeFromError } from '../utils'; +import type { User } from '@openstax/ts-utils/services/authProvider'; const Error = ({ children, ...props }: React.PropsWithChildren) => {children}; @@ -47,6 +48,8 @@ export const ErrorBoundary = ({ // Optionally re-render with the children so they can display inline errors with const renderElement = error && renderFallback ? (typedFallback || fallback) : <>{children}; + type WindowWithUserData = Window & { _OX_USER_DATA?: User } + React.useEffect(() => { if (!sentryDsn && !sentryInit) { return; @@ -59,6 +62,9 @@ export const ErrorBoundary = ({ Sentry.init(sentryInit || { dsn: sentryDsn, environment: window.location.hostname, + initialScope: { + user: { uuid: (window as WindowWithUserData)._OX_USER_DATA?.uuid }, + }, integrations: [ Sentry.browserTracingIntegration(), Sentry.extraErrorDataIntegration()