Add rake task to collect admin overview metrics (#13023)

* Add rake task to collect admin overview metrics

* Print the Forem Instance domain
This commit is contained in:
Jacob Herrington 2021-03-24 14:16:46 -05:00 committed by GitHub
parent 0834a7453f
commit 03465e8882
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -6,5 +6,7 @@ module Ahoy
belongs_to :visit
belongs_to :user, optional: true
scope :overview_link_clicks, -> { where(name: "Overview Link Clicked") }
end
end

10
lib/tasks/metrics.rake Normal file
View file

@ -0,0 +1,10 @@
namespace :metrics do
desc "Collects metrics from Forem instances"
task overview: :environment do
puts "Admin Overview Link Tracking for #{SiteConfig.app_domain}:"
links_by_target = Ahoy::Event.overview_link_clicks.group("properties -> 'target'").count
links_by_target.each do |k, v|
puts "#{k.delete_prefix(URL.url)}: #{v}"
end
end
end