refactor: GUI error handling (#9528)

* refactor: error reporting

Signed-off-by: Pranav C <pranavxc@gmail.com>

* refactor: handle ee part

Signed-off-by: Pranav C <pranavxc@gmail.com>

* refactor: coderabbit review comments

Signed-off-by: Pranav C <pranavxc@gmail.com>

* refactor: linting

Signed-off-by: Pranav C <pranavxc@gmail.com>

* refactor: remove duplicate error log

Signed-off-by: Pranav C <pranavxc@gmail.com>

* refactor: request type correction

Signed-off-by: Pranav C <pranavxc@gmail.com>

---------

Signed-off-by: Pranav C <pranavxc@gmail.com>
This commit is contained in:
Pranav C
2024-10-08 11:49:53 +05:30
committed by GitHub
parent 288cfa8b75
commit 21e1f2a9fa
9 changed files with 210 additions and 10 deletions

View File

@@ -20,14 +20,14 @@ export default defineNuxtPlugin((nuxtApp) => {
let initialized = false
const init = () => {
const init = (dsn: string) => {
// prevent multiple init
if (initialized) return
initialized = true
Sentry.init({
app: [vueApp],
dsn: 'https://64cb4904bcbec03a1b9a0be02a2d10a9@o4505953073889280.ingest.us.sentry.io/4507725383663616',
dsn,
environment: env,
integrations: [
new Sentry.BrowserTracing({
@@ -56,11 +56,14 @@ export default defineNuxtPlugin((nuxtApp) => {
// load sentry only if enabled
watch(
() => (nuxtApp.$state as ReturnType<typeof useGlobal>).appInfo?.value?.errorReportingEnabled,
(enabled) => {
[
() => (nuxtApp.$state as ReturnType<typeof useGlobal>).appInfo?.value?.errorReportingEnabled,
() => (nuxtApp.$state as ReturnType<typeof useGlobal>).appInfo?.value?.sentryDSN,
],
([enabled, sentryDSN]) => {
try {
if (enabled) init()
} catch (e) {
if (enabled && sentryDSN) init(sentryDSN)
} catch {
// ignore
}
},