Skip to content

Commit 2f78e86

Browse files
authored
Merge pull request #7933 from microsoft/bobbrow/telemetryUpdate
2 parents 0e3dd7a + f814414 commit 2f78e86

File tree

1 file changed

+38
-22
lines changed

1 file changed

+38
-22
lines changed

Extension/src/telemetry.ts

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function activate(): void {
8181
}
8282
}
8383

84-
export async function getExperimentationService(): Promise<IExperimentationService | undefined> {
84+
export function getExperimentationService(): Promise<IExperimentationService> | undefined {
8585
return initializationPromise;
8686
}
8787

@@ -92,34 +92,50 @@ export async function deactivate(): Promise<void> {
9292
} catch (e) {
9393
// Continue even if we were not able to initialize the experimentation platform.
9494
}
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.
10695
}
10796
if (experimentationTelemetry) {
108-
const eventNamePrefix: string = "cppdbg/VS/Diagnostics/Debugger/";
109-
experimentationTelemetry.sendTelemetryEvent(eventNamePrefix + eventName, properties);
97+
experimentationTelemetry.dispose();
11098
}
11199
}
112100

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+
}
118117
}
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+
}
122137
}
138+
sendTelemetry();
123139
}
124140

125141
function getPackageInfo(): IPackageInfo {

0 commit comments

Comments
 (0)