apps/web: add sentry scope to set user on client
This commit is contained in:
parent
d374208097
commit
79e707a232
@ -6,14 +6,15 @@ import { Grid } from '@/Components/Layout/Page';
|
|||||||
import Output from '@/Components/Output';
|
import Output from '@/Components/Output';
|
||||||
import { defaultRoles } from '@/config/users';
|
import { defaultRoles } from '@/config/users';
|
||||||
import * as CRMTypes from '@/graphql/crm.types';
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
import { useInsuranceData, useMainData, useReactions } from '@/process/hooks';
|
import * as hooks from '@/process/hooks';
|
||||||
import { dehydrate, QueryClient } from '@tanstack/react-query';
|
import { dehydrate, QueryClient } from '@tanstack/react-query';
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
|
|
||||||
export default function Home(props) {
|
export default function Home(props) {
|
||||||
useMainData();
|
hooks.useSentryScope();
|
||||||
useInsuranceData();
|
hooks.useMainData();
|
||||||
useReactions();
|
hooks.useInsuranceData();
|
||||||
|
hooks.useReactions();
|
||||||
|
|
||||||
if (props.statusCode !== 200) return <Error {...props} />;
|
if (props.statusCode !== 200) return <Error {...props} />;
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { Error } from '@/Components/Common/Error';
|
|||||||
import { Grid } from '@/Components/Layout/Page';
|
import { Grid } from '@/Components/Layout/Page';
|
||||||
import Output from '@/Components/Output';
|
import Output from '@/Components/Output';
|
||||||
import { unlimitedRoles } from '@/config/users';
|
import { unlimitedRoles } from '@/config/users';
|
||||||
import { useGetUsers, useInsuranceData, useMainData, useReactions } from '@/process/hooks';
|
import * as hooks from '@/process/hooks';
|
||||||
import { useStore } from '@/stores/hooks';
|
import { useStore } from '@/stores/hooks';
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
|
|
||||||
@ -12,10 +12,11 @@ export default function Unlimited(props) {
|
|||||||
const store = useStore();
|
const store = useStore();
|
||||||
store.$process.add('Unlimited');
|
store.$process.add('Unlimited');
|
||||||
|
|
||||||
useMainData();
|
hooks.useSentryScope();
|
||||||
useGetUsers();
|
hooks.useMainData();
|
||||||
useInsuranceData();
|
hooks.useGetUsers();
|
||||||
useReactions();
|
hooks.useInsuranceData();
|
||||||
|
hooks.useReactions();
|
||||||
|
|
||||||
if (props.statusCode !== 200) return <Error {...props} />;
|
if (props.statusCode !== 200) return <Error {...props} />;
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
export * from './common';
|
export * from './common';
|
||||||
export * from './init';
|
export * from './init';
|
||||||
export * from './reactions';
|
export * from './reactions';
|
||||||
|
export * from './sentry';
|
||||||
|
|||||||
16
apps/web/process/hooks/sentry.ts
Normal file
16
apps/web/process/hooks/sentry.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
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);
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user