diff --git a/packages/backend/src/studio.ts b/packages/backend/src/studio.ts index 550d9deff..8171149e5 100644 --- a/packages/backend/src/studio.ts +++ b/packages/backend/src/studio.ts @@ -16,8 +16,8 @@ * SPDX-License-Identifier: Apache-2.0 ***********************************************************************/ -import type { ExtensionContext, WebviewOptions, WebviewPanel } from '@podman-desktop/api'; -import { Uri, window } from '@podman-desktop/api'; +import type { ExtensionContext, TelemetryLogger, WebviewOptions, WebviewPanel, WebviewPanelOnDidChangeViewStateEvent } from '@podman-desktop/api'; +import { Uri, window, env } from '@podman-desktop/api'; import { RpcExtension } from '@shared/src/messages/MessageProxy'; import { StudioApiImpl } from './studio-api-impl'; import { ApplicationManager } from './managers/applicationManager'; @@ -44,6 +44,7 @@ export class Studio { playgroundManager: PlayGroundManager; catalogManager: CatalogManager; modelsManager: ModelsManager; + telemetry: TelemetryLogger; constructor(readonly extensionContext: ExtensionContext) { this.#extensionContext = extensionContext; @@ -52,6 +53,9 @@ export class Studio { public async activate(): Promise { console.log('starting studio extension'); + this.telemetry = env.createTelemetryLogger(); + this.telemetry.logUsage('start'); + const extensionUri = this.#extensionContext.extensionUri; // register webview @@ -112,6 +116,10 @@ export class Studio { this.modelsManager, ); + this.#panel.onDidChangeViewState((e: WebviewPanelOnDidChangeViewStateEvent) => { + this.telemetry.logUsage(e.webviewPanel.visible ? 'opened' : 'closed'); + }); + // Creating StudioApiImpl this.studioApi = new StudioApiImpl( appUserDirectory, @@ -131,6 +139,7 @@ export class Studio { public async deactivate(): Promise { console.log('stopping studio extension'); + this.telemetry.logUsage('stop'); } getWebviewOptions(extensionUri: Uri): WebviewOptions {