action_tracker 0.1.0.2 → 0.1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +16 -0
- data/README.md +61 -7
- data/action_tracker.gemspec +1 -2
- data/lib/action_tracker.rb +1 -0
- data/lib/action_tracker/concerns/tracker.rb +16 -14
- data/lib/action_tracker/version.rb +1 -1
- metadata +4 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfb149079d10597d07994207f8a82c235004c638
|
4
|
+
data.tar.gz: f3983a018a57ed372ba89f083d4b9c2b767155db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56bf58bae35cad88d44b2908f5c35e80c59540d8c31ddee84c2956c3889f1acf4ea96c24e9fdce512bc1f0a233f3a5baac52e326c274e2a212d1c37a993a2ad5
|
7
|
+
data.tar.gz: 3efbe77d676c092a0393aa11daae5f20b3efa5b3a125d859b5e786cdee212ae4f2ecd67f28f3995124ccd570cb2d0b2e3d3eaea0f89a84f60b9c803891c2f0dc
|
data/Changelog.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# action_tracker changelog
|
2
|
+
|
3
|
+
## 0.1.0.3 (2016-04-18)
|
4
|
+
|
5
|
+
### Implemented enhancements
|
6
|
+
|
7
|
+
- Auto loading ActionTracker::Concerns::Tracker in ActionController::Base
|
8
|
+
- Refactoring Tracker class
|
9
|
+
|
10
|
+
### Fixed bugs
|
11
|
+
|
12
|
+
None
|
13
|
+
|
14
|
+
### Merged pull requests
|
15
|
+
|
16
|
+
None
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
<a href="https://codeclimate.com/github/appprova/action_tracker"><img src="https://codeclimate.com/github/appprova/action_tracker/badges/gpa.svg" /></a>
|
2
2
|
|
3
|
-
|
3
|
+
# Action Tracker
|
4
4
|
|
5
|
-
|
5
|
+
Action and event trackers made easy. With this gem you can track your user actions without adding unnecessary code in your controllers.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -20,9 +20,64 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
$ gem install action_tracker
|
22
22
|
|
23
|
-
## Usage
|
23
|
+
<!-- ## Usage
|
24
24
|
|
25
|
-
|
25
|
+
To use Action Tracker is easy, is needed to create a Tracker to any Controller to track. The structure of the files is simple.
|
26
|
+
|
27
|
+
To specify the tracker tool you want to use, you need to create a initializer and set the wanted tools.
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
# config/initializers/action_tracker.rb
|
31
|
+
ActionTracker::Settings.configuration do |config|
|
32
|
+
config.use_tool :mix_panel
|
33
|
+
config.use_tool :dito
|
34
|
+
config.use_tool :custom_tool
|
35
|
+
end
|
36
|
+
``` -->
|
37
|
+
|
38
|
+
The Tracker file structure must follow the controllers names and actions
|
39
|
+
|
40
|
+
### Simple usage
|
41
|
+
|
42
|
+
Simple add the wanted actions to track, with same name as the controller.
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
# app/trackers/users_tracker.rb
|
46
|
+
class UsersTracker < ActionTracker::Base
|
47
|
+
# This file tracks UsersController
|
48
|
+
|
49
|
+
def index; end
|
50
|
+
def show; end
|
51
|
+
def create; end
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
55
|
+
### Advanced usage
|
56
|
+
|
57
|
+
The parameters that will be send to Tracker tools can be easily customized. As the example above, is necessary to create the action, same as controllers and the return will be send to tracker tool.
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
# app/trackers/posts_tracker.rb
|
61
|
+
class PostsTracker < ActionTracker::Base
|
62
|
+
# This file tracks PostsController
|
63
|
+
|
64
|
+
def show
|
65
|
+
{
|
66
|
+
name: 'post-was-viewed',
|
67
|
+
data: {
|
68
|
+
post_id: @post.id,
|
69
|
+
tags: @post.tags
|
70
|
+
}
|
71
|
+
}
|
72
|
+
end
|
73
|
+
end
|
74
|
+
```
|
75
|
+
|
76
|
+
#### Options
|
77
|
+
|
78
|
+
| Name | Description | Default |
|
79
|
+
|--|--|--|--|
|
80
|
+
|*name*| The name of the tracked event. | The controller action name. Eg.: 'users#index'|
|
26
81
|
|
27
82
|
## Development
|
28
83
|
|
@@ -32,10 +87,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
87
|
|
33
88
|
## Contributing
|
34
89
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
90
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/appprova/action_tracker.
|
36
91
|
|
37
92
|
|
38
93
|
## License
|
39
94
|
|
40
95
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
-
|
data/action_tracker.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["andre.taiar@appprova.com.br", "joaogabriel@appprova.com.br"]
|
11
11
|
|
12
12
|
spec.summary = %q{Easy way to track actions in your application.}
|
13
|
-
spec.description = %q{Easy way to track actions in your application without adding unnecessary code to your
|
13
|
+
spec.description = %q{Easy way to track actions in your application without adding unnecessary code to your controllers.}
|
14
14
|
spec.homepage = "http://coders.appprova.com.br/"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_dependency 'rails3_before_render', '0.2.0'
|
23
23
|
spec.add_dependency 'activesupport', '~> 3.2'
|
24
|
-
spec.add_dependency 'actionpack', '~> 3.2'
|
25
24
|
|
26
25
|
spec.add_development_dependency "bundler", "~> 1.11"
|
27
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/action_tracker.rb
CHANGED
@@ -12,25 +12,27 @@ module ActionTracker
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def track_event
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
obj.user, obj.params = user, params
|
19
|
-
@tracker_params = obj.method(action_name).call if obj.respond_to? action_name
|
20
|
-
rescue NameError => e
|
21
|
-
# Significa que não tem tracker definido para esta action
|
22
|
-
end
|
15
|
+
tracker_user = current_user || current_teacher
|
16
|
+
tracker_class = "#{namespace}#{controller_name.camelize}Tracker"
|
17
|
+
@tracker_params = tracker_params(tracker_class, tracker_user)
|
23
18
|
end
|
24
19
|
|
25
20
|
private
|
26
21
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
def tracker_params(tracker_class, tracker_user)
|
23
|
+
begin
|
24
|
+
tracker = Object.const_get(tracker_class, false).new
|
25
|
+
tracker.user = tracker_user
|
26
|
+
tracker.params = params
|
27
|
+
output = tracker.method(action_name).call if tracker.respond_to? action_name
|
28
|
+
rescue NameError
|
29
|
+
output = ''
|
33
30
|
end
|
31
|
+
output
|
32
|
+
end
|
33
|
+
|
34
|
+
def namespace
|
35
|
+
self.class.name.deconstantize.try(:+, '::')
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_tracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- André Taiar
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-04-
|
12
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails3_before_render
|
@@ -39,20 +39,6 @@ dependencies:
|
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '3.2'
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: actionpack
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - "~>"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '3.2'
|
49
|
-
type: :runtime
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - "~>"
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: '3.2'
|
56
42
|
- !ruby/object:Gem::Dependency
|
57
43
|
name: bundler
|
58
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,7 +82,7 @@ dependencies:
|
|
96
82
|
- !ruby/object:Gem::Version
|
97
83
|
version: '3.0'
|
98
84
|
description: Easy way to track actions in your application without adding unnecessary
|
99
|
-
code to your
|
85
|
+
code to your controllers.
|
100
86
|
email:
|
101
87
|
- andre.taiar@appprova.com.br
|
102
88
|
- joaogabriel@appprova.com.br
|
@@ -107,6 +93,7 @@ files:
|
|
107
93
|
- ".gitignore"
|
108
94
|
- ".rspec"
|
109
95
|
- ".travis.yml"
|
96
|
+
- Changelog.md
|
110
97
|
- Gemfile
|
111
98
|
- LICENSE.txt
|
112
99
|
- README.md
|