Class: TrackRelay::ClientId::AhoyVisitor
- Inherits:
-
Object
- Object
- TrackRelay::ClientId::AhoyVisitor
- Defined in:
- lib/track_relay/client_id/ahoy_visitor.rb
Overview
Resolver that returns the current Ahoy visitor token, when the host application has the [ahoy](github.com/ankane/ahoy) gem installed AND the controller exposes its ‘ahoy` helper.
Default position-1 entry in TrackRelay::Configuration#client_id_resolvers — between Ga (cookie-based) and Session (UUID fallback).
## Duck-typed integration
This resolver does NOT ‘require “ahoy”`. It probes the controller via `respond_to?(:ahoy, true)` so the gem boots cleanly in apps without Ahoy. When Ahoy is absent, `#call` returns `nil` and the next resolver in the chain takes over.
When Ahoy IS present, ‘controller.ahoy` returns an `Ahoy::Tracker` whose `#visitor_token` returns the visitor cookie value (no DB query). We use that public API only; nothing internal.
Instance Method Summary collapse
-
#call(controller:) ⇒ String?
‘ahoy.visitor_token` if available, else `nil`.
Instance Method Details
#call(controller:) ⇒ String?
Returns ‘ahoy.visitor_token` if available, else `nil`.
27 28 29 30 31 |
# File 'lib/track_relay/client_id/ahoy_visitor.rb', line 27 def call(controller:, **) return nil unless controller&.respond_to?(:ahoy, true) controller.ahoy&.visitor_token end |