From 4cada1ccf00ac4632654980be4ac4393833305e9 Mon Sep 17 00:00:00 2001 From: Philippe Martin Date: Mon, 29 Jan 2024 14:29:02 +0100 Subject: [PATCH] Expose telemetry to frontend --- packages/backend/src/studio-api-impl.ts | 9 +++++++++ packages/backend/src/studio.ts | 1 + packages/shared/src/StudioAPI.ts | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/packages/backend/src/studio-api-impl.ts b/packages/backend/src/studio-api-impl.ts index e166faa69..dbe08f3a3 100644 --- a/packages/backend/src/studio-api-impl.ts +++ b/packages/backend/src/studio-api-impl.ts @@ -38,6 +38,7 @@ export class StudioApiImpl implements StudioAPI { private playgroundManager: PlayGroundManager, private catalogManager: CatalogManager, private modelsManager: ModelsManager, + private telemetry: podmanDesktopApi.TelemetryLogger, ) {} async ping(): Promise { @@ -111,4 +112,12 @@ export class StudioApiImpl implements StudioAPI { async deleteLocalModel(modelId: string): Promise { await this.modelsManager.deleteLocalModel(modelId); } + + async telemetryLogUsage(eventName: string, data?: Record): Promise { + this.telemetry.logUsage(eventName, data); + } + + async telemetryLogError(eventName: string, data?: Record): Promise { + this.telemetry.logError(eventName, data); + } } diff --git a/packages/backend/src/studio.ts b/packages/backend/src/studio.ts index 8171149e5..725dce4e3 100644 --- a/packages/backend/src/studio.ts +++ b/packages/backend/src/studio.ts @@ -128,6 +128,7 @@ export class Studio { this.playgroundManager, this.catalogManager, this.modelsManager, + this.telemetry, ); await this.catalogManager.loadCatalog(); diff --git a/packages/shared/src/StudioAPI.ts b/packages/shared/src/StudioAPI.ts index 98928932b..79cbdcbad 100644 --- a/packages/shared/src/StudioAPI.ts +++ b/packages/shared/src/StudioAPI.ts @@ -3,6 +3,7 @@ import type { ModelInfo } from './models/IModelInfo'; import type { QueryState } from './models/IPlaygroundQueryState'; import type { Catalog } from './models/ICatalog'; import type { PlaygroundState } from './models/IPlaygroundState'; +import type { TelemetryTrustedValue } from '@podman-desktop/api'; export abstract class StudioAPI { abstract ping(): Promise; @@ -24,4 +25,9 @@ export abstract class StudioAPI { abstract askPlayground(modelId: string, prompt: string): Promise; abstract getPlaygroundQueriesState(): Promise; abstract getPlaygroundsState(): Promise; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + abstract telemetryLogUsage(eventName: string, data?: Record): Promise; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + abstract telemetryLogError(eventName: string, data?: Record): Promise; }