@@ -0,0 +1,4 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib", + "typescript.enablePromptUseWorkspaceTsdk": true +} \ No newline at end of file @@ -1,15 +0,0 @@ -const Sentry = { - init: jest.fn(), - captureException: jest.fn(), - captureMessage: jest.fn(), - withScope: jest.fn((callback) => { - callback({ - setExtra: jest.fn(), - setTag: jest.fn(), - setUser: jest.fn(), - }); - }), -}; - - -export default Sentry; @@ -0,0 +1,38 @@ +"use client"; + +import { useRef, useEffect } from 'react'; +import { initializeFaro as coreInit, ReactIntegration, getWebInstrumentations, Faro } from '@grafana/faro-react'; + +export default function FrontendObservability() { + const faroRef = useRef(null); + + useEffect(() => { + if (!faroRef.current) { + try { + // Initialize Grafana Faro + const faro = coreInit({ + url: process.env.NEXT_PUBLIC_FARO_API_URL, + apiKey: process.env.NEXT_PUBLIC_FARO_API_KEY, + app: { + name: process.env.NEXT_PUBLIC_FARO_APP_NAME, + version: process.env.NEXT_PUBLIC_RELEASE, + environment: process.env.NEXT_PUBLIC_ENVIRONMENT, + }, + instrumentations: [ + ...getWebInstrumentations({captureConsole: true}), + ], + isolate: true, + }); + + faroRef.current = faro + + console.log('Faro Initialized:', faro); + + } catch (error) { + console.error('Error initializing Faro:', error); + } + } + }, []); + + return null; // This component doesn't render anything in the UI +} \ No newline at end of file @@ -17,6 +17,7 @@ import { API_URL } from '#/shared/lib/constants' import { declineToken } from '#/shared/lib/helpers/get-token' import { IProps } from '#/shared/lib/types/entities' import { NavigationSearch } from '#/widgets/navigation-search' +import { faro } from '@grafana/faro-web-sdk' interface InfoBarProps extends IProps {} @@ -153,7 +154,7 @@ const InfoBar: React.FC = ({ device }) => { dispatch(change(null))} + onClick={() => {console.error('ъеъ');dispatch(change(null))}} style={{ cursor: 'pointer', marginLeft: '30px' }} src={'/sleep.svg'} width={20} @@ -8,7 +8,6 @@ import { getModalTest } from '#/../jest/utils/modal-tester' import { api } from '#/shared/api/instance' jest.mock('next/router') -jest.mock('@sentry/nextjs') jest.mock('#/shared/api/instance') @@ -50,10 +49,10 @@ describe('chage-password', () => { email: 'aleksander.freelancer@gmail.com', }) }) - ;(api.patch as jest.Mock).mockResolvedValue({ - status: 200, - data: { detail: 'Host password has been updated' }, - }) + ; (api.patch as jest.Mock).mockResolvedValue({ + status: 200, + data: { detail: 'Host password has been updated' }, + }) const password = screen.getByPlaceholderText('Пароль') const newPassword = screen.getByPlaceholderText('Повторить пароль') @@ -10,7 +10,6 @@ import axios from 'axios' import { sendReport } from '../api' jest.mock('next/router') -jest.mock('@sentry/nextjs') jest.mock('../api') @@ -50,10 +49,10 @@ describe('error-report', () => { act(() => { modal.setState(true) }) - ;(sendReport as jest.Mock).mockResolvedValue({ - status: 201, - data: { detail: 'error report sent' }, - }) + ; (sendReport as jest.Mock).mockResolvedValue({ + status: 201, + data: { detail: 'error report sent' }, + }) const textarea = screen.getByPlaceholderText('Опишите детально возникшую проблему') const button = screen.getByText('Отправить') @@ -5,7 +5,6 @@ import { windowMock } from '#/../jest/utils/window-mock' import { ModelInput } from './model-input' jest.mock('next/router') -jest.mock('@sentry/nextjs') windowMock() @@ -1,18 +0,0 @@ -import { captureMessage } from '@sentry/nextjs' -import { useSession } from 'next-auth/react' - -export function useLoadingLogs() { - const { data } = useSession() - - function onMounted() { - if (!data) return captureMessage(`long time loading - session not defined`) - - const { user } = data - - captureMessage(`long time loading - ${user ? user.email : 'unknown email'} - ${new Date().toDateString()} - ${JSON.stringify(data)}`) - } - - return { - onMounted - } -} @@ -3,18 +3,10 @@ import styles from './slow-loading.module.scss' import { Loader } from '#/shared' import { CommonButton } from '#/shared/ui/button' import { signOut, useSession } from 'next-auth/react' -import { captureMessage } from '@sentry/nextjs' -import { useLoadingLogs } from '../model' -interface SlowLoadingProps {} +interface SlowLoadingProps { } -export const SlowLoading = ({}: SlowLoadingProps) => { - const { onMounted } = useLoadingLogs() - - useEffect(() => { - onMounted() - }, []) - +export const SlowLoading = ({ }: SlowLoadingProps) => { return (
@@ -1,7 +1,6 @@ import axios, { AxiosResponse } from 'axios' import { User } from 'next-auth' import { JWT } from 'next-auth/jwt' -import * as Sentry from '@sentry/browser' import { getAll } from '#/entities/user-account/model/user-type-slice' import { API_URL } from '#/shared/lib/constants' @@ -7,7 +7,6 @@ import type { AppProps } from 'next/app' import { Raleway } from 'next/font/google' import { SessionProvider, getSession } from 'next-auth/react' import { appWithTranslation } from 'next-i18next' -import * as Sentry from '@sentry/browser' import { store, useAppSelector } from '#/app/store/store' @@ -20,7 +19,7 @@ import { pingFangFont } from '#/shared/lib/constants/font/font' import { useBlockTelegram } from '#/shared/lib/hooks/use-block-telegram' import { Error } from '#/shared' import { Providers } from '#/widgets/providers' - +import FrontendObservability from '#/app/components/FrontendObservability' axios.defaults.httpsAgent = new https.Agent({ rejectUnauthorized: false, }) @@ -66,6 +65,7 @@ function App({ Component, pageProps: { session, ...pageProps } }: AppPropsWithLa return ( <> +