@@ -423,75 +423,25 @@ export function registerCommands(enabled: boolean): void {
423423 commandDisposables . push ( vscode . commands . registerCommand ( 'C_Cpp.RestartIntelliSenseForFile' , enabled ? onRestartIntelliSenseForFile : onDisabledCommand ) ) ;
424424 commandDisposables . push ( vscode . commands . registerCommand ( 'C_Cpp.GenerateDoxygenComment' , enabled ? onGenerateDoxygenComment : onDisabledCommand ) ) ;
425425 commandDisposables . push ( vscode . commands . registerCommand ( 'C_Cpp.CreateDeclarationOrDefinition' , enabled ? onCreateDeclarationOrDefinition : onDisabledCommand ) ) ;
426- // ---------------- Wrappers -------------
427- commandDisposables . push ( vscode . commands . registerCommand ( 'C_Cpp.ConfigurationSelectUI_Telemetry' , enabled ?
428- ( ) => {
429- logForUIExperiment ( "ConfigurationSelect" ) ;
430- onSelectConfiguration ( ) ;
431- }
432- : onDisabledCommand ) ) ;
433- commandDisposables . push ( vscode . commands . registerCommand ( 'C_Cpp.RescanWorkspaceUI_Telemetry' , enabled ?
434- ( ) => {
435- logForUIExperiment ( "RescanWorkspace" ) ;
436- onRescanWorkspace ( ) ;
437- }
438- : onDisabledCommand ) ) ;
439- commandDisposables . push ( vscode . commands . registerCommand ( 'C_Cpp.ShowIdleCodeAnalysisCommandsUI_Telemetry' , enabled ?
440- ( ) => {
441- logForUIExperiment ( "ShowIdleCodeAnalysisCommands" ) ;
442- onShowIdleCodeAnalysisCommands ( ) ;
443- }
444- : onDisabledCommand ) ) ;
445- commandDisposables . push ( vscode . commands . registerCommand ( 'C_Cpp.ShowActiveCodeAnalysisCommandsUI_Telemetry' , enabled ?
446- ( ) => {
447- logForUIExperiment ( "ShowActiveCodeAnalysisCommands" ) ;
448- onShowActiveCodeAnalysisCommands ( ) ;
449- }
450- : onDisabledCommand ) ) ;
451- commandDisposables . push ( vscode . commands . registerCommand ( 'C_Cpp.PauseParsingUI_Telemetry' , enabled ?
452- ( ) => {
453- logForUIExperiment ( "ParsingCommands" ) ;
454- onPauseParsing ( ) ;
455- }
456- : onDisabledCommand ) ) ;
457- commandDisposables . push ( vscode . commands . registerCommand ( 'C_Cpp.ResumeParsingUI_Telemetry' , enabled ?
458- ( ) => {
459- logForUIExperiment ( "ParsingCommands" ) ;
460- onResumeParsing ( ) ;
461- }
462- : onDisabledCommand ) ) ;
463- commandDisposables . push ( vscode . commands . registerCommand ( 'C_Cpp.CheckForCompilerUI_Telemetry' , enabled ?
464- ( ) => {
465- logForUIExperiment ( "CheckForCompiler" ) ;
466- onCheckForCompiler ( ) ;
467- }
468- : onDisabledCommand ) ) ;
469- commandDisposables . push ( vscode . commands . registerCommand ( 'C_Cpp.RestartIntelliSenseForFileUI_Telemetry' , enabled ?
470- ( ) => {
471- logForUIExperiment ( "RestartIntelliSenseForFile" ) ;
472- onRestartIntelliSenseForFile ( ) ;
473- }
474- : onDisabledCommand ) ) ;
475- commandDisposables . push ( vscode . commands . registerCommand ( 'C_Cpp.ShowReferencesProgressUI_Telemetry' , enabled ?
476- ( ) => {
477- logForUIExperiment ( "ShowReferencesProgress" ) ;
478- onShowReferencesProgress ( ) ;
479- }
480- : onDisabledCommand ) ) ;
481- commandDisposables . push ( vscode . commands . registerCommand ( 'C_Cpp.ShowParsingCommandsUI_Telemetry' , enabled ?
482- ( ) => {
483- logForUIExperiment ( "ParsingCommands" ) ;
484- onShowParsingCommands ( ) ;
485- }
486- : onDisabledCommand ) ) ;
487- // ----------------------------------------
488426}
489427
490- async function logForUIExperiment ( command : string ) : Promise < void > {
428+ function logForUIExperiment ( command : string , sender ?: any ) : void {
491429 const settings : CppSettings = new CppSettings ( ( vscode . workspace . workspaceFolders && vscode . workspace . workspaceFolders . length > 0 ) ? vscode . workspace . workspaceFolders [ 0 ] ?. uri : undefined ) ;
492- const isNewUI : string = ui . isNewUI . toString ( ) ;
493- const isOverridden : string = ( settings . experimentalFeatures ?? false ) . toString ( ) ;
494- telemetry . logLanguageServerEvent ( `experiment${ command } ` , { newUI : isNewUI , uiOverride : isOverridden } ) ;
430+ const properties : { [ key : string ] : string } = {
431+ newUI : ui . isNewUI . toString ( ) ,
432+ uiOverride : ( settings . experimentalFeatures ?? false ) . toString ( ) ,
433+ sender : getSenderType ( sender )
434+ } ;
435+ telemetry . logLanguageServerEvent ( `experiment${ command } ` , properties ) ;
436+ }
437+
438+ function getSenderType ( sender ?: any ) : string {
439+ if ( util . isString ( sender ) ) {
440+ return sender ;
441+ } else if ( util . isUri ( sender ) ) {
442+ return 'contextMenu' ;
443+ }
444+ return 'commandPalette' ;
495445}
496446
497447function onDisabledCommand ( ) : void {
@@ -506,7 +456,8 @@ function onDisabledCommand(): void {
506456 vscode . window . showWarningMessage ( message ) ;
507457}
508458
509- function onRestartIntelliSenseForFile ( ) : void {
459+ function onRestartIntelliSenseForFile ( sender ?: any ) : void {
460+ logForUIExperiment ( "RestartIntelliSenseForFile" , sender ) ;
510461 const activeEditor : vscode . TextEditor | undefined = vscode . window . activeTextEditor ;
511462 if ( ! activeEditor || ! activeEditor . document || activeEditor . document . uri . scheme !== "file" ||
512463 ( activeEditor . document . languageId !== "c" && activeEditor . document . languageId !== "cpp" && activeEditor . document . languageId !== "cuda-cpp" ) ) {
@@ -590,7 +541,8 @@ function selectDefaultCompiler(): void {
590541 clients . ActiveClient . promptSelectCompiler ( true ) ;
591542}
592543
593- function onSelectConfiguration ( ) : void {
544+ function onSelectConfiguration ( sender ?: any ) : void {
545+ logForUIExperiment ( "ConfigurationSelect" , sender ) ;
594546 if ( ! isFolderOpen ( ) ) {
595547 vscode . window . showInformationMessage ( localize ( "configuration.select.first" , 'Open a folder first to select a configuration.' ) ) ;
596548 } else {
@@ -656,7 +608,8 @@ function onGoToPrevDirectiveInGroup(): void {
656608 client . handleGoToDirectiveInGroup ( false ) ;
657609}
658610
659- function onCheckForCompiler ( ) : void {
611+ function onCheckForCompiler ( sender ?: any ) : void {
612+ logForUIExperiment ( "CheckForCompiler" , sender ) ;
660613 const client : Client = getActiveClient ( ) ;
661614 client . handleCheckForCompiler ( ) ;
662615}
@@ -731,7 +684,11 @@ async function onDisableAllTypeCodeAnalysisProblems(code: string, identifiersAnd
731684 getActiveClient ( ) . handleDisableAllTypeCodeAnalysisProblems ( code , identifiersAndUris ) ;
732685}
733686
734- async function onCreateDeclarationOrDefinition ( ) : Promise < void > {
687+ async function onCreateDeclarationOrDefinition ( sender ?: any ) : Promise < void > {
688+ const properties : { [ key : string ] : string } = {
689+ sender : getSenderType ( sender )
690+ } ;
691+ telemetry . logLanguageServerEvent ( 'CreateDeclDefn' , properties ) ;
735692 getActiveClient ( ) . handleCreateDeclarationOrDefinition ( ) ;
736693}
737694
@@ -769,11 +726,13 @@ function onToggleDimInactiveRegions(): void {
769726 settings . update < boolean > ( "dimInactiveRegions" , ! settings . dimInactiveRegions ) ;
770727}
771728
772- function onPauseParsing ( ) : void {
729+ function onPauseParsing ( sender ?: any ) : void {
730+ logForUIExperiment ( "ParsingCommands" , sender ) ;
773731 clients . ActiveClient . pauseParsing ( ) ;
774732}
775733
776- function onResumeParsing ( ) : void {
734+ function onResumeParsing ( sender ?: any ) : void {
735+ logForUIExperiment ( "ParsingCommands" , sender ) ;
777736 clients . ActiveClient . resumeParsing ( ) ;
778737}
779738
@@ -789,19 +748,23 @@ function onCancelCodeAnalysis(): void {
789748 clients . ActiveClient . CancelCodeAnalysis ( ) ;
790749}
791750
792- function onShowParsingCommands ( ) : void {
751+ function onShowParsingCommands ( sender ?: any ) : void {
752+ logForUIExperiment ( "ParsingCommands" , sender ) ;
793753 clients . ActiveClient . handleShowParsingCommands ( ) ;
794754}
795755
796- function onShowActiveCodeAnalysisCommands ( ) : void {
756+ function onShowActiveCodeAnalysisCommands ( sender ?: any ) : void {
757+ logForUIExperiment ( "ShowActiveCodeAnalysisCommands" , sender ) ;
797758 clients . ActiveClient . handleShowActiveCodeAnalysisCommands ( ) ;
798759}
799760
800- function onShowIdleCodeAnalysisCommands ( ) : void {
761+ function onShowIdleCodeAnalysisCommands ( sender ?: any ) : void {
762+ logForUIExperiment ( "ShowIdleCodeAnalysisCommands" , sender ) ;
801763 clients . ActiveClient . handleShowIdleCodeAnalysisCommands ( ) ;
802764}
803765
804- function onShowReferencesProgress ( ) : void {
766+ function onShowReferencesProgress ( sender ?: any ) : void {
767+ logForUIExperiment ( "ShowReferencesProgress" , sender ) ;
805768 clients . ActiveClient . handleReferencesIcon ( ) ;
806769}
807770
@@ -898,7 +861,8 @@ function onLogDiagnostics(): void {
898861 clients . ActiveClient . logDiagnostics ( ) ;
899862}
900863
901- function onRescanWorkspace ( ) : void {
864+ function onRescanWorkspace ( sender ?: string ) : void {
865+ logForUIExperiment ( "RescanWorkspace" , sender ) ;
902866 clients . ActiveClient . rescanFolder ( ) ;
903867}
904868
0 commit comments