From 57d26a096c374ec6425a6388e7c654ab6624f7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Mon, 1 Jun 2026 16:10:44 -0400 Subject: [PATCH] fix(studio): inject version from package.json and include in all telemetry events The Vite build relied on process.env.npm_package_version which is only set when invoked through npm/bun run scripts. CI builds running vite build directly got "dev" as the version. Read package.json directly so the version is always correct regardless of invocation method. Also add studio_version to the BrowserSystemMeta interface so the new telemetry system (studio_session_start, studio_render_start, etc.) includes the deployed version in every event. --- packages/studio/src/telemetry/system.ts | 5 +++++ packages/studio/vite.config.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/studio/src/telemetry/system.ts b/packages/studio/src/telemetry/system.ts index f785c1b96c..73d5fc1f16 100644 --- a/packages/studio/src/telemetry/system.ts +++ b/packages/studio/src/telemetry/system.ts @@ -12,6 +12,7 @@ export interface BrowserSystemMeta { device_pixel_ratio: number; timezone_offset_minutes: number; is_mobile: boolean; + studio_version: string; } const EMPTY_META: BrowserSystemMeta = { @@ -22,6 +23,7 @@ const EMPTY_META: BrowserSystemMeta = { device_pixel_ratio: 0, timezone_offset_minutes: 0, is_mobile: false, + studio_version: "dev", }; let cached: BrowserSystemMeta | null = null; @@ -43,6 +45,9 @@ export function getBrowserSystemMeta(): BrowserSystemMeta { device_pixel_ratio: window.devicePixelRatio, timezone_offset_minutes: new Date().getTimezoneOffset(), is_mobile: /Android|iPhone|iPad/i.test(ua), + studio_version: typeof __STUDIO_VERSION__ !== "undefined" ? __STUDIO_VERSION__ : "dev", }; return cached; } + +declare const __STUDIO_VERSION__: string; diff --git a/packages/studio/vite.config.ts b/packages/studio/vite.config.ts index 57713807f4..fd213fd6f6 100644 --- a/packages/studio/vite.config.ts +++ b/packages/studio/vite.config.ts @@ -21,6 +21,8 @@ async function loadRuntimeSourceForDev( return null; } +const studioPkg = JSON.parse(readFileSync(resolve(__dirname, "package.json"), "utf-8")); + // ── Bridge Hono fetch → Node http response ─────────────────────────────────── async function bridgeHonoResponse( @@ -167,7 +169,7 @@ function devProjectApi(): Plugin { export default defineConfig({ plugins: [react(), devProjectApi()], define: { - __STUDIO_VERSION__: JSON.stringify(process.env.npm_package_version ?? "dev"), + __STUDIO_VERSION__: JSON.stringify(studioPkg.version), }, resolve: { alias: {