Skip to content

Commit 13fc7fc

Browse files
committed
Add docs
1 parent 2d3c184 commit 13fc7fc

File tree

3 files changed

+69
-4
lines changed

3 files changed

+69
-4
lines changed

src/telemetry/telemetry.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ type EventResult = {
1414
};
1515

1616
export class Telemetry {
17-
public static hostingMode?: string;
17+
public static baseCommonProperties: CommonProperties = {
18+
...MACHINE_METADATA,
19+
hosting_mode: "standalone",
20+
};
1821

1922
private isBufferingEvents: boolean = true;
2023
/** Resolves when the setup is complete or a timeout occurs */
@@ -37,14 +40,13 @@ export class Telemetry {
3740
userConfig: UserConfig,
3841
deviceId: DeviceId,
3942
{
40-
commonProperties = { ...MACHINE_METADATA },
43+
commonProperties = this.baseCommonProperties,
4144
eventCache = EventCache.getInstance(),
4245
}: {
4346
eventCache?: EventCache;
4447
commonProperties?: CommonProperties;
4548
} = {}
4649
): Telemetry {
47-
commonProperties.hosting_mode = Telemetry.hostingMode;
4850
const instance = new Telemetry(session, userConfig, commonProperties, { eventCache, deviceId });
4951

5052
void instance.setup();

src/telemetry/types.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,85 @@ export type ServerEvent = TelemetryEvent<ServerEventProperties>;
5353
* Interface for static properties, they can be fetched once and reused.
5454
*/
5555
export type CommonStaticProperties = {
56+
/**
57+
* The version of the MCP server (as read from package.json).
58+
*/
5659
mcp_server_version: string;
60+
61+
/**
62+
* The name of the MCP server (as read from package.json).
63+
*/
5764
mcp_server_name: string;
65+
66+
/**
67+
* The platform/OS the MCP server is running on.
68+
*/
5869
platform: string;
70+
71+
/**
72+
* The architecture of the OS the server is running on.
73+
*/
5974
arch: string;
75+
76+
/**
77+
* Same as platform.
78+
*/
6079
os_type: string;
80+
81+
/**
82+
* The version of the OS the server is running on.
83+
*/
6184
os_version?: string;
6285
};
6386

6487
/**
6588
* Common properties for all events that might change.
6689
*/
6790
export type CommonProperties = {
91+
/**
92+
* The device id - will be populated with the machine id when it resolves.
93+
*/
6894
device_id?: string;
95+
96+
/**
97+
* A boolean indicating whether the server is running in a container environment.
98+
*/
6999
is_container_env?: boolean;
100+
101+
/**
102+
* The version of the MCP client as reported by the client on session establishment.
103+
*/
70104
mcp_client_version?: string;
105+
106+
/**
107+
* The name of the MCP client as reported by the client on session establishment.
108+
*/
71109
mcp_client_name?: string;
110+
111+
/**
112+
* The transport protocol used by the MCP server.
113+
*/
72114
transport?: "stdio" | "http";
115+
116+
/**
117+
* A boolean indicating whether Atlas credentials are configured.
118+
*/
73119
config_atlas_auth?: TelemetryBoolSet;
120+
121+
/**
122+
* A boolean indicating whether a connection string is configured.
123+
*/
74124
config_connection_string?: TelemetryBoolSet;
125+
126+
/**
127+
* The randomly generated session id.
128+
*/
75129
session_id?: string;
130+
131+
/**
132+
* The way the MCP server is hosted - e.g. standalone for a server running independently or
133+
* "vscode" if embedded in the VSCode extension. This field should be populated by the hosting
134+
* application to differentiate events coming from an MCP server it's hosting.
135+
*/
76136
hosting_mode?: string;
77137
} & CommonStaticProperties;

tests/unit/telemetry.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ describe("Telemetry", () => {
214214
});
215215

216216
it("should add hostingMode to events if set", async () => {
217-
Telemetry.hostingMode = "vscode-extension";
217+
Telemetry.baseCommonProperties = {
218+
...Telemetry.baseCommonProperties,
219+
hosting_mode: "vscode-extension",
220+
};
218221
telemetry = Telemetry.create(session, config, mockDeviceId, {
219222
eventCache: mockEventCache as unknown as EventCache,
220223
});

0 commit comments

Comments
 (0)