ahoy_matey 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +6 -0
- data/app/controllers/ahoy/base_controller.rb +1 -1
- data/lib/ahoy/model.rb +3 -1
- data/lib/ahoy/tracker.rb +1 -1
- data/lib/ahoy/version.rb +1 -1
- data/lib/ahoy/warden.rb +14 -0
- data/lib/ahoy_matey.rb +4 -14
- data/vendor/assets/javascripts/ahoy.js +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bfd98e74a3c8164034e720f074c623e461e197f
|
4
|
+
data.tar.gz: b91ab16168e6fa4301741c0a32a45107e28d46f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d0d3df7bb8e468751d299e7073d00924119d6e035ea436a1384f02785f462523473c58d5b11a649dd7db3e1bb5fc365ea67f62dbf3fa8151f9587d011b7f96a
|
7
|
+
data.tar.gz: f65476622c0be90b84619dd09bd9d5299a90507e46738e7f0fc7525d950e9ea0adcef385256f05203d27a633d3eac6dadf39b9016d255cec1f827e82636d6c80
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -367,6 +367,12 @@ Use a different model for events
|
|
367
367
|
Ahoy.subscribers << Ahoy::Subscribers::ActiveRecord.new(model: Event)
|
368
368
|
```
|
369
369
|
|
370
|
+
Track bots [master]
|
371
|
+
|
372
|
+
```ruby
|
373
|
+
Ahoy.track_bots = true
|
374
|
+
```
|
375
|
+
|
370
376
|
## Upgrading
|
371
377
|
|
372
378
|
In `0.1.6`, a big improvement was made to `browser` and `os`. Update existing visits with:
|
data/lib/ahoy/model.rb
CHANGED
data/lib/ahoy/tracker.rb
CHANGED
data/lib/ahoy/version.rb
CHANGED
data/lib/ahoy/warden.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Warden::Manager.after_set_user except: :fetch do |user, auth, opts|
|
2
|
+
request = ActionDispatch::Request.new(auth.env)
|
3
|
+
visit_token = request.cookies["ahoy_visit"] || request.headers["Ahoy-Visit"]
|
4
|
+
visit = nil
|
5
|
+
if visit_token
|
6
|
+
visit = Ahoy.visit_model.where(visit_token: visit_token).first
|
7
|
+
if visit and !visit.user
|
8
|
+
visit.user = user
|
9
|
+
visit.save!
|
10
|
+
end
|
11
|
+
end
|
12
|
+
ahoy = Ahoy::Tracker.new
|
13
|
+
ahoy.track "$authenticate", {}, user: user, visit: visit
|
14
|
+
end
|
data/lib/ahoy_matey.rb
CHANGED
@@ -10,6 +10,7 @@ require "ahoy/controller"
|
|
10
10
|
require "ahoy/model"
|
11
11
|
require "ahoy/subscribers/active_record"
|
12
12
|
require "ahoy/engine"
|
13
|
+
require "ahoy/warden" if defined?(Warden)
|
13
14
|
|
14
15
|
module Ahoy
|
15
16
|
|
@@ -47,21 +48,10 @@ module Ahoy
|
|
47
48
|
|
48
49
|
mattr_accessor :subscribers
|
49
50
|
self.subscribers = []
|
51
|
+
|
52
|
+
mattr_accessor :track_bots
|
53
|
+
self.track_bots = false
|
50
54
|
end
|
51
55
|
|
52
56
|
ActionController::Base.send :include, Ahoy::Controller
|
53
57
|
ActiveRecord::Base.send(:extend, Ahoy::Model) if defined?(ActiveRecord)
|
54
|
-
|
55
|
-
if defined?(Warden)
|
56
|
-
Warden::Manager.after_set_user except: :fetch do |user, auth, opts|
|
57
|
-
request = ActionDispatch::Request.new(auth.env)
|
58
|
-
visit_token = request.cookies["ahoy_visit"] || request.headers["Ahoy-Visit"]
|
59
|
-
if visit_token
|
60
|
-
visit = Ahoy.visit_model.where(visit_token: visit_token).first
|
61
|
-
if visit and !visit.user
|
62
|
-
visit.user = user
|
63
|
-
visit.save!
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
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: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- lib/ahoy/subscribers/active_record.rb
|
148
148
|
- lib/ahoy/tracker.rb
|
149
149
|
- lib/ahoy/version.rb
|
150
|
+
- lib/ahoy/warden.rb
|
150
151
|
- lib/ahoy_matey.rb
|
151
152
|
- lib/generators/ahoy/events/active_record_generator.rb
|
152
153
|
- lib/generators/ahoy/events/templates/create_events.rb
|