ankane / ahoy

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

Fix `NoMethodError` when no request and `cookies == :none` #554

Open rgarner opened 7 months ago

rgarner commented 7 months ago

When tracking with no request,

Ahoy.cookies = :none
Ahoy::Tracker.new.track_event(:would_fail)

would raise NoMethodError: undefined method 'remote_ip' for nil. Since we explicitly don't have a request, allow visitor_token_helper to fall back on generate_id by returning nil from visitor_anonymity_set when there is no request.