8000 Fix `NoMethodError` when no request and `cookies == :none` by rgarner · Pull Request #554 · ankane/ahoy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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
0