mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-01-29 22:12:05 +00:00
Adds zero-configuration anonymous usage statistics to track: - Number of active users with deterministic user IDs - Which MCP tools AI agents use most - What workflows are built (sanitized to protect privacy) - Common errors and issues Key features: - Zero-configuration design with hardcoded write-only credentials - Privacy-first approach with comprehensive data sanitization - Opt-out support via config file and environment variables - Docker-friendly with environment variable support - Multi-process safe with immediate flush strategy - Row Level Security (RLS) policies for write-only access Technical implementation: - Supabase backend with anon key for INSERT-only operations - Workflow sanitization removes all sensitive data - Environment variables checked for opt-out (TELEMETRY_DISABLED, etc.) - Telemetry enabled by default but respects user preferences - Cleaned up all debug logging for production readiness 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
62 lines
2.7 KiB
TypeScript
62 lines
2.7 KiB
TypeScript
#!/usr/bin/env npx tsx
|
|
/**
|
|
* Test telemetry environment variable override
|
|
*/
|
|
|
|
import { TelemetryConfigManager } from '../src/telemetry/config-manager';
|
|
import { telemetry } from '../src/telemetry/telemetry-manager';
|
|
|
|
async function testEnvOverride() {
|
|
console.log('🧪 Testing Telemetry Environment Variable Override\n');
|
|
|
|
const configManager = TelemetryConfigManager.getInstance();
|
|
|
|
// Test 1: Check current status without env var
|
|
console.log('Test 1: Without environment variable');
|
|
console.log('Is Enabled:', configManager.isEnabled());
|
|
console.log('Status:', configManager.getStatus());
|
|
|
|
// Test 2: Set environment variable and check again
|
|
console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
console.log('Test 2: With N8N_MCP_TELEMETRY_DISABLED=true');
|
|
process.env.N8N_MCP_TELEMETRY_DISABLED = 'true';
|
|
|
|
// Force reload by creating new instance (for testing)
|
|
const newConfigManager = TelemetryConfigManager.getInstance();
|
|
console.log('Is Enabled:', newConfigManager.isEnabled());
|
|
console.log('Status:', newConfigManager.getStatus());
|
|
|
|
// Test 3: Try tracking with env disabled
|
|
console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
console.log('Test 3: Attempting to track with telemetry disabled');
|
|
telemetry.trackToolUsage('test_tool', true, 100);
|
|
console.log('Tool usage tracking attempted (should be ignored)');
|
|
|
|
// Test 4: Alternative env vars
|
|
console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
console.log('Test 4: Alternative environment variables');
|
|
|
|
delete process.env.N8N_MCP_TELEMETRY_DISABLED;
|
|
process.env.TELEMETRY_DISABLED = 'true';
|
|
console.log('With TELEMETRY_DISABLED=true:', newConfigManager.isEnabled());
|
|
|
|
delete process.env.TELEMETRY_DISABLED;
|
|
process.env.DISABLE_TELEMETRY = 'true';
|
|
console.log('With DISABLE_TELEMETRY=true:', newConfigManager.isEnabled());
|
|
|
|
// Test 5: Env var takes precedence over config
|
|
console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
console.log('Test 5: Environment variable precedence');
|
|
|
|
// Enable via config
|
|
newConfigManager.enable();
|
|
console.log('After enabling via config:', newConfigManager.isEnabled());
|
|
|
|
// But env var should still override
|
|
process.env.N8N_MCP_TELEMETRY_DISABLED = 'true';
|
|
console.log('With env var set (should override config):', newConfigManager.isEnabled());
|
|
|
|
console.log('\n✅ All tests completed!');
|
|
}
|
|
|
|
testEnvOverride().catch(console.error); |