Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(desktop): point the openapi client generator at the api-client package (#79301)

Phil Haack9b1a7139b171
diff --git a/products/desktop/apps/code/scripts/update-openapi-client.ts b/products/desktop/apps/code/scripts/update-openapi-client.ts
index aeeb10222816..9a931f4e0355 100644
--- a/products/desktop/apps/code/scripts/update-openapi-client.ts
+++ b/products/desktop/apps/code/scripts/update-openapi-client.ts
@@ -2,9 +2,15 @@
import { execSync } from "node:child_process";
import * as fs from "node:fs";
+import * as path from "node:path";
+import { fileURLToPath } from "node:url";
import { config } from "dotenv";
import * as yaml from "yaml";
+// Anchor to apps/code so the relative paths below (and dotenv, and the pnpm binary lookup)
+// resolve the same way no matter which directory the script is invoked from.
+process.chdir(path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."));
+
config();
const POSTHOG_API_HOST = process.env.VITE_POSTHOG_API_HOST;
@@ -14,7 +20,7 @@ if (!POSTHOG_API_HOST) {
const SCHEMA_URL = `${POSTHOG_API_HOST}/api/schema/`;
const TEMP_SCHEMA_PATH = "temp-openapi.yaml";
-const OUTPUT_PATH = "src/renderer/api/generated.ts";
+const OUTPUT_PATH = "../../packages/api-client/src/generated.ts";
const INCLUDED_ENDPOINT_PREFIXES = [
"/api/projects/{project_id}/tasks",