Add counter - #439
Merged
Merged
Conversation
- Included Trackable module in ApplicationController for tracking purposes. - Added new analytics jobs in recurring.yml for hourly, daily rollup, and pruning. - Updated queue.yml to configure analytics queue with specific threading and polling settings. - Defined route for analytics dashboard in routes.rb. - Enhanced layout views to include links to the analytics dashboard for authorized users. - Added Chart.js to importmap for data visualization support.
- Created tables for analytics_daily_rollups and analytics_hourly_rollups with relevant columns for tracking user interactions. - Added sequences for both tables to manage primary key generation. - Established primary key constraints and unique indexes to ensure data integrity and optimize query performance. - Included additional table for page_views with corresponding sequence and constraints for comprehensive analytics tracking.
- Implemented a refresh action in the AnalyticsDashboardController to trigger rollup jobs synchronously, allowing immediate chart updates. - Updated the analytics dashboard view to include a refresh button and a notice for stale data. - Modified the analytics policy to authorize the refresh action for admin users. - Adjusted routes to include a POST endpoint for refreshing analytics data. - Enhanced the PageView model with live summary and top pages methods to provide real-time analytics data. - Improved data handling in the controller to ensure top pages and summary stats reflect current data without waiting for rollup jobs.
- Modified the properties layer in tailwind.css to enhance support for various CSS features. - Updated theme and base layers to ensure consistent styling and improved layout handling. - Adjusted spacing and color variables for better design flexibility and responsiveness.
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.
This pull request introduces a comprehensive first-party analytics system for tracking, aggregating, and displaying page view data within the application. It adds automatic page view tracking, background jobs for data rollup and pruning, models for storing aggregated analytics, and a new admin-only dashboard for visualizing traffic and usage trends. The dashboard includes summary cards, interactive charts, and top pages, and is accessible via a new navigation link for admins.
Analytics Tracking and Data Collection
Trackableconcern, included inApplicationController, which automatically tracks page views (excluding bots and non-HTML requests) by enqueueing aTrackPageViewJobafter each request. The job records session, user, controller/action, sanitized path, referrer, device type, HTTP status, and request duration in thePageViewmodel. [1] [2] [3] [4]Data Aggregation and Rollup
AnalyticsRollupJob) and models (AnalyticsHourlyRollup,AnalyticsDailyRollup) to aggregate raw page view data into hourly and daily rollup tables for efficient querying and charting. Includes logic for pruning old data. [1] [2] [3]Analytics Dashboard UI
AnalyticsDashboardControllerand associated views to display live summary stats, interactive hourly/daily charts (using a new Stimulus controller and Chart.js), and top pages. The dashboard supports time range selection and manual chart refresh. [1] [2] [3] [4]Authorization and Navigation
AnalyticsDashboardPolicy, and adds a navigation link to the dashboard for authorized users. [1] [2]Most important changes:
1. Analytics Tracking and Jobs
Trackableconcern toApplicationControllerto automatically track page views, with logic to filter bots and sensitive paths, and enqueues a background job for each tracked view. [1] [2]TrackPageViewJobto persist page view data, andPageViewmodel methods for live stats, top pages, and aggregation. [1] [2]2. Data Aggregation
AnalyticsRollupJobfor hourly/daily aggregation and pruning, and new rollup models (AnalyticsHourlyRollup,AnalyticsDailyRollup) with methods for summarizing and querying analytics data. [1] [2] [3]3. Analytics Dashboard UI
AnalyticsDashboardControllerand views for the admin dashboard, including summary cards, interactive charts (with Chart.js via Stimulus), and a top pages table. Supports time range selection and manual refresh. [1] [2] [3] [4]4. Authorization and Navigation
AnalyticsDashboardPolicy, and adds a navigation link for authorized users. [1] [2]