@@ -7,10 +7,6 @@ import { MACHINE_METADATA } from "./constants.js";
7
7
import { EventCache } from "./eventCache.js" ;
8
8
import nodeMachineId from "node-machine-id" ;
9
9
import { getDeviceId } from "@mongodb-js/device-id" ;
10
- import fs from "fs/promises" ;
11
- import os from "os" ;
12
- import path from "path" ;
13
- import { randomUUID } from "crypto" ;
14
10
15
11
type EventResult = {
16
12
success : boolean ;
@@ -19,26 +15,6 @@ type EventResult = {
19
15
20
16
export const DEVICE_ID_TIMEOUT = 3000 ;
21
17
22
- async function fileExists ( filepath : string ) : Promise < boolean > {
23
- try {
24
- await fs . stat ( filepath ) ;
25
- return true ;
26
- } catch {
27
- return false ;
28
- }
29
- }
30
-
31
- async function isContainerEnv ( ) : Promise < boolean > {
32
- if ( await fileExists ( "/.dockerenv" ) ) {
33
- return true ;
34
- }
35
- return process . env . container != "" ;
36
- }
37
-
38
- function containerIdFilePath ( ) : string {
39
- return path . join ( os . homedir ( ) , ".mongodb" , "container" , ".containerId" ) ;
40
- }
41
-
42
18
export class Telemetry {
43
19
private isBufferingEvents : boolean = true ;
44
20
/** Resolves when the device ID is retrieved or timeout occurs */
@@ -98,22 +74,6 @@ export class Telemetry {
98
74
abortSignal : this . deviceIdAbortController . signal ,
99
75
} ) ;
100
76
101
- const containerEnv = await isContainerEnv ( ) ;
102
-
103
- if ( containerEnv ) {
104
- const filePath = containerIdFilePath ( ) ;
105
- const exists = await fileExists ( filePath ) ;
106
- let content : string ;
107
- if ( exists ) {
108
- content = await fs . readFile ( filePath , "utf8" ) ;
109
- } else {
110
- content = randomUUID ( ) . toString ( ) ;
111
- await fs . mkdir ( path . dirname ( filePath ) , { recursive : true } ) ;
112
- await fs . writeFile ( filePath , content , "utf8" ) ;
113
- }
114
- this . commonProperties . container_id = content ;
115
- }
116
-
117
77
this . commonProperties . device_id = await this . deviceIdPromise ;
118
78
119
79
this . isBufferingEvents = false ;
0 commit comments