Skip to content

fix(desktop): pass Amplitude API key to controller launchd service#763

Merged
Siri-Ray merged 3 commits intomainfrom
fix/amplitude-controller-env
Apr 2, 2026
Merged

fix(desktop): pass Amplitude API key to controller launchd service#763
Siri-Ray merged 3 commits intomainfrom
fix/amplitude-controller-env

Conversation

@lefarcen
Copy link
Copy Markdown
Collaborator

@lefarcen lefarcen commented Apr 2, 2026

What

Pass AMPLITUDE_API_KEY environment variable to the controller process via launchd plist.

Why

Controller's analytics-service.ts checks amplitudeApiKey on startup — if missing, it silently skips all event tracking (session_start, skill_use, user_message_sent). The key was injected as a CI build-time env var but never added to the controller's launchd plist EnvironmentVariables, so these events were never sent in packaged desktop builds.

How

  • Add amplitudeApiKey?: string to PlistEnv interface and LaunchdBootstrapEnv interface
  • Inject AMPLITUDE_API_KEY into controller plist when present (same pattern as NEXU_HOME, OPENCLAW_GATEWAY_TOKEN)
  • Pass process.env.AMPLITUDE_API_KEY from Electron main process to bootstrap env

Affected areas

  • Desktop app (Electron shell)
  • Controller (backend / API)
  • Web dashboard (React UI)
  • OpenClaw runtime
  • Skills
  • Shared schemas / packages
  • Build / CI / Tooling

Checklist

  • pnpm typecheck passes
  • pnpm lint passes
  • No credentials or tokens in code or logs
  • No any types introduced (use unknown with narrowing)

Controller analytics service checks for amplitudeApiKey on startup and
silently skips all event tracking when missing. The key was passed as a
build-time env var in CI but never injected into the controller's
launchd plist, so session_start and skill_use events were never sent
in packaged mode.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 76ca51601b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/main/index.ts Outdated
lefarcen added 2 commits April 2, 2026 13:13
…aged mode

Codex review correctly identified that process.env.AMPLITUDE_API_KEY is
empty in packaged Finder launches. Write the key into build-config.json
at dist:mac time and read it back via getDesktopRuntimeConfig(), matching
the existing pattern for SENTRY_DSN and other build-time values.
@Siri-Ray Siri-Ray merged commit 24c8b45 into main Apr 2, 2026
11 checks passed
@lefarcen lefarcen mentioned this pull request Apr 2, 2026
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.

3 participants