Skip to content

Commit

Permalink
Expose telemetry to frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy committed Jan 29, 2024
1 parent c767595 commit 4cada1c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/backend/src/studio-api-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
Expand Down Expand Up @@ -111,4 +112,12 @@ export class StudioApiImpl implements StudioAPI {
async deleteLocalModel(modelId: string): Promise<void> {
await this.modelsManager.deleteLocalModel(modelId);
}

async telemetryLogUsage(eventName: string, data?: Record<string, any | podmanDesktopApi.TelemetryTrustedValue>): Promise<void> {
this.telemetry.logUsage(eventName, data);
}

async telemetryLogError(eventName: string, data?: Record<string, any | podmanDesktopApi.TelemetryTrustedValue>): Promise<void> {
this.telemetry.logError(eventName, data);
}
}
1 change: 1 addition & 0 deletions packages/backend/src/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export class Studio {
this.playgroundManager,
this.catalogManager,
this.modelsManager,
this.telemetry,
);

await this.catalogManager.loadCatalog();
Expand Down
6 changes: 6 additions & 0 deletions packages/shared/src/StudioAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>;
Expand All @@ -24,4 +25,9 @@ export abstract class StudioAPI {
abstract askPlayground(modelId: string, prompt: string): Promise<number>;
abstract getPlaygroundQueriesState(): Promise<QueryState[]>;
abstract getPlaygroundsState(): Promise<PlaygroundState[]>;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
abstract telemetryLogUsage(eventName: string, data?: Record<string, any | TelemetryTrustedValue>): Promise<void>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
abstract telemetryLogError(eventName: string, data?: Record<string, any | TelemetryTrustedValue>): Promise<void>;
}

0 comments on commit 4cada1c

Please sign in to comment.