diff --git a/package-lock.json b/package-lock.json index a69b3e22..be12c447 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3616,111 +3616,6 @@ "resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.2.0.tgz", "integrity": "sha512-sXo/qW2/pAcmT43VoRKOJbDOfV3cYpq3szSVfIThQXNt+E4DfKj361vaAt3c88U5tPUxzEswam7GW48PJqtKAg==" }, - "@sentry-internal/tracing": { - "version": "7.53.1", - "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.53.1.tgz", - "integrity": "sha512-a4H4rvVdz0XDGgNfRqc7zg6rMt2P1P05xBmgfIfztYy94Vciw1QMdboNiT7einr8ra8wogdEaK4Pe2AzYAPBJQ==", - "requires": { - "@sentry/core": "7.53.1", - "@sentry/types": "7.53.1", - "@sentry/utils": "7.53.1", - "tslib": "^1.9.3" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - } - } - }, - "@sentry/browser": { - "version": "7.53.1", - "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.53.1.tgz", - "integrity": "sha512-1zas2R6riJaj0k7FoeieCW0SuC7UyKaBGA6jEG2LsgIqyD7IDOlF3BPZ4Yt08GFav0ImpyhGn5Vbrq5JLbeQdw==", - "requires": { - "@sentry-internal/tracing": "7.53.1", - "@sentry/core": "7.53.1", - "@sentry/replay": "7.53.1", - "@sentry/types": "7.53.1", - "@sentry/utils": "7.53.1", - "tslib": "^1.9.3" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - } - } - }, - "@sentry/core": { - "version": "7.53.1", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.53.1.tgz", - "integrity": "sha512-DAH8IJNORJJ7kQLqsZuhMkN6cwJjXzFuuUoZor7IIDHIHjtl51W+2F3Stg3+I3ZoKDfJfUNKqhipk2WZjG0FBg==", - "requires": { - "@sentry/types": "7.53.1", - "@sentry/utils": "7.53.1", - "tslib": "^1.9.3" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - } - } - }, - "@sentry/react": { - "version": "7.53.1", - "resolved": "https://registry.npmjs.org/@sentry/react/-/react-7.53.1.tgz", - "integrity": "sha512-eEOY/peBepSD/nhPn4SU77aYdjQfAI1svOqpG4sbpjaGZU1P6L7+IIGmip8l2T68oPEeKDaiH9Qy/3uxu55B/Q==", - "requires": { - "@sentry/browser": "7.53.1", - "@sentry/types": "7.53.1", - "@sentry/utils": "7.53.1", - "hoist-non-react-statics": "^3.3.2", - "tslib": "^1.9.3" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - } - } - }, - "@sentry/replay": { - "version": "7.53.1", - "resolved": "https://registry.npmjs.org/@sentry/replay/-/replay-7.53.1.tgz", - "integrity": "sha512-5He5JLJiYLeWtXHC53z2ZzfbgAedafbHNZVS4+MBCOtydCk7cnuyJ0gGV6Rfxej/lZSNXZxOdW7HeMhzBtZCxw==", - "requires": { - "@sentry/core": "7.53.1", - "@sentry/types": "7.53.1", - "@sentry/utils": "7.53.1" - } - }, - "@sentry/types": { - "version": "7.53.1", - "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.53.1.tgz", - "integrity": "sha512-/ijchRIu+jz3+j/zY+7KRPfLSCY14fTx5xujjbOdmEKjmIHQmwPBdszcQm40uwofrR8taV4hbt5MFN+WnjCkCw==" - }, - "@sentry/utils": { - "version": "7.53.1", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.53.1.tgz", - "integrity": "sha512-DKJA1LSUOEv4KOR828MzVuLh+drjeAgzyKgN063OEKmnirgjgRgNNS8wUgwpG0Tn2k6ANZGCwrdfzPeSBxshKg==", - "requires": { - "@sentry/types": "7.53.1", - "tslib": "^1.9.3" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - } - } - }, "@sinclair/typebox": { "version": "0.24.51", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.51.tgz", diff --git a/package.json b/package.json index c023ddac..8e59a5b2 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ }, "dependencies": { "@reactour/tour": "^3.3.0", - "@sentry/react": "^7.53.1", "@stripe/react-stripe-js": "^1.4.0", "@stripe/stripe-js": "^1.13.2", "babel-polyfill": "^6.26.0", diff --git a/src/components/ErrorBoundary/index.tsx b/src/components/ErrorBoundary/index.tsx index 4f3ad182..b3a27e45 100644 --- a/src/components/ErrorBoundary/index.tsx +++ b/src/components/ErrorBoundary/index.tsx @@ -1,8 +1,8 @@ -import React from 'react' +// eslint-disable react/destructuring-assignment -import type{ ReactNode } from 'react' +import { Component } from 'react' -import * as Sentry from '@sentry/react' +import type{ ErrorInfo, ReactNode } from 'react' import { Error } from '../Error' @@ -10,15 +10,41 @@ interface Props { children?: ReactNode, } -export const ErrorBoundary = ({ children }: Props) => ( - - {children} - - - )} - > - { children } - -) +interface State { + hasError: boolean, +} + +class ErrorBoundary extends Component { + // eslint-disable-next-line react/state-in-constructor + public state: State = { + hasError: false, + } + + public static getDerivedStateFromError(_: Error): State { + // Update state so the next render will show the fallback UI. + return { hasError: true } + } + + public componentDidCatch(error: Error, errorInfo: ErrorInfo) { + // eslint-disable-next-line no-console + console.error( + 'Uncaught error:', + error, + errorInfo, + ) + } + + public render() { + const { hasError } = this.state + const { children } = this.props + + return ( + <> + {hasError && } + {children} + + ) + } +} +export default ErrorBoundary diff --git a/src/features/App/index.tsx b/src/features/App/index.tsx index d65ffd0a..af66da71 100644 --- a/src/features/App/index.tsx +++ b/src/features/App/index.tsx @@ -23,7 +23,7 @@ import { GlobalStyles } from 'features/GlobalStyles' import { Theme } from 'features/Theme' import { UnavailableText } from 'components/UnavailableText' -import { ErrorBoundary } from 'components/ErrorBoundary' +import ErrorBoundary from 'components/ErrorBoundary' import { AuthenticatedApp } from './AuthenticatedApp' import { useAuthStore } from '../AuthStore' diff --git a/src/helpers/callApi/logoutIfUnauthorized.tsx b/src/helpers/callApi/logoutIfUnauthorized.tsx index d9958362..18e71881 100644 --- a/src/helpers/callApi/logoutIfUnauthorized.tsx +++ b/src/helpers/callApi/logoutIfUnauthorized.tsx @@ -1,13 +1,5 @@ -import * as Sentry from '@sentry/react' - export const logoutIfUnauthorized = async (response: Response) => { /* отключили из-за доступа без авторизации */ - const body = await response.json() - - if (response.status === 400) { - Sentry.captureException(body) - } - if (response.status === 401 || response.status === 403) { window.dispatchEvent(new Event('FORBIDDEN_REQUEST')) } @@ -16,5 +8,6 @@ export const logoutIfUnauthorized = async (response: Response) => { // eslint-disable-next-line no-console console.error(error) + const body = await response.json() return Promise.reject(body) } diff --git a/src/index.tsx b/src/index.tsx index 8622573d..81041121 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -5,24 +5,11 @@ import { } from 'react' import ReactDOM from 'react-dom' -import * as Sentry from '@sentry/react' -import { BrowserTracing } from '@sentry/react' - -import { isIOS, ENV } from 'config' - +import { isIOS } from 'config/userAgent' // import { makeServer } from 'utilits/mirage/Mirage' import * as serviceWorker from './serviceWorker' -if (process.env.NODE_ENV !== 'development') { - Sentry.init({ - dsn: 'https://bbe0cdfb954644ebaf3be16bb472cc3d@sentry.insports.tv/21', - environment: ENV, - integrations: [new BrowserTracing()], - tracesSampleRate: 1.0, - }) -} - export const App = process.env.REACT_APP_TYPE === 'auth-service' ? lazy(() => import('features/AuthServiceApp')) : lazy(() => import('features/App'))