-
Notifications
You must be signed in to change notification settings - Fork 29
feat: Add Sentry error tracking to create-agents CLI #407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Claude finished @amikofalvy's task —— View job TypeScript Staff Engineer Code ReviewI've conducted a comprehensive review of this Sentry error tracking implementation. Here's my analysis: ✅ Strengths and Well-Executed ElementsThe privacy-first approach is commendable with multiple opt-out mechanisms, comprehensive PII sanitization, and clear user consent flows. The testing coverage is solid with good separation of concerns between modules. 🚨 Critical Architecture & Security Concerns1. Security: Hardcoded DSN Pattern Creates Vulnerability// packages/create-agents/src/errorTracking.ts:46
const sentryDsn = process.env.SENTRY_DSN || 'https://your-sentry-dsn-here@sentry.io/project-id'; Issue: Using a predictable placeholder with Recommendation: Use proper validation: const sentryDsn = process.env.SENTRY_DSN;
if (!sentryDsn || !isValidSentryDsn(sentryDsn)) {
return; // Skip initialization
}
function isValidSentryDsn(dsn: string): boolean {
try {
const url = new URL(dsn);
return url.hostname === 'sentry.io' || url.hostname.endsWith('.sentry.io');
} catch {
return false;
}
} 2. Race Conditions in Concurrent OperationsFile System Race Conditions ( export function saveTelemetryConfig(config: TelemetryConfig): void {
try {
fs.ensureDirSync(TELEMETRY_CONFIG_DIR); // Race condition possible
fs.writeFileSync(TELEMETRY_CONFIG_FILE, JSON.stringify(config, null, 2));
} catch (error) {
// Silently ignored - problematic
}
} Issues:
Recommendation: Use atomic writes with proper error handling: export function saveTelemetryConfig(config: TelemetryConfig): boolean {
try {
fs.ensureDirSync(TELEMETRY_CONFIG_DIR);
const tempFile = `${TELEMETRY_CONFIG_FILE}.tmp`;
fs.writeFileSync(tempFile, JSON.stringify(config, null, 2));
fs.renameSync(tempFile, TELEMETRY_CONFIG_FILE); // Atomic operation
telemetryConfig = config;
return true;
} catch (error) {
console.warn('Failed to save telemetry config:', error);
return false;
}
} 3. Memory Leaks and Resource Management IssuesSentry Connection Lifecycle ( await closeSentry();
process.exit(1); Issues:
Recommendation: Implement proper cleanup lifecycle: process.on('exit', async () => {
await closeSentry();
});
process.on('SIGTERM', async () => {
await closeSentry();
process.exit(0);
}); 🔧 System Design & Architecture Concerns4. Inconsistent Error Handling PatternsThe codebase mixes different error handling approaches:
Recommendation: Establish consistent error handling hierarchy:
5. Violation of Single Responsibility Principle
Recommendation: Split into focused modules:
📊 Testing & Quality Assurance Issues6. Missing Critical Test CoverageUntested scenarios:
Integration gaps: // Missing tests for:
initErrorTracking('1.0.0'); // Never tested with actual Sentry
saveTelemetryConfig({}); // File system operations mocked away
sanitizeFilePath('/Users/sensitive/'); // PII edge cases 7. Insufficient Environment HandlingThe environment detection logic is fragile: if (process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'development') {
return; // Skip Sentry
} Issues:
💡 Performance & Scalability Considerations8. Synchronous File Operations in Hot Path// utils.ts:132-140 - Blocks on every CLI run
const config = getTelemetryConfig(); // Sync file read
if (!config.askedConsent) { /* show prompt */ } Impact: Every CLI execution performs synchronous file I/O, impacting startup performance. Recommendation: Cache with TTL or use async operations where possible. 9. Network Operations Without Timeout
🎯 Customer Experience Concerns10. Telemetry Notice UX IssuesThe consent flow (
Recommendation: Add status commands: create-agents --telemetry-status # Show current setting
create-agents --enable-telemetry # Re-enable
create-agents --show-privacy # Show privacy info 📋 Summary & Priority Recommendations🔴 High Priority (Security/Reliability):
🟡 Medium Priority (Architecture):
🟢 Low Priority (Enhancement):
The implementation demonstrates good privacy practices and thoughtful user consent, but requires attention to security hardening and architectural consistency before production deployment. |
Add privacy-first error tracking with user consent to help improve the CLI tool. Features: - Sentry integration for anonymous error reporting - User consent prompt on first run with clear privacy notice - Multiple opt-out methods (--disable-telemetry flag, DO_NOT_TRACK env var, interactive prompt) - PII scrubbing (file paths, usernames automatically removed) - Breadcrumb tracking for debugging context - Environment-aware (disabled in test/dev) - Telemetry config stored in ~/.inkeep/telemetry-config.json Privacy measures: - No collection of file contents, API keys, or personal information - Stack traces sanitized to remove usernames and sensitive paths - Disabled by default if DO_NOT_TRACK=1 or --disable-telemetry flag - User given clear choice with detailed privacy notice - Config persisted to respect user preference Testing: - Unit tests for error tracking functionality - Existing tests updated to mock Sentry - All tests passing with proper mocking Documentation: - README updated with telemetry section - Clear explanation of what is/isn't collected - Multiple opt-out methods documented - Privacy policy link included 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
b9fc76d
to
10fde65
Compare
Summary
Adds privacy-first error tracking to the
create-agents
CLI using Sentry to help improve the tool by capturing anonymous error reports.Key Features
✅ Privacy-First Design
✅ Error Tracking
✅ User Control
--disable-telemetry
flagDO_NOT_TRACK=1
environment variable~/.inkeep/telemetry-config.json
Privacy Measures
What we collect:
What we DO NOT collect:
Implementation Details
Files Created:
src/errorTracking.ts
- Core error tracking service with PII scrubbingsrc/__tests__/errorTracking.test.ts
- Unit testsFiles Modified:
src/index.ts
- Initialize tracking, capture top-level errorssrc/utils.ts
- Add breadcrumbs, capture errors, consent promptsrc/templates.ts
- Track template cloning errorssrc/__tests__/utils.test.ts
- Mock Sentry in existing testsREADME.md
- Document telemetry with privacy infopackage.json
- Add @sentry/node dependencyTesting
✅ All tests passing (30/30)
✅ TypeScript compilation successful
✅ Build successful
✅ Proper mocking of Sentry in tests
Documentation
Updated README with:
Configuration
To use in production, set the Sentry DSN:
Currently uses placeholder DSN that prevents initialization until configured.
🤖 Generated with Claude Code