mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-01 19:42:03 +00:00
fix(studio): inject version from package.json and include in all telemetry events (#1151)
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user