{"version":3,"file":"static/chunks/61558.4f43ddd4d103c576.js","sources":["webpack://_N_E/./src/LegacyApp/client/modules/app/sentryClass.ts"],"sourceRoot":"","sourcesContent":["import * as Sentry from '@sentry/browser';\nimport { NEXT_CONFIG } from '@common/constants/config/nextConfig';\nimport { lsGet } from '@modules/localStorage/methods/lsGet';\nimport { LocalStorageKeysType } from '@modules/localStorage/types/localStorageKeys.type';\nimport { jsonToString } from '@common/methods/jsonToString';\nimport fetchService from './fetchService';\nimport { cloneObj } from './appService';\n\nconst STACKTRACE_EXCEPTIONS = [\n\t'fengari-web',\n\t'',\n\t'',\n\t'assets/script',\n];\n\nconst EXACT_MESSAGE_EXCEPTIONS = [\n\t'Script error.',\n\t'Timeout',\n\t// 'Failed to fetch',\n\t'Invalid sentry error',\n];\n\nconst MESSAGE_EXCEPTIONS = [\n\t'Request failed with status code',\n\t'Paho is not defined',\n\t'Non-Error promise rejection captured with keys',\n\t\"Unexpected token 'else'\",\n\t\"Unexpected identifier 'script'\",\n\t'$(',\n\t'$ is not defined',\n\t'_avast_submit',\n\t'Unexpected end of input',\n\t'Non-Error promise rejection captured with',\n\t\"Cannot read property 'disconnect' of null\",\n\t\"Cannot read property 'click' of null\",\n\t'SecurityError: The operation is insecure.',\n\t'N.apply is not a function',\n\t'NS_ERROR_FILE_CORRUPTED',\n\t'Non-Error promise rejection captured with value: Timeout',\n];\n\nexport class sentryClass {\n\tpublic dsn: any;\n\tpublic instance: typeof Sentry;\n\tpublic isActive: boolean;\n\tpublic state: string;\n\tpublic store: any;\n\n\tconstructor(dsn) {\n\t\tthis.dsn = dsn;\n\t\tthis.instance = Sentry;\n\t\tthis.isActive = !NEXT_CONFIG.DEV;\n\t\tthis.state = '{}';\n\t\tthis.store = null;\n\t\tthis.init();\n\t}\n\n\taddStore = () => {\n\t\t// this.store = store;\n\t};\n\n\tinit() {\n\t\tif (!this.isActive) {\n\t\t\treturn;\n\t\t}\n\t\tconst options: Sentry.BrowserOptions = {\n\t\t\tdsn: this.dsn,\n\t\t\t// eslint-disable-next-line no-undef\n\t\t\tenvironment: NEXT_CONFIG.APP_ENV,\n\t\t\t// eslint-disable-next-line no-undef\n\t\t\trelease: NEXT_CONFIG.RELEASE_VERSION,\n\t\t\t// This sets the sample rate to be 10%. You may want this to be 100% while\n\t\t\t// in development and sample at a lower rate in production\n\t\t\treplaysSessionSampleRate: 0.1,\n\t\t\t// If the entire session is not sampled, use the below sample rate to sample\n\t\t\t// sessions when an error occurs.\n\t\t\treplaysOnErrorSampleRate: 1.0,\n\t\t\tautoSessionTracking: false,\n\t\t\tbeforeSend(event, hint) {\n\t\t\t\tconst firstExceptionValues = event?.exception?.values?.[0];\n\t\t\t\tconst firstStackTraceFileName =\n\t\t\t\t\tfirstExceptionValues?.stacktrace?.frames?.[0]?.filename;\n\t\t\t\tif (\n\t\t\t\t\tfirstStackTraceFileName &&\n\t\t\t\t\t!!STACKTRACE_EXCEPTIONS.find((name) => {\n\t\t\t\t\t\tconst frames = firstExceptionValues?.stacktrace?.frames;\n\t\t\t\t\t\tif (!frames?.length) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn !!frames.find((frame) => frame.filename.indexOf(name) > -1);\n\t\t\t\t\t})\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tconst error = hint.originalException;\n\t\t\t\tconst messageFromError =\n\t\t\t\t\t// @ts-expect-error invalid type\n\t\t\t\t\ttypeof error === 'string' ? error : error?.message;\n\t\t\t\tconst message =\n\t\t\t\t\tmessageFromError ||\n\t\t\t\t\tfirstExceptionValues?.value ||\n\t\t\t\t\t'Invalid sentry error';\n\t\t\t\tif (message && EXACT_MESSAGE_EXCEPTIONS.some((el) => message === el)) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tmessage &&\n\t\t\t\t\tMESSAGE_EXCEPTIONS.some((el) => message.indexOf(el) > -1)\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\treturn event;\n\t\t\t},\n\t\t};\n\t\tthis.instance.init(options);\n\t}\n\n\tparseState(state) {\n\t\treturn cloneObj({\n\t\t\t...state,\n\t\t\twebsocket: {\n\t\t\t\t...state.websocket,\n\t\t\t\tchannels: Object.keys(state.websocket.channels),\n\t\t\t},\n\t\t\tuser: this.getUserState(state),\n\t\t});\n\t}\n\n\tupdateState() {\n\t\tif (!this.isActive) {\n\t\t\treturn;\n\t\t}\n\t\tconst parsed = this.getState();\n\t\tconst stringState = jsonToString(parsed);\n\t\tif (stringState === this.state) {\n\t\t\treturn;\n\t\t}\n\t\tthis.state = stringState;\n\t\tSentry.configureScope((scope) => {\n\t\t\tscope.setExtras({\n\t\t\t\t...this.getExtras(parsed),\n\t\t\t});\n\t\t});\n\t}\n\n\tupdateUser(state) {\n\t\tif (!this.isActive) {\n\t\t\treturn;\n\t\t}\n\t\tSentry.configureScope((scope) => {\n\t\t\tscope.setUser({\n\t\t\t\temail: state.user.email,\n\t\t\t\tusername: state.user.name,\n\t\t\t});\n\t\t});\n\t}\n\n\tgetUserState(state) {\n\t\tif (!state.user) {\n\t\t\treturn {};\n\t\t}\n\t\treturn {\n\t\t\t...state.user,\n\t\t\ttoken: {\n\t\t\t\t...state.user.token,\n\t\t\t\tvalue: state.user.isLogged,\n\t\t\t},\n\t\t};\n\t}\n\n\tgetState() {\n\t\treturn {};\n\t\t// const {\n\t\t// user,\n\t\t// app,\n\t\t// game,\n\t\t// gameAutobet,\n\t\t// twoFa,\n\t\t// forms,\n\t\t// vip,\n\t\t// chat,\n\t\t// } = this.parseState(state || {});\n\t\t// const {\n\t\t// menuList,\n\t\t// ...appState\n\t\t// } = app;\n\t\t// const {\n\t\t// stream,\n\t\t// users,\n\t\t// ...chatState\n\t\t// } = chat;\n\t\t// return {\n\t\t// user,\n\t\t// app: appState,\n\t\t// chat: chatState,\n\t\t// game,\n\t\t// gameAutobet,\n\t\t// twoFa,\n\t\t// forms,\n\t\t// vip,\n\t\t// };\n\t}\n\n\tgetExtras(errorInfo) {\n\t\tconst localStorage: Record = {};\n\t\tif (process.browser) {\n\t\t\tObject.keys(window.localStorage).forEach((key: LocalStorageKeysType) => {\n\t\t\t\tlocalStorage[key] = lsGet(key);\n\t\t\t});\n\t\t}\n\t\tif (localStorage.token) {\n\t\t\tlocalStorage.token.value = `${localStorage.token.value.slice(0, 15)}...`;\n\t\t}\n\t\tconst fetch = {};\n\t\tconst fetchHistory = fetchService.requestHistory || {};\n\t\tObject.keys(fetchHistory).forEach((key) => {\n\t\t\tfetch[key] = fetchHistory[key].map((el) => jsonToString(el));\n\t\t});\n\t\treturn {\n\t\t\terrorInfo,\n\t\t\t// state: this.getState(),\n\t\t\tfetch,\n\t\t\t// localStorage,\n\t\t\t// cookies: document.cookie,\n\t\t};\n\t}\n\n\tsendError(error, errorInfo) {\n\t\tconst extras = this.getExtras(errorInfo);\n\t\tconsole.error(\n\t\t\t'sendSentryError',\n\t\t\t{\n\t\t\t\terror,\n\t\t\t\textras,\n\t\t\t\tSentry,\n\t\t\t},\n\t\t\terrorInfo,\n\t\t);\n\t\tif (!this.isActive || !this.instance || !Sentry) {\n\t\t\treturn false;\n\t\t}\n\t\tSentry.withScope((scope) => {\n\t\t\tscope.setExtras(extras);\n\t\t\tSentry.captureException(error);\n\t\t});\n\t}\n}\n"],"names":["STACKTRACE_EXCEPTIONS","EXACT_MESSAGE_EXCEPTIONS","MESSAGE_EXCEPTIONS","sentryClass","dsn","this","instance","Sentry","isActive","NEXT_CONFIG","state","store","init","options","environment","release","replaysSessionSampleRate","replaysOnErrorSampleRate","autoSessionTracking","beforeSend","event","hint","firstExceptionValues","exception","values","stacktrace","frames","filename","find","name","length","frame","indexOf","error","originalException","message","value","some","el","cloneObj","websocket","channels","Object","keys","user","getUserState","parsed","getState","stringState","jsonToString","scope","setExtras","getExtras","setUser","email","username","token","isLogged","errorInfo","localStorage","window","forEach","key","lsGet","slice","fetch","fetchHistory","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