$ show ankane/ahoy
Ahoy is a Rails engine that provides first-party analytics for Ruby on Rails applications. It tracks visits and events, storing data in the application's database by default while supporting custom data stores. The architecture follows Rails engine patterns with controllers, models, and concerns. Key features include automatic visit tracking, event tracking, geocoding via background jobs, IP masking for GDPR compliance, and associating visits with application models. The system provides both server-side Ruby tracking and client-side JavaScript/AMP/native app tracking through a configurable API.
The LLM identified 2 files worth highlighting for reuse:
Defines the abstract interface for Ahoy data stores with common functionality like user resolution, bot detection, and exclusion logic. Enables pluggable storage backends (ActiveRecord, Mongoid, Kafka, etc.) through inheritance. Demonstrates skill in handling flexible configuration (user methods as symbols/procs), sophisticated bot detection with versioning, and proper separation of concerns.
Encapsulates all logic for collecting visit properties from requests, including UTM parameters, traffic source, technology details, and geolocation. Cleanly separates concerns into distinct methods (utm_properties, traffic_properties, etc.) with graceful error handling. Implements IP masking following Google Analytics anonymization standards and supports both regular and API request modes.