Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/update-openapi-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { execSync } from "node:child_process";
import * as fs from "node:fs";
import * as yaml from "yaml";

// const SCHEMA_URL = "http://localhost:8010/api/schema/";
const SCHEMA_URL = "https://us.posthog.com/api/schema/";
const TEMP_SCHEMA_PATH = "temp-openapi.yaml";
const OUTPUT_PATH = "src/api/generated.ts";
Expand Down
120 changes: 70 additions & 50 deletions src/api/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,14 @@ export namespace Schemas {
stop_sequence?: (string | null) | undefined;
usage: AnthropicUsage;
};
export type TranscriptSegment = {
timestamp?: (number | null) | undefined;
speaker?: (string | null) | undefined;
text: string;
confidence?: (number | null) | undefined;
is_final?: (boolean | null) | undefined;
};
export type AppendSegments = { segments: Array<TranscriptSegment> };
export type AttributionModeEnum = "first_touch" | "last_touch";
export type AutocompleteCompletionItemKind =
| "Method"
Expand Down Expand Up @@ -2797,13 +2805,10 @@ export namespace Schemas {
| "processing"
| "ready"
| "error";
export type RecordingTranscript = {
full_text: string;
segments?: unknown | undefined;
summary?: (string | null) | undefined;
extracted_tasks?: unknown | undefined;
created_at: string;
updated_at: string;
export type Task = {
title: string;
description?: string | undefined;
assignee?: (string | null) | undefined;
};
export type CreateRecordingResponse = {
id: string;
Expand All @@ -2816,14 +2821,21 @@ export namespace Schemas {
meeting_url?: (string | null) | undefined;
duration_seconds?: (number | null) | undefined;
status?: Status292Enum | undefined;
notes?: (string | null) | undefined;
error_message?: (string | null) | undefined;
video_url?: (string | null) | undefined;
video_size_bytes?: (number | null) | undefined;
participants?: unknown | undefined;
participants?: Array<string> | undefined;
transcript_text: string;
transcript_segments?: Array<TranscriptSegment> | undefined;
summary?: (string | null) | undefined;
extracted_tasks?: Array<Task> | undefined;
tasks_generated_at?: (string | null) | undefined;
summary_generated_at?: (string | null) | undefined;
started_at?: string | undefined;
completed_at?: (string | null) | undefined;
created_at: string;
updated_at: string;
transcript: RecordingTranscript & unknown;
upload_token: string;
};
export type CreationContextEnum =
Expand Down Expand Up @@ -2851,6 +2863,7 @@ export namespace Schemas {
created_at: string;
created_by: UserBasic & unknown;
last_accessed_at?: (string | null) | undefined;
last_viewed_at: string | null;
is_shared: boolean;
deleted?: boolean | undefined;
creation_mode: CreationModeEnum & unknown;
Expand Down Expand Up @@ -2882,6 +2895,7 @@ export namespace Schemas {
created_at: string;
created_by: UserBasic & unknown;
last_accessed_at: string | null;
last_viewed_at: string | null;
is_shared: boolean;
deleted: boolean;
creation_mode: CreationModeEnum & unknown;
Expand Down Expand Up @@ -3263,6 +3277,7 @@ export namespace Schemas {
| "twilio"
| "linear"
| "github"
| "gitlab"
| "meta-ads"
| "clickup"
| "reddit-ads"
Expand Down Expand Up @@ -4753,14 +4768,21 @@ export namespace Schemas {
meeting_url?: (string | null) | undefined;
duration_seconds?: (number | null) | undefined;
status?: Status292Enum | undefined;
notes?: (string | null) | undefined;
error_message?: (string | null) | undefined;
video_url?: (string | null) | undefined;
video_size_bytes?: (number | null) | undefined;
participants?: unknown | undefined;
participants?: Array<string> | undefined;
transcript_text: string;
transcript_segments?: Array<TranscriptSegment> | undefined;
summary?: (string | null) | undefined;
extracted_tasks?: Array<Task> | undefined;
tasks_generated_at?: (string | null) | undefined;
summary_generated_at?: (string | null) | undefined;
started_at?: string | undefined;
completed_at?: (string | null) | undefined;
created_at: string;
updated_at: string;
transcript: RecordingTranscript & unknown;
};
export type DisplayEnum = "number" | "sparkline";
export type DistanceFunc = "L1Distance" | "L2Distance" | "cosineDistance";
Expand Down Expand Up @@ -4985,12 +5007,17 @@ export namespace Schemas {
storage_ptr?: (string | null) | undefined;
failure_reason?: (string | null) | undefined;
};
export type EvaluationTypeEnum = "llm_judge";
export type OutputTypeEnum = "boolean";
export type Evaluation = {
id: string;
name: string;
description?: string | undefined;
enabled?: boolean | undefined;
prompt: string;
evaluation_type: EvaluationTypeEnum;
evaluation_config?: unknown | undefined;
output_type: OutputTypeEnum;
output_config?: unknown | undefined;
conditions?: unknown | undefined;
created_at: string;
updated_at: string;
Expand Down Expand Up @@ -6295,6 +6322,7 @@ export namespace Schemas {
| "email"
| "linear"
| "github"
| "gitlab"
| "meta-ads"
| "twilio"
| "clickup"
Expand Down Expand Up @@ -7605,22 +7633,6 @@ export namespace Schemas {
previous?: (string | null) | undefined;
results: Array<Table>;
};
export type Task = {
id: string;
task_number: number | null;
slug: string;
title?: string | undefined;
description: string;
origin_product: OriginProductEnum;
position?: number | undefined;
github_integration?: (number | null) | undefined;
repository_config?: unknown | undefined;
repository_list: string;
primary_repository: string;
latest_run: string;
created_at: string;
updated_at: string;
};
export type PaginatedTaskList = {
count: number;
next?: (string | null) | undefined;
Expand Down Expand Up @@ -7836,6 +7848,7 @@ export namespace Schemas {
created_at: string;
created_by: UserBasic & unknown;
last_accessed_at: string | null;
last_viewed_at: string | null;
is_shared: boolean;
deleted: boolean;
creation_mode: CreationModeEnum & unknown;
Expand Down Expand Up @@ -7937,14 +7950,21 @@ export namespace Schemas {
meeting_url: string | null;
duration_seconds: number | null;
status: Status292Enum;
notes: string | null;
error_message: string | null;
video_url: string | null;
video_size_bytes: number | null;
participants: unknown;
participants: Array<string>;
transcript_text: string;
transcript_segments: Array<TranscriptSegment>;
summary: string | null;
extracted_tasks: Array<Task>;
tasks_generated_at: string | null;
summary_generated_at: string | null;
started_at: string;
completed_at: string | null;
created_at: string;
updated_at: string;
transcript: RecordingTranscript & unknown;
}>;
export type PatchedEarlyAccessFeature = Partial<{
id: string;
Expand Down Expand Up @@ -7996,7 +8016,10 @@ export namespace Schemas {
name: string;
description: string;
enabled: boolean;
prompt: string;
evaluation_type: EvaluationTypeEnum;
evaluation_config: unknown;
output_type: OutputTypeEnum;
output_config: unknown;
conditions: unknown;
created_at: string;
updated_at: string;
Expand Down Expand Up @@ -8489,6 +8512,7 @@ export namespace Schemas {
latest_run: string;
created_at: string;
updated_at: string;
created_by: UserBasic & unknown;
}>;
export type PatchedTaskRunDetail = Partial<{
id: string;
Expand Down Expand Up @@ -10011,10 +10035,6 @@ export namespace Schemas {
product_intents: string;
managed_viewsets: string;
};
export type UploadTranscript = Partial<{
segments: Array<Record<string, unknown>>;
full_text: string;
}>;
export type WebAnalyticsBreakdownResponse = {
next?: (string | null) | undefined;
results: Array<unknown>;
Expand Down Expand Up @@ -10715,25 +10735,16 @@ export namespace Endpoints {
};
responses: { 204: unknown };
};
export type get_Environments_desktop_recordings_transcript_retrieve = {
method: "GET";
path: "/api/environments/{project_id}/desktop_recordings/{id}/transcript/";
requestFormat: "json";
parameters: {
path: { id: string; project_id: string };
};
responses: { 200: Schemas.RecordingTranscript; 404: unknown };
};
export type post_Environments_desktop_recordings_transcript_create = {
export type post_Environments_desktop_recordings_append_segments_create = {
method: "POST";
path: "/api/environments/{project_id}/desktop_recordings/{id}/transcript/";
path: "/api/environments/{project_id}/desktop_recordings/{id}/append_segments/";
requestFormat: "json";
parameters: {
path: { id: string; project_id: string };

body: Schemas.UploadTranscript;
body: Schemas.AppendSegments;
};
responses: { 200: Schemas.RecordingTranscript };
responses: { 200: Schemas.DesktopRecording };
};
export type get_Environments_endpoints_retrieve = {
method: "GET";
Expand Down Expand Up @@ -11533,6 +11544,15 @@ export namespace Endpoints {
};
responses: { 200: unknown };
};
export type get_Environments_file_system_log_view_retrieve = {
method: "GET";
path: "/api/environments/{project_id}/file_system/log_view/";
requestFormat: "json";
parameters: {
path: { project_id: string };
};
responses: { 200: unknown };
};
export type post_Environments_file_system_log_view_create = {
method: "POST";
path: "/api/environments/{project_id}/file_system/log_view/";
Expand Down Expand Up @@ -13620,7 +13640,6 @@ export type EndpointByMethod = {
"/api/environments/{project_id}/datasets/{id}/": Endpoints.get_Environments_datasets_retrieve;
"/api/environments/{project_id}/desktop_recordings/": Endpoints.get_Environments_desktop_recordings_list;
"/api/environments/{project_id}/desktop_recordings/{id}/": Endpoints.get_Environments_desktop_recordings_retrieve;
"/api/environments/{project_id}/desktop_recordings/{id}/transcript/": Endpoints.get_Environments_desktop_recordings_transcript_retrieve;
"/api/environments/{project_id}/endpoints/": Endpoints.get_Environments_endpoints_retrieve;
"/api/environments/{project_id}/endpoints/{name}/": Endpoints.get_Environments_endpoints_retrieve_2;
"/api/environments/{project_id}/endpoints/{name}/run/": Endpoints.get_Environments_endpoints_run_retrieve;
Expand Down Expand Up @@ -13648,6 +13667,7 @@ export type EndpointByMethod = {
"/api/environments/{project_id}/exports/{id}/content/": Endpoints.get_Environments_exports_content_retrieve;
"/api/environments/{project_id}/file_system/": Endpoints.get_Environments_file_system_list;
"/api/environments/{project_id}/file_system/{id}/": Endpoints.get_Environments_file_system_retrieve;
"/api/environments/{project_id}/file_system/log_view/": Endpoints.get_Environments_file_system_log_view_retrieve;
"/api/environments/{project_id}/file_system/unfiled/": Endpoints.get_Environments_file_system_unfiled_retrieve;
"/api/environments/{project_id}/file_system_shortcut/": Endpoints.get_Environments_file_system_shortcut_list;
"/api/environments/{project_id}/file_system_shortcut/{id}/": Endpoints.get_Environments_file_system_shortcut_retrieve;
Expand Down Expand Up @@ -13753,7 +13773,7 @@ export type EndpointByMethod = {
"/api/environments/{project_id}/dataset_items/": Endpoints.post_Environments_dataset_items_create;
"/api/environments/{project_id}/datasets/": Endpoints.post_Environments_datasets_create;
"/api/environments/{project_id}/desktop_recordings/": Endpoints.post_Environments_desktop_recordings_create;
"/api/environments/{project_id}/desktop_recordings/{id}/transcript/": Endpoints.post_Environments_desktop_recordings_transcript_create;
"/api/environments/{project_id}/desktop_recordings/{id}/append_segments/": Endpoints.post_Environments_desktop_recordings_append_segments_create;
"/api/environments/{project_id}/endpoints/": Endpoints.post_Environments_endpoints_create;
"/api/environments/{project_id}/endpoints/{name}/run/": Endpoints.post_Environments_endpoints_run_create;
"/api/environments/{project_id}/endpoints/last_execution_times/": Endpoints.post_Environments_endpoints_last_execution_times_create;
Expand Down
41 changes: 8 additions & 33 deletions src/api/posthogClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class PostHogAPIClient {

const data = await this.api.post(`/api/projects/{project_id}/tasks/`, {
path: { project_id: teamId.toString() },
// @ts-expect-error (marking it as ignore since unrelated to this PR)
body: payload as Schemas.Task,
});

Expand Down Expand Up @@ -103,7 +104,9 @@ export class PostHogAPIClient {
async duplicateTask(taskId: string) {
const task = await this.getTask(taskId);
return this.createTask(
// @ts-expect-error (marking it as ignore since unrelated to this PR)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added these because after syncing the latest openai api changed it start failing. let me know if i should remove though

task.description,
// @ts-expect-error (marking it as ignore since unrelated to this PR)
task.repository_config as RepositoryConfig | undefined,
);
}
Expand Down Expand Up @@ -298,25 +301,6 @@ export class PostHogAPIClient {
return await response.json();
}

async getDesktopRecordingTranscript(recordingId: string) {
this.validateRecordingId(recordingId);
const teamId = await this.getTeamId();
const url = new URL(
`${this.api.baseUrl}/api/environments/${teamId}/desktop_recordings/${recordingId}/transcript/`,
);
const response = await this.api.fetcher.fetch({
method: "get",
url,
path: `/api/environments/${teamId}/desktop_recordings/${recordingId}/transcript/`,
});

if (!response.ok) {
throw new Error(`Failed to fetch transcript: ${response.statusText}`);
}

return await response.json();
}

async listDesktopRecordings(filters?: {
platform?: string;
status?: string;
Expand Down Expand Up @@ -382,27 +366,18 @@ export class PostHogAPIClient {
return data;
}

async updateDesktopRecordingTranscript(
async appendTranscriptSegments(
recordingId: string,
updates: {
segments?: Array<{
timestamp_ms: number;
speaker: string | null;
text: string;
confidence: number | null;
is_final: boolean;
}>;
full_text?: string;
},
) {
segments: Array<Schemas.TranscriptSegment>,
): Promise<Schemas.DesktopRecording> {
this.validateRecordingId(recordingId);
const teamId = await this.getTeamId();

const data = await this.api.post(
"/api/environments/{project_id}/desktop_recordings/{id}/transcript/",
"/api/environments/{project_id}/desktop_recordings/{id}/append_segments/",
{
path: { project_id: teamId.toString(), id: recordingId },
body: updates as any,
body: { segments } as Schemas.AppendSegments,
},
);

Expand Down
Loading