set sentry user ID, if available and applicable

This commit is contained in:
Amruth Pillai
2022-12-03 00:15:08 +01:00
parent 716a05032d
commit 9af9a0284e
2 changed files with 28 additions and 10 deletions

View File

@ -0,0 +1,17 @@
import * as Sentry from '@sentry/nextjs';
import { useEffect } from 'react';
import { useAppSelector } from '@/store/hooks';
const SentryWrapper: React.FC<React.PropsWithChildren<unknown>> = ({ children }) => {
const user = useAppSelector((state) => state.auth.user);
useEffect(() => {
const sentryUser: Sentry.User | null = user && { ...user, id: user?.id.toString() };
Sentry.setUser(sentryUser);
}, [user]);
return <>{children}</>;
};
export default SentryWrapper;