Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Summary

Moves telemetry event capture from the browser (posthog-js) to the Electron main process (posthog-node). Events from the renderer are forwarded via ORPC to the backend TelemetryService.

Problem

Ad blockers can intercept and block network requests to PostHog's servers (us.i.posthog.com) from the browser/renderer process, causing telemetry to be silently dropped.

Solution

Move telemetry to the main process using posthog-node. The main process makes direct HTTP requests that aren't subject to browser-based ad blocking.

Architecture

flowchart LR
    subgraph Renderer["Renderer (Browser)"]
        A[useTelemetry hook]
        B[trackEvent calls]
    end
    
    subgraph Main["Main Process (Node.js)"]
        C[ORPC telemetry routes]
        D[posthog-node client]
    end
    
    E[(PostHog)]
    
    A --> B
    B -->|ORPC| C
    C --> D
    D -->|HTTP| E
Loading

Changes

  • New: posthog-node dependency
  • New: TelemetryService in src/node/services/
  • New: ORPC telemetry.{track, setEnabled, isEnabled} routes
  • Updated: Frontend client now calls backend via ORPC
  • Simplified: Payload types no longer require base properties from frontend

What Stays the Same

  • useTelemetry() hook API
  • trackEvent() function signature
  • Opt-out UX via localStorage
  • All existing event types

Testing

  • make typecheck
  • make lint
  • make static-check
  • make test (1 pre-existing failure unrelated to this PR)

Generated with mux

This moves telemetry event capture from the browser (posthog-js) to the
Electron main process (posthog-node). Events from the renderer are now
forwarded via ORPC to the backend TelemetryService.

Benefits:
- Ad blockers cannot block telemetry requests from the main process
- Centralized distinct ID management (persisted in ~/.mux/telemetry_id)
- Base properties (version, platform, electronVersion) added by backend

Changes:
- Add posthog-node dependency
- Create TelemetryService in src/node/services/
- Add ORPC telemetry.{track, setEnabled, isEnabled} routes
- Update frontend client to call backend via ORPC
- Simplify payload types (backend adds base properties)

The frontend API (useTelemetry hook, trackEvent function) remains unchanged.

_Generated with mux_
@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

- Remove the 100ms setTimeout that tried to sync enabled state to backend
  (unnecessary - frontend guards trackEvent with isTelemetryEnabled())
- Change all telemetry logs from log/warn to debug level to avoid
  giving users a reason to disable telemetry
@ammar-agent ammar-agent force-pushed the backend-posthoc-telemetry-reporting branch from 47db2b3 to 8b94565 Compare December 4, 2025 17:13
- Remove conditional telemetry-disabled messaging from update tooltip
- Remove telemetryEnabled check from getIndicatorStatus
- Update docs/telemetry.md with MUX_DISABLE_TELEMETRY env var
- Update source code links to new paths
- Fix client.test.ts to match simplified API
@ammar-agent ammar-agent force-pushed the backend-posthoc-telemetry-reporting branch from 8b94565 to 59e8aa7 Compare December 4, 2025 17:15
@ammario ammario changed the title 🤖 feat: move PostHog telemetry to backend to avoid adblock 🤖 feat: move telemetry reporting to backend Dec 4, 2025
@ammario ammario merged commit 2c91806 into main Dec 4, 2025
18 checks passed
@ammario ammario deleted the backend-posthoc-telemetry-reporting branch December 4, 2025 17:29
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.

2 participants