浏览代码

feature(logging): добавлено логирование sentry; обновлён .env.example;

horanchikk 10 月之前
父节点
当前提交
f36e538b88
共有 6 个文件被更改,包括 57 次插入3 次删除
  1. 7 1
      .env.example
  2. 4 2
      components/Base/Header.vue
  3. 16 0
      env.d.ts
  4. 15 0
      nuxt.config.ts
  5. 1 0
      package.json
  6. 14 0
      sentry.client.config.ts

+ 7 - 1
.env.example

@@ -1,3 +1,9 @@
 API_URL=http://localhost:8000
+
 ACCOUNT_LOGIN=
-ACCOUNT_PASSWD=
+ACCOUNT_PASSWD=
+
+SENTRY_ORG=
+SENTRY_PROJECT=
+SENTRY_AUTH_TOKEN=
+SENTRY_DSN=

+ 4 - 2
components/Base/Header.vue

@@ -82,9 +82,11 @@ const menu = [
     action: () => debug.show(),
   },
   {
-    name: 'Debug',
+    name: 'Trigger error',
     icon: 'bug-report',
-    action: () => debug.show(),
+    action: () => {
+      throw new Error('Test Error <3')
+    },
   },
 ]
 </script>

+ 16 - 0
env.d.ts

@@ -0,0 +1,16 @@
+declare global {
+  namespace NodeJS {
+    interface ProcessEnv {
+      API_URL: string
+      ACCOUNT_LOGIN: string
+      ACCOUNT_PASSWD: string
+
+      SENTRY_ORG: string
+      SENTRY_PROJECT: string
+      SENTRY_AUTH_TOKEN: string
+      SENTRY_DSN: string
+    }
+  }
+}
+
+export {}

+ 15 - 0
nuxt.config.ts

@@ -7,6 +7,7 @@ export default defineNuxtConfig({
     '@nuxt/eslint',
     '@pinia/nuxt',
     '@formkit/auto-animate/nuxt',
+    '@sentry/nuxt/module',
     'nuxt-booster',
     'nuxt-svgo',
   ],
@@ -25,8 +26,13 @@ export default defineNuxtConfig({
       API_URL: process.env.API_URL || 'http://localhost:8000',
       ACCOUNT_LOGIN: process.env.ACCOUNT_LOGIN,
       ACCOUNT_PASSWD: process.env.ACCOUNT_PASSWD,
+      SENTRY_DSN: process.env.SENTRY_DSN,
     },
   },
+
+  sourcemap: {
+    client: true,
+  },
   devServer: {
     port: 3000,
   },
@@ -43,6 +49,14 @@ export default defineNuxtConfig({
     },
   },
 
+  sentry: {
+    sourceMapsUploadOptions: {
+      org: process.env.SENTRY_ORG,
+      project: process.env.SENTRY_PROJECT,
+      authToken: process.env.SENTRY_AUTH_TOKEN,
+    },
+  },
+
   svgo: {
     autoImportPath: '~/assets/icons',
     componentPrefix: 'i',
@@ -75,4 +89,5 @@ export default defineNuxtConfig({
       },
     },
   },
+
 })

+ 1 - 0
package.json

@@ -27,6 +27,7 @@
     "@milkdown/kit": "^7.5.5",
     "@milkdown/theme-nord": "^7.5.0",
     "@milkdown/vue": "^7.5.0",
+    "@sentry/nuxt": "^8.38.0",
     "@types/pako": "^2.0.3",
     "@types/turndown": "^5.0.5",
     "@vueuse/components": "^11.1.0",

+ 14 - 0
sentry.client.config.ts

@@ -0,0 +1,14 @@
+import * as Sentry from '@sentry/nuxt'
+
+const { public: { SENTRY_DSN } } = useRuntimeConfig()
+
+Sentry.init({
+  dsn: SENTRY_DSN,
+  integrations: [Sentry.replayIntegration()],
+
+  tracesSampleRate: 1.0,
+  tracePropagationTargets: ['localhost'],
+
+  replaysSessionSampleRate: 0.1,
+  replaysOnErrorSampleRate: 1.0,
+})