You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🤖 feat: move telemetry reporting to backend (#905)
## 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
```mermaid
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
```
## 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`_
Copy file name to clipboardExpand all lines: docs/telemetry.md
+9-17Lines changed: 9 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,10 @@ mux collects anonymous usage telemetry to help us understand how the product is
4
4
5
5
## Privacy Policy
6
6
7
-
-**Opt-out by default**: You can disable telemetry at any time
8
7
-**No personal information**: We never collect usernames, project names, file paths, or code content
9
8
-**Random IDs only**: Only randomly-generated workspace IDs are sent (impossible to trace back to you)
10
9
-**No hashing**: We don't hash sensitive data because hashing is vulnerable to rainbow table attacks
11
-
-**Transparent data**: See exactly what data structures we send in [`src/telemetry/payload.ts`](https://github.com/coder/mux/blob/main/src/telemetry/payload.ts)
10
+
-**Transparent data**: See exactly what data structures we send in [`src/common/telemetry/payload.ts`](https://github.com/coder/mux/blob/main/src/common/telemetry/payload.ts)
12
11
13
12
## What We Track
14
13
@@ -36,26 +35,19 @@ All telemetry events include basic system information:
36
35
37
36
## Disabling Telemetry
38
37
39
-
You can disable telemetry at any time using the `/telemetry` slash command:
38
+
To disable telemetry, set the `MUX_DISABLE_TELEMETRY` environment variable before starting the app:
40
39
41
-
```
42
-
/telemetry off
43
-
```
44
-
45
-
To re-enable it:
46
-
47
-
```
48
-
/telemetry on
40
+
```bash
41
+
MUX_DISABLE_TELEMETRY=1 mux
49
42
```
50
43
51
-
Your preference is saved and persists across app restarts.
44
+
This completely disables all telemetry collection at the backend level.
52
45
53
46
## Source Code
54
47
55
48
For complete transparency, you can review the telemetry implementation:
56
49
57
-
-**Payload definitions**: [`src/telemetry/payload.ts`](https://github.com/coder/mux/blob/main/src/telemetry/payload.ts) - All data structures we send
58
-
-**Client code**: [`src/telemetry/client.ts`](https://github.com/coder/mux/blob/main/src/telemetry/client.ts) - How telemetry is sent
59
-
-**Privacy utilities**: [`src/telemetry/utils.ts`](https://github.com/coder/mux/blob/main/src/telemetry/utils.ts) - Base-2 rounding and helpers
60
-
61
-
The telemetry system includes debug logging that you can see in the developer console (View → Toggle Developer Tools).
50
+
-**Payload definitions**: [`src/common/telemetry/payload.ts`](https://github.com/coder/mux/blob/main/src/common/telemetry/payload.ts) - All data structures we send
0 commit comments