The Ahoy gem is simply not storing any geo-location data in the database, and is returning [FILTERED] as the value for the visit_token and visitor_token.
File Setup:
rails_app/Gemfile:
ruby "3.1.0"
gem "ahoy_matey"
gem "geocoder"
gem "maxminddb"
gem "rails", "~> 7.0.3", ">= 7.0.3.1"
gem "pg", "~>1.1"
Ran the following commands from root of project:
bundle install
rails generate ahoy:install
rails db:migrate
rails_app/config/initializers/GeoLite2/:
=> GeoLite2-City.mmdb
rails_app/config/initializers/geocoder.rb:
Geocoder.configure(
ip_lookup: :geoip2,
geoip2: {
file: "./GeoLite2/GeoLite2-City.mmdb"
}
)
rails_app/config/initializers/ahoy.rb:
class Ahoy::Store < Ahoy::DatabaseStore
end
# set to true for JavaScript tracking
Ahoy.api = false
# set to true for geocoding (and add the geocoder gem to your Gemfile)
# we recommend configuring local geocoding as well
# see https://github.com/ankane/ahoy#geocoding
Ahoy.geocode = true
Ahoy.job_queue = :low_priority
rails_app/config/importmap.rb:
pin "ahoy", to: "ahoy.js"
rails_app/app/javascript/application.js:
import "ahoy"
