We've moved discussions to Discord

What's the correct way to import ahoy with current JSP Rails 7 template?

Brian Carpenter
What's the correct way to import ahoy using JSP with rails 7 template?

Watched the gorails ahoy & blazer video and went through the steps at https://github.com/ankane/ahoy.

Server side event creation is working from rails controllers, but I can't get client side to work in my javascript files.   

Getting error " Could not resolve "ahoy" when starting the server.

config/initializers/ahoy.rb
class Ahoy::Store < Ahoy::DatabaseStore
  # set to true for JavaScript tracking
  Ahoy.api = true
  Ahoy.geocode = false
end


/app/javascript/application.js

/* eslint no-console:0 */

// Rails functionality
import Rails from "@rails/ujs"
import { Turbo } from "@hotwired/turbo-rails"

...

import 'ahoy'

...

Mateusz Kozak
You need to add ahoy.js to your packages.json - the backend library and frontend library are separated.

And import it like this:

import ahoy from "ahoy.js";
Notifications
You’re not receiving notifications from this thread.