Save visitor ip
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
|
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
|
end
|
||||||
|
|||||||
5
db/migrate/20150808100936_add_ip_to_ahoy_event.rb
Normal file
5
db/migrate/20150808100936_add_ip_to_ahoy_event.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class AddIpToAhoyEvent < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :ahoy_events, :ip, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -22,6 +22,7 @@ ActiveRecord::Schema.define(version: 20150806163142) do
|
|||||||
t.string "name"
|
t.string "name"
|
||||||
t.jsonb "properties"
|
t.jsonb "properties"
|
||||||
t.datetime "time"
|
t.datetime "time"
|
||||||
|
t.string "ip"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "ahoy_events", ["time"], name: "index_ahoy_events_on_time", using: :btree
|
add_index "ahoy_events", ["time"], name: "index_ahoy_events_on_time", using: :btree
|
||||||
|
|||||||
Reference in New Issue
Block a user