@@ -6,6 +6,7 @@ import type { CompassApplication } from './application';
66import type { EventEmitter } from 'events' ;
77import { getOsInfo } from '@mongodb-js/get-os-info' ;
88import type { IdentifyTraits } from '@mongodb-js/compass-telemetry' ;
9+ import { getDeviceId } from './device-id' ;
910
1011const { log, mongoLogId } = createLogger ( 'COMPASS-TELEMETRY' ) ;
1112
@@ -38,6 +39,7 @@ class CompassTelemetry {
3839 private static queuedEvents : EventInfo [ ] = [ ] ; // Events that happen before we fetch user preferences
3940 private static telemetryAnonymousId = '' ; // The randomly generated anonymous user id.
4041 private static telemetryAtlasUserId ?: string ;
42+ private static telemetryDeviceId = 'unknown' ;
4143 private static lastReportedScreen = '' ;
4244 private static osInfo : ReturnType < typeof getOsInfo > extends Promise < infer T >
4345 ? Partial < T >
@@ -53,6 +55,7 @@ class CompassTelemetry {
5355 // Used in both track and identify to add common traits
5456 // to any event that we send to segment
5557 return {
58+ device_id : this . telemetryDeviceId ,
5659 compass_version : app . getVersion ( ) . split ( '.' ) . slice ( 0 , 2 ) . join ( '.' ) ,
5760 compass_full_version : app . getVersion ( ) ,
5861 compass_distribution : process . env . HADRON_DISTRIBUTION ,
@@ -138,6 +141,15 @@ class CompassTelemetry {
138141 preferences . getPreferences ( ) ;
139142 this . telemetryAnonymousId = telemetryAnonymousId ?? '' ;
140143 this . telemetryAtlasUserId = telemetryAtlasUserId ;
144+ this . telemetryDeviceId = await getDeviceId ( {
145+ onError : ( err ) =>
146+ log . error (
147+ mongoLogId ( 1_001_000_148 ) ,
148+ 'Telemetry' ,
149+ 'Failed to get device ID' ,
150+ { err : err . message }
151+ ) ,
152+ } ) ;
141153
142154 try {
143155 this . osInfo = await getOsInfo ( ) ;
0 commit comments