- 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.
72 lines
2.0 KiB
Ruby
72 lines
2.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
ActiveAdmin.register_page "Dashboard" do
|
|
menu priority: 1, label: proc { I18n.t("active_admin.dashboard") }
|
|
|
|
content title: proc { I18n.t("active_admin.dashboard") } do
|
|
div class: "blank_slate_container", id: "dashboard_default_message" do
|
|
span class: "blank_slate" do
|
|
span I18n.t("active_admin.dashboard_welcome.welcome")
|
|
small I18n.t("active_admin.dashboard_welcome.call_to_action")
|
|
end
|
|
end
|
|
|
|
columns do
|
|
column do
|
|
panel "访问统计" do
|
|
para "总访问量: #{Ahoy::Visit.count}"
|
|
para "总事件数: #{Ahoy::Event.count}"
|
|
para "独立访客数: #{Ahoy::Visit.distinct.count(:visitor_token)}"
|
|
end
|
|
end
|
|
|
|
column do
|
|
panel "热门城市" do
|
|
table_for City.by_popularity.limit(10) do
|
|
column("城市") { |city| link_to(city.name, admin_city_path(city)) }
|
|
column("访问量") { |city| city.view_count }
|
|
end
|
|
end
|
|
end
|
|
|
|
column do
|
|
panel "热门天气艺术" do
|
|
table_for WeatherArt.by_popularity.limit(10) do
|
|
column("作品") { |art| link_to(art.to_s, admin_weather_art_path(art)) }
|
|
column("访问量") { |art| art.view_count }
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
# 添加一个事件列表面板
|
|
panel "最近事件" do
|
|
table_for Ahoy::Event.order(time: :desc).limit(10) do
|
|
column :time
|
|
column :name
|
|
column :properties
|
|
end
|
|
end
|
|
|
|
# Here is an example of a simple dashboard with columns and panels.
|
|
#
|
|
# columns do
|
|
# column do
|
|
# panel "Recent Posts" do
|
|
# ul do
|
|
# Post.recent(5).map do |post|
|
|
# li link_to(post.title, admin_post_path(post))
|
|
# end
|
|
# end
|
|
# end
|
|
# end
|
|
|
|
# column do
|
|
# panel "Info" do
|
|
# para "Welcome to ActiveAdmin."
|
|
# end
|
|
# end
|
|
# end
|
|
end # content
|
|
end
|