ahoy_matey 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +59 -35
- data/ahoy_matey.gemspec +1 -1
- data/app/controllers/ahoy/base_controller.rb +6 -1
- data/lib/ahoy.rb +5 -2
- data/lib/ahoy/controller.rb +12 -4
- data/lib/ahoy/deckhands/request_deckhand.rb +13 -7
- data/lib/ahoy/deckhands/technology_deckhand.rb +5 -5
- data/lib/ahoy/engine.rb +1 -19
- data/lib/ahoy/log_silencer.rb +16 -0
- data/lib/ahoy/logger_silencer.rb +7 -11
- data/lib/ahoy/stores/base_store.rb +1 -1
- data/lib/ahoy/stores/bunny_store.rb +33 -0
- data/lib/ahoy/stores/kinesis_firehose_store.rb +42 -0
- data/lib/ahoy/version.rb +1 -1
- data/lib/generators/ahoy/stores/bunny_generator.rb +15 -0
- data/lib/generators/ahoy/stores/kinesis_firehose_generator.rb +15 -0
- data/lib/generators/ahoy/stores/templates/bunny_initializer.rb +9 -0
- data/lib/generators/ahoy/stores/templates/kinesis_firehose_initializer.rb +17 -0
- metadata +15 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6686254ab1f5bb79219bdb93194e2e3ddb9ddd8
|
4
|
+
data.tar.gz: afd9cb6035e939db2c60b881b5a80a2ea0bb407e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 504dd73058c78a635072af48ca326f623a335af74d5cbfc7636ccd0c2d5a0ab12304cee3cc01d51f11829aa80200dada366734d7f55d1b99946ff0d49b072bb2
|
7
|
+
data.tar.gz: f1664a981c88b2896e856ec8bcdba0e4b1e94e26b93f290b1b495ad72166787952965ff5566e5325eb0be59ddcf8f70ebc4cdeeccf40cfa8614475fa4c5e35ae
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 1.2.2
|
2
|
+
|
3
|
+
- Fixed issue with latest version of `browser` gem
|
4
|
+
- Added support for RabbitMQ
|
5
|
+
- Added support for Amazon Kinesis Firehose
|
6
|
+
- Fixed deprecation warnings in Rails 5
|
7
|
+
|
1
8
|
## 1.2.1
|
2
9
|
|
3
10
|
- Fixed `SystemStackError: stack level too deep` when used with `activerecord-session_store`
|
data/README.md
CHANGED
@@ -36,19 +36,21 @@ Ahoy supports a number of data stores out of the box. You can start with one of
|
|
36
36
|
- [SQLite](#mysql-or-sqlite)
|
37
37
|
- [MongoDB](#mongodb)
|
38
38
|
- [Fluentd](#fluentd)
|
39
|
+
- [RabbitMQ](#rabbitmq-master)
|
40
|
+
- [Kinesis Firehose](#kinesis-firehose-master)
|
39
41
|
- [Logs](#logs)
|
40
42
|
- [Custom](#custom)
|
41
43
|
|
42
44
|
### PostgreSQL
|
43
45
|
|
44
|
-
For Rails 4 and PostgreSQL 9.4 or greater, use:
|
46
|
+
For Rails 4.2 and PostgreSQL 9.4 or greater, use:
|
45
47
|
|
46
48
|
```sh
|
47
49
|
rails generate ahoy:stores:active_record -d postgresql-jsonb
|
48
50
|
rake db:migrate
|
49
51
|
```
|
50
52
|
|
51
|
-
For Rails 4 and PostgreSQL 9.2
|
53
|
+
For Rails 4 and PostgreSQL 9.2 or greater, use:
|
52
54
|
|
53
55
|
```sh
|
54
56
|
rails generate ahoy:stores:active_record -d postgresql
|
@@ -101,6 +103,38 @@ rails generate ahoy:stores:fluentd
|
|
101
103
|
|
102
104
|
Use `ENV["FLUENTD_HOST"]` and `ENV["FLUENTD_PORT"]` to configure.
|
103
105
|
|
106
|
+
### RabbitMQ
|
107
|
+
|
108
|
+
Add [bunny](https://github.com/ruby-amqp/bunny) to your Gemfile.
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
gem 'bunny'
|
112
|
+
```
|
113
|
+
|
114
|
+
And run:
|
115
|
+
|
116
|
+
```sh
|
117
|
+
rails generate ahoy:stores:bunny
|
118
|
+
```
|
119
|
+
|
120
|
+
Use `ENV["RABBITMQ_URL"]` to configure.
|
121
|
+
|
122
|
+
### Kinesis Firehose
|
123
|
+
|
124
|
+
Add [aws-sdk](https://github.com/aws/aws-sdk-ruby) to your Gemfile.
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
gem 'aws-sdk', '>= 2.0.0'
|
128
|
+
```
|
129
|
+
|
130
|
+
And run:
|
131
|
+
|
132
|
+
```sh
|
133
|
+
rails generate ahoy:stores:kinesis_firehose
|
134
|
+
```
|
135
|
+
|
136
|
+
Configure delivery streams and credentials in the initializer.
|
137
|
+
|
104
138
|
### Logs
|
105
139
|
|
106
140
|
```sh
|
@@ -119,13 +153,11 @@ This creates a class for you to fill out.
|
|
119
153
|
|
120
154
|
```ruby
|
121
155
|
class Ahoy::Store < Ahoy::Stores::BaseStore
|
122
|
-
|
123
156
|
def track_visit(options)
|
124
157
|
end
|
125
158
|
|
126
159
|
def track_event(name, properties, options)
|
127
160
|
end
|
128
|
-
|
129
161
|
end
|
130
162
|
```
|
131
163
|
|
@@ -172,7 +204,7 @@ ahoy.track "Viewed book", title: "Hot, Flat, and Crowded"
|
|
172
204
|
|
173
205
|
#### Native Apps
|
174
206
|
|
175
|
-
See the [HTTP spec](#native-apps) until libraries are built.
|
207
|
+
See the [HTTP spec](#native-apps-1) until libraries are built.
|
176
208
|
|
177
209
|
### Users
|
178
210
|
|
@@ -202,11 +234,9 @@ Exclude visits and events from being tracked with:
|
|
202
234
|
|
203
235
|
```ruby
|
204
236
|
class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
|
205
|
-
|
206
237
|
def exclude?
|
207
238
|
bot? || request.ip == "192.168.1.1"
|
208
239
|
end
|
209
|
-
|
210
240
|
end
|
211
241
|
```
|
212
242
|
|
@@ -216,7 +246,6 @@ Bots are excluded by default.
|
|
216
246
|
|
217
247
|
```ruby
|
218
248
|
class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
|
219
|
-
|
220
249
|
def track_visit(options)
|
221
250
|
super do |visit|
|
222
251
|
visit.gclid = visit_properties.landing_params["gclid"]
|
@@ -228,7 +257,6 @@ class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
|
|
228
257
|
event.ip = request.ip
|
229
258
|
end
|
230
259
|
end
|
231
|
-
|
232
260
|
end
|
233
261
|
```
|
234
262
|
|
@@ -238,11 +266,9 @@ If you use a method other than `current_user`, set it here:
|
|
238
266
|
|
239
267
|
```ruby
|
240
268
|
class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
|
241
|
-
|
242
269
|
def user
|
243
270
|
controller.true_user
|
244
271
|
end
|
245
|
-
|
246
272
|
end
|
247
273
|
```
|
248
274
|
|
@@ -256,11 +282,9 @@ To customize this, use:
|
|
256
282
|
|
257
283
|
```ruby
|
258
284
|
class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
|
259
|
-
|
260
285
|
def report_exception(e)
|
261
286
|
Rollbar.report_exception(e)
|
262
287
|
end
|
263
|
-
|
264
288
|
end
|
265
289
|
```
|
266
290
|
|
@@ -270,7 +294,6 @@ For ActiveRecord and Mongoid stores
|
|
270
294
|
|
271
295
|
```ruby
|
272
296
|
class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
|
273
|
-
|
274
297
|
def visit_model
|
275
298
|
CustomVisit
|
276
299
|
end
|
@@ -278,7 +301,6 @@ class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
|
|
278
301
|
def event_model
|
279
302
|
CustomEvent
|
280
303
|
end
|
281
|
-
|
282
304
|
end
|
283
305
|
```
|
284
306
|
|
@@ -302,7 +324,7 @@ Rails actions
|
|
302
324
|
|
303
325
|
```ruby
|
304
326
|
class ApplicationController < ActionController::Base
|
305
|
-
|
327
|
+
after_action :track_action
|
306
328
|
|
307
329
|
protected
|
308
330
|
|
@@ -332,7 +354,19 @@ Ahoy.visit_duration = 30.minutes
|
|
332
354
|
|
333
355
|
### ActiveRecord
|
334
356
|
|
335
|
-
Let’s associate orders with visits.
|
357
|
+
Let’s associate orders with visits.
|
358
|
+
|
359
|
+
First, generate a migration and add a `visit_id` column.
|
360
|
+
|
361
|
+
```ruby
|
362
|
+
class AddVisitIdToOrders < ActiveRecord::Migration
|
363
|
+
def change
|
364
|
+
add_column :orders, :visit_id, :uuid
|
365
|
+
end
|
366
|
+
end
|
367
|
+
```
|
368
|
+
|
369
|
+
Then, add `visitable` to the model.
|
336
370
|
|
337
371
|
```ruby
|
338
372
|
class Order < ActiveRecord::Base
|
@@ -340,9 +374,7 @@ class Order < ActiveRecord::Base
|
|
340
374
|
end
|
341
375
|
```
|
342
376
|
|
343
|
-
When a visitor places an order, the `visit_id` column is automatically set.
|
344
|
-
|
345
|
-
:tada: Magic!
|
377
|
+
When a visitor places an order, the `visit_id` column is automatically set. :tada:
|
346
378
|
|
347
379
|
Customize the column and class name with:
|
348
380
|
|
@@ -356,13 +388,11 @@ To attach the user with [Doorkeeper](https://github.com/doorkeeper-gem/doorkeepe
|
|
356
388
|
|
357
389
|
```ruby
|
358
390
|
class ApplicationController < ActionController::Base
|
359
|
-
|
360
391
|
private
|
361
392
|
|
362
393
|
def current_resource_owner
|
363
394
|
User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
|
364
395
|
end
|
365
|
-
|
366
396
|
end
|
367
397
|
```
|
368
398
|
|
@@ -393,7 +423,7 @@ Ahoy.track_visits_immediately = true
|
|
393
423
|
You can exclude API endpoints and other actions with:
|
394
424
|
|
395
425
|
```ruby
|
396
|
-
|
426
|
+
skip_before_action :track_ahoy_visit
|
397
427
|
```
|
398
428
|
|
399
429
|
## Development
|
@@ -517,13 +547,13 @@ rails g migration change_properties_to_jsonb_on_ahoy_events
|
|
517
547
|
And add:
|
518
548
|
|
519
549
|
```rb
|
520
|
-
|
521
|
-
|
522
|
-
|
550
|
+
def up
|
551
|
+
change_column :ahoy_events, :properties, :jsonb, using: "properties::jsonb"
|
552
|
+
end
|
523
553
|
|
524
|
-
|
525
|
-
|
526
|
-
|
554
|
+
def down
|
555
|
+
change_column :ahoy_events, :properties, :json
|
556
|
+
end
|
527
557
|
```
|
528
558
|
|
529
559
|
Note: This will lock the table while the migration is running.
|
@@ -573,11 +603,9 @@ If you have a custom subscriber, copy the `track` method to `track_event` in `Ah
|
|
573
603
|
|
574
604
|
```ruby
|
575
605
|
class Ahoy::Store < Ahoy::Stores::ActiveRecordTokenStore
|
576
|
-
|
577
606
|
def track_event(name, properties, options)
|
578
607
|
# code copied from the track method in your subscriber
|
579
608
|
end
|
580
|
-
|
581
609
|
end
|
582
610
|
```
|
583
611
|
|
@@ -589,12 +617,10 @@ To restore this behavior, use:
|
|
589
617
|
|
590
618
|
```ruby
|
591
619
|
class Ahoy::Store < Ahoy::Stores::ActiveRecordTokenStore
|
592
|
-
|
593
620
|
def authenticate(user)
|
594
621
|
super
|
595
622
|
ahoy.track "$authenticate"
|
596
623
|
end
|
597
|
-
|
598
624
|
end
|
599
625
|
```
|
600
626
|
|
@@ -606,7 +632,6 @@ Skip this step if you do not use these options.
|
|
606
632
|
|
607
633
|
```ruby
|
608
634
|
class Ahoy::Store < Ahoy::Stores::ActiveRecordTokenStore
|
609
|
-
|
610
635
|
def user
|
611
636
|
# logic from Ahoy.user_method goes here
|
612
637
|
controller.true_user
|
@@ -616,7 +641,6 @@ class Ahoy::Store < Ahoy::Stores::ActiveRecordTokenStore
|
|
616
641
|
# logic from Ahoy.track_bots and Ahoy.exclude_method goes here
|
617
642
|
bot? || request.ip == "192.168.1.1"
|
618
643
|
end
|
619
|
-
|
620
644
|
end
|
621
645
|
```
|
622
646
|
|
data/ahoy_matey.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency "rails"
|
22
22
|
spec.add_dependency "addressable"
|
23
|
-
spec.add_dependency "browser", "
|
23
|
+
spec.add_dependency "browser", "~> 2.0"
|
24
24
|
spec.add_dependency "geocoder"
|
25
25
|
spec.add_dependency "referer-parser", ">= 0.3.0"
|
26
26
|
spec.add_dependency "user_agent_parser"
|
@@ -1,7 +1,12 @@
|
|
1
1
|
module Ahoy
|
2
2
|
class BaseController < ApplicationController
|
3
3
|
# skip all filters except for authlogic
|
4
|
-
|
4
|
+
filters = _process_action_callbacks.map(&:filter) - [:load_authlogic]
|
5
|
+
if respond_to?(:skip_action)
|
6
|
+
skip_action *filters
|
7
|
+
else
|
8
|
+
skip_filter *filters
|
9
|
+
end
|
5
10
|
|
6
11
|
def ahoy
|
7
12
|
@ahoy ||= Ahoy::Tracker.new(controller: self, api: true)
|
data/lib/ahoy.rb
CHANGED
@@ -25,6 +25,9 @@ require "ahoy/stores/active_record_token_store"
|
|
25
25
|
require "ahoy/stores/log_store"
|
26
26
|
require "ahoy/stores/fluentd_store"
|
27
27
|
require "ahoy/stores/mongoid_store"
|
28
|
+
require "ahoy/stores/kinesis_firehose_store"
|
29
|
+
require "ahoy/stores/bunny_store"
|
30
|
+
require "ahoy/log_silencer"
|
28
31
|
require "ahoy/engine"
|
29
32
|
require "ahoy/warden" if defined?(Warden)
|
30
33
|
|
@@ -91,10 +94,10 @@ begin
|
|
91
94
|
require "active_record/session_store/extension/logger_silencer"
|
92
95
|
rescue LoadError
|
93
96
|
require "ahoy/logger_silencer"
|
94
|
-
Logger.send
|
97
|
+
Logger.send(:prepend, Ahoy::LoggerSilencer)
|
95
98
|
|
96
99
|
begin
|
97
100
|
require "syslog/logger"
|
98
|
-
Syslog::Logger.send
|
101
|
+
Syslog::Logger.send(:prepend, Ahoy::LoggerSilencer)
|
99
102
|
rescue LoadError; end
|
100
103
|
end
|
data/lib/ahoy/controller.rb
CHANGED
@@ -5,10 +5,14 @@ module Ahoy
|
|
5
5
|
def self.included(base)
|
6
6
|
base.helper_method :current_visit
|
7
7
|
base.helper_method :ahoy
|
8
|
-
base.
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
if base.respond_to?(:before_action)
|
9
|
+
base.before_action :set_ahoy_cookies
|
10
|
+
base.before_action :track_ahoy_visit
|
11
|
+
base.before_action :set_ahoy_request_store
|
12
|
+
else
|
13
|
+
base.before_filter :set_ahoy_cookies
|
14
|
+
base.before_filter :track_ahoy_visit
|
15
|
+
base.before_filter :set_ahoy_request_store
|
12
16
|
end
|
13
17
|
end
|
14
18
|
|
@@ -30,5 +34,9 @@ module Ahoy
|
|
30
34
|
ahoy.track_visit(defer: !Ahoy.track_visits_immediately)
|
31
35
|
end
|
32
36
|
end
|
37
|
+
|
38
|
+
def set_ahoy_request_store
|
39
|
+
RequestStore.store[:ahoy] ||= ahoy
|
40
|
+
end
|
33
41
|
end
|
34
42
|
end
|
@@ -17,31 +17,37 @@ module Ahoy
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def referrer
|
20
|
-
@options[:api] ?
|
20
|
+
@options[:api] ? params["referrer"] : request.referer
|
21
21
|
end
|
22
22
|
|
23
23
|
def landing_page
|
24
|
-
@options[:api] ?
|
24
|
+
@options[:api] ? params["landing_page"] : request.original_url
|
25
25
|
end
|
26
26
|
|
27
27
|
def platform
|
28
|
-
|
28
|
+
params["platform"]
|
29
29
|
end
|
30
30
|
|
31
31
|
def app_version
|
32
|
-
|
32
|
+
params["app_version"]
|
33
33
|
end
|
34
34
|
|
35
35
|
def os_version
|
36
|
-
|
36
|
+
params["os_version"]
|
37
37
|
end
|
38
38
|
|
39
39
|
def screen_height
|
40
|
-
|
40
|
+
params["screen_height"]
|
41
41
|
end
|
42
42
|
|
43
43
|
def screen_width
|
44
|
-
|
44
|
+
params["screen_width"]
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def params
|
50
|
+
@params ||= request.params
|
45
51
|
end
|
46
52
|
end
|
47
53
|
end
|
@@ -15,16 +15,16 @@ module Ahoy
|
|
15
15
|
|
16
16
|
def device_type
|
17
17
|
@device_type ||= begin
|
18
|
-
browser = Browser.new(
|
18
|
+
browser = Browser.new(@user_agent)
|
19
19
|
if browser.bot?
|
20
20
|
"Bot"
|
21
|
-
elsif browser.tv?
|
21
|
+
elsif browser.device.tv?
|
22
22
|
"TV"
|
23
|
-
elsif browser.console?
|
23
|
+
elsif browser.device.console?
|
24
24
|
"Console"
|
25
|
-
elsif browser.tablet?
|
25
|
+
elsif browser.device.tablet?
|
26
26
|
"Tablet"
|
27
|
-
elsif browser.mobile?
|
27
|
+
elsif browser.device.mobile?
|
28
28
|
"Mobile"
|
29
29
|
else
|
30
30
|
"Desktop"
|
data/lib/ahoy/engine.rb
CHANGED
@@ -1,25 +1,7 @@
|
|
1
1
|
module Ahoy
|
2
2
|
class Engine < ::Rails::Engine
|
3
|
-
# from https://github.com/evrone/quiet_assets/blob/master/lib/quiet_assets.rb
|
4
3
|
initializer "ahoy.middleware", after: "sprockets.environment" do
|
5
|
-
|
6
|
-
|
7
|
-
# Parse PATH_INFO by assets prefix
|
8
|
-
AHOY_PREFIX = "/ahoy/".freeze
|
9
|
-
|
10
|
-
# Just create an alias for call in middleware
|
11
|
-
Rails::Rack::Logger.class_eval do
|
12
|
-
def call_with_quiet_ahoy(env)
|
13
|
-
if env["PATH_INFO"].start_with?(AHOY_PREFIX) && logger.respond_to?(:silence_logger)
|
14
|
-
logger.silence_logger do
|
15
|
-
call_without_quiet_ahoy(env)
|
16
|
-
end
|
17
|
-
else
|
18
|
-
call_without_quiet_ahoy(env)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
alias_method_chain :call, :quiet_ahoy
|
22
|
-
end
|
4
|
+
Rails::Rack::Logger.send(:prepend, Ahoy::LogSilencer) if Ahoy.quiet
|
23
5
|
end
|
24
6
|
end
|
25
7
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Ahoy
|
2
|
+
module LogSilencer
|
3
|
+
PATH_INFO = "PATH_INFO".freeze
|
4
|
+
AHOY_PREFIX = "/ahoy/".freeze
|
5
|
+
|
6
|
+
def call(env)
|
7
|
+
if env[PATH_INFO].start_with?(AHOY_PREFIX) && logger.respond_to?(:silence_logger)
|
8
|
+
logger.silence_logger do
|
9
|
+
super
|
10
|
+
end
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/ahoy/logger_silencer.rb
CHANGED
@@ -7,13 +7,9 @@ require "active_support/concern"
|
|
7
7
|
|
8
8
|
module Ahoy
|
9
9
|
module LoggerSilencer
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
cattr_accessor :silencer
|
14
|
-
self.silencer = true
|
15
|
-
alias_method_chain :level, :threadsafety
|
16
|
-
alias_method_chain :add, :threadsafety
|
10
|
+
def self.prepended(base)
|
11
|
+
base.cattr_accessor :silencer
|
12
|
+
base.silencer = true
|
17
13
|
end
|
18
14
|
|
19
15
|
def thread_level
|
@@ -24,15 +20,15 @@ module Ahoy
|
|
24
20
|
Thread.current[thread_hash_level_key] = level
|
25
21
|
end
|
26
22
|
|
27
|
-
def
|
28
|
-
thread_level ||
|
23
|
+
def level
|
24
|
+
thread_level || super
|
29
25
|
end
|
30
26
|
|
31
|
-
def
|
27
|
+
def add(severity, message = nil, progname = nil, &block)
|
32
28
|
if !defined?(@logdev) || @logdev.nil? || (severity || UNKNOWN) < level
|
33
29
|
true
|
34
30
|
else
|
35
|
-
|
31
|
+
super
|
36
32
|
end
|
37
33
|
end
|
38
34
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Ahoy
|
2
|
+
module Stores
|
3
|
+
class BunnyStore < LogStore
|
4
|
+
def log_visit(data)
|
5
|
+
post(visits_queue, data)
|
6
|
+
end
|
7
|
+
|
8
|
+
def log_event(data)
|
9
|
+
post(events_queue, data)
|
10
|
+
end
|
11
|
+
|
12
|
+
def channel
|
13
|
+
@channel ||= begin
|
14
|
+
conn = Bunny.new
|
15
|
+
conn.start
|
16
|
+
conn.create_channel
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def post(queue, message)
|
21
|
+
channel.queue(queue, durable: true).publish(message.to_json)
|
22
|
+
end
|
23
|
+
|
24
|
+
def visits_queue
|
25
|
+
"ahoy_visits"
|
26
|
+
end
|
27
|
+
|
28
|
+
def events_queue
|
29
|
+
"ahoy_events"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Ahoy
|
2
|
+
module Stores
|
3
|
+
class KinesisFirehoseStore < LogStore
|
4
|
+
def log_visit(data)
|
5
|
+
post(visits_stream, data)
|
6
|
+
end
|
7
|
+
|
8
|
+
def log_event(data)
|
9
|
+
post(events_stream, data)
|
10
|
+
end
|
11
|
+
|
12
|
+
def client
|
13
|
+
@client ||= Aws::Firehose::Client.new(credentials)
|
14
|
+
end
|
15
|
+
|
16
|
+
def post(stream, data)
|
17
|
+
client.put_record(
|
18
|
+
delivery_stream_name: stream,
|
19
|
+
record: {
|
20
|
+
data: "#{data.to_json}\n"
|
21
|
+
}
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def credentials
|
26
|
+
{
|
27
|
+
access_key_id: ENV["AWS_ACCESS_KEY_ID"],
|
28
|
+
secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
|
29
|
+
region: "us-east-1"
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def visits_stream
|
34
|
+
"ahoy_visits"
|
35
|
+
end
|
36
|
+
|
37
|
+
def events_stream
|
38
|
+
"ahoy_events"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/ahoy/version.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
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
|
@@ -0,0 +1,15 @@
|
|
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
|
@@ -0,0 +1,17 @@
|
|
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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ahoy_matey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: browser
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '2.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: geocoder
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -205,12 +205,15 @@ files:
|
|
205
205
|
- lib/ahoy/deckhands/utm_parameter_deckhand.rb
|
206
206
|
- lib/ahoy/engine.rb
|
207
207
|
- lib/ahoy/geocode_job.rb
|
208
|
+
- lib/ahoy/log_silencer.rb
|
208
209
|
- lib/ahoy/logger_silencer.rb
|
209
210
|
- lib/ahoy/model.rb
|
210
211
|
- lib/ahoy/stores/active_record_store.rb
|
211
212
|
- lib/ahoy/stores/active_record_token_store.rb
|
212
213
|
- lib/ahoy/stores/base_store.rb
|
214
|
+
- lib/ahoy/stores/bunny_store.rb
|
213
215
|
- lib/ahoy/stores/fluentd_store.rb
|
216
|
+
- lib/ahoy/stores/kinesis_firehose_store.rb
|
214
217
|
- lib/ahoy/stores/log_store.rb
|
215
218
|
- lib/ahoy/stores/mongoid_store.rb
|
216
219
|
- lib/ahoy/subscribers/active_record.rb
|
@@ -222,8 +225,10 @@ files:
|
|
222
225
|
- lib/generators/ahoy/stores/active_record_events_generator.rb
|
223
226
|
- lib/generators/ahoy/stores/active_record_generator.rb
|
224
227
|
- lib/generators/ahoy/stores/active_record_visits_generator.rb
|
228
|
+
- lib/generators/ahoy/stores/bunny_generator.rb
|
225
229
|
- lib/generators/ahoy/stores/custom_generator.rb
|
226
230
|
- lib/generators/ahoy/stores/fluentd_generator.rb
|
231
|
+
- lib/generators/ahoy/stores/kinesis_firehose_generator.rb
|
227
232
|
- lib/generators/ahoy/stores/log_generator.rb
|
228
233
|
- lib/generators/ahoy/stores/mongoid_events_generator.rb
|
229
234
|
- lib/generators/ahoy/stores/mongoid_generator.rb
|
@@ -233,8 +238,10 @@ files:
|
|
233
238
|
- lib/generators/ahoy/stores/templates/active_record_initializer.rb
|
234
239
|
- lib/generators/ahoy/stores/templates/active_record_visit_model.rb
|
235
240
|
- lib/generators/ahoy/stores/templates/active_record_visits_migration.rb
|
241
|
+
- lib/generators/ahoy/stores/templates/bunny_initializer.rb
|
236
242
|
- lib/generators/ahoy/stores/templates/custom_initializer.rb
|
237
243
|
- lib/generators/ahoy/stores/templates/fluentd_initializer.rb
|
244
|
+
- lib/generators/ahoy/stores/templates/kinesis_firehose_initializer.rb
|
238
245
|
- lib/generators/ahoy/stores/templates/log_initializer.rb
|
239
246
|
- lib/generators/ahoy/stores/templates/mongoid_event_model.rb
|
240
247
|
- lib/generators/ahoy/stores/templates/mongoid_initializer.rb
|
@@ -262,10 +269,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
262
269
|
version: '0'
|
263
270
|
requirements: []
|
264
271
|
rubyforge_project:
|
265
|
-
rubygems_version: 2.
|
272
|
+
rubygems_version: 2.6.1
|
266
273
|
signing_key:
|
267
274
|
specification_version: 4
|
268
275
|
summary: Simple, powerful visit tracking for Rails
|
269
276
|
test_files:
|
270
277
|
- test/test_helper.rb
|
271
278
|
- test/visit_properties_test.rb
|
279
|
+
has_rdoc:
|