Rails 哎呀,没有创建新访问

Rails Ahoy new visits not being created

Rails 应用使用 Ahoy。现有访问似乎没有过期——事件附加到 2、3 或更长时间前的访问(而不是新访问)。

例如,这是从 4 月 7 日开始的生产访问:

<Ahoy::Visit id: 336, visit_token: "XXXXXXX", visitor_token: "XXXXXXX", user_id: 27, ip: "XXXXXXX", user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) Ap...", referrer: nil, referring_domain: nil, landing_page: "XXXXXX", browser: "Chrome", os: "Mac", device_type: "Desktop", country: nil, region: nil, city: nil, latitude: nil, longitude: nil, utm_source: nil, utm_medium: nil, utm_term: nil, utm_content: nil, utm_campaign: nil, started_at: "2020-04-07 15:22:02"

这是与该访问相关的前两个事件:

[#<Ahoy::Event id: 7398, visit_id: 336, user_id: 27, name: "Page visit", properties: {"path"=>"XXXXX", "slug"=>"XXXXX"}, time: "2020-04-21 15:53:11">, #<Ahoy::Event id: 7397, visit_id: 336, user_id: 27, name: "Page visit", properties: {"path"=>"XXXXX", "slug"=>"XXXXX"}, time: "2020-04-21 15:53:03">]

我在 config/initializers/ahoy.rb 中设置了 Ahoy.visit_duration = 30.minutes。这是整个 config/initializers/ahoy.rb 文件:

class Ahoy::Store < Ahoy::DatabaseStore
end

Ahoy.api = false
Ahoy.mask_ips = true
Ahoy.cookies = false
Ahoy.visit_duration = 30.minutes

Ahoy::Visit型号:

class Ahoy::Visit < ActiveRecord::Base

  self.table_name = "ahoy_visits"
  has_many :events, class_name: "Ahoy::Event"
  belongs_to :user, optional: true

end

感谢您的任何建议。

创建 cookie 时使用 Ahoy.visit_duration

既然你设置的是Ahoy.cookie = false,一次访问也是一样的,只要UserAgent和RemoteIP是一样的。

也就是Anonymity Sets & Cookies

的部分