Skip to content

Commit c52d91f

Browse files
committed
fixes and add test
1 parent afe863e commit c52d91f

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

src/telemetry/telemetry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Session } from "../common/session.js";
2-
import type { BaseEvent, CommonProperties, TelemetryEvent } from "./types.js";
2+
import type { BaseEvent, CommonProperties } from "./types.js";
33
import type { UserConfig } from "../common/config.js";
44
import { LogId } from "../common/logger.js";
55
import type { ApiClient } from "../common/atlas/apiClient.js";
@@ -80,7 +80,7 @@ export class Telemetry {
8080
const [deviceIdValue, containerEnv] = await this.setupPromise;
8181

8282
this.commonProperties.device_id = deviceIdValue;
83-
this.commonProperties.is_container_env = containerEnv;
83+
this.commonProperties.is_container_env = containerEnv ? "true" : "false";
8484

8585
this.isBufferingEvents = false;
8686
}

src/telemetry/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export type CommonProperties = {
9797
/**
9898
* A boolean indicating whether the server is running in a container environment.
9999
*/
100-
is_container_env?: boolean;
100+
is_container_env?: TelemetryBoolSet;
101101

102102
/**
103103
* The version of the MCP client as reported by the client on session establishment.

tests/integration/telemetry.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,32 @@ describe("Telemetry", () => {
3636
expect(telemetry.getCommonProperties().device_id).toBe(actualDeviceId);
3737
expect(telemetry["isBufferingEvents"]).toBe(false);
3838
});
39+
40+
it("should redact sensitive data", async () => {
41+
const logger = new CompositeLogger();
42+
const deviceId = DeviceId.create(logger);
43+
44+
// configure keychain with a secret that would show up in random properties
45+
const keychain = new Keychain();
46+
keychain.register(process.platform, "url");
47+
48+
const telemetry = Telemetry.create(
49+
new Session({
50+
apiBaseUrl: "",
51+
logger,
52+
exportsManager: ExportsManager.init(config, logger),
53+
connectionManager: new MCPConnectionManager(config, driverOptions, logger, deviceId),
54+
keychain: keychain,
55+
}),
56+
config,
57+
deviceId
58+
);
59+
60+
await telemetry.setupPromise;
61+
62+
// expect the platform to be redacted
63+
const commonProperties = telemetry.getCommonProperties();
64+
expect(commonProperties.platform).toBe("<url>");
65+
expect(telemetry["isBufferingEvents"]).toBe(false);
66+
});
3967
});

0 commit comments

Comments
 (0)