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 +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +1 -1
- data/Rakefile +7 -0
- data/ahoy_matey.gemspec +3 -1
- data/app/controllers/ahoy/base_controller.rb +2 -2
- data/lib/ahoy/deckhands/request_deckhand.rb +8 -0
- data/lib/ahoy/deckhands/traffic_source_deckhand.rb +2 -2
- data/lib/ahoy/stores/active_record_store.rb +2 -2
- data/lib/ahoy/stores/active_record_token_store.rb +1 -1
- data/lib/ahoy/stores/base_store.rb +7 -1
- data/lib/ahoy/version.rb +1 -1
- data/lib/ahoy/visit_properties.rb +6 -2
- data/lib/ahoy.rb +1 -0
- data/lib/generators/ahoy/stores/templates/active_record_visits_migration.rb +2 -0
- data/lib/generators/ahoy/stores/templates/mongoid_visit_model.rb +2 -0
- data/test/test_helper.rb +4 -0
- data/test/visit_properties_test.rb +44 -0
- metadata +37 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40291bf283651d14352010eda0c253cebed87db6
|
4
|
+
data.tar.gz: 0ecfe15d70e6be8c3d4078b7148049edad546401
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdc0d68f6ef24f2da215fa89a1b0a0a1dcb44b2a85e09eea078c2dc95d2705b776e0dda75e962563261bd7029a1ed28587128ea63129865045ba21fa53929fe9
|
7
|
+
data.tar.gz: ecd7f16f4c533da8970adc20dae85fdcebb661be1d87872b269ddc7b53ad453ff3b5f72a1f82bc1888f29f77ed390d4e27a21715545f17d7e15c3d51d256ff71
|
data/CHANGELOG.md
CHANGED
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(:
|
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
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)
|
@@ -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)[
|
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::
|
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
|
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
|
41
|
+
rescue *unique_exception_classes
|
42
42
|
# do nothing
|
43
43
|
end
|
44
44
|
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,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
|
-
|
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
data/test/test_helper.rb
ADDED
@@ -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.
|
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:
|
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:
|
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:
|
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
|