Skip to content

Commit f0142ec

Browse files
committed
address comments: inject userconfig in telemetry
1 parent 3eee38c commit f0142ec

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class Server {
2828
constructor({ session, mcpServer, userConfig }: ServerOptions) {
2929
this.startTime = Date.now();
3030
this.session = session;
31-
this.telemetry = new Telemetry(session);
31+
this.telemetry = new Telemetry(session, userConfig);
3232
this.mcpServer = mcpServer;
3333
this.userConfig = userConfig;
3434
}

src/telemetry/telemetry.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Session } from "../session.js";
22
import { BaseEvent, CommonProperties } from "./types.js";
3-
import { config } from "../config.js";
3+
import { UserConfig } from "../config.js";
44
import logger, { LogId } from "../logger.js";
55
import { ApiClient } from "../common/atlas/apiClient.js";
66
import { MACHINE_METADATA } from "./constants.js";
@@ -16,6 +16,7 @@ export class Telemetry {
1616

1717
constructor(
1818
private readonly session: Session,
19+
private readonly userConfig: UserConfig,
1920
private readonly eventCache: EventCache = EventCache.getInstance()
2021
) {
2122
this.commonProperties = {
@@ -51,7 +52,7 @@ export class Telemetry {
5152
mcp_client_name: this.session.agentRunner?.name,
5253
session_id: this.session.sessionId,
5354
config_atlas_auth: this.session.apiClient.hasCredentials() ? "true" : "false",
54-
config_connection_string: config.connectionString ? "true" : "false",
55+
config_connection_string: this.userConfig.connectionString ? "true" : "false",
5556
};
5657
}
5758

@@ -64,7 +65,7 @@ export class Telemetry {
6465
*/
6566
public isTelemetryEnabled(): boolean {
6667
// Check if telemetry is explicitly disabled in config
67-
if (config.telemetry === "disabled") {
68+
if (this.userConfig.telemetry === "disabled") {
6869
return false;
6970
}
7071

tests/unit/telemetry.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ describe("Telemetry", () => {
113113
} as unknown as Session;
114114

115115
// Create the telemetry instance with mocked dependencies
116-
telemetry = new Telemetry(session, mockEventCache);
117-
116+
telemetry = new Telemetry(session, config, mockEventCache);
118117
config.telemetry = "enabled";
119118
});
120119

0 commit comments

Comments
 (0)