A command line program that processes cookie log files and returns the most active cookie for a specific day.
Given a cookie log file with entries in the format:
cookie,timestamp
AtY0laUfhglK3lC7,2018-12-09T14:19:00+00:00
SAZuXPGUrfbcn5UA,2018-12-09T10:13:00+00:00
5UAVanZf6UtGyKVS,2018-12-09T07:25:00+00:00
The program finds the cookie(s) that appear most frequently on a given date.
# Basic usage (with info logging)
./most-active-cookie -f <filename> -d <date>
# Silent output (production use)
LOG_LEVEL=silent ./most-active-cookie -f <filename> -d <date>
# With debug logging
LOG_LEVEL=debug ./most-active-cookie -f <filename> -d <date>-f: Path to the cookie log file to process-d: Date to analyze (format: YYYY-MM-DD, UTC timezone)
With info logging (default):
./most-active-cookie -f cookie_log.csv -d 2018-12-09Expected output:
AtY0laUfhglK3lC7
[2025-08-25 14:57:01] INFO: Starting Most Active Cookie analysis
[2025-08-25 14:57:01] INFO: Starting to process cookie_log.csv for date 2018-12-09
[2025-08-25 14:57:01] INFO: Processing completed in 7ms. Found 1 winning cookie(s)
Silent output (clean result only):
LOG_LEVEL=silent ./most-active-cookie -f cookie_log.csv -d 2018-12-09Expected output:
AtY0laUfhglK3lC7
# Clone/download the project
cd most-active-cookie
# Install dependencies
bun install
# Build the binary
bun run build# Run with test data (debug logging)
bun run dev
# Build production binary
bun run build
# Run comprehensive test suite (error logging)
bun run test
# Test the compiled binary (error logging)
bun run preview
# Run with custom log level
LOG_LEVEL=info bun src/index.ts -f cookie_log.csv -d 2018-12-09- debug: Full logging (used by
bun run dev) - info: Standard logging (default)
- warn: Warnings and errors only
- error: Errors only (used by
bun run testandbun run preview) - silent: No logging
src/
├── index.ts # Main entry point
├── cli.ts # CLI argument parsing
├── processor.ts # Core streaming logic
├── utils.ts # Validation utilities
└── types.ts # Type definitions
test/
├── unit/ # Unit tests
├── integration/ # CLI integration tests
└── fixtures/ # Test data files
- Streaming Processing: Uses Node.js streams for memory-efficient file processing
- TypeScript: Fully typed with strict compiler settings
- Performance: Single-pass algorithm with O(1) cookie counting
- Error Handling: Comprehensive validation with user-friendly messages
- Testing: 19 tests covering unit, integration, and edge cases
- Returns the most active cookie(s) for the specified date
- If multiple cookies have the same highest count, all are returned on separate lines
- Only uses additional libraries for testing, logging, and CLI parsing
- Assumes sufficient memory to load the entire file
- Assumes log entries are sorted by timestamp (most recent first)