22
33import * as net from 'net' ;
44import * as path from 'path' ;
5- import { CancellationToken , CodeActionKind , commands , ConfigurationTarget , DocumentSelector , EventEmitter , ExtensionContext , extensions , languages , Location , ProgressLocation , TextEditor , Uri , ViewColumn , window , workspace } from "vscode" ;
6- import { ConfigurationParams , ConfigurationRequest , LanguageClientOptions , Location as LSLocation , MessageType , Position as LSPosition , TextDocumentPositionParams , WorkspaceEdit , StaticFeature , ClientCapabilities , FeatureState } from "vscode-languageclient" ;
5+ import { CancellationToken , CodeActionKind , commands , ConfigurationTarget , DocumentSelector , EventEmitter , ExtensionContext , extensions , languages , Location , ProgressLocation , TextEditor , Uri , ViewColumn , window , workspace , WorkspaceConfiguration } from "vscode" ;
6+ import { ConfigurationParams , ConfigurationRequest , LanguageClientOptions , Location as LSLocation , MessageType , Position as LSPosition , TextDocumentPositionParams , WorkspaceEdit , StaticFeature , ClientCapabilities , FeatureState , TelemetryEventNotification } from "vscode-languageclient" ;
77import { LanguageClient , StreamInfo } from "vscode-languageclient/node" ;
88import { apiManager } from "./apiManager" ;
99import * as buildPath from './buildpath' ;
@@ -336,10 +336,45 @@ export class StandardLanguageClient {
336336 return result ;
337337 } ) ;
338338
339+ function getJavaSettingsForTelemetry ( config : WorkspaceConfiguration ) {
340+ // settings whose values we can record
341+ const SETTINGS_BASIC = [
342+ "java.quickfix.showAt" , "java.symbols.includeSourceMethodDeclarations" ,
343+ "java.completion.collapseCompletionItems" , "java.completion.guessMethodArguments" ,
344+ "java.cleanup.actionsOnSave" , "java.completion.postfix.enabled" ,
345+ "java.sharedIndexes.enabled" , "java.inlayHints.parameterNames.enabled" ,
346+ "java.server.launchMode" , "java.autobuild.enabled"
347+ ] ;
348+ // settings where we only record their existence
349+ const SETTINGS_CUSTOM = [
350+ "java.settings.url" , "java.format.settings.url"
351+ ] ;
352+
353+ let value : any ;
354+ const properties = { } ;
355+
356+ for ( const key of SETTINGS_CUSTOM ) {
357+ if ( config . get ( key ) ) {
358+ properties [ key ] = true ;
359+ }
360+ }
361+ for ( const key of SETTINGS_BASIC ) {
362+ value = config . get ( key ) ;
363+ if ( value !== undefined ) {
364+ properties [ key ] = value ;
365+ }
366+ }
367+
368+ return properties ;
369+ }
370+
339371 this . languageClient . onTelemetry ( async ( e : TelemetryEvent ) => {
340372 apiManager . fireTraceEvent ( e ) ;
341373 if ( e . name === Telemetry . SERVER_INITIALIZED_EVT ) {
342- return Telemetry . sendTelemetry ( Telemetry . STARTUP_EVT , e . properties ) ;
374+ const javaSettings = getJavaSettingsForTelemetry ( workspace . getConfiguration ( ) ) ;
375+
376+ const properties = { ...e . properties , ...javaSettings } ;
377+ await Telemetry . sendTelemetry ( Telemetry . STARTUP_EVT , ) ;
343378 } else if ( e . name === Telemetry . LS_ERROR ) {
344379 const tags = [ ] ;
345380 const exception : string = e ?. properties . exception ;
@@ -357,8 +392,10 @@ export class StandardLanguageClient {
357392
358393 if ( tags . length > 0 ) {
359394 e . properties [ 'tags' ] = tags ;
360- return Telemetry . sendTelemetry ( Telemetry . LS_ERROR , e . properties ) ;
395+ await Telemetry . sendTelemetry ( Telemetry . LS_ERROR , e . properties ) ;
361396 }
397+ } else if ( e . name === Telemetry . IMPORT_PROJECT ) {
398+ await Telemetry . sendTelemetry ( Telemetry . IMPORT_PROJECT , e . properties ) ;
362399 }
363400 } ) ;
364401
0 commit comments