Tracking usage - #2
Merged
Merged
Conversation
Implements Phase 1 of RFC 001 - local-only anonymous analytics: - Config management with atomic writes and proper permissions (0600) - Event tracking with JSONL storage (~/.lwp/analytics/events.jsonl) - Opt-in prompt for first run (defaults to opt-out in non-interactive) - CI/CD auto-detection (disabled when CI env vars present) - Command exclusion for sensitive commands (wpe.*, analytics.*) - Event rotation at 10k limit (keeps newest 80%) - Summary generation for CLI dashboard Privacy: Only tracks command names, success/failure, and duration. Never tracks arguments, site names, paths, or any PII. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Integrates the analytics module into the CLI: Commands: - `lwp analytics status` - Show enabled/disabled and event count - `lwp analytics on` - Enable analytics - `lwp analytics off` - Disable analytics - `lwp analytics show` - View summary (or --json for raw events) - `lwp analytics reset` - Delete all data and disable Tracking: - Commander hooks track command execution automatically - First-run opt-in prompt (skipped for help/update/analytics commands) - Failed commands tracked via try/catch wrapper - Command path derived from Commander hierarchy (e.g., "sites.list") Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Tests for the analytics module covering: - Config management (read/write, corruption handling) - Environment detection (CI, LWP_ANALYTICS override) - Event tracking (recording, exclusions) - JSONL parsing and summary generation - File permissions Refactored path initialization to use lazy functions for testability. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Analytics now enabled by default to maximize data collection - First-run shows informational message instead of asking for consent - Users can easily disable with `lwp analytics off` - Updated RFC to reflect decision change - Updated tests for new default behavior Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…d path The preAction hook receives (thisCommand, actionCommand) where thisCommand is the root program and actionCommand is the actual command being executed. Using thisCommand resulted in commands being tracked as "unknown". Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Tests cover: - analytics status (current state, event count) - analytics on/off (enable/disable tracking) - analytics show (summary and --json output) - analytics reset (clear events) - command exclusion (analytics.* not tracked) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
… transmission - Add installationId (UUID) to config, persisted across sessions - Add session_id (UUID) generated per CLI invocation - Extend event format with cli_version, os, node_version - Add error_category support for failure tracking - Add transmitEvent() for server transmission (fire-and-forget) - Add resetAnalytics() to regenerate installationId - Update status command to show installationId - Update tests for Phase 2 fields Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add D1 schema for events table with indexes - Implement POST /v1/events endpoint for event ingestion - Implement GET /v1/stats endpoint for aggregate statistics - Add health check endpoint - Add CORS support for cross-origin requests Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add secretKey generation (32 random bytes, base64) for HMAC signing - Sign all event transmissions with HMAC-SHA256 - First request sends secretKey, server stores for future verification - Add installations table to D1 for storing secret keys - Protect /v1/stats endpoint with ADMIN_TOKEN - Add /dashboard/:installationId with signed URL (1 hour expiry) - Add `lwp analytics dashboard` command Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add tests for getSecretKey() - Add tests for getDashboardUrl() - Update resetAnalytics test to verify secretKey regeneration - Add tests for X-Signature and X-Secret-Key headers - Verify first request sends secretKey, subsequent requests don't Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.