diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index 3ca11459..332ff1b7 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -122,7 +122,6 @@ jobs: run: npm ci - name: Build Cef-html env: - SENTRY_URL: ${{ secrets.SentryUrl }} SENTRY_AUTH_TOKEN: ${{ secrets.SentryAuthToken }} run: npm run prod - name: Upload Cef-html artifacts diff --git a/src/app.js b/src/app.js index 9f7fd4c1..a225cdca 100644 --- a/src/app.js +++ b/src/app.js @@ -20,7 +20,7 @@ app.use(pinia); app.use(i18n); app.use(ElementPlus); initComponents(app); -initSentry(app); +await initSentry(app); app.mount('#root'); diff --git a/src/plugin/sentry.js b/src/plugin/sentry.js index ec986827..d5a2a7c4 100644 --- a/src/plugin/sentry.js +++ b/src/plugin/sentry.js @@ -34,6 +34,7 @@ export async function initSentry(app) { app, dsn, environment: 'nightly', + release: version, replaysSessionSampleRate: 0.1, replaysOnErrorSampleRate: 1.0, beforeSend(event, hint) { diff --git a/src/vite.config.js b/src/vite.config.js index 19c17204..d94c878a 100644 --- a/src/vite.config.js +++ b/src/vite.config.js @@ -3,22 +3,35 @@ import vue from '@vitejs/plugin-vue'; import { sentryVitePlugin } from '@sentry/vite-plugin'; import { fileURLToPath } from 'node:url'; import { dirname, resolve } from 'node:path'; +import fs from 'node:fs'; const __dirname = dirname(fileURLToPath(import.meta.url)); -const url = process.env.SENTRY_URL; + const authToken = process.env.SENTRY_AUTH_TOKEN; +const buildAndUploadSourceMaps = authToken ? true : false; +const vrcxVersion = fs + .readFileSync(resolve(__dirname, '../Version'), 'utf-8') + .trim(); +if (buildAndUploadSourceMaps) { + console.log('Source maps will be built and uploaded to Sentry'); +} // https://vite.dev/config/ export default defineConfig(() => ({ base: '', plugins: [ vue(), - url && + buildAndUploadSourceMaps && sentryVitePlugin({ - url, authToken, - org: 'vrcx', - project: 'vrcx-web' + project: 'vrcx-web', + release: { + name: vrcxVersion + }, + sourcemaps: { + assets: './build/html/**', + filesToDeleteAfterUpload: './build/html/**/*.js.map' + } }) ], define: { @@ -42,6 +55,6 @@ export default defineConfig(() => ({ vr: resolve(__dirname, 'vr.html') } }, - sourcemap: true + sourcemap: buildAndUploadSourceMaps } }));