mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
feat(telemetry): include host OS properties
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@kilocode/kilo-telemetry": patch
|
||||
---
|
||||
|
||||
Include the host operating system name, version, and architecture in telemetry events.
|
||||
@@ -1,4 +1,6 @@
|
||||
import { describe, test, expect, beforeEach } from "bun:test"
|
||||
import { arch, platform, release } from "node:os"
|
||||
import { describe, test, expect, beforeEach, spyOn } from "bun:test"
|
||||
import { Client } from "../client.js"
|
||||
import { Identity } from "../identity.js"
|
||||
import { TelemetryEvent } from "../events.js"
|
||||
import { Telemetry } from "../telemetry.js"
|
||||
@@ -83,6 +85,26 @@ describe("TelemetryEvent", () => {
|
||||
})
|
||||
|
||||
describe("Telemetry", () => {
|
||||
test("includes immutable host OS properties", () => {
|
||||
const capture = spyOn(Client, "capture").mockImplementation(() => {})
|
||||
|
||||
Telemetry.track(TelemetryEvent.CLI_START, {
|
||||
os_name: "overridden",
|
||||
os_version: "overridden",
|
||||
os_arch: "overridden",
|
||||
})
|
||||
|
||||
expect(capture).toHaveBeenCalledWith(
|
||||
TelemetryEvent.CLI_START,
|
||||
expect.objectContaining({
|
||||
os_name: platform(),
|
||||
os_version: release(),
|
||||
os_arch: arch(),
|
||||
}),
|
||||
)
|
||||
capture.mockRestore()
|
||||
})
|
||||
|
||||
test("indexing helpers are exposed", () => {
|
||||
expect(typeof Telemetry.trackIndexingStarted).toBe("function")
|
||||
expect(typeof Telemetry.trackIndexingCompleted).toBe("function")
|
||||
@@ -96,4 +118,3 @@ describe("Telemetry", () => {
|
||||
expect(typeof Telemetry.trackSuggestionAccepted).toBe("function")
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { release } from "node:os"
|
||||
import { Client } from "./client.js"
|
||||
import { Identity } from "./identity.js"
|
||||
import { TelemetryEvent } from "./events.js"
|
||||
@@ -6,6 +7,9 @@ export interface TelemetryProperties {
|
||||
appName: string
|
||||
appVersion: string
|
||||
platform: string
|
||||
os_name: string
|
||||
os_version: string
|
||||
os_arch: string
|
||||
editorName?: string
|
||||
vscodeVersion?: string
|
||||
}
|
||||
@@ -58,6 +62,9 @@ export namespace Telemetry {
|
||||
appName: "kilo-cli",
|
||||
appVersion: "unknown",
|
||||
platform: process.platform,
|
||||
os_name: process.platform,
|
||||
os_version: release(),
|
||||
os_arch: process.arch,
|
||||
}
|
||||
|
||||
export async function init(options: { dataPath: string; version: string; enabled: boolean }): Promise<void> {
|
||||
@@ -109,6 +116,9 @@ export namespace Telemetry {
|
||||
appName: props.appName,
|
||||
appVersion: props.appVersion,
|
||||
platform: props.platform,
|
||||
os_name: props.os_name,
|
||||
os_version: props.os_version,
|
||||
os_arch: props.os_arch,
|
||||
})
|
||||
|
||||
// Link the anonymous machineId to the authenticated email
|
||||
@@ -117,7 +127,13 @@ export namespace Telemetry {
|
||||
}
|
||||
|
||||
export function track(event: TelemetryEvent, properties?: Record<string, unknown>) {
|
||||
Client.capture(event, { ...props, ...properties })
|
||||
Client.capture(event, {
|
||||
...props,
|
||||
...properties,
|
||||
os_name: props.os_name,
|
||||
os_version: props.os_version,
|
||||
os_arch: props.os_arch,
|
||||
})
|
||||
}
|
||||
|
||||
// CLI Lifecycle
|
||||
|
||||
Reference in New Issue
Block a user