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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1ddf7a214c83d60f35b1d7a39653ef65d5ab3ee
4
- data.tar.gz: e3c9af288c825faffda2cb7bf97cd8aa248c41a6
3
+ metadata.gz: 7bfd98e74a3c8164034e720f074c623e461e197f
4
+ data.tar.gz: b91ab16168e6fa4301741c0a32a45107e28d46f6
5
5
  SHA512:
6
- metadata.gz: e3c068287e17bc73b51ce57af242a91013720b64dceefb00330a85ac2c586ba9b11b3fdd6395b9d8adf3d952b9dee1a73557d16a6a8792a49fa62d9c1893ba3c
7
- data.tar.gz: 137594a001bb62a37274b94fe7776074b0880e74ddfdd0d48cc305d67847d13ca056de3f6fe38161d180d13cf22f79d6d363888a949d2d3abbdea8eed056d7cd
6
+ metadata.gz: 7d0d3df7bb8e468751d299e7073d00924119d6e035ea436a1384f02785f462523473c58d5b11a649dd7db3e1bb5fc365ea67f62dbf3fa8151f9587d011b7f96a
7
+ data.tar.gz: f65476622c0be90b84619dd09bd9d5299a90507e46738e7f0fc7525d950e9ea0adcef385256f05203d27a633d3eac6dadf39b9016d255cec1f827e82636d6c80
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.2.1
2
+
3
+ - Fixed IE 8 error
4
+ - Added `track_bots` option
5
+ - Added `$authenticate` event
6
+
1
7
  ## 0.2.0
2
8
 
3
9
  - Added event tracking (merged ahoy_events)
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:
@@ -12,7 +12,7 @@ module Ahoy
12
12
  end
13
13
 
14
14
  def halt_bots
15
- if browser.bot?
15
+ if !Ahoy.track_bots and browser.bot?
16
16
  render json: {}
17
17
  end
18
18
  end
data/lib/ahoy/model.rb CHANGED
@@ -36,7 +36,9 @@ module Ahoy
36
36
 
37
37
  browser = Browser.new(ua: user_agent)
38
38
  self.device_type =
39
- if browser.tv?
39
+ if browser.bot?
40
+ "Bot"
41
+ elsif browser.tv?
40
42
  "TV"
41
43
  elsif browser.console?
42
44
  "Console"
data/lib/ahoy/tracker.rb CHANGED
@@ -5,7 +5,7 @@ module Ahoy
5
5
  @controller = options[:controller]
6
6
  end
7
7
 
8
- def track(name, properties, options = {})
8
+ def track(name, properties = {}, options = {})
9
9
  # publish to each subscriber
10
10
  if @controller
11
11
  options[:controller] ||= @controller
data/lib/ahoy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ahoy
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -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
@@ -123,7 +123,7 @@
123
123
  return {
124
124
  tag: $target.get(0).tagName.toLowerCase(),
125
125
  id: $target.attr("id"),
126
- class: $target.attr("class")
126
+ "class": $target.attr("class")
127
127
  };
128
128
  }
129
129
 
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.0
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-14 00:00:00.000000000 Z
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