diff --git a/src/main.tsx b/src/main.tsx index 5b0fd3a09..21b7dc696 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -10,6 +10,7 @@ const sentryDsn = Sentry.init({ dsn: sentryDsn, enabled: Boolean(sentryDsn), + release: __APP_VERSION__, }); Sentry.metrics.count("app_open", 1, { diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 11f02fe2a..dbb4c627d 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -1 +1,3 @@ /// + +declare const __APP_VERSION__: string; diff --git a/vite.config.ts b/vite.config.ts index 6aee1f884..db531818d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,15 +1,25 @@ +import { readFileSync } from "node:fs"; import { defineConfig } from "vitest/config"; import react from "@vitejs/plugin-react"; // @ts-expect-error process is a nodejs global const host = process.env.TAURI_DEV_HOST; +const packageJson = JSON.parse( + readFileSync(new URL("./package.json", import.meta.url), "utf-8"), +) as { + version: string; +}; + // https://vite.dev/config/ export default defineConfig(async () => ({ plugins: [react()], worker: { format: "es", }, + define: { + __APP_VERSION__: JSON.stringify(packageJson.version), + }, test: { environment: "node", include: ["src/**/*.test.ts", "src/**/*.test.tsx"],