ahoy_matey 1.1.0 → 1.1.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: 242d802ebd49a361498abd778f6584270403a044
4
- data.tar.gz: fbac0f07a91a227d362f81c59b9e5407f12a1914
3
+ metadata.gz: 40291bf283651d14352010eda0c253cebed87db6
4
+ data.tar.gz: 0ecfe15d70e6be8c3d4078b7148049edad546401
5
5
  SHA512:
6
- metadata.gz: 480eb913a57be006b6ed8a9387381f97fa90093ddf81f7509279e1821da88af79a50bb48811f61133efc480018e2ee09bca1f194e9a1a66ae130322abaf7f9d4
7
- data.tar.gz: ad94528f28a55a852638cea255b0e17e0a1ecc941231f2bf2830faaa77541c736a17196baab0279771cdca5c20bb172d437b0f33f833c0e6dd5bcbfc7db46787
6
+ metadata.gz: bdc0d68f6ef24f2da215fa89a1b0a0a1dcb44b2a85e09eea078c2dc95d2705b776e0dda75e962563261bd7029a1ed28587128ea63129865045ba21fa53929fe9
7
+ data.tar.gz: ecd7f16f4c533da8970adc20dae85fdcebb661be1d87872b269ddc7b53ad453ff3b5f72a1f82bc1888f29f77ed390d4e27a21715545f17d7e15c3d51d256ff71
data/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
- ## 1.1.0 [unreleased]
1
+ ## 1.1.1
2
+
3
+ - Better support for Authlogic
4
+ - Added `screen_height` and `screen_width`
5
+
6
+ ## 1.1.0
2
7
 
3
8
  - Added `geocode` option
4
9
  - Report errors to service by default
data/README.md CHANGED
@@ -404,7 +404,7 @@ Visit.group(:referring_domain).count
404
404
  [Chartkick](http://chartkick.com/) and [Groupdate](https://github.com/ankane/groupdate) make it super easy to visualize the data.
405
405
 
406
406
  ```erb
407
- <%= line_chart Visit.group_by_day(:created_at).count %>
407
+ <%= line_chart Visit.group_by_day(:started_at).count %>
408
408
  ```
409
409
 
410
410
  See where orders are coming from with simple joins:
data/Rakefile CHANGED
@@ -1 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ task :default => :test
5
+ Rake::TestTask.new do |t|
6
+ t.libs << "test"
7
+ t.pattern = "test/**/*_test.rb"
8
+ end
data/ahoy_matey.gemspec CHANGED
@@ -18,10 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency "rails"
21
22
  spec.add_dependency "addressable"
22
23
  spec.add_dependency "browser", ">= 0.4.0"
23
24
  spec.add_dependency "geocoder"
24
- spec.add_dependency "referer-parser"
25
+ spec.add_dependency "referer-parser", ">= 0.3.0"
25
26
  spec.add_dependency "user_agent_parser"
26
27
  spec.add_dependency "request_store"
27
28
  spec.add_dependency "uuidtools"
@@ -29,4 +30,5 @@ Gem::Specification.new do |spec|
29
30
 
30
31
  spec.add_development_dependency "bundler", "~> 1.5"
31
32
  spec.add_development_dependency "rake"
33
+ spec.add_development_dependency "minitest"
32
34
  end
@@ -1,7 +1,7 @@
1
1
  module Ahoy
2
2
  class BaseController < ApplicationController
3
- # skip all filters
4
- skip_filter *_process_action_callbacks.map(&:filter)
3
+ # skip all filters except for authlogic
4
+ skip_filter *(_process_action_callbacks.map(&:filter) - [:load_authlogic])
5
5
 
6
6
  def ahoy
7
7
  @ahoy ||= Ahoy::Tracker.new(controller: self, api: true)
@@ -36,6 +36,14 @@ module Ahoy
36
36
  request.params["os_version"]
37
37
  end
38
38
 
39
+ def screen_height
40
+ request.params["screen_height"]
41
+ end
42
+
43
+ def screen_width
44
+ request.params["screen_width"]
45
+ end
46
+
39
47
  end
40
48
  end
41
49
  end
@@ -11,12 +11,12 @@ module Ahoy
11
11
  end
12
12
 
13
13
  def search_keyword
14
- @search_keyword ||= (self.class.referrer_parser.parse(@referrer)[1].first(255) rescue nil).presence
14
+ @search_keyword ||= (self.class.referrer_parser.parse(@referrer)[:term][0..255] rescue nil).presence
15
15
  end
16
16
 
17
17
  # performance hack for referer-parser
18
18
  def self.referrer_parser
19
- @referrer_parser ||= RefererParser::Referer.new("https://github.com/ankane/ahoy")
19
+ @referrer_parser ||= RefererParser::Parser.new
20
20
  end
21
21
 
22
22
  end
@@ -18,7 +18,7 @@ module Ahoy
18
18
  begin
19
19
  visit.save!
20
20
  geocode(visit)
21
- rescue ActiveRecord::RecordNotUnique
21
+ rescue *unique_exception_classes
22
22
  # do nothing
23
23
  end
24
24
  end
@@ -38,7 +38,7 @@ module Ahoy
38
38
 
39
39
  begin
40
40
  event.save!
41
- rescue ActiveRecord::RecordNotUnique
41
+ rescue *unique_exception_classes
42
42
  # do nothing
43
43
  end
44
44
  end
@@ -18,7 +18,7 @@ module Ahoy
18
18
  begin
19
19
  visit.save!
20
20
  geocode(visit)
21
- rescue ActiveRecord::RecordNotUnique
21
+ rescue *unique_exception_classes
22
22
  # do nothing
23
23
  end
24
24
  end
@@ -67,7 +67,6 @@ module Ahoy
67
67
 
68
68
  def set_visit_properties(visit)
69
69
  keys = visit_properties.keys
70
- keys -= Ahoy::VisitProperties::LOCATION_KEYS if Ahoy.geocode != true
71
70
  keys.each do |key|
72
71
  visit.send(:"#{key}=", visit_properties[key]) if visit.respond_to?(:"#{key}=") && visit_properties[key]
73
72
  end
@@ -79,6 +78,13 @@ module Ahoy
79
78
  end
80
79
  end
81
80
 
81
+ def unique_exception_classes
82
+ classes = []
83
+ classes << ActiveRecord::RecordNotUnique if defined?(ActiveRecord::RecordNotUnique)
84
+ classes << PG::UniqueViolation if defined?(PG::UniqueViolation)
85
+ classes
86
+ end
87
+
82
88
  end
83
89
  end
84
90
  end
data/lib/ahoy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ahoy
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  module Ahoy
2
2
  class VisitProperties
3
3
 
4
- REQUEST_KEYS = [:ip, :user_agent, :referrer, :landing_page, :platform, :app_version, :os_version]
4
+ REQUEST_KEYS = [:ip, :user_agent, :referrer, :landing_page, :platform, :app_version, :os_version, :screen_height, :screen_width]
5
5
  TRAFFIC_SOURCE_KEYS = [:referring_domain, :search_keyword]
6
6
  UTM_PARAMETER_KEYS = [:utm_source, :utm_medium, :utm_term, :utm_content, :utm_campaign]
7
7
  TECHNOLOGY_KEYS = [:browser, :os, :device_type]
@@ -25,7 +25,11 @@ module Ahoy
25
25
  end
26
26
 
27
27
  def keys
28
- KEYS
28
+ if Ahoy.geocode == true # no location keys for :async
29
+ KEYS
30
+ else
31
+ KEYS - LOCATION_KEYS
32
+ end
29
33
  end
30
34
 
31
35
  def to_hash
data/lib/ahoy.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "rails"
1
2
  require "addressable/uri"
2
3
  require "browser"
3
4
  require "geocoder"
@@ -25,6 +25,8 @@ class <%= migration_class_name %> < ActiveRecord::Migration
25
25
  t.string :browser
26
26
  t.string :os
27
27
  t.string :device_type
28
+ t.integer :screen_height
29
+ t.integer :screen_width
28
30
 
29
31
  # location
30
32
  t.string :country
@@ -24,6 +24,8 @@ class Visit
24
24
  field :browser, type: String
25
25
  field :os, type: String
26
26
  field :device_type, type: String
27
+ field :screen_height, type: Integer
28
+ field :screen_width, type: Integer
27
29
 
28
30
  # location
29
31
  field :country, type: String
@@ -0,0 +1,4 @@
1
+ require "bundler/setup"
2
+ Bundler.require(:default)
3
+ require "minitest/autorun"
4
+ require "minitest/pride"
@@ -0,0 +1,44 @@
1
+ require_relative "test_helper"
2
+
3
+ class TestVisitProperties < Minitest::Test
4
+ def setup
5
+ request = MiniTest::Mock.new
6
+ @visit_properties = Ahoy::VisitProperties.new(request)
7
+ end
8
+
9
+ def test_keys
10
+ with_geocode(true) do
11
+ assert_equal @visit_properties.keys, Ahoy::VisitProperties::KEYS
12
+ end
13
+ end
14
+
15
+ def test_keys_when_geocode_disabled
16
+ with_geocode(false) do
17
+ keys = @visit_properties.keys
18
+
19
+ refute keys.include?(:country)
20
+ refute keys.include?(:region)
21
+ refute keys.include?(:city)
22
+ end
23
+ end
24
+
25
+ def test_keys_when_geocode_async
26
+ with_geocode(:async) do
27
+ keys = @visit_properties.keys
28
+
29
+ refute keys.include?(:country)
30
+ refute keys.include?(:region)
31
+ refute keys.include?(:city)
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def with_geocode(enabled)
38
+ original = Ahoy.geocode
39
+ Ahoy.geocode = enabled
40
+ yield
41
+ ensure
42
+ Ahoy.geocode = original
43
+ end
44
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ahoy_matey
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.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-11-02 00:00:00.000000000 Z
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: addressable
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +72,14 @@ dependencies:
58
72
  requirements:
59
73
  - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: '0'
75
+ version: 0.3.0
62
76
  type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: '0'
82
+ version: 0.3.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: user_agent_parser
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +164,20 @@ dependencies:
150
164
  - - ">="
151
165
  - !ruby/object:Gem::Version
152
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: minitest
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
153
181
  description: Simple, powerful visit tracking for Rails
154
182
  email:
155
183
  - andrew@chartkick.com
@@ -207,6 +235,8 @@ files:
207
235
  - lib/generators/ahoy/stores/templates/mongoid_event_model.rb
208
236
  - lib/generators/ahoy/stores/templates/mongoid_initializer.rb
209
237
  - lib/generators/ahoy/stores/templates/mongoid_visit_model.rb
238
+ - test/test_helper.rb
239
+ - test/visit_properties_test.rb
210
240
  - vendor/assets/javascripts/ahoy.js
211
241
  homepage: https://github.com/ankane/ahoy
212
242
  licenses:
@@ -232,4 +262,6 @@ rubygems_version: 2.2.2
232
262
  signing_key:
233
263
  specification_version: 4
234
264
  summary: Simple, powerful visit tracking for Rails
235
- test_files: []
265
+ test_files:
266
+ - test/test_helper.rb
267
+ - test/visit_properties_test.rb