11import { logger } from "@renderer/lib/logger" ;
2- import type {
3- SignalReportArtefactsResponse ,
4- SignalReportsResponse ,
5- Task ,
6- TaskRun ,
7- } from "@shared/types" ;
2+ import type { Task , TaskRun } from "@shared/types" ;
83import type { StoredLogEntry } from "@shared/types/session-events" ;
94import { buildApiFetcher } from "./fetcher" ;
105import { createApiClient , type Schemas } from "./generated" ;
@@ -66,11 +61,7 @@ export class PostHogAPIClient {
6661 return data as Schemas . Team ;
6762 }
6863
69- async getTasks ( options ?: {
70- repository ?: string ;
71- createdBy ?: number ;
72- originProduct ?: string ;
73- } ) {
64+ async getTasks ( options ?: { repository ?: string ; createdBy ?: number } ) {
7465 const teamId = await this . getTeamId ( ) ;
7566 const params : Record < string , string | number > = {
7667 limit : 500 ,
@@ -84,10 +75,6 @@ export class PostHogAPIClient {
8475 params . created_by = options . createdBy ;
8576 }
8677
87- if ( options ?. originProduct ) {
88- params . origin_product = options . originProduct ;
89- }
90-
9178 const data = await this . api . get ( `/api/projects/{project_id}/tasks/` , {
9279 path : { project_id : teamId . toString ( ) } ,
9380 query : params ,
@@ -387,81 +374,6 @@ export class PostHogAPIClient {
387374 return data . results ?? [ ] ;
388375 }
389376
390- async getSignalReports ( ) : Promise < SignalReportsResponse > {
391- const teamId = await this . getTeamId ( ) ;
392- const url = new URL (
393- `${ this . api . baseUrl } /api/projects/${ teamId } /signal_reports/` ,
394- ) ;
395- const response = await this . api . fetcher . fetch ( {
396- method : "get" ,
397- url,
398- path : `/api/projects/${ teamId } /signal_reports/` ,
399- } ) ;
400-
401- if ( ! response . ok ) {
402- throw new Error (
403- `Failed to fetch signal reports: ${ response . statusText } ` ,
404- ) ;
405- }
406-
407- const data = await response . json ( ) ;
408- return {
409- results : data . results ?? data ?? [ ] ,
410- count : data . count ?? data . results ?. length ?? data ?. length ?? 0 ,
411- } ;
412- }
413-
414- async getSignalReportArtefacts (
415- reportId : string ,
416- ) : Promise < SignalReportArtefactsResponse > {
417- const teamId = await this . getTeamId ( ) ;
418- const url = new URL (
419- `${ this . api . baseUrl } /api/projects/${ teamId } /signal_reports/${ reportId } /artefacts/` ,
420- ) ;
421- const response = await this . api . fetcher . fetch ( {
422- method : "get" ,
423- url,
424- path : `/api/projects/${ teamId } /signal_reports/${ reportId } /artefacts/` ,
425- } ) ;
426-
427- if ( ! response . ok ) {
428- throw new Error (
429- `Failed to fetch signal report artefacts: ${ response . statusText } ` ,
430- ) ;
431- }
432-
433- const data = await response . json ( ) ;
434- return {
435- results : data . results ?? data ?? [ ] ,
436- count : data . count ?? data . results ?. length ?? data ?. length ?? 0 ,
437- } ;
438- }
439-
440- /**
441- * Run a HogQL query against the PostHog query API
442- */
443- async runQuery < T = unknown > ( query : {
444- kind : string ;
445- query : string ;
446- } ) : Promise < T > {
447- const teamId = await this . getTeamId ( ) ;
448- const url = new URL ( `${ this . api . baseUrl } /api/projects/${ teamId } /query/` ) ;
449- const response = await this . api . fetcher . fetch ( {
450- method : "post" ,
451- url,
452- path : `/api/projects/${ teamId } /query/` ,
453- overrides : {
454- body : JSON . stringify ( query ) ,
455- } ,
456- } ) ;
457-
458- if ( ! response . ok ) {
459- throw new Error ( `Failed to run query: ${ response . statusText } ` ) ;
460- }
461-
462- return await response . json ( ) ;
463- }
464-
465377 /**
466378 * Update the current team/project settings
467379 */
0 commit comments