-
Notifications
You must be signed in to change notification settings - Fork 67
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
Changes from 32 commits
9cf0447
1b8ea02
af714b4
40aaef0
8adc20d
cff01e0
5336e4a
76e2a6f
1850676
3a5d4c1
23fff05
754ce8d
8301e43
994b698
3bfc9f2
6d92021
7997c54
f18b916
a9cd835
6813518
65fad1d
7e98c33
5209073
2e33584
d92adf1
8ec7d9c
6ad2a19
807109d
f9a46f9
599201d
7a889b4
eb360e2
710b131
a15eeb6
90caa25
89113a5
143f898
f751a30
0927d28
fb0b8af
9e625aa
a61d9b4
2bd00cf
3636fde
0df870c
4b7563d
6dd1f79
807b2ca
139c3ee
3a05d31
8505d91
024a3d1
File filter
Filter by extension
Conversations
Jump to
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.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,16 @@ import argv from "yargs-parser"; | |
import packageJson from "../package.json" with { type: "json" }; | ||
import { ReadConcernLevel, ReadPreferenceMode, W } from "mongodb"; | ||
|
||
export const SERVER_NAME = "MdbMcpServer"; | ||
export const SERVER_VERSION = packageJson.version; | ||
|
||
// If we decide to support non-string config options, we'll need to extend the mechanism for parsing | ||
// env variables. | ||
interface UserConfig { | ||
apiBaseUrl?: string; | ||
apiClientId?: string; | ||
apiClientSecret?: string; | ||
telemetry?: "enabled" | "disabled"; | ||
blva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
logPath: string; | ||
connectionString?: string; | ||
connectOptions: { | ||
|
@@ -41,7 +45,8 @@ const mergedUserConfig = { | |
|
||
const config = { | ||
...mergedUserConfig, | ||
version: packageJson.version, | ||
version: SERVER_VERSION, | ||
mcpServerName: SERVER_NAME, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd move this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use it in the client though, so wanted to keep it here where is common There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a bit confusing for me as it is inside a configuration, which to me means it is configurable |
||
}; | ||
|
||
export default config; | ||
gagik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pkg from "../../package.json" with { type: "json" }; | ||
import config from "../config.js"; | ||
import { getMachineIdSync } from "native-machine-id"; | ||
|
||
/** | ||
* Machine-specific metadata formatted for telemetry | ||
*/ | ||
export const MACHINE_METADATA = { | ||
device_id: getMachineIdSync(), | ||
mcp_server_version: pkg.version, | ||
mcp_server_name: config.mcpServerName, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems constant, do we need this? maybe we add useragent instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need it for telemetry right? we could give user agent, but i figure that having the data split is better.. no strong opinion as we hope not to change server_name, but we might change after public preview |
||
platform: process.platform, | ||
arch: process.arch, | ||
os_type: process.platform, | ||
os_version: process.version, | ||
} as const; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { BaseEvent } from "./types.js"; | ||
|
||
/** | ||
* Singleton class for in-memory telemetry event caching | ||
* Provides a central storage for telemetry events that couldn't be sent | ||
*/ | ||
export class EventCache { | ||
private static instance: EventCache; | ||
private events: BaseEvent[] = []; | ||
|
||
private constructor() {} | ||
|
||
/** | ||
* 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 [...this.events]; | ||
} | ||
|
||
/** | ||
* Sets the cached events, replacing any existing events | ||
* @param events - The events to cache | ||
*/ | ||
public setEvents(events: BaseEvent[]): void { | ||
blva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this.events = [...events]; | ||
} | ||
|
||
/** | ||
* Clears all cached events | ||
*/ | ||
public clearEvents(): void { | ||
this.events = []; | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.