Skip to content

Simple admin panel for Ahoy analytics

License

Notifications You must be signed in to change notification settings

followerstracker/ahoy_admin

Repository files navigation

AhoyAdmin

📊 Simple Admin Panel for ahoy analytics and Rails.

WARNING: Despite the fact that it's been running in production for a while, this is still a beta software.

Features

  • 📅 Analytics for different time periods today/last-24hr/yesterday/this-week/last-7-days/this-month etc..
  • 📈 Beatiful and lightweight charts with uPlot
  • 💪 Caching for heavy DB queries and templates
  • 📊 Top pages/bots/devices/countries etc...
  • 🚤 Lightweight, Mobile friendly UI

Demo

The live demo is located here

Screenshots

Limitations

  • PostgreSQL support only at this moment

Installation

gem "ahoy_admin", git: "https://github.com/followerstracker/ahoy_admin"

Add mounting to the routes (config/routes.rb)

mount(AhoyAdmin::Engine, at: "/ahoy")

Configuration

Add a configuration to initializers, config/initializers/ahoy_admin.rb:

AhoyAdmin.configure do |config|
  config.brand_name = "Ahoy Admin"
  config.current_user_admin = lambda { |user| user&.admin? || Rails.env.development? }
  config.current_user_method = :current_user
  config.domains = []
  config.head_favicon_url = "/favicon.ico"
  config.head_meta_description = "Ahoy Admin Panel"
  config.head_meta_keywords = "ahoy, admin, panel, analytics"
  config.head_meta_noindex = false
  config.head_title = "Ahoy Admin"
  config.time_zone = "UTC"
  config.widgets = %w[
    views_by_page
    visits_by_bot
    visits_by_country
    visits_by_device
    visits_by_referrer
  ]
end

Tracking bots

By default ahoy gem doesn't track bots. We think that information could be useful, tracked and analyzed.

In order to enable this functionality, you might want to create a migration and to add the bot column to ahoy_visits table:

  disable_ddl_transaction!

  def change
    add_column(:ahoy_visits, :bot, :string)
    add_index(:ahoy_visits, :bot, algorithm: :concurrently)
  end

Now we need to change the way we populate that column:

class Ahoy::Store < Ahoy::DatabaseStore
  def track_visit(data)
    data[:bot] = DeviceDetector.new(request.user_agent).send(:bot)&.send(:regex_meta).try(:[], :name)
    super(data)
  end
end

This should be enough to see reports for bots.

Tests

Yeah, there are no tests yet. Stay tuned.

Contributing

TBD

License

The gem is available as open source under the terms of the MIT License.

About

Simple admin panel for Ahoy analytics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published