Skip to content

feat: add PostHog telemetry - #424

Merged
dimavedenyapin merged 1 commit into
mainfrom
task/posthog-telemetry-kuim4pl80
Jul 19, 2026
Merged

feat: add PostHog telemetry#424
dimavedenyapin merged 1 commit into
mainfrom
task/posthog-telemetry-kuim4pl80

Conversation

@dimavedenyapin

@dimavedenyapin dimavedenyapin commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a main-process PostHog telemetry service with an installation-scoped anonymous id, periodic batching, bounded buffering, and shutdown flush.
  • Record boot, task lifecycle, agent session lifecycle, user turn, approval response, and stop-all telemetry with aggregate metadata only.
  • Keep telemetry inert unless POSTHOG_KEY is configured; POSTHOG_HOST and telemetry buffering controls can be overridden through environment variables.

Local setup

  • Export a PostHog project key before starting the Electron app: export POSTHOG_KEY=<project-key>.
  • Optional overrides: export POSTHOG_HOST=https://us.i.posthog.com, export TELEMETRY_ENABLED=true, export TELEMETRY_FLUSH_BATCH_SIZE=20, export TELEMETRY_MAX_BUFFERED_EVENTS=1000.
  • Start the app normally with pnpm dev; events flush from the main process to ${POSTHOG_HOST}/batch/.
  • To disable telemetry locally, run with TELEMETRY_ENABLED=false or omit POSTHOG_KEY.

Release environment setup

  • In GitHub, add POSTHOG_KEY as a repository or environment secret for the release environment.
  • Add non-sensitive defaults as repository or environment variables if needed: POSTHOG_HOST, TELEMETRY_ENABLED, TELEMETRY_FLUSH_BATCH_SIZE, and TELEMETRY_MAX_BUFFERED_EVENTS.
  • Wire the release workflow job to expose those values to the app build/release step, for example: env: { POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }}, POSTHOG_HOST: ${{ vars.POSTHOG_HOST }}, TELEMETRY_ENABLED: ${{ vars.TELEMETRY_ENABLED }}}.
  • GitHub Actions env vars are available to the release runner. If the packaged desktop app must include the key for end-user installs, the release pipeline must explicitly inject it into the packaged runtime environment or build-time config.

Test plan

  • pnpm typecheck
  • node node_modules/eslint/bin/eslint.js src/main/analytics-service.ts src/main/index.ts src/main/agent-manager.ts src/main/ipc-handlers.ts (passes with one existing warning in src/main/agent-manager.ts)

Generated with Codex

@dimavedenyapin
dimavedenyapin merged commit 3462d41 into main Jul 19, 2026
1 check passed
dimavedenyapin added a commit that referenced this pull request Jul 27, 2026
…nflicts)

Brings the transcript stack up to date with main (10 commits: PostHog
analytics #424/#425/#426, codex fixes #423/#427, releases) and resolves the
conflicts for the #421 → main merge.

Key resolutions:
- agent-manager.ts resumeAdapterSession / replayMissedTranscriptPartsBeforeIdle:
  keep our event-sourced model (resume never replays history to the renderer;
  clients render the durable projection) AND keep main's #427 assistantTextKeys
  codex reconciled-text dedup. In the idle-replay path both dedup layers now
  run — main's assistantTextKeys AND our projection-content dedup — which are
  complementary against the codex agent-msg_/agent-item id-scheme mismatch.
- Renderer + mobile agent-store: took our projection-cache rewrite and re-applied
  main's PostHog telemetry (agent_session_status_changed, agent_output_batch_received,
  agent_approval_requested, agent_created/updated/deleted, agent_session_stopped).
- use-agent-session.ts: kept the "Starting…"/pendingSend send flow AND main's
  agent_message_sent analytics in both send branches.
- agent-manager.test.ts: kept BOTH codex-dedup regression tests (projection-content
  and assistantTextKeys) as separate cases, since both mechanisms now exist.

Verified: typecheck clean, build ✓, full suite 1579 passing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant