Fix ahoy tracking and visits

This commit is contained in:
Stella Rouzi 2018-03-18 10:57:39 +02:00 committed by James Mason
parent b54e3f7ab9
commit 3bb73f27cf
6 changed files with 38 additions and 21 deletions

View file

@ -57,19 +57,18 @@ GEM
awesome_nested_set (>= 2.0) awesome_nested_set (>= 2.0)
acts_as_list (0.9.7) acts_as_list (0.9.7)
activerecord (>= 3.0) activerecord (>= 3.0)
addressable (2.5.1) addressable (2.5.2)
public_suffix (~> 2.0, >= 2.0.2) public_suffix (>= 2.0.2, < 4.0)
ahoy_matey (1.6.0) ahoy_matey (2.1.0)
addressable addressable
browser (~> 2.0) browser (~> 2.0)
geocoder device_detector
rack-attack (< 6) geocoder (>= 1.4.5)
railties railties (>= 4.2)
referer-parser (>= 0.3.0) referer-parser (>= 0.3)
request_store request_store
safely_block (>= 0.1.1) safely_block (>= 0.2.1)
user_agent_parser user_agent_parser
uuidtools
airbrake (7.1.1) airbrake (7.1.1)
airbrake-ruby (~> 2.5) airbrake-ruby (~> 2.5)
airbrake-ruby (2.7.0) airbrake-ruby (2.7.0)
@ -92,7 +91,7 @@ GEM
bootstrap-switch-rails (3.0.2) bootstrap-switch-rails (3.0.2)
bootstrap3-datetimepicker-rails (3.0.3) bootstrap3-datetimepicker-rails (3.0.3)
momentjs-rails (>= 2.8.1) momentjs-rails (>= 2.8.1)
browser (2.5.1) browser (2.5.3)
builder (3.2.3) builder (3.2.3)
byebug (9.0.6) byebug (9.0.6)
cancancan (2.0.0) cancancan (2.0.0)
@ -150,6 +149,7 @@ GEM
delayed_job_active_record (4.1.2) delayed_job_active_record (4.1.2)
activerecord (>= 3.0, < 5.2) activerecord (>= 3.0, < 5.2)
delayed_job (>= 3.0, < 5) delayed_job (>= 3.0, < 5)
device_detector (1.0.1)
devise (4.4.3) devise (4.4.3)
bcrypt (~> 3.0) bcrypt (~> 3.0)
orm_adapter (~> 0.1) orm_adapter (~> 0.1)
@ -166,7 +166,7 @@ GEM
dotenv-rails (2.2.1) dotenv-rails (2.2.1)
dotenv (= 2.2.1) dotenv (= 2.2.1)
railties (>= 3.2, < 5.2) railties (>= 3.2, < 5.2)
errbase (0.0.3) errbase (0.1.0)
erubis (2.7.0) erubis (2.7.0)
execjs (2.6.0) execjs (2.6.0)
factory_girl (4.5.0) factory_girl (4.5.0)
@ -189,7 +189,7 @@ GEM
actionpack (>= 3.2.13) actionpack (>= 3.2.13)
formtastic-bootstrap (3.1.1) formtastic-bootstrap (3.1.1)
formtastic (>= 3.0) formtastic (>= 3.0)
geocoder (1.4.4) geocoder (1.4.9)
globalid (0.4.0) globalid (0.4.0)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
gravtastic (3.2.6) gravtastic (3.2.6)
@ -295,7 +295,7 @@ GEM
nenv (0.3.0) nenv (0.3.0)
netrc (0.11.0) netrc (0.11.0)
nio4r (2.1.0) nio4r (2.1.0)
nokogiri (1.8.2) nokogiri (1.8.3)
mini_portile2 (~> 2.3.0) mini_portile2 (~> 2.3.0)
notiffany (0.1.1) notiffany (0.1.1)
nenv (~> 0.1) nenv (~> 0.1)
@ -356,11 +356,9 @@ GEM
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.8.1)
slop (~> 3.4) slop (~> 3.4)
public_suffix (2.0.5) public_suffix (3.0.2)
puma (3.10.0) puma (3.10.0)
rack (2.0.5) rack (2.0.5)
rack-attack (5.0.1)
rack
rack-openid (1.3.1) rack-openid (1.3.1)
rack (>= 1.1.0) rack (>= 1.1.0)
ruby-openid (>= 2.1.8) ruby-openid (>= 2.1.8)
@ -484,7 +482,7 @@ GEM
ruby_dep (1.5.0) ruby_dep (1.5.0)
rubyzip (1.2.1) rubyzip (1.2.1)
safe_yaml (1.0.4) safe_yaml (1.0.4)
safely_block (0.2.0) safely_block (0.2.1)
errbase errbase
sass (3.2.19) sass (3.2.19)
sass-rails (5.0.6) sass-rails (5.0.6)
@ -546,8 +544,7 @@ GEM
unobtrusive_flash (3.1.0) unobtrusive_flash (3.1.0)
railties railties
url (0.3.2) url (0.3.2)
user_agent_parser (2.4.0) user_agent_parser (2.4.1)
uuidtools (2.1.5)
warden (1.2.7) warden (1.2.7)
rack (>= 1.0) rack (>= 1.0)
web-console (2.3.0) web-console (2.3.0)

View file

@ -2,6 +2,7 @@
module Ahoy module Ahoy
class Event < ApplicationRecord class Event < ApplicationRecord
include Ahoy::QueryMethods
self.table_name = 'ahoy_events' self.table_name = 'ahoy_events'
belongs_to :visit belongs_to :visit

View file

@ -1,5 +1,7 @@
module Ahoy module Ahoy
class Store < Ahoy::Stores::ActiveRecordStore class Store < Ahoy::DatabaseStore
# customize here def visit_model
Visit
end
end end
end end

View file

@ -14,6 +14,8 @@ Osem::Application.routes.draw do
path: 'accounts' path: 'accounts'
end end
mount Ahoy::Engine => '/ahoy'
# Use letter_opener_web to open mails in browser (e.g. necessary for Vagrant) # Use letter_opener_web to open mails in browser (e.g. necessary for Vagrant)
if Rails.env.development? if Rails.env.development?
mount LetterOpenerWeb::Engine, at: "/letter_opener" mount LetterOpenerWeb::Engine, at: "/letter_opener"

View file

@ -0,0 +1,11 @@
# frozen_string_literal: true
class CreateAhoyVisitsAndEvents < ActiveRecord::Migration[5.0]
def change
add_column :visits, :visit_token, :string
add_column :visits, :visitor_token, :string
add_index :visits, [:visit_token], unique: true
add_index :ahoy_events, [:name, :time]
end
end

View file

@ -18,6 +18,7 @@ ActiveRecord::Schema.define(version: 20180316220446) do
t.string "name" t.string "name"
t.text "properties" t.text "properties"
t.datetime "time" t.datetime "time"
t.index ["name", "time"], name: "index_ahoy_events_on_name_and_time"
t.index ["time"], name: "index_ahoy_events_on_time" t.index ["time"], name: "index_ahoy_events_on_time"
t.index ["user_id"], name: "index_ahoy_events_on_user_id" t.index ["user_id"], name: "index_ahoy_events_on_user_id"
t.index ["visit_id"], name: "index_ahoy_events_on_visit_id" t.index ["visit_id"], name: "index_ahoy_events_on_visit_id"
@ -651,7 +652,10 @@ ActiveRecord::Schema.define(version: 20180316220446) do
t.string "utm_content" t.string "utm_content"
t.string "utm_campaign" t.string "utm_campaign"
t.datetime "started_at" t.datetime "started_at"
t.string "visit_token"
t.string "visitor_token"
t.index ["user_id"], name: "index_visits_on_user_id" t.index ["user_id"], name: "index_visits_on_user_id"
t.index ["visit_token"], name: "index_visits_on_visit_token", unique: true
end end
create_table "votes", force: :cascade do |t| create_table "votes", force: :cascade do |t|