- Updated Sentry configuration to include new integrations such as eventFilters, moduleMetadata, httpClient, and reactRouterV6BrowserTracing. - Expanded the list of ignored error patterns to cover more specific cases, improving error handling. - Removed redundant error handling logic from the Sentry initialization process, streamlining the setup. These changes aim to enhance error tracking capabilities and improve overall application stability. Signed-off-by: Innei <tukon479@gmail.com>
33 lines
918 B
TypeScript
33 lines
918 B
TypeScript
import { ELECTRON_BUILD } from "@follow/shared/constants"
|
|
import { whoami } from "@follow/store/user/getters"
|
|
import { appSessionTraceId } from "@follow/utils/environment"
|
|
import { version } from "@pkg"
|
|
import { nanoid } from "nanoid"
|
|
|
|
import { SentryConfig } from "./sentry.config"
|
|
|
|
Object.defineProperty(window.Error.prototype, "traceId", {
|
|
get() {
|
|
if (!this._traceId) {
|
|
this._traceId = nanoid()
|
|
}
|
|
return this._traceId
|
|
},
|
|
})
|
|
export const initSentry = async () => {
|
|
if (!window.SENTRY_RELEASE) return
|
|
if (import.meta.env.DEV) return
|
|
const Sentry = await import("@sentry/react")
|
|
Sentry.init(SentryConfig)
|
|
|
|
const user = whoami()
|
|
if (user) {
|
|
Sentry.setTag("user_id", user.id)
|
|
Sentry.setTag("user_name", user.name)
|
|
}
|
|
|
|
Sentry.setTag("session_trace_id", appSessionTraceId)
|
|
Sentry.setTag("app_version", version)
|
|
Sentry.setTag("build", ELECTRON_BUILD ? "electron" : "web")
|
|
}
|