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,49 @@ 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.inlayHints.parameterNames.suppressWhenSameNameNumbered" ,
347+ "java.inlayHints.variableTypes.enabled" ,
348+ "java.inlayHints.parameterTypes.enabled" ,
349+ "java.server.launchMode" , "java.autobuild.enabled"
350+ ] ;
351+
352+ // settings where we only record their existence
353+ const SETTINGS_CUSTOM = [
354+ "java.settings.url" , "java.format.settings.url"
355+ ] ;
356+
357+ let value : any ;
358+ const properties = { } ;
359+
360+ for ( const key of SETTINGS_CUSTOM ) {
361+ if ( config . get ( key ) ) {
362+ properties [ key ] = true ;
363+ }
364+ }
365+ for ( const key of SETTINGS_BASIC ) {
366+ value = config . get ( key ) ;
367+ if ( value !== undefined ) {
368+ properties [ key ] = value ;
369+ }
370+ }
371+
372+ return properties ;
373+ }
374+
339375 this . languageClient . onTelemetry ( async ( e : TelemetryEvent ) => {
340376 apiManager . fireTraceEvent ( e ) ;
341377 if ( e . name === Telemetry . SERVER_INITIALIZED_EVT ) {
342- return Telemetry . sendTelemetry ( Telemetry . STARTUP_EVT , e . properties ) ;
378+ const javaSettings = getJavaSettingsForTelemetry ( workspace . getConfiguration ( ) ) ;
379+
380+ const properties = { ...e . properties , ...javaSettings } ;
381+ await Telemetry . sendTelemetry ( Telemetry . STARTUP_EVT , properties ) ;
343382 } else if ( e . name === Telemetry . LS_ERROR ) {
344383 const tags = [ ] ;
345384 const exception : string = e ?. properties . exception ;
@@ -357,7 +396,7 @@ export class StandardLanguageClient {
357396
358397 if ( tags . length > 0 || DEBUG || isPrereleaseOrInsiderVersion ( context ) ) {
359398 e . properties [ 'tags' ] = tags ;
360- return Telemetry . sendTelemetry ( Telemetry . LS_ERROR , e . properties ) ;
399+ await Telemetry . sendTelemetry ( Telemetry . LS_ERROR , e . properties ) ;
361400 }
362401 }
363402 } ) ;
0 commit comments