Skip to content

Commit 003a076

Browse files
committed
fix: make telemetry version access safe
1 parent 755a36b commit 003a076

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/telemetry/utils.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,20 @@ import { VERSION } from "../version";
88
/**
99
* Get base telemetry properties included with all events
1010
*/
11+
function resolveGitDescribe(value: unknown): string {
12+
if (typeof value === "object" && value !== null && "git_describe" in value) {
13+
const describe = (value as Record<string, unknown>).git_describe;
14+
if (typeof describe === "string") {
15+
return describe;
16+
}
17+
}
18+
19+
return "unknown";
20+
}
21+
1122
export function getBaseTelemetryProperties(): BaseTelemetryProperties {
1223
return {
13-
version: String(VERSION.git_describe),
24+
version: resolveGitDescribe(VERSION),
1425
platform: window.api?.platform || "unknown",
1526
electronVersion: window.api?.versions?.electron || "unknown",
1627
};

src/utils/tools/toolDefinitions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ export const TOOL_DEFINITIONS = {
125125
create: z
126126
.boolean()
127127
.optional()
128-
.describe("Legacy compatibility; files are created automatically when missing, so this flag is ignored."),
128+
.describe(
129+
"Legacy compatibility; files are created automatically when missing, so this flag is ignored."
130+
),
129131
before: z
130132
.string()
131133
.min(1)

0 commit comments

Comments
 (0)