// `rnx config telemetry on|off` — retained as the command spelling for the // product analytics preference shown by guided setup and Settings. // // this is the process-wide preference; `DO_NOT_TRACK=1` still forces opt-out // for a single run regardless of what's stored (honored by isOptedOut in // telemetry.ts, the same cross-tool signal npm/turbo/supabase use). import { configFilePath, readPrivacyPreferences, writePrivacyPreferences, } from '../../src/home-paths' import { rnxExit } from '../run-rnx' function printStatus(): void { const preferences = readPrivacyPreferences() const enabled = preferences.configured && preferences.productAnalytics console.log(` bounded diagnostics are ${enabled ? 'ON' : 'OFF'}`) console.log(' permitted fields: package name/version/unsupported API or error class') console.log(` config: ${configFilePath()}`) const doNotTrack = process.env.DO_NOT_TRACK if (doNotTrack === '1' || doNotTrack === 'true') { console.log( ` note: DO_NOT_TRACK=${doNotTrack} is set — telemetry is off for this run`, ) } } export async function runTelemetry(args: string[]): Promise { const sub = args.find((a) => !a.startsWith('-'))?.toLowerCase() switch (sub) { case undefined: case 'status': printStatus() return case 'on': writePrivacyPreferences({ productAnalytics: true, crashReports: false }) console.log(' bounded diagnostics ON') console.log(` config: ${configFilePath()}`) return case 'off': writePrivacyPreferences({ productAnalytics: false, crashReports: false }) console.log(' bounded diagnostics OFF') console.log(` config: ${configFilePath()}`) return default: console.error(` unknown telemetry action: ${sub}`) console.error(' usage: rnx config telemetry [on|off|status]') rnxExit(1) } }