-
Notifications
You must be signed in to change notification settings - Fork 34
feat: core telemetry functionality #87
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
Changes from 51 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
9cf0447
wip
blva 1b8ea02
WIP
blva af714b4
wip
blva 40aaef0
wip: simple approach
blva 8adc20d
add cache and client logic
blva cff01e0
Merge remote-tracking branch 'origin/main' into telemetry
blva 5336e4a
update deps
blva 76e2a6f
update
blva 1850676
update logs
blva 3a5d4c1
reformat
blva 23fff05
address comment: server main
blva 754ce8d
address comment: make dynamic config part of session
blva 8301e43
address comment: remove redundant method
blva 994b698
address comment: move tool emission to tool.ts
blva 3bfc9f2
address comment: update agentClient to agentRunner
blva 6d92021
address comment: update agentClient to agentRunner
blva 7997c54
address comment: isolate machine data
blva f18b916
address comment: inject config to constructor
blva a9cd835
feat: use machineid library
blva 6813518
chore: reformat
blva 65fad1d
chore: reformat
blva 7e98c33
address comment: fix misleading comment
blva 5209073
address npm check
blva 2e33584
address comment: support do_not_track
blva d92adf1
Merge branch 'main' into telemetry
blva 8ec7d9c
address comment: use in-memory cache
blva 6ad2a19
address comments: use const
blva 807109d
Merge branch 'main' into telemetry
blva f9a46f9
chore: fix lint and tests
blva 599201d
address comment: remove unused const
blva 7a889b4
address comment: do not use object freeze
blva eb360e2
address comment: as const
blva 710b131
Update src/common/atlas/apiClient.ts
blva a15eeb6
address comment: make common props readonly
blva 90caa25
Merge remote-tracking branch 'origin/main' into telemetry
blva 89113a5
address comment: do not use enum
blva 143f898
fix
blva f751a30
address comment: inject and use eventcache
blva 0927d28
minor fixeS
blva fb0b8af
chore: gen sessionId
blva 9e625aa
add lru cache
blva a61d9b4
chore: disable telemetry in tests
blva 2bd00cf
Merge remote-tracking branch 'origin/main' into telemetry
blva 3636fde
chore: reformat
blva 0df870c
clean up
blva 4b7563d
fix check
blva 6dd1f79
address comment for category and update emit tool to get tool result …
blva 807b2ca
address comment: fix telemetry init
blva 139c3ee
Merge remote-tracking branch 'origin/main' into telemetry
blva 3a05d31
format
blva 8505d91
fix check
blva 024a3d1
address comment
blva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { getMachineIdSync } from "native-machine-id"; | ||
import { packageInfo } from "../packageInfo.js"; | ||
|
||
/** | ||
* Machine-specific metadata formatted for telemetry | ||
*/ | ||
export const MACHINE_METADATA = { | ||
device_id: getMachineIdSync(), | ||
mcp_server_version: packageInfo.version, | ||
mcp_server_name: packageInfo.mcpServerName, | ||
platform: process.platform, | ||
arch: process.arch, | ||
os_type: process.platform, | ||
os_version: process.version, | ||
} as const; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { BaseEvent } from "./types.js"; | ||
import { LRUCache } from "lru-cache"; | ||
|
||
/** | ||
* Singleton class for in-memory telemetry event caching | ||
* Provides a central storage for telemetry events that couldn't be sent | ||
* Uses LRU cache to automatically drop oldest events when limit is exceeded | ||
*/ | ||
export class EventCache { | ||
private static instance: EventCache; | ||
private static readonly MAX_EVENTS = 1000; | ||
|
||
private cache: LRUCache<number, BaseEvent>; | ||
private nextId = 0; | ||
|
||
private constructor() { | ||
this.cache = new LRUCache({ | ||
max: EventCache.MAX_EVENTS, | ||
// Using FIFO eviction strategy for events | ||
allowStale: false, | ||
updateAgeOnGet: false, | ||
}); | ||
} | ||
|
||
/** | ||
* Gets the singleton instance of EventCache | ||
* @returns The EventCache instance | ||
*/ | ||
public static getInstance(): EventCache { | ||
blva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!EventCache.instance) { | ||
EventCache.instance = new EventCache(); | ||
} | ||
return EventCache.instance; | ||
} | ||
|
||
/** | ||
* Gets a copy of the currently cached events | ||
* @returns Array of cached BaseEvent objects | ||
*/ | ||
public getEvents(): BaseEvent[] { | ||
return Array.from(this.cache.values()); | ||
} | ||
|
||
/** | ||
* Appends new events to the cached events | ||
* LRU cache automatically handles dropping oldest events when limit is exceeded | ||
* @param events - The events to append | ||
*/ | ||
public appendEvents(events: BaseEvent[]): void { | ||
for (const event of events) { | ||
this.cache.set(this.nextId++, event); | ||
} | ||
} | ||
|
||
/** | ||
* Clears all cached events | ||
*/ | ||
public clearEvents(): void { | ||
this.cache.clear(); | ||
this.nextId = 0; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.