Skip to content

Commit 3cc473a

Browse files
authored
chore: add config flags (#129)
1 parent a6f9ce2 commit 3cc473a

File tree

4 files changed

+31
-34
lines changed

4 files changed

+31
-34
lines changed

src/common/atlas/apiClient.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { AccessToken, ClientCredentials } from "simple-oauth2";
44
import { ApiClientError } from "./apiClientError.js";
55
import { paths, operations } from "./openapi.js";
66
import { BaseEvent } from "../../telemetry/types.js";
7-
import { mongoLogId } from "mongodb-log-writer";
8-
import logger from "../../logger.js";
97
import { packageInfo } from "../../packageInfo.js";
108

119
const ATLAS_API_VERSION = "2025-03-12";
@@ -98,11 +96,6 @@ export class ApiClient {
9896
}
9997

10098
public hasCredentials(): boolean {
101-
logger.info(
102-
mongoLogId(1_000_000),
103-
"api-client",
104-
`Checking if API client has credentials: ${!!(this.oauth2Client && this.accessToken)}`
105-
);
10699
return !!(this.oauth2Client && this.accessToken);
107100
}
108101

src/telemetry/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { getMachineIdSync } from "native-machine-id";
22
import { packageInfo } from "../packageInfo.js";
3-
3+
import { type CommonStaticProperties } from "./types.js";
44
/**
55
* Machine-specific metadata formatted for telemetry
66
*/
7-
export const MACHINE_METADATA = {
7+
export const MACHINE_METADATA: CommonStaticProperties = {
88
device_id: getMachineIdSync(),
99
mcp_server_version: packageInfo.version,
1010
mcp_server_name: packageInfo.mcpServerName,

src/telemetry/telemetry.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Session } from "../session.js";
2-
import { BaseEvent } from "./types.js";
2+
import { BaseEvent, CommonProperties } from "./types.js";
33
import { config } from "../config.js";
44
import logger from "../logger.js";
55
import { mongoLogId } from "mongodb-log-writer";
@@ -12,19 +12,6 @@ type EventResult = {
1212
error?: Error;
1313
};
1414

15-
type CommonProperties = {
16-
device_id?: string;
17-
mcp_server_version: string;
18-
mcp_server_name: string;
19-
mcp_client_version?: string;
20-
mcp_client_name?: string;
21-
platform: string;
22-
arch: string;
23-
os_type: string;
24-
os_version?: string;
25-
session_id?: string;
26-
};
27-
2815
export class Telemetry {
2916
private readonly commonProperties: CommonProperties;
3017

@@ -88,6 +75,8 @@ export class Telemetry {
8875
mcp_client_version: this.session.agentRunner?.version,
8976
mcp_client_name: this.session.agentRunner?.name,
9077
session_id: this.session.sessionId,
78+
config_atlas_auth: this.session.apiClient.hasCredentials() ? "true" : "false",
79+
config_connection_string: config.connectionString ? "true" : "false",
9180
};
9281
}
9382

src/telemetry/types.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
export type TelemetryResult = "success" | "failure";
55
export type ServerCommand = "start" | "stop";
6+
export type TelemetryBoolSet = "true" | "false";
67

78
/**
89
* Base interface for all events
@@ -14,21 +15,11 @@ export interface Event {
1415
}
1516

1617
export interface BaseEvent extends Event {
17-
properties: {
18-
device_id?: string;
19-
mcp_server_version: string;
20-
mcp_server_name: string;
21-
mcp_client_version?: string;
22-
mcp_client_name?: string;
23-
platform: string;
24-
arch: string;
25-
os_type: string;
18+
properties: CommonProperties & {
2619
component: string;
2720
duration_ms: number;
2821
result: TelemetryResult;
2922
category: string;
30-
os_version?: string;
31-
session_id?: string;
3223
} & Event["properties"];
3324
}
3425

@@ -58,3 +49,27 @@ export interface ServerEvent extends BaseEvent {
5849
runtime_duration_ms?: number;
5950
} & BaseEvent["properties"];
6051
}
52+
53+
/**
54+
* Interface for static properties, they can be fetched once and reused.
55+
*/
56+
export type CommonStaticProperties = {
57+
device_id?: string;
58+
mcp_server_version: string;
59+
mcp_server_name: string;
60+
platform: string;
61+
arch: string;
62+
os_type: string;
63+
os_version?: string;
64+
};
65+
66+
/**
67+
* Common properties for all events that might change.
68+
*/
69+
export type CommonProperties = {
70+
mcp_client_version?: string;
71+
mcp_client_name?: string;
72+
config_atlas_auth?: TelemetryBoolSet;
73+
config_connection_string?: TelemetryBoolSet;
74+
session_id?: string;
75+
} & CommonStaticProperties;

0 commit comments

Comments
 (0)