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
9 changes: 6 additions & 3 deletions apps/code/src/renderer/api/posthogClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1341,15 +1341,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);
}
Comment on lines +1349 to +1355
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.

const response = await this.api.fetcher.fetch({
method: "get",
url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,10 @@ function GitHubSetup({ onComplete, onCancel }: SetupFormProps) {
try {
if (!client) return;
// Trigger a refetch of integrations
const integrations =
await client.getIntegrationsForProject(projectId);
const integrations = await client.getIntegrationsForProject(
projectId,
"github",
);
const hasGithub = integrations.some(
(i: { kind: string }) => i.kind === "github",
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion apps/code/src/renderer/hooks/useIntegrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function useIntegrations() {

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.

);

useEffect(() => {
Expand Down
Loading