Ahoy
Simple, powerful, first-party analytics for Rails
...It stores data in your own database by default, which gives developers full control over what data is captured, how it's processed, and how it’s used, sidestepping privacy concerns of external analytics providers. The library supports Rails, JavaScript, and native apps, making it flexible across front-end/back-end and mobile contexts. Because it’s designed for developers who already own their data stack, Ahoy encourages self-hosted analytics workflows, custom reporting, and integration with existing database infrastructure. It includes features for tracking visits (sessions), events (actions), and user properties, so you can introspect user journeys and behaviour within your application domain.