fix: Add telemetry opt-out via installer prompt and env var

Sentry error reporting can now be disabled by:
1. Declining during the interactive installer (sets CODEGRAPH_TELEMETRY=off
   in the MCP server config env)
2. Setting CODEGRAPH_TELEMETRY=off in your shell environment

README updated with a Telemetry section documenting what is collected
and how to opt out.

Closes #68

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Colby McHenry
2026-04-01 14:14:33 -05:00
co-authored by Claude Opus 4.6
parent c401a96d17
commit 5a185eb736
4 changed files with 61 additions and 17 deletions
+8 -4
View File
@@ -100,18 +100,22 @@ function writeJsonFile(filePath: string, data: Record<string, any>): void {
/**
* Get the MCP server configuration
*/
function getMcpServerConfig(): Record<string, any> {
return {
function getMcpServerConfig(options?: { telemetry?: boolean }): Record<string, any> {
const config: Record<string, any> = {
type: 'stdio',
command: 'codegraph',
args: ['serve', '--mcp'],
};
if (options?.telemetry === false) {
config.env = { CODEGRAPH_TELEMETRY: 'off' };
}
return config;
}
/**
* Write the MCP server configuration to claude.json
*/
export function writeMcpConfig(location: InstallLocation): void {
export function writeMcpConfig(location: InstallLocation, options?: { telemetry?: boolean }): void {
const claudeJsonPath = getClaudeJsonPath(location);
const config = readJsonFile(claudeJsonPath);
@@ -121,7 +125,7 @@ export function writeMcpConfig(location: InstallLocation): void {
}
// Add or update codegraph server
config.mcpServers.codegraph = getMcpServerConfig();
config.mcpServers.codegraph = getMcpServerConfig(options);
writeJsonFile(claudeJsonPath, config);
}
+20 -8
View File
@@ -51,9 +51,25 @@ export async function runInstaller(): Promise<void> {
const location = await promptInstallLocation();
console.log();
// Step 3: Write MCP configuration (always uses npx for reliability)
// Step 3: Ask about auto-allow permissions
const autoAllow = await promptAutoAllow();
console.log();
// Step 4: Ask about anonymous error reporting
console.log(chalk.bold(' Send anonymous error reports?') + chalk.dim(' (Helps fix bugs — no source code collected)'));
console.log();
const enableTelemetry = await promptConfirm('Enable anonymous error reporting', true);
if (!enableTelemetry) {
info('Telemetry disabled');
} else {
success('Anonymous error reporting enabled');
}
console.log();
// Step 5: Write MCP configuration (includes telemetry env if opted out)
const alreadyHasMcp = hasMcpConfig(location);
writeMcpConfig(location);
writeMcpConfig(location, { telemetry: enableTelemetry });
if (alreadyHasMcp) {
success(`Updated MCP server in ${location === 'global' ? '~/.claude.json' : './.claude.json'}`);
@@ -61,10 +77,6 @@ export async function runInstaller(): Promise<void> {
success(`Added MCP server to ${location === 'global' ? '~/.claude.json' : './.claude.json'}`);
}
// Step 4: Ask about auto-allow permissions
const autoAllow = await promptAutoAllow();
console.log();
if (autoAllow) {
const alreadyHasPerms = hasPermissions(location);
writePermissions(location);
@@ -76,7 +88,7 @@ export async function runInstaller(): Promise<void> {
}
}
// Step 5: Write auto-sync hooks
// Step 6: Write auto-sync hooks
const alreadyHasHooks = hasHooks(location);
writeHooks(location);
@@ -86,7 +98,7 @@ export async function runInstaller(): Promise<void> {
success(`Added auto-sync hooks to ${location === 'global' ? '~/.claude/settings.json' : './.claude/settings.json'}`);
}
// Step 6: Write CLAUDE.md instructions
// Step 7: Write CLAUDE.md instructions
const claudeMdResult = writeClaudeMd(location);
const claudeMdPath = location === 'global' ? '~/.claude/CLAUDE.md' : './.claude/CLAUDE.md';