ankane/ahoy

Routes not being found in Heroku production but work in development

johnkyeremeh opened this issue · 1 comments

Hi,

Really like the gem using it for my coding capstone project. Currently having issues in production where routes are not being found. Looking to understand why routes on not being found in production in Heroku environment.

Currently using
Rails 6.1.6.1

I referenced:
#29
#31

Models
page.rb

   has_many :ahoy_visits, class_name: "Ahoy::Visit"
    has_many :ahoy_events, class_name: "Ahoy::Event"

user.rb

   has_many :ahoy_visits, class_name: "Ahoy::Visit"
    has_many :ahoy_events, class_name: "Ahoy::Event"

Visitor.rb
has_many :visits, class_name: "Ahoy::Visit"
has_many :events, class_name: "Ahoy::Event"

routes.rb

mount Ahoy::Engine => "/ahoy"
...

event.rb

class Ahoy::Event < ApplicationRecord
  include Ahoy::QueryMethods

  self.table_name = "ahoy_events"

  belongs_to :visit
  belongs_to :user, optional: true
end

Visit.rb

class Ahoy::Visit < ApplicationRecord
  self.table_name = "ahoy_visits"
  after_save :create_visitor_object 
  
  has_many :events, class_name: "Ahoy::Event"
  belongs_to :user, optional: true

  def create_visitor_object 

    @visitor = Visitor.find_or_create_by(ahoy_visit_id: self.id) do |visitor|
      visitor.name = "Anonomous Visitor " + Faker::Name.name
      visitor.first_seen = self.started_at
      visitor.ahoy_visit_id =  self.id
      app_id = self.landing_page.match(/\d+$/).to_s.to_i
      visitor.app_id = app_id
      

      @app = App.find(app_id)
      visitor.pages << @app.pages.find(app_id)
    end
  end
end
initializers/ahoy.rb
class Ahoy::Store < Ahoy::DatabaseStore
  mattr_accessor :auto_mount
  self.auto_mount = false

  def geocode(data)
    super(data)
  end

  def track_visit(data)
    # new visit
    super(data)
  end

  def track_event(data)
    # new event
    super(data)
  end

  def geocode(data)
    # visit geocoded
    super(data)
  end

  def authenticate(data)
    # user authenticates
    super(data)
  end

end



Ahoy.api = true

Ahoy.geocode = true


Ahoy.job_queue = :low_priority

Ahoy.quiet = false

Screen Shot 2022-08-18 at 11 45 58 AM

Not sure why the error is coming?

Hey @johnkyeremeh, unfortunately, I don't have the bandwidth to help with app-specific issues, but from the error log, it looks like you may be including ahoy.js as a relative path instead of including it through the asset pipeline.