today_ai_weather/app/controllers/application_controller.rb
songtianlun dd6cd0451d feat: add ahoy analytics for event tracking
- Integrate Ahoy gem for tracking user events and visits
- Create models for Ahoy events and visits
- Implement admin interfaces for managing events and visits
- Add background job for cleaning up old analytics data
- Update application controller and other relevant controllers to track specific actions

This commit implements a comprehensive event tracking system that logs user interactions
within the application. Additionally, it includes mechanisms for managing and
cleaning historical visit and event data, ensuring efficient data handling.
2025-01-27 00:43:18 +08:00

20 lines
474 B
Ruby

class ApplicationController < ActionController::Base
include SeoConcern
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
allow_browser versions: :modern
before_action :set_locale
after_action :track_action
protected
def track_action
ahoy.track "Viewed Application", request.path_parameters
end
private
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
end