ahoy_matey 1.5.5 → 4.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +184 -34
- data/CONTRIBUTING.md +42 -0
- data/LICENSE.txt +1 -1
- data/README.md +464 -407
- data/app/controllers/ahoy/base_controller.rb +23 -15
- data/app/controllers/ahoy/events_controller.rb +8 -2
- data/app/controllers/ahoy/visits_controller.rb +8 -1
- data/app/jobs/ahoy/geocode_job.rb +11 -0
- data/app/jobs/ahoy/geocode_v2_job.rb +31 -0
- data/config/routes.rb +1 -1
- data/lib/ahoy/base_store.rb +101 -0
- data/lib/ahoy/controller.rb +23 -16
- data/lib/ahoy/database_store.rb +94 -0
- data/lib/ahoy/engine.rb +14 -7
- data/lib/ahoy/helper.rb +40 -0
- data/lib/ahoy/model.rb +5 -27
- data/lib/ahoy/query_methods.rb +88 -0
- data/lib/ahoy/tracker.rb +105 -51
- data/lib/ahoy/utils.rb +7 -0
- data/lib/ahoy/version.rb +1 -1
- data/lib/ahoy/visit_properties.rb +99 -37
- data/lib/ahoy.rb +83 -93
- data/lib/ahoy_matey.rb +1 -1
- data/lib/generators/ahoy/activerecord_generator.rb +67 -0
- data/lib/generators/ahoy/base_generator.rb +13 -0
- data/lib/generators/ahoy/install_generator.rb +44 -0
- data/lib/generators/ahoy/mongoid_generator.rb +16 -0
- data/lib/generators/ahoy/templates/active_record_event_model.rb.tt +10 -0
- data/lib/generators/ahoy/templates/active_record_migration.rb.tt +62 -0
- data/lib/generators/ahoy/templates/active_record_visit_model.rb.tt +6 -0
- data/lib/generators/ahoy/templates/base_store_initializer.rb.tt +25 -0
- data/lib/generators/ahoy/templates/database_store_initializer.rb.tt +10 -0
- data/lib/generators/ahoy/{stores/templates/mongoid_event_model.rb → templates/mongoid_event_model.rb.tt} +4 -2
- data/lib/generators/ahoy/{stores/templates/mongoid_visit_model.rb → templates/mongoid_visit_model.rb.tt} +15 -9
- data/vendor/assets/javascripts/ahoy.js +271 -133
- metadata +37 -273
- data/.gitignore +0 -17
- data/Gemfile +0 -6
- data/Rakefile +0 -8
- data/ahoy_matey.gemspec +0 -38
- data/lib/ahoy/deckhands/location_deckhand.rb +0 -49
- data/lib/ahoy/deckhands/request_deckhand.rb +0 -52
- data/lib/ahoy/deckhands/technology_deckhand.rb +0 -47
- data/lib/ahoy/deckhands/traffic_source_deckhand.rb +0 -22
- data/lib/ahoy/deckhands/utm_parameter_deckhand.rb +0 -23
- data/lib/ahoy/geocode_job.rb +0 -13
- data/lib/ahoy/logger_silencer.rb +0 -75
- data/lib/ahoy/properties.rb +0 -58
- data/lib/ahoy/stores/active_record_store.rb +0 -61
- data/lib/ahoy/stores/active_record_token_store.rb +0 -114
- data/lib/ahoy/stores/base_store.rb +0 -88
- data/lib/ahoy/stores/bunny_store.rb +0 -33
- data/lib/ahoy/stores/fluentd_store.rb +0 -17
- data/lib/ahoy/stores/kafka_store.rb +0 -40
- data/lib/ahoy/stores/kinesis_firehose_store.rb +0 -42
- data/lib/ahoy/stores/log_store.rb +0 -53
- data/lib/ahoy/stores/mongoid_store.rb +0 -63
- data/lib/ahoy/stores/nats_store.rb +0 -34
- data/lib/ahoy/stores/nsq_store.rb +0 -36
- data/lib/ahoy/subscribers/active_record.rb +0 -19
- data/lib/ahoy/throttle.rb +0 -17
- data/lib/generators/ahoy/stores/active_record_events_generator.rb +0 -53
- data/lib/generators/ahoy/stores/active_record_generator.rb +0 -16
- data/lib/generators/ahoy/stores/active_record_visits_generator.rb +0 -43
- data/lib/generators/ahoy/stores/bunny_generator.rb +0 -15
- data/lib/generators/ahoy/stores/custom_generator.rb +0 -15
- data/lib/generators/ahoy/stores/fluentd_generator.rb +0 -15
- data/lib/generators/ahoy/stores/kafka_generator.rb +0 -15
- data/lib/generators/ahoy/stores/kinesis_firehose_generator.rb +0 -15
- data/lib/generators/ahoy/stores/log_generator.rb +0 -15
- data/lib/generators/ahoy/stores/mongoid_events_generator.rb +0 -19
- data/lib/generators/ahoy/stores/mongoid_generator.rb +0 -14
- data/lib/generators/ahoy/stores/mongoid_visits_generator.rb +0 -27
- data/lib/generators/ahoy/stores/nats_generator.rb +0 -15
- data/lib/generators/ahoy/stores/nsq_generator.rb +0 -15
- data/lib/generators/ahoy/stores/templates/active_record_event_model.rb +0 -12
- data/lib/generators/ahoy/stores/templates/active_record_events_migration.rb +0 -19
- data/lib/generators/ahoy/stores/templates/active_record_initializer.rb +0 -3
- data/lib/generators/ahoy/stores/templates/active_record_visit_model.rb +0 -4
- data/lib/generators/ahoy/stores/templates/active_record_visits_migration.rb +0 -57
- data/lib/generators/ahoy/stores/templates/bunny_initializer.rb +0 -9
- data/lib/generators/ahoy/stores/templates/custom_initializer.rb +0 -10
- data/lib/generators/ahoy/stores/templates/fluentd_initializer.rb +0 -3
- data/lib/generators/ahoy/stores/templates/kafka_initializer.rb +0 -9
- data/lib/generators/ahoy/stores/templates/kinesis_firehose_initializer.rb +0 -17
- data/lib/generators/ahoy/stores/templates/log_initializer.rb +0 -3
- data/lib/generators/ahoy/stores/templates/mongoid_initializer.rb +0 -3
- data/lib/generators/ahoy/stores/templates/nats_initializer.rb +0 -9
- data/lib/generators/ahoy/stores/templates/nsq_initializer.rb +0 -9
- data/test/properties/mysql_json_test.rb +0 -18
- data/test/properties/mysql_text_test.rb +0 -19
- data/test/properties/postgresql_hstore_test.rb +0 -18
- data/test/properties/postgresql_json_test.rb +0 -18
- data/test/properties/postgresql_jsonb_test.rb +0 -18
- data/test/properties/postgresql_text_test.rb +0 -19
- data/test/test_helper.rb +0 -99
- data/test/visit_properties_test.rb +0 -44
@@ -1,36 +0,0 @@
|
|
1
|
-
module Ahoy
|
2
|
-
module Stores
|
3
|
-
class NsqStore < LogStore
|
4
|
-
def log_visit(data)
|
5
|
-
post(visits_topic, data)
|
6
|
-
end
|
7
|
-
|
8
|
-
def log_event(data)
|
9
|
-
post(events_topic, data)
|
10
|
-
end
|
11
|
-
|
12
|
-
def client
|
13
|
-
@client ||= begin
|
14
|
-
require "nsq"
|
15
|
-
client = Nsq::Producer.new(
|
16
|
-
nsqd: ENV["NSQ_URL"] || "127.0.0.1:4150"
|
17
|
-
)
|
18
|
-
at_exit { client.terminate }
|
19
|
-
client
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def post(topic, data)
|
24
|
-
client.write_to_topic(topic, data.to_json)
|
25
|
-
end
|
26
|
-
|
27
|
-
def visits_topic
|
28
|
-
"ahoy_visits"
|
29
|
-
end
|
30
|
-
|
31
|
-
def events_topic
|
32
|
-
"ahoy_events"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Ahoy
|
2
|
-
module Subscribers
|
3
|
-
class ActiveRecord
|
4
|
-
def initialize(options = {})
|
5
|
-
@model = options[:model] || Ahoy::Event
|
6
|
-
end
|
7
|
-
|
8
|
-
def track(name, properties, options = {})
|
9
|
-
@model.create! do |e|
|
10
|
-
e.visit = options[:visit]
|
11
|
-
e.user = options[:user]
|
12
|
-
e.name = name
|
13
|
-
e.properties = properties
|
14
|
-
e.time = options[:time]
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/ahoy/throttle.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require "rack/attack"
|
2
|
-
|
3
|
-
module Ahoy
|
4
|
-
class Throttle < Rack::Attack
|
5
|
-
throttle("ahoy/ip", limit: Ahoy.throttle_limit, period: Ahoy.throttle_period) do |req|
|
6
|
-
if req.path.start_with?("/ahoy/")
|
7
|
-
req.ip
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def_delegators self, :whitelisted?, :blacklisted?, :throttled?, :tracked?, :blocklisted?, :safelisted?
|
12
|
-
|
13
|
-
def self.throttled_response
|
14
|
-
Rack::Attack.throttled_response
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# taken from https://github.com/collectiveidea/audited/blob/master/lib/generators/audited/install_generator.rb
|
2
|
-
require "rails/generators"
|
3
|
-
require "rails/generators/migration"
|
4
|
-
require "active_record"
|
5
|
-
require "rails/generators/active_record"
|
6
|
-
|
7
|
-
module Ahoy
|
8
|
-
module Stores
|
9
|
-
module Generators
|
10
|
-
class ActiveRecordEventsGenerator < Rails::Generators::Base
|
11
|
-
include Rails::Generators::Migration
|
12
|
-
source_root File.expand_path("../templates", __FILE__)
|
13
|
-
|
14
|
-
class_option :database, type: :string, aliases: "-d"
|
15
|
-
|
16
|
-
# Implement the required interface for Rails::Generators::Migration.
|
17
|
-
def self.next_migration_number(dirname) #:nodoc:
|
18
|
-
next_migration_number = current_migration_number(dirname) + 1
|
19
|
-
if ::ActiveRecord::Base.timestamped_migrations
|
20
|
-
[Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
|
21
|
-
else
|
22
|
-
"%.3d" % next_migration_number
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def copy_migration
|
27
|
-
@database = options["database"] || detect_database
|
28
|
-
unless @database.in?([nil, "postgresql", "postgresql-jsonb", "mysql", "sqlite"])
|
29
|
-
raise Thor::Error, "Unknown database option"
|
30
|
-
end
|
31
|
-
migration_template "active_record_events_migration.rb", "db/migrate/create_ahoy_events.rb"
|
32
|
-
end
|
33
|
-
|
34
|
-
def generate_model
|
35
|
-
template "active_record_event_model.rb", "app/models/ahoy/event.rb"
|
36
|
-
end
|
37
|
-
|
38
|
-
def create_initializer
|
39
|
-
template "active_record_initializer.rb", "config/initializers/ahoy.rb"
|
40
|
-
end
|
41
|
-
|
42
|
-
def detect_database
|
43
|
-
postgresql_version = ActiveRecord::Base.connection.send(:postgresql_version) rescue 0
|
44
|
-
if postgresql_version >= 90400
|
45
|
-
"postgresql-jsonb"
|
46
|
-
elsif postgresql_version >= 90200
|
47
|
-
"postgresql"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require "rails/generators"
|
2
|
-
|
3
|
-
module Ahoy
|
4
|
-
module Stores
|
5
|
-
module Generators
|
6
|
-
class ActiveRecordGenerator < Rails::Generators::Base
|
7
|
-
class_option :database, type: :string, aliases: "-d"
|
8
|
-
|
9
|
-
def boom
|
10
|
-
invoke "ahoy:stores:active_record_visits", nil, options
|
11
|
-
invoke "ahoy:stores:active_record_events", nil, options
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# taken from https://github.com/collectiveidea/audited/blob/master/lib/generators/audited/install_generator.rb
|
2
|
-
require "rails/generators"
|
3
|
-
require "rails/generators/migration"
|
4
|
-
require "active_record"
|
5
|
-
require "rails/generators/active_record"
|
6
|
-
|
7
|
-
module Ahoy
|
8
|
-
module Stores
|
9
|
-
module Generators
|
10
|
-
class ActiveRecordVisitsGenerator < Rails::Generators::Base
|
11
|
-
include Rails::Generators::Migration
|
12
|
-
source_root File.expand_path("../templates", __FILE__)
|
13
|
-
|
14
|
-
class_option :database, type: :string, aliases: "-d"
|
15
|
-
|
16
|
-
# Implement the required interface for Rails::Generators::Migration.
|
17
|
-
def self.next_migration_number(dirname) #:nodoc:
|
18
|
-
next_migration_number = current_migration_number(dirname) + 1
|
19
|
-
if ::ActiveRecord::Base.timestamped_migrations
|
20
|
-
[Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
|
21
|
-
else
|
22
|
-
"%.3d" % next_migration_number
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def copy_migration
|
27
|
-
unless options["database"].in?([nil, "postgresql", "postgresql-jsonb"])
|
28
|
-
raise Thor::Error, "Unknown database option"
|
29
|
-
end
|
30
|
-
migration_template "active_record_visits_migration.rb", "db/migrate/create_visits.rb"
|
31
|
-
end
|
32
|
-
|
33
|
-
def generate_model
|
34
|
-
template "active_record_visit_model.rb", "app/models/visit.rb"
|
35
|
-
end
|
36
|
-
|
37
|
-
def create_initializer
|
38
|
-
template "active_record_initializer.rb", "config/initializers/ahoy.rb"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "rails/generators"
|
2
|
-
|
3
|
-
module Ahoy
|
4
|
-
module Stores
|
5
|
-
module Generators
|
6
|
-
class BunnyGenerator < Rails::Generators::Base
|
7
|
-
source_root File.expand_path("../templates", __FILE__)
|
8
|
-
|
9
|
-
def create_initializer
|
10
|
-
template "bunny_initializer.rb", "config/initializers/ahoy.rb"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "rails/generators"
|
2
|
-
|
3
|
-
module Ahoy
|
4
|
-
module Stores
|
5
|
-
module Generators
|
6
|
-
class CustomGenerator < Rails::Generators::Base
|
7
|
-
source_root File.expand_path("../templates", __FILE__)
|
8
|
-
|
9
|
-
def create_initializer
|
10
|
-
template "custom_initializer.rb", "config/initializers/ahoy.rb"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "rails/generators"
|
2
|
-
|
3
|
-
module Ahoy
|
4
|
-
module Stores
|
5
|
-
module Generators
|
6
|
-
class FluentdGenerator < Rails::Generators::Base
|
7
|
-
source_root File.expand_path("../templates", __FILE__)
|
8
|
-
|
9
|
-
def create_initializer
|
10
|
-
template "fluentd_initializer.rb", "config/initializers/ahoy.rb"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "rails/generators"
|
2
|
-
|
3
|
-
module Ahoy
|
4
|
-
module Stores
|
5
|
-
module Generators
|
6
|
-
class KafkaGenerator < Rails::Generators::Base
|
7
|
-
source_root File.expand_path("../templates", __FILE__)
|
8
|
-
|
9
|
-
def create_initializer
|
10
|
-
template "kafka_initializer.rb", "config/initializers/ahoy.rb"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "rails/generators"
|
2
|
-
|
3
|
-
module Ahoy
|
4
|
-
module Stores
|
5
|
-
module Generators
|
6
|
-
class KinesisFirehoseGenerator < Rails::Generators::Base
|
7
|
-
source_root File.expand_path("../templates", __FILE__)
|
8
|
-
|
9
|
-
def create_initializer
|
10
|
-
template "kinesis_firehose_initializer.rb", "config/initializers/ahoy.rb"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "rails/generators"
|
2
|
-
|
3
|
-
module Ahoy
|
4
|
-
module Stores
|
5
|
-
module Generators
|
6
|
-
class LogGenerator < Rails::Generators::Base
|
7
|
-
source_root File.expand_path("../templates", __FILE__)
|
8
|
-
|
9
|
-
def create_initializer
|
10
|
-
template "log_initializer.rb", "config/initializers/ahoy.rb"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require "rails/generators"
|
2
|
-
|
3
|
-
module Ahoy
|
4
|
-
module Stores
|
5
|
-
module Generators
|
6
|
-
class MongoidEventsGenerator < Rails::Generators::Base
|
7
|
-
source_root File.expand_path("../templates", __FILE__)
|
8
|
-
|
9
|
-
def generate_model
|
10
|
-
template "mongoid_event_model.rb", "app/models/ahoy/event.rb"
|
11
|
-
end
|
12
|
-
|
13
|
-
def create_initializer
|
14
|
-
template "mongoid_initializer.rb", "config/initializers/ahoy.rb"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require "rails/generators"
|
2
|
-
|
3
|
-
module Ahoy
|
4
|
-
module Stores
|
5
|
-
module Generators
|
6
|
-
class MongoidVisitsGenerator < Rails::Generators::Base
|
7
|
-
source_root File.expand_path("../templates", __FILE__)
|
8
|
-
|
9
|
-
def generate_model
|
10
|
-
@visitor_id_type =
|
11
|
-
if defined?(::BSON)
|
12
|
-
"BSON::Binary"
|
13
|
-
elsif defined?(::Moped::BSON)
|
14
|
-
"Moped::BSON::Binary"
|
15
|
-
else
|
16
|
-
"String"
|
17
|
-
end
|
18
|
-
template "mongoid_visit_model.rb", "app/models/visit.rb"
|
19
|
-
end
|
20
|
-
|
21
|
-
def create_initializer
|
22
|
-
template "mongoid_initializer.rb", "config/initializers/ahoy.rb"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "rails/generators"
|
2
|
-
|
3
|
-
module Ahoy
|
4
|
-
module Stores
|
5
|
-
module Generators
|
6
|
-
class NatsGenerator < Rails::Generators::Base
|
7
|
-
source_root File.expand_path("../templates", __FILE__)
|
8
|
-
|
9
|
-
def create_initializer
|
10
|
-
template "nats_initializer.rb", "config/initializers/ahoy.rb"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "rails/generators"
|
2
|
-
|
3
|
-
module Ahoy
|
4
|
-
module Stores
|
5
|
-
module Generators
|
6
|
-
class NsqGenerator < Rails::Generators::Base
|
7
|
-
source_root File.expand_path("../templates", __FILE__)
|
8
|
-
|
9
|
-
def create_initializer
|
10
|
-
template "nsq_initializer.rb", "config/initializers/ahoy.rb"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module Ahoy
|
2
|
-
class Event < ActiveRecord::Base
|
3
|
-
include Ahoy::Properties
|
4
|
-
|
5
|
-
self.table_name = "ahoy_events"
|
6
|
-
|
7
|
-
belongs_to :visit
|
8
|
-
belongs_to :user<%= Rails::VERSION::MAJOR >= 5 ? ", optional: true" : nil %><% unless %w(postgresql postgresql-jsonb).include?(@database) %>
|
9
|
-
|
10
|
-
serialize :properties, JSON<% end %>
|
11
|
-
end
|
12
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class <%= migration_class_name %> < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
create_table :ahoy_events do |t|
|
4
|
-
t.integer :visit_id
|
5
|
-
|
6
|
-
# user
|
7
|
-
t.integer :user_id
|
8
|
-
# add t.string :user_type if polymorphic
|
9
|
-
|
10
|
-
t.string :name
|
11
|
-
t.<% case @database when "postgresql" %>json<% when "postgresql-jsonb" %>jsonb<% else %>text<% end %> :properties
|
12
|
-
t.timestamp :time
|
13
|
-
end
|
14
|
-
|
15
|
-
add_index :ahoy_events, [:visit_id, :name]
|
16
|
-
add_index :ahoy_events, [:user_id, :name]
|
17
|
-
add_index :ahoy_events, [:name, :time]
|
18
|
-
end
|
19
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
class <%= migration_class_name %> < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
create_table :visits do |t|
|
4
|
-
t.string :visit_token
|
5
|
-
t.string :visitor_token
|
6
|
-
|
7
|
-
# the rest are recommended but optional
|
8
|
-
# simply remove the columns you don't want
|
9
|
-
|
10
|
-
# standard
|
11
|
-
t.string :ip
|
12
|
-
t.text :user_agent
|
13
|
-
t.text :referrer
|
14
|
-
t.text :landing_page
|
15
|
-
|
16
|
-
# user
|
17
|
-
t.integer :user_id
|
18
|
-
# add t.string :user_type if polymorphic
|
19
|
-
|
20
|
-
# traffic source
|
21
|
-
t.string :referring_domain
|
22
|
-
t.string :search_keyword
|
23
|
-
|
24
|
-
# technology
|
25
|
-
t.string :browser
|
26
|
-
t.string :os
|
27
|
-
t.string :device_type
|
28
|
-
t.integer :screen_height
|
29
|
-
t.integer :screen_width
|
30
|
-
|
31
|
-
# location
|
32
|
-
t.string :country
|
33
|
-
t.string :region
|
34
|
-
t.string :city
|
35
|
-
t.string :postal_code
|
36
|
-
t.decimal :latitude
|
37
|
-
t.decimal :longitude
|
38
|
-
|
39
|
-
# utm parameters
|
40
|
-
t.string :utm_source
|
41
|
-
t.string :utm_medium
|
42
|
-
t.string :utm_term
|
43
|
-
t.string :utm_content
|
44
|
-
t.string :utm_campaign
|
45
|
-
|
46
|
-
# native apps
|
47
|
-
# t.string :platform
|
48
|
-
# t.string :app_version
|
49
|
-
# t.string :os_version
|
50
|
-
|
51
|
-
t.timestamp :started_at
|
52
|
-
end
|
53
|
-
|
54
|
-
add_index :visits, [:visit_token], unique: true
|
55
|
-
add_index :visits, [:user_id]
|
56
|
-
end
|
57
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class Ahoy::Store < Ahoy::Stores::KinesisFirehoseStore
|
2
|
-
def credentials
|
3
|
-
{
|
4
|
-
access_key_id: ENV["AWS_ACCESS_KEY_ID"],
|
5
|
-
secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
|
6
|
-
region: "us-east-1"
|
7
|
-
}
|
8
|
-
end
|
9
|
-
|
10
|
-
def visits_stream
|
11
|
-
"ahoy_visits"
|
12
|
-
end
|
13
|
-
|
14
|
-
def events_stream
|
15
|
-
"ahoy_events"
|
16
|
-
end
|
17
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
ActiveRecord::Base.establish_connection adapter: "mysql2", username: "root", database: "ahoy_test"
|
4
|
-
|
5
|
-
ActiveRecord::Migration.create_table :mysql_json_events, force: true do |t|
|
6
|
-
t.json :properties
|
7
|
-
end
|
8
|
-
|
9
|
-
class MysqlJsonEvent < MysqlBase
|
10
|
-
end
|
11
|
-
|
12
|
-
class MysqlJsonTest < Minitest::Test
|
13
|
-
include PropertiesTest
|
14
|
-
|
15
|
-
def model
|
16
|
-
MysqlJsonEvent
|
17
|
-
end
|
18
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
ActiveRecord::Base.establish_connection adapter: "mysql2", username: "root", database: "ahoy_test"
|
4
|
-
|
5
|
-
ActiveRecord::Migration.create_table :mysql_text_events, force: true do |t|
|
6
|
-
t.text :properties
|
7
|
-
end
|
8
|
-
|
9
|
-
class MysqlTextEvent < MysqlBase
|
10
|
-
serialize :properties, JSON
|
11
|
-
end
|
12
|
-
|
13
|
-
class MysqlTextTest < Minitest::Test
|
14
|
-
include PropertiesTest
|
15
|
-
|
16
|
-
def model
|
17
|
-
MysqlTextEvent
|
18
|
-
end
|
19
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
ActiveRecord::Base.establish_connection adapter: "postgresql", database: "ahoy_test"
|
4
|
-
|
5
|
-
ActiveRecord::Migration.create_table :postgresql_hstore_events, force: true do |t|
|
6
|
-
t.hstore :properties
|
7
|
-
end
|
8
|
-
|
9
|
-
class PostgresqlHstoreEvent < PostgresqlBase
|
10
|
-
end
|
11
|
-
|
12
|
-
class PostgresqlHstoreTest < Minitest::Test
|
13
|
-
include PropertiesTest
|
14
|
-
|
15
|
-
def model
|
16
|
-
PostgresqlHstoreEvent
|
17
|
-
end
|
18
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
ActiveRecord::Base.establish_connection adapter: "postgresql", database: "ahoy_test"
|
4
|
-
|
5
|
-
ActiveRecord::Migration.create_table :postgresql_json_events, force: true do |t|
|
6
|
-
t.json :properties
|
7
|
-
end
|
8
|
-
|
9
|
-
class PostgresqlJsonEvent < PostgresqlBase
|
10
|
-
end
|
11
|
-
|
12
|
-
class PostgresqlJsonTest < Minitest::Test
|
13
|
-
include PropertiesTest
|
14
|
-
|
15
|
-
def model
|
16
|
-
PostgresqlJsonEvent
|
17
|
-
end
|
18
|
-
end
|