Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.
Closed
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
2 changes: 1 addition & 1 deletion apps/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ All are Vite build-time vars (`import.meta.env.*`), baked in at build time.

| Var | Required | Purpose |
| --- | --- | --- |
| `VITE_POSTHOG_API_KEY` | Recommended | Real `phc_…` project key. Enables posthog-js analytics, error/rejection capture, session recording, and real feature flags. The guard in `main.tsx` requires the `phc_` prefix; without it posthog stays uninitialized and the tracker/analytics service no-op, leaving only the host-forced `SYNC_CLOUD_TASKS_FLAG` on (every other flag reads `false`). |
| `VITE_POSTHOG_API_KEY` | Recommended | Real project key. Enables posthog-js analytics, error/rejection capture, session recording, and real feature flags. Without it posthog stays uninitialized and the tracker/analytics service no-op, leaving only the host-forced `SYNC_CLOUD_TASKS_FLAG` on (every other flag reads `false`). |
| `VITE_POSTHOG_API_HOST` | No | posthog-js ingestion host. Default `https://internal-c.posthog.com`. |
| `VITE_POSTHOG_UI_HOST` | No | posthog-js UI host. Default `https://us.i.posthog.com`. |
| `VITE_POSTHOG_ACCESS_TOKEN_OVERRIDE` | No | Dev/test only: a static access token that bypasses the OAuth flow (`AUTH_TOKEN_OVERRIDE`). Leave unset in production. |
Expand Down
23 changes: 22 additions & 1 deletion apps/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,28 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PostHog (Web)</title>
<link rel="icon" type="image/png" href="/favicon.png" />
<title>PostHog Desktop: Web Edition</title>
<meta
name="description"
content="The product editor for product builders"
/>
<meta name="author" content="PostHog" />
<meta name="theme-color" content="#f54d00" />
<meta property="og:type" content="website" />
<meta property="og:title" content="PostHog" />
<meta
property="og:description"
content="The product editor for product builders"
/>
<meta property="og:image" content="/favicon.png" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="PostHog" />
<meta
name="twitter:description"
content="The product editor for product builders"
/>
<meta name="twitter:image" content="/favicon.png" />
</head>
<body>
<div id="root"></div>
Expand Down
Binary file added apps/web/public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions apps/web/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ if (window.location.pathname === OAUTH_CALLBACK_PATH) {
// and analytics service then no-op gracefully rather than firing at a bogus
// endpoint. In production web builds this also enables posthog-js's automatic
// unhandled-error/rejection capture and session recording.
const posthogKey = import.meta.env.VITE_POSTHOG_API_KEY;
if (typeof posthogKey === "string" && posthogKey.startsWith("phc_")) {
initializePostHog();
}
const posthogKey = import.meta.env.VITE_POSTHOG_API_KEY?.trim();
if (posthogKey) initializePostHog();

// Restore any persisted session (desktop does this in main-process
// bootstrap); flips authState.bootstrapComplete when done.
Expand Down
5 changes: 5 additions & 0 deletions apps/web/src/web-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ import {
type GithubConnectClient as OnboardingGithubConnectContract,
} from "@posthog/core/onboarding/identifiers";
import { onboardingModule } from "@posthog/core/onboarding/onboarding.module";
import { PI_RUNNER } from "@posthog/core/pi-runtime/identifiers";
import { piRuntimeModule } from "@posthog/core/pi-runtime/pi-runtime.module";
import type { PiRunner } from "@posthog/core/pi-runtime/piRunner";
import {
PI_SESSION_CLIENT,
type PiSessionClient,
Expand Down Expand Up @@ -295,6 +297,7 @@ import {
webNotifications,
} from "./web-notifications";
import { WebOAuthFlowService } from "./web-oauth-flow";
import { webPiRunner } from "./web-pi-runner";
import { webDiffWorkerFactory, webReviewHost } from "./web-review-host";
import {
webBundleLocalSkill,
Expand All @@ -313,6 +316,7 @@ import { hostTrpcClient } from "./web-trpc";

interface WebBindings {
[HOST_TRPC_CLIENT]: HostTrpcClient;
[PI_RUNNER]: PiRunner;
[PI_SESSION_CLIENT]: PiSessionClient;
[ROOT_LOGGER]: RootLogger;
[HOST_LOGGER]: HostLogger;
Expand Down Expand Up @@ -395,6 +399,7 @@ export const container = new TypedContainer<WebBindings>({
// here (web-trpc.ts) instead of over Electron IPC.
container.bind(HOST_TRPC_CLIENT).toConstantValue(hostTrpcClient);
container.bind(PI_SESSION_CLIENT).to(TrpcPiSessionClient);
container.bind(PI_RUNNER).toConstantValue(webPiRunner);
container.load(piRuntimeModule);

// Logger: web uses console; electron uses electron-log. Same RootLogger shape.
Expand Down
15 changes: 15 additions & 0 deletions apps/web/src/web-pi-runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { PiRunner } from "@posthog/core/pi-runtime/piRunner";

// There is no local pi runtime in a browser. TASK_SERVICE injects PI_RUNNER and
// resolves eagerly at the task views, but the runner only fires for local
// `runtime === "pi"` tasks — web is cloud-only (no local workspaces), so cloud
// tasks never reach these methods. This stub exists so the eager DI resolution
// succeeds; its methods reject since no local pi session can exist on web.
const notSupported = () =>
Promise.reject(new Error("Local pi tasks are not available on the web"));

export const webPiRunner: PiRunner = {
create: notSupported,
resume: notSupported,
stop: notSupported,
};
5 changes: 4 additions & 1 deletion packages/ui/src/features/setup/useSetupDiscovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import { DISCOVERY_RUN_FLAG } from "@posthog/shared";
import { useFeatureFlag } from "@posthog/ui/features/feature-flags/useFeatureFlag";
import { useEffect } from "react";
import { useActiveRepoStore } from "../../shell/activeRepoStore";
import { useHostCapabilities } from "../../shell/useHostCapabilities";

export function useSetupDiscovery() {
const selectedDirectory = useActiveRepoStore((s) => s.path);
const service = useService(SetupRunService);
const discoveryEnabled = useFeatureFlag(DISCOVERY_RUN_FLAG);
const { localWorkspaces } = useHostCapabilities();

useEffect(() => {
if (!localWorkspaces) return;
if (!selectedDirectory) return;
service.maybeStart(selectedDirectory, discoveryEnabled);
}, [selectedDirectory, service, discoveryEnabled]);
}, [localWorkspaces, selectedDirectory, service, discoveryEnabled]);
}
Loading