Skip to content

Commit 72f1ab8

Browse files
blvaCopilot
andauthored
Update src/helpers/deviceId.ts
Co-authored-by: Copilot <[email protected]>
1 parent 524d965 commit 72f1ab8

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/helpers/deviceId.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,16 @@ import logger, { LogId } from "../common/logger.js";
55
export const DEVICE_ID_TIMEOUT = 3000;
66

77
/**
8-
* Sets the appName parameter with the extended format: appName--deviceId--clientName
9-
* Only sets the appName if it's not already present in the connection string
8+
* Retrieves the device ID for telemetry purposes.
9+
* The device ID is generated using the machine ID and additional logic to handle errors.
1010
*
11-
* @param connectionString - The connection string to modify
12-
* @param components - The components to build the appName from
13-
* @returns Promise that resolves to the modified connection string
11+
* @returns Promise that resolves to the device ID string
12+
* If an error occurs during retrieval, the function returns "unknown".
1413
*
1514
* @example
1615
* ```typescript
17-
* const result = await setExtendedAppNameParam({
18-
* connectionString: "mongodb://localhost:27017",
19-
* components: { appName: "MyApp", clientName: "Cursor" }
20-
* });
21-
* // Result: "mongodb://localhost:27017/?appName=MyApp--deviceId--Cursor"
16+
* const deviceId = await getDeviceIdForConnection();
17+
* console.log(deviceId); // Outputs the device ID or "unknown" in case of failure
2218
* ```
2319
*/
2420
export async function getDeviceIdForConnection(): Promise<string> {

0 commit comments

Comments
 (0)