Files
faceclaw/app/analytics/analytics-sources.ts
T
FilipAlexanderandClaude Opus 5.5 e2caf28392 Voice: self-hosted Whisper server provider; Transcribe on iOS
- "Whisper server (self-hosted)" transcription provider for OpenAI-compatible
  Whisper servers (vLLM, speaches, LocalAI) over plain HTTP batch requests,
  with URL, model, language and key settings (Voice). Pause-ended spans are
  one request each, finalized in audio order, with provisional text while a
  span is open. See notes/whisper-server.md.
- Transcribe (and other continuous capture) works on iOS with a cloud or
  Whisper-server provider; push-to-talk shares a running capture.
- Transcribe saves each session's audio as transcribe-<time>.wav in Downloads
  (setting "Save Transcribe audio", on by default), written as it is captured
  so a crash leaves a playable file; a saved transcript uses the same stamp.
- Calculator stops continuous listening when its window closes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 16:43:18 +02:00

86 lines
3.6 KiB
TypeScript

/**
* The app-wide things analytics reports (the reliability counts come from
* Kotlin, drained in analytics.ts):
* - Minimal: which devices are paired, and which were in use each day;
* - Full: which kinds of API key are set, how many terminal and T3 Code
* connections there are, the UI font, and every fixed-choice setting.
* Never anything a person typed in: no keys, addresses, names or URLs.
*/
import { loadEnvironments } from "../apps/t3code/t3-environments";
import { loadConnections } from "../apps/terminal/connections";
import { loadDeviceAddresses } from "../g2/device-addresses";
import { onGlassesPresenceChanged } from "../g2/glasses-presence";
import { isPreinstalledFont } from "../graphics/installed-fonts";
import { getUiFontSelection } from "../graphics/ui-fonts";
import { getStringSetting } from "../native/settings-store";
import { isPreviewOnlyMode } from "../phone-ui/onboarding-state";
import { fixedChoiceSettingValues, ringConnectionModeSetting } from "../ui/dashboard-settings";
import { addInputListener } from "../ui/input-monitor";
import { flagAnalyticsEvent, registerAnalyticsSnapshot, startAnalytics } from "./analytics";
import type { Snapshot } from "./analytics-store";
/** Settings holding API keys and tokens, reported only as set or not, by kind. */
const API_KEY_SETTINGS: Record<string, string> = {
anthropic: "llm.anthropicApiKey",
openai: "voice.openAiApiKey",
elevenlabs: "voice.elevenLabsApiKey",
soniox: "voice.sonioxApiKey",
"whisper-server": "voice.whisperServerApiKey",
mapbox: "maps.mapboxApiKey",
roam: "integrations.roam.apiToken",
nightscout: "integrations.nightscout.apiToken",
"agent-bridge": "assistant.bridgeToken",
evenhub: "integrations.evenhub.token",
};
let started = false;
/** Registers the sources above and starts analytics. Main thread, at boot. */
export function startAppAnalytics(): void {
if (started) return;
started = true;
registerAnalyticsSnapshot("minimal", deviceSnapshot);
registerAnalyticsSnapshot("full", configurationSnapshot);
onGlassesPresenceChanged((presence) => {
if (presence.connected) flagAnalyticsEvent("minimal", "device.g2.used");
});
addInputListener((event) => {
if (!("source" in event)) return;
if (event.source === "ring") flagAnalyticsEvent("minimal", "device.r1.used");
else if (event.source === "left-arm" || event.source === "right-arm") flagAnalyticsEvent("minimal", "device.g2.touchpad-used");
});
startAnalytics();
}
function deviceSnapshot(): Snapshot {
const addresses = loadDeviceAddresses();
return {
"device.g2.paired": Boolean(addresses.left && addresses.right),
"device.g2.preview-only": isPreviewOnlyMode(),
"device.r1.paired": Boolean(addresses.ring),
"device.r1.connection": ringConnectionModeSetting.get(),
};
}
function configurationSnapshot(): Snapshot {
const snapshot: Snapshot = {};
for (const [kind, storageKey] of Object.entries(API_KEY_SETTINGS)) {
snapshot[`apikey.${kind}`] = getStringSetting(storageKey, "").trim() !== "";
}
snapshot["config.nightscout-site"] = getStringSetting("integrations.nightscout.siteUrl", "").trim() !== "";
snapshot["config.terminal-connections"] = loadConnections().length;
snapshot["config.t3code-environments"] = loadEnvironments().length;
const font = getUiFontSelection();
snapshot["config.ui-font"] =
font.kind === "bitmap"
? font.face
: `${isPreinstalledFont(font.file) ? font.file.replace(/\.ttf$/i, "") : "installed"}:${font.size}`;
for (const [storageKey, value] of Object.entries(fixedChoiceSettingValues())) {
snapshot[`setting.${storageKey}`] = value;
}
return snapshot;
}