ankane / ahoy

Simple, powerful, first-party analytics for Rails
MIT License
4.24k stars 377 forks source link

Enable ahoy only in certain controllers? #471

Closed mnort9 closed 3 years ago

mnort9 commented 3 years ago

Is it possible to enable ahoy only in certain controllers/actions? The only way I see to accomplish this is by adding skip_before_action :track_ahoy_visit to other controllers.

Also, I notice the exclude_method option can do this, but it would be easier if there were a controller-level enable option so exclude_method is not called by every route in the application.

I also tried setting Ahoy.server_side_visits = false and added before_action :track_ahoy_visit to an individual controller, but doesn't work.

ankane commented 3 years ago

Hey @mnort9, have you tried skip_before_action :track_ahoy_visit in ApplicationController and before_action :track_ahoy_visit in the ones where you want to enable it?

ankane commented 3 years ago

Cleaning up issues

fabiolima commented 3 months ago

@ankane How are you? I've add the skip_before_action on ApplicationController and enabling to controllers that I want, but keeps saving visits from any page. There is possible to deactivate the default behavior of track all visits?