Skip to content

Commit 1883e82

Browse files
VojtechBartosjonathanlab
authored andcommitted
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
1 parent 5bcf25f commit 1883e82

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

apps/code/src/renderer/api/posthogClient.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,15 +1473,18 @@ export class PostHogAPIClient {
14731473
}
14741474
}
14751475

1476-
async getIntegrations() {
1476+
async getIntegrations(kind?: string) {
14771477
const teamId = await this.getTeamId();
1478-
return this.getIntegrationsForProject(teamId);
1478+
return this.getIntegrationsForProject(teamId, kind);
14791479
}
14801480

1481-
async getIntegrationsForProject(projectId: number) {
1481+
async getIntegrationsForProject(projectId: number, kind?: string) {
14821482
const url = new URL(
14831483
`${this.api.baseUrl}/api/environments/${projectId}/integrations/`,
14841484
);
1485+
if (kind) {
1486+
url.searchParams.set("kind", kind);
1487+
}
14851488
const response = await this.api.fetcher.fetch({
14861489
method: "get",
14871490
url,

apps/code/src/renderer/features/onboarding/hooks/usePrefetchSignalData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function usePrefetchSignalData(): void {
3636
queryClient.prefetchQuery({
3737
queryKey: ["integrations", "list"],
3838
queryFn: async () => {
39-
const integrations = await client.getIntegrations();
39+
const integrations = await client.getIntegrations("github");
4040
const ghIntegration = (
4141
integrations as { id: number; kind: string }[]
4242
).find((i) => i.kind === "github");

apps/code/src/renderer/hooks/useIntegrations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function useIntegrations() {
7171

7272
const query = useAuthenticatedQuery(
7373
integrationKeys.list(),
74-
(client) => client.getIntegrations() as Promise<Integration[]>,
74+
(client) => client.getIntegrations("github") as Promise<Integration[]>,
7575
);
7676

7777
useEffect(() => {

0 commit comments

Comments
 (0)