Skip to content

chore: reinstate telemetry/docker change after revert MCP-49 #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 4, 2025
Merged

Conversation

fmenezes
Copy link
Collaborator

@fmenezes fmenezes commented Jul 3, 2025

Proposed changes

changes were initially introduced at #298 which caused #320 and reverted at #330, I'm adding it back without any refactorings

Checklist

@fmenezes fmenezes marked this pull request as ready for review July 3, 2025 17:26
@Copilot Copilot AI review requested due to automatic review settings July 3, 2025 17:26
@fmenezes fmenezes requested a review from a team as a code owner July 3, 2025 17:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR reinstates the previously reverted telemetry and Docker environment detection changes without any additional refactorings.

  • Re-adds container environment detection alongside device ID retrieval
  • Updates telemetry types to include a new is_container_env property
  • Adjusts unit and integration tests to await the combined dataPromise instead of deviceIdPromise

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/unit/telemetry.test.ts Updated tests to await telemetry.dataPromise instead of deviceIdPromise
tests/integration/telemetry.test.ts Updated integration test to await telemetry.dataPromise
src/telemetry/types.ts Added new optional is_container_env field to CommonProperties
src/telemetry/telemetry.ts Implemented isContainerEnv check, merged device ID and container flag into dataPromise
Comments suppressed due to low confidence (3)

src/telemetry/types.ts:69

  • Add a JSDoc comment to describe the purpose and possible values for the new is_container_env property, improving clarity for API consumers.
    is_container_env?: boolean;

src/telemetry/telemetry.ts:22

  • [nitpick] The name dataPromise is ambiguous. Consider renaming it to something more descriptive, like deviceDataPromise or initializationPromise.
    public dataPromise: Promise<[string, boolean]> | undefined;

src/telemetry/telemetry.ts:102

  • Add unit tests to verify that is_container_env is correctly set based on the detected environment, covering both container and non-container scenarios.
        this.commonProperties.is_container_env = containerEnv;

@@ -52,11 +53,32 @@ export class Telemetry {
return instance;
}

private async isContainerEnv(): Promise<boolean> {
Copy link
Preview

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider using Promise.any instead of Promise.all when checking file existence to short-circuit on the first success and avoid unnecessary filesystem checks.

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't have thought of this myself but that is a good point 🤖

@coveralls
Copy link
Collaborator

coveralls commented Jul 3, 2025

Pull Request Test Coverage Report for Build 16076959781

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 20 of 24 (83.33%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 74.187%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/telemetry/telemetry.ts 20 24 83.33%
Totals Coverage Status
Change from base Build 16021965229: -0.1%
Covered Lines: 816
Relevant Lines: 1020

💛 - Coveralls

Copy link
Collaborator

@gagik gagik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, non-blocking subjective stylistic changes you can consider

@@ -18,7 +19,7 @@ export const DEVICE_ID_TIMEOUT = 3000;
export class Telemetry {
private isBufferingEvents: boolean = true;
/** Resolves when the device ID is retrieved or timeout occurs */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** Resolves when the device ID is retrieved or timeout occurs */
/** Resolves when the setup is complete or a timeout occurs */

@@ -18,7 +19,7 @@ export const DEVICE_ID_TIMEOUT = 3000;
export class Telemetry {
private isBufferingEvents: boolean = true;
/** Resolves when the device ID is retrieved or timeout occurs */
public deviceIdPromise: Promise<string> | undefined;
public dataPromise: Promise<[string, boolean]> | undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public dataPromise: Promise<[string, boolean]> | undefined;
public setupPromise: Promise<[string, boolean]> | undefined;

super nit, just may be a nicer name

@@ -52,11 +53,32 @@ export class Telemetry {
return instance;
}

private async isContainerEnv(): Promise<boolean> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't have thought of this myself but that is a good point 🤖

@@ -184,7 +190,9 @@ describe("Telemetry", () => {
});
});

it("should correctly add common properties to events", () => {
it("should correctly add common properties to events", async () => {
await telemetry.dataPromise;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await telemetry.dataPromise;
await telemetry.setupPromise;

@@ -219,7 +227,7 @@ describe("Telemetry", () => {
expect(telemetry["isBufferingEvents"]).toBe(true);
expect(telemetry.getCommonProperties().device_id).toBe(undefined);

await telemetry.deviceIdPromise;
await telemetry.dataPromise;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await telemetry.dataPromise;
await telemetry.setupPromise;

@@ -235,7 +243,7 @@ describe("Telemetry", () => {
expect(telemetry["isBufferingEvents"]).toBe(true);
expect(telemetry.getCommonProperties().device_id).toBe(undefined);

await telemetry.deviceIdPromise;
await telemetry.dataPromise;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await telemetry.dataPromise;
await telemetry.setupPromise;

@@ -263,7 +271,7 @@ describe("Telemetry", () => {

jest.advanceTimersByTime(DEVICE_ID_TIMEOUT);

await telemetry.deviceIdPromise;
await telemetry.dataPromise;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await telemetry.dataPromise;
await telemetry.setupPromise;


return exists.includes(true);
}

private async start(): Promise<void> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private async start(): Promise<void> {
private async setup(): Promise<void> {

break;
}
},
abortSignal: this.deviceIdAbortController.signal,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we turn this abortcontroller into a generalized abort controller and use it with isContainerEnv as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds like a good improvement for a next PR

@gagik gagik changed the title chore: reinstate telemetry/docker change after revert (MCP-49) chore: reinstate telemetry/docker change after revert MCP-49 Jul 4, 2025
@fmenezes fmenezes enabled auto-merge (squash) July 4, 2025 15:30
@fmenezes fmenezes merged commit 5b7ba55 into main Jul 4, 2025
16 of 17 checks passed
@fmenezes fmenezes deleted the MCP-49 branch July 4, 2025 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants