Improve lazy loading (#12186)
WIP, using preview app to test performance (which was very bad)
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { AppErrorBoundaryEffect } from '@/error-handler/components/internal/AppErrorBoundaryEffect';
|
||||
import * as Sentry from '@sentry/react';
|
||||
import { captureException } from '@sentry/react';
|
||||
import { ErrorInfo, ReactNode } from 'react';
|
||||
import { ErrorBoundary, FallbackProps } from 'react-error-boundary';
|
||||
|
||||
@ -15,7 +15,7 @@ export const AppErrorBoundary = ({
|
||||
resetOnLocationChange = true,
|
||||
}: AppErrorBoundaryProps) => {
|
||||
const handleError = (error: Error, info: ErrorInfo) => {
|
||||
Sentry.captureException(error, (scope) => {
|
||||
captureException(error, (scope) => {
|
||||
scope.setExtras({ info });
|
||||
return scope;
|
||||
});
|
||||
|
||||
@ -1,4 +1,9 @@
|
||||
import * as Sentry from '@sentry/react';
|
||||
import {
|
||||
browserTracingIntegration,
|
||||
init,
|
||||
replayIntegration,
|
||||
setUser,
|
||||
} from '@sentry/react';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
@ -7,8 +12,8 @@ import { currentUserState } from '@/auth/states/currentUserState';
|
||||
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||
import { sentryConfigState } from '@/client-config/states/sentryConfigState';
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
|
||||
export const SentryInitEffect = () => {
|
||||
const sentryConfig = useRecoilValue(sentryConfigState);
|
||||
@ -21,14 +26,11 @@ export const SentryInitEffect = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (isNonEmptyString(sentryConfig?.dsn) && !isSentryInitialized) {
|
||||
Sentry.init({
|
||||
init({
|
||||
environment: sentryConfig?.environment ?? undefined,
|
||||
release: sentryConfig?.release ?? undefined,
|
||||
dsn: sentryConfig?.dsn,
|
||||
integrations: [
|
||||
Sentry.browserTracingIntegration({}),
|
||||
Sentry.replayIntegration(),
|
||||
],
|
||||
integrations: [browserTracingIntegration({}), replayIntegration()],
|
||||
tracePropagationTargets: ['localhost:3001', REACT_APP_SERVER_BASE_URL],
|
||||
tracesSampleRate: 1.0,
|
||||
replaysSessionSampleRate: 0.1,
|
||||
@ -39,14 +41,14 @@ export const SentryInitEffect = () => {
|
||||
}
|
||||
|
||||
if (isDefined(currentUser)) {
|
||||
Sentry.setUser({
|
||||
setUser({
|
||||
email: currentUser?.email,
|
||||
id: currentUser?.id,
|
||||
workspaceId: currentWorkspace?.id,
|
||||
workspaceMemberId: currentWorkspaceMember?.id,
|
||||
});
|
||||
} else {
|
||||
Sentry.setUser(null);
|
||||
setUser(null);
|
||||
}
|
||||
}, [
|
||||
sentryConfig,
|
||||
|
||||
Reference in New Issue
Block a user