Skip to content

feat(integrations): filter integrations by kind server-side#1954

Open
VojtechBartos wants to merge 1 commit intomainfrom
vojta/integrations-kind-filter
Open

feat(integrations): filter integrations by kind server-side#1954
VojtechBartos wants to merge 1 commit intomainfrom
vojta/integrations-kind-filter

Conversation

@VojtechBartos
Copy link
Copy Markdown
Member

Summary

Use the new kind query parameter on GET /api/environments/{projectId}/integrations/ so the desktop app fetches only GitHub integrations 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.

Test plan

  • pnpm --filter code typecheck passes
  • posthogClient.test.ts passes
  • Manual smoke check: open the app on a GitHub-connected project; confirm …/integrations/?kind=github in the network panel and that GitHub repos still load in the inbox / onboarding flows

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
@VojtechBartos VojtechBartos self-assigned this Apr 30, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
apps/code/src/renderer/hooks/useIntegrations.ts:41
**Magic string `"github"` duplicated across call sites**

The string literal `"github"` is now hardcoded in three separate files (`useIntegrations.ts`, `usePrefetchSignalData.ts`, `DataSourceSetup.tsx`) as the `kind` argument. This violates the OnceAndOnlyOnce principle — if the kind identifier ever changes, all three sites need updating. Consider exporting a shared constant (e.g. `GITHUB_INTEGRATION_KIND = "github"`) from `integrationStore.ts` and referencing it at every call site and in the existing `i.kind === "github"` guards.

### Issue 2 of 2
apps/code/src/renderer/api/posthogClient.ts:1349-1355
**No test coverage for the new `kind` query parameter**

`posthogClient.test.ts` has no test for `getIntegrations` / `getIntegrationsForProject`. The new `kind` parameter changes the URL that is fetched (appending `?kind=github`), but no test verifies that the query string is correctly set — or omitted when `kind` is `undefined`. A parameterised test covering both the filtered and unfiltered cases would prevent a silent regression if the URL-building logic is touched later.

Reviews (1): Last reviewed commit: "feat(integrations): filter integrations ..." | Re-trigger Greptile

const query = useAuthenticatedQuery(
integrationKeys.list(),
(client) => client.getIntegrations() as Promise<Integration[]>,
(client) => client.getIntegrations("github") as Promise<Integration[]>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Magic string "github" duplicated across call sites

The string literal "github" is now hardcoded in three separate files (useIntegrations.ts, usePrefetchSignalData.ts, DataSourceSetup.tsx) as the kind argument. This violates the OnceAndOnlyOnce principle — if the kind identifier ever changes, all three sites need updating. Consider exporting a shared constant (e.g. GITHUB_INTEGRATION_KIND = "github") from integrationStore.ts and referencing it at every call site and in the existing i.kind === "github" guards.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/hooks/useIntegrations.ts
Line: 41

Comment:
**Magic string `"github"` duplicated across call sites**

The string literal `"github"` is now hardcoded in three separate files (`useIntegrations.ts`, `usePrefetchSignalData.ts`, `DataSourceSetup.tsx`) as the `kind` argument. This violates the OnceAndOnlyOnce principle — if the kind identifier ever changes, all three sites need updating. Consider exporting a shared constant (e.g. `GITHUB_INTEGRATION_KIND = "github"`) from `integrationStore.ts` and referencing it at every call site and in the existing `i.kind === "github"` guards.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +1349 to +1355
async getIntegrationsForProject(projectId: number, kind?: string) {
const url = new URL(
`${this.api.baseUrl}/api/environments/${projectId}/integrations/`,
);
if (kind) {
url.searchParams.set("kind", kind);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 No test coverage for the new kind query parameter

posthogClient.test.ts has no test for getIntegrations / getIntegrationsForProject. The new kind parameter changes the URL that is fetched (appending ?kind=github), but no test verifies that the query string is correctly set — or omitted when kind is undefined. A parameterised test covering both the filtered and unfiltered cases would prevent a silent regression if the URL-building logic is touched later.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/api/posthogClient.ts
Line: 1349-1355

Comment:
**No test coverage for the new `kind` query parameter**

`posthogClient.test.ts` has no test for `getIntegrations` / `getIntegrationsForProject`. The new `kind` parameter changes the URL that is fetched (appending `?kind=github`), but no test verifies that the query string is correctly set — or omitted when `kind` is `undefined`. A parameterised test covering both the filtered and unfiltered cases would prevent a silent regression if the URL-building logic is touched later.

How can I resolve this? If you propose a fix, please make it concise.

@VojtechBartos VojtechBartos requested a review from a team April 30, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants