-
Notifications
You must be signed in to change notification settings - Fork 67
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
Conversation
There was a problem hiding this 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 ofdeviceIdPromise
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, likedeviceDataPromise
orinitializationPromise
.
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> { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 🤖
Pull Request Test Coverage Report for Build 16076959781Warning: 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
💛 - Coveralls |
There was a problem hiding this 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
src/telemetry/telemetry.ts
Outdated
@@ -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 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** Resolves when the device ID is retrieved or timeout occurs */ | |
/** Resolves when the setup is complete or a timeout occurs */ |
src/telemetry/telemetry.ts
Outdated
@@ -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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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> { |
There was a problem hiding this comment.
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 🤖
tests/unit/telemetry.test.ts
Outdated
@@ -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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await telemetry.dataPromise; | |
await telemetry.setupPromise; |
tests/unit/telemetry.test.ts
Outdated
@@ -219,7 +227,7 @@ describe("Telemetry", () => { | |||
expect(telemetry["isBufferingEvents"]).toBe(true); | |||
expect(telemetry.getCommonProperties().device_id).toBe(undefined); | |||
|
|||
await telemetry.deviceIdPromise; | |||
await telemetry.dataPromise; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await telemetry.dataPromise; | |
await telemetry.setupPromise; |
tests/unit/telemetry.test.ts
Outdated
@@ -235,7 +243,7 @@ describe("Telemetry", () => { | |||
expect(telemetry["isBufferingEvents"]).toBe(true); | |||
expect(telemetry.getCommonProperties().device_id).toBe(undefined); | |||
|
|||
await telemetry.deviceIdPromise; | |||
await telemetry.dataPromise; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await telemetry.dataPromise; | |
await telemetry.setupPromise; |
tests/unit/telemetry.test.ts
Outdated
@@ -263,7 +271,7 @@ describe("Telemetry", () => { | |||
|
|||
jest.advanceTimersByTime(DEVICE_ID_TIMEOUT); | |||
|
|||
await telemetry.deviceIdPromise; | |||
await telemetry.dataPromise; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await telemetry.dataPromise; | |
await telemetry.setupPromise; |
src/telemetry/telemetry.ts
Outdated
|
||
return exists.includes(true); | ||
} | ||
|
||
private async start(): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private async start(): Promise<void> { | |
private async setup(): Promise<void> { |
break; | ||
} | ||
}, | ||
abortSignal: this.deviceIdAbortController.signal, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Proposed changes
changes were initially introduced at #298 which caused #320 and reverted at #330, I'm adding it back without any refactorings
Checklist