Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/studio/src/telemetry/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -22,6 +23,7 @@ const EMPTY_META: BrowserSystemMeta = {
device_pixel_ratio: 0,
timezone_offset_minutes: 0,
is_mobile: false,
studio_version: "dev",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: EMPTY_META.studio_version is hardcoded "dev", but __STUDIO_VERSION__ is a build-time constant (not a DOM access), so it's available in the SSR/no-DOM path too. Could use the same typeof __STUDIO_VERSION__ !== "undefined" guard here for consistency — though Studio telemetry rarely fires server-side so impact is low.

};

let cached: BrowserSystemMeta | null = null;
Expand All @@ -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;
4 changes: 3 additions & 1 deletion packages/studio/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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: {
Expand Down
Loading