17 lines
486 B
TypeScript
17 lines
486 B
TypeScript
import { getUser } from '@/api/user/query';
|
|
import { STALE_TIME } from '@/constants/request';
|
|
import { getCurrentScope } from '@sentry/nextjs';
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import { useEffect } from 'react';
|
|
|
|
export function useSentryScope() {
|
|
const { data: user } = useQuery(['user'], ({ signal }) => getUser({ signal }), {
|
|
staleTime: STALE_TIME,
|
|
});
|
|
|
|
useEffect(() => {
|
|
const scope = getCurrentScope();
|
|
if (user) scope.setUser(user);
|
|
}, []);
|
|
}
|