Acknowledge that telemetryListener may be undefined
This commit is contained in:
Родитель
8346eda8b8
Коммит
f9777016a7
|
@ -147,7 +147,7 @@ export function commandRunner(
|
|||
return undefined;
|
||||
} finally {
|
||||
const executionTime = Date.now() - startTime;
|
||||
telemetryListener.sendCommandUsage(commandId, executionTime, error);
|
||||
telemetryListener?.sendCommandUsage(commandId, executionTime, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ export function commandRunnerWithProgress<R>(
|
|||
return undefined;
|
||||
} finally {
|
||||
const executionTime = Date.now() - startTime;
|
||||
telemetryListener.sendCommandUsage(commandId, executionTime, error);
|
||||
telemetryListener?.sendCommandUsage(commandId, executionTime, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -227,12 +227,15 @@ export class TelemetryListener extends ConfigListener {
|
|||
/**
|
||||
* The global Telemetry instance
|
||||
*/
|
||||
export let telemetryListener: TelemetryListener;
|
||||
export let telemetryListener: TelemetryListener | undefined;
|
||||
|
||||
export async function initializeTelemetry(
|
||||
extension: Extension<any>,
|
||||
ctx: ExtensionContext,
|
||||
): Promise<void> {
|
||||
if (telemetryListener !== undefined) {
|
||||
throw new Error("Telemetry is already initialized");
|
||||
}
|
||||
telemetryListener = new TelemetryListener(
|
||||
extension.id,
|
||||
extension.packageJSON.version,
|
||||
|
|
Загрузка…
Ссылка в новой задаче