Skip to content

Commit 14aad91

Browse files
TeoSlayerteovlclaudeAlexgodoroja
authored
fix(telemetry): default daemon to production endpoint; emit app_usage on pilotctl call (#293)
fix(telemetry): default daemon to production endpoint; emit app_usage on call - cmd/daemon/main.go: default -telemetry-url to telemetry.DefaultEndpoint when PILOT_TELEMETRY_URL is unset. Previously the daemon silently dropped all telemetry because the flag defaulted to "" (hard no-op). - cmd/pilotctl/appstore.go: emit app_usage event after a successful `pilotctl appstore call`. Previously this event was only reachable through the daemon supervisor path, not the direct IPC call path. Both emissions are consent-gated (telemetry flag, default on) and best-effort. Co-authored-by: Teodor Calin <teodor@vulturelabs.io> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Alex Godoroja <50743382+Alexgodoroja@users.noreply.github.com>
1 parent 2b2dd78 commit 14aad91

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

cmd/daemon/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ func main() {
103103
sandboxDir := flag.String("sandbox-dir", "", "confinement root when -sandbox is set (default: ~/.pilot)")
104104
motdFeedURL := flag.String("motd-feed-url", motd.DefaultFeedURL, "message-of-the-day feed URL (empty to disable); overridden by $PILOT_MOTD_URL")
105105
motdInterval := flag.Duration("motd-interval", 0, "message-of-the-day poll interval (default 15m)")
106-
telemetryURL := flag.String("telemetry-url", os.Getenv("PILOT_TELEMETRY_URL"),
106+
telemetryURLDefault := os.Getenv("PILOT_TELEMETRY_URL")
107+
if telemetryURLDefault == "" {
108+
telemetryURLDefault = telemetry.DefaultEndpoint
109+
}
110+
telemetryURL := flag.String("telemetry-url", telemetryURLDefault,
107111
"telemetry endpoint URL (empty = consent off, hard no-op). "+
108112
"Env: PILOT_TELEMETRY_URL. Default: "+telemetry.DefaultEndpoint+".")
109113
flag.Parse()

cmd/pilotctl/appstore.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,6 +2076,17 @@ func cmdAppStoreCall(args []string) {
20762076
fatalHint("ipc_error", hint, "%v", err)
20772077
}
20782078

2079+
// Emit app_usage telemetry for a successful call (consent-gated, best-effort).
2080+
if h, _ := os.UserHomeDir(); consent.GetConsent(h, "telemetry") {
2081+
turl := os.Getenv("PILOT_TELEMETRY_URL")
2082+
if turl == "" {
2083+
turl = telemetry.DefaultEndpoint
2084+
}
2085+
payload, _ := json.Marshal(map[string]string{"app_id": appID, "method": method})
2086+
client := telemetry.NewClientFromIdentity(turl, configDir()+"/identity.json", nodeIDFromDaemon())
2087+
_ = client.Send(telemetry.Event{Kind: "app_usage", Payload: json.RawMessage(payload)})
2088+
}
2089+
20792090
// Maybe replace the real result with a review prompt (gated by
20802091
// appstore.review_prompt feature flag + random roll).
20812092
replaced, intercepted := maybeInterceptOutput(result, appID)

0 commit comments

Comments
 (0)