{"action":"opened","issue":{"url":"https://api.github.com/repos/ankane/ahoy/issues/103","labels_url":"https://api.github.com/repos/ankane/ahoy/issues/103/labels{/name}","comments_url":"https://api.github.com/repos/ankane/ahoy/issues/103/comments","events_url":"https://api.github.com/repos/ankane/ahoy/issues/103/events","html_url":"https://github.com/ankane/ahoy/issues/103","id":81028481,"number":103,"title":"Events & Visits not storing in the db","user":{"login":"Jasonbit","id":8883,"avatar_url":"https://avatars.githubusercontent.com/u/8883?v=3","gravatar_id":"","url":"https://api.github.com/users/Jasonbit","html_url":"https://github.com/Jasonbit","followers_url":"https://api.github.com/users/Jasonbit/followers","following_url":"https://api.github.com/users/Jasonbit/following{/other_user}","gists_url":"https://api.github.com/users/Jasonbit/gists{/gist_id}","starred_url":"https://api.github.com/users/Jasonbit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jasonbit/subscriptions","organizations_url":"https://api.github.com/users/Jasonbit/orgs","repos_url":"https://api.github.com/users/Jasonbit/repos","events_url":"https://api.github.com/users/Jasonbit/events{/privacy}","received_events_url":"https://api.github.com/users/Jasonbit/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-26T16:07:40Z","updated_at":"2015-05-26T16:07:40Z","closed_at":null,"body":"I'm using Postgres 9.4, ahoy 1.1.1, Rails 4.2.1, ruby 2.1.1p76\r\n\r\nI've looked through all the issues and have seen some similar Visit problems. However, none of them seem to solve my issue.\r\n\r\nFirst off, events work when I go through a web based controller. However, I have a subclassed api controller that events never work for. My app controller looks something like:\r\n\r\n```ruby\r\nclass ApplicationController < ActionController::Base\r\n\r\n  protect_from_forgery with: :exception\r\n  \r\n  before_action :require_login\r\n  after_filter  :track_action\r\n\r\n  protected\r\n\r\n  def track_action\r\n    ahoy.track \"Processed #{controller_name}##{action_name}\", request.filtered_parameters\r\n  end\r\n```\r\n\r\nMy api controller looks like:\r\n\r\n```ruby\r\nclass Api::ApiController < ApplicationController\r\n\r\n  protect_from_forgery with: :null_session\r\n    \r\n  skip_before_filter  :verify_authenticity_token, :require_login\r\n  before_filter       :provide_api_user\r\n  after_filter        :track_action  \r\n  \r\n  private\r\n\r\n  def provide_api_user\r\n\r\n    ...\r\n\r\n    # For tracking\r\n    ahoy.authenticate(current_user)\r\n    \r\n  end\r\n```\r\n\r\nWhen I drill down thru the code and log out the current_user, it's all set correctly - in Ahoy, I can see that @user is set correctly. The visit_id in the events table is there for my non-api controller events, but no visit entry.\r\n\r\nI have also added the logging to the initializer like so and no extra logging info:\r\n\r\n```ruby\r\nclass Ahoy::Store < Ahoy::Stores::ActiveRecordStore\r\n  Ahoy.quiet = false\r\nend\r\n```\r\n\r\nSo, I'm not sure what the issue is - why part of it works in a non-api controller and none of it works in my api controller."}}