Save visitor ip

This commit is contained in:
Eloy Gomez
2015-08-08 12:23:28 +02:00
parent aaeb77d969
commit 42d6e49915
3 changed files with 14 additions and 2 deletions

View File

@@ -1,3 +1,9 @@
class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
# customize here
# Track user IP
def track_event(name, properties, options)
super do |event|
event.ip = request.ip
end
end
end

View File

@@ -0,0 +1,5 @@
class AddIpToAhoyEvent < ActiveRecord::Migration
def change
add_column :ahoy_events, :ip, :string
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150806163142) do
ActiveRecord::Schema.define(version: 20150808100936) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -22,6 +22,7 @@ ActiveRecord::Schema.define(version: 20150806163142) do
t.string "name"
t.jsonb "properties"
t.datetime "time"
t.string "ip"
end
add_index "ahoy_events", ["time"], name: "index_ahoy_events_on_time", using: :btree