Skip to content

Conversation

@stevemoraco
Copy link

Summary

This PR fixes three critical bugs that were preventing users from properly syncing their data and using the leaderboard across multiple devices:

  1. Failed historical sync with no retry option (Other CLI tool integration #1)
  2. Multi-device support not aggregating usage (User Page/Card #2)
  3. "Invalid OAuth link" error on re-authentication (Fix sync retry, multi-device support, and OAuth error handling #3)

What's Changed

🔄 New Sync/Retry Functionality

  • Added stats command to manually view stats and sync historical data
  • Added --resync flag to force complete resync when needed
  • Fixed error messages to guide users to the correct commands

📱 Multi-Device Support

  • Implemented device identification system with unique IDs per device
  • All devices now properly aggregate usage under one Twitter account
  • Device metadata (hostname, platform) sent with API requests for better tracking

🔐 Improved OAuth Flow

  • Added --force flag to auth command for clean re-authentication
  • Enhanced error messages to distinguish between token issues, rate limits, and server errors
  • Better handling of re-authentication from different devices

🛠️ Additional Improvements

  • Added sync-status command to check sync state without triggering a sync
  • Debug logging support via CLAUDE_COUNT_DEBUG=1 environment variable
  • Comprehensive troubleshooting section in README
  • Better error handling throughout with actionable error messages

Testing

I've tested the command structure and error handling locally. The maintainer will need to test against the production backend for:

  • OAuth authentication flow
  • Multi-device data aggregation
  • Historical data syncing

Local Testing Commands

# Test new commands exist
node bin/cli.js --help
node bin/cli.js stats --help

# Test device ID generation
cat ~/.claude/leaderboard.json | grep deviceId

# Test debug mode
CLAUDE_COUNT_DEBUG=1 node bin/cli.js stats

Implementation Details

  • All changes maintain backward compatibility
  • Follows existing code patterns and conventions
  • No breaking changes to existing functionality
  • Device IDs are generated using hostname + random component for uniqueness

Files Changed

  • src/commands/stats.js - New file for stats/sync functionality
  • src/utils/device.js - New file for device identification
  • src/utils/logger.js - New file for debug logging
  • src/auth/oauth1a.js - Enhanced error handling and device support
  • src/commands/auth.js - Added --force flag
  • src/utils/api.js - Added device ID to all requests
  • bin/cli.js - Registered new commands
  • README.md - Added troubleshooting section and command docs

This is my first open source contribution, so please let me know if you need any changes or have questions! I'm happy to iterate on the implementation.

Contributors: Steve Moraco (@stevemoraco) with assistance from Claude

🤖 Generated with Claude Code

This PR addresses three critical bugs reported by users:

1. Failed historical sync with no retry option
   - Added new 'stats' command for manual sync/resync
   - Added '--resync' flag to force resync of historical data
   - Fixed error message to point to correct command

2. Multi-device support not working properly
   - Added device identification system with unique device IDs
   - Device metadata sent with all API requests
   - Supports multiple OAuth token pairs per user account

3. "Invalid OAuth link" error on re-authentication
   - Added '--force' flag to auth command for clean re-auth
   - Improved OAuth error messages with specific failure reasons
   - Better error handling for rate limits and token issues

Additional improvements:
- Added 'sync-status' command to check sync state without triggering sync
- Added debug logging support (CLAUDE_COUNT_DEBUG=1)
- Updated README with comprehensive troubleshooting section
- Added device.js for device identification
- Added logger.js for better debugging

All changes maintain backward compatibility and follow existing code patterns.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@sonnyc56-around
Copy link

This is great, would love multidevice support I have two computers I use almost equally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants