Skip to content

Conversation

@rgarner
Copy link

@rgarner rgarner commented Apr 11, 2024

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.

@rgarner rgarner force-pushed the fix-no-method-error branch from a5ac2a1 to a0d10c1 Compare April 11, 2024 17:17
@rgarner rgarner changed the title Fix NoMethodError when cookies == :none Fix NoMethodError when cookies == :none Apr 11, 2024
@rgarner rgarner force-pushed the fix-no-method-error branch from a0d10c1 to 8aaaed4 Compare April 11, 2024 17:27
@rgarner rgarner changed the title Fix NoMethodError when cookies == :none Fix NoMethodError when controllerless tracking and cookies == :none Apr 12, 2024
@rgarner rgarner force-pushed the fix-no-method-error branch from 8aaaed4 to 4f54499 Compare April 12, 2024 11:08
@rgarner rgarner changed the title Fix NoMethodError when controllerless tracking and cookies == :none Fix NoMethodError when no request and cookies == :none Apr 12, 2024
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.
@rgarner rgarner force-pushed the fix-no-method-error branch from 4f54499 to b3c2b8c Compare April 12, 2024 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant