From 1883e82365896dcdd837fad0211c179022523bd0 Mon Sep 17 00:00:00 2001 From: Vojta Bartos Date: Thu, 30 Apr 2026 13:06:58 +0000 Subject: [PATCH] feat(integrations): filter integrations by kind server-side Use the new `kind` query parameter on the integrations endpoint to fetch only GitHub integrations from the desktop app, instead of pulling every integration kind and filtering client-side. Backend support: PostHog/posthog#57135. The client-side `kind === "github"` filter in `integrationStore` is kept as a safety net for self-hosted PostHog instances that pre-date that PR. Generated-By: PostHog Code Task-Id: d6eddcca-1d82-4d29-8a3e-baead66e19df --- apps/code/src/renderer/api/posthogClient.ts | 9 ++++++--- .../features/onboarding/hooks/usePrefetchSignalData.ts | 2 +- apps/code/src/renderer/hooks/useIntegrations.ts | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/code/src/renderer/api/posthogClient.ts b/apps/code/src/renderer/api/posthogClient.ts index 0114942534..5f24d28303 100644 --- a/apps/code/src/renderer/api/posthogClient.ts +++ b/apps/code/src/renderer/api/posthogClient.ts @@ -1473,15 +1473,18 @@ export class PostHogAPIClient { } } - async getIntegrations() { + async getIntegrations(kind?: string) { const teamId = await this.getTeamId(); - return this.getIntegrationsForProject(teamId); + return this.getIntegrationsForProject(teamId, kind); } - async getIntegrationsForProject(projectId: number) { + async getIntegrationsForProject(projectId: number, kind?: string) { const url = new URL( `${this.api.baseUrl}/api/environments/${projectId}/integrations/`, ); + if (kind) { + url.searchParams.set("kind", kind); + } const response = await this.api.fetcher.fetch({ method: "get", url, diff --git a/apps/code/src/renderer/features/onboarding/hooks/usePrefetchSignalData.ts b/apps/code/src/renderer/features/onboarding/hooks/usePrefetchSignalData.ts index 5f65d593a9..84c7f11abc 100644 --- a/apps/code/src/renderer/features/onboarding/hooks/usePrefetchSignalData.ts +++ b/apps/code/src/renderer/features/onboarding/hooks/usePrefetchSignalData.ts @@ -36,7 +36,7 @@ export function usePrefetchSignalData(): void { queryClient.prefetchQuery({ queryKey: ["integrations", "list"], queryFn: async () => { - const integrations = await client.getIntegrations(); + const integrations = await client.getIntegrations("github"); const ghIntegration = ( integrations as { id: number; kind: string }[] ).find((i) => i.kind === "github"); diff --git a/apps/code/src/renderer/hooks/useIntegrations.ts b/apps/code/src/renderer/hooks/useIntegrations.ts index b32cd2c63f..4c07c38b44 100644 --- a/apps/code/src/renderer/hooks/useIntegrations.ts +++ b/apps/code/src/renderer/hooks/useIntegrations.ts @@ -71,7 +71,7 @@ export function useIntegrations() { const query = useAuthenticatedQuery( integrationKeys.list(), - (client) => client.getIntegrations() as Promise, + (client) => client.getIntegrations("github") as Promise, ); useEffect(() => {