@@ -81,7 +81,7 @@ export function activate(): void {
81
81
}
82
82
}
83
83
84
- export async function getExperimentationService ( ) : Promise < IExperimentationService | undefined > {
84
+ export function getExperimentationService ( ) : Promise < IExperimentationService > | undefined {
85
85
return initializationPromise ;
86
86
}
87
87
@@ -92,34 +92,50 @@ export async function deactivate(): Promise<void> {
92
92
} catch ( e ) {
93
93
// Continue even if we were not able to initialize the experimentation platform.
94
94
}
95
- if ( experimentationTelemetry ) {
96
- experimentationTelemetry . dispose ( ) ;
97
- }
98
- }
99
- }
100
-
101
- export async function logDebuggerEvent ( eventName : string , properties ?: { [ key : string ] : string } ) : Promise < void > {
102
- try {
103
- await initializationPromise ;
104
- } catch ( e ) {
105
- // Continue even if we were not able to initialize the experimentation platform.
106
95
}
107
96
if ( experimentationTelemetry ) {
108
- const eventNamePrefix : string = "cppdbg/VS/Diagnostics/Debugger/" ;
109
- experimentationTelemetry . sendTelemetryEvent ( eventNamePrefix + eventName , properties ) ;
97
+ experimentationTelemetry . dispose ( ) ;
110
98
}
111
99
}
112
100
113
- export async function logLanguageServerEvent ( eventName : string , properties ?: { [ key : string ] : string } , metrics ?: { [ key : string ] : number } ) : Promise < void > {
114
- try {
115
- await initializationPromise ;
116
- } catch ( e ) {
117
- // Continue even if we were not able to initialize the experimentation platform.
101
+ export function logDebuggerEvent ( eventName : string , properties ?: { [ key : string ] : string } ) : void {
102
+ const sendTelemetry = ( ) => {
103
+ if ( experimentationTelemetry ) {
104
+ const eventNamePrefix : string = "cppdbg/VS/Diagnostics/Debugger/" ;
105
+ experimentationTelemetry . sendTelemetryEvent ( eventNamePrefix + eventName , properties ) ;
106
+ }
107
+ } ;
108
+
109
+ if ( initializationPromise ) {
110
+ try {
111
+ // Use 'then' instead of 'await' because telemetry should be "fire and forget".
112
+ initializationPromise . then ( sendTelemetry ) ;
113
+ return ;
114
+ } catch ( e ) {
115
+ // Continue even if we were not able to initialize the experimentation platform.
116
+ }
118
117
}
119
- if ( experimentationTelemetry ) {
120
- const eventNamePrefix : string = "C_Cpp/LanguageServer/" ;
121
- experimentationTelemetry . sendTelemetryEvent ( eventNamePrefix + eventName , properties , metrics ) ;
118
+ sendTelemetry ( ) ;
119
+ }
120
+
121
+ export function logLanguageServerEvent ( eventName : string , properties ?: { [ key : string ] : string } , metrics ?: { [ key : string ] : number } ) : void {
122
+ const sendTelemetry = ( ) => {
123
+ if ( experimentationTelemetry ) {
124
+ const eventNamePrefix : string = "C_Cpp/LanguageServer/" ;
125
+ experimentationTelemetry . sendTelemetryEvent ( eventNamePrefix + eventName , properties , metrics ) ;
126
+ }
127
+ } ;
128
+
129
+ if ( initializationPromise ) {
130
+ try {
131
+ // Use 'then' instead of 'await' because telemetry should be "fire and forget".
132
+ initializationPromise . then ( sendTelemetry ) ;
133
+ return ;
134
+ } catch ( e ) {
135
+ // Continue even if we were not able to initialize the experimentation platform.
136
+ }
122
137
}
138
+ sendTelemetry ( ) ;
123
139
}
124
140
125
141
function getPackageInfo ( ) : IPackageInfo {
0 commit comments